• Status: Solved
• Priority: Medium
• Security: Public
• Views: 192

# Image Manipulation Filter

I want to manipulate an image--pixel by pixel--so that when I apply the filter to the image, the resulting image is different from the original.

For one filter, I want to create a watercolor effect to the image. For another, I want to greyscale the image. However, I don't really know how to do either....

I have something like this:

public class EffectFilter implements Filter {

public void filter(PixelImage pi) {
Pixel[][] data = pi.getData();

for (int row = 0; row < pi.getWidth(); row++) {
for (int col = 0; col < pi.getHeight(); col++) {
/** Create an effect for every pixel of the image */
}
}
}

This is for an intro java programming class, so I'm a beginner.

Any help appreciated. Thanks!

0
Yoohoo
2 Solutions

Commented:
Hi Yoohoo,
Water color effect will require lot of mathemetics,
though converting to gray scale is pretty stright forward.
take the R, G, B values and take the 'average' and then set each of the R,G,B to the average value..
many people dont take just simple average .. rather a weighted average .. but the key is that whatever calculation you do .. set the newpixel.R=newpixel.G=newpixel.B=new average value
if u take simple arithmetic mean .. it will also give decent result..
and when u r done with changing the pixel values .. save it to the new image.. ( create the new Image with new pixel values)
and for the water color effect . .. check google for the mathemetical operations required for that.

Cheers!
0

Author Commented:
I'm confused with 'newpixel'. What is that?
0

Author Commented:
I'm confused with 'newpixel'. What is that?
0

Commented:
well new pixel is nothing but another pixel array ,
Pixel[][] newpixel;
this i wud recommend, if u want to keep ur original image intact.
so make save the changes to this new pixel array , and make new image out of it..

0

Commented:
Java already provides classes for filtering images.
Here's an example:

http://javaalmanac.com/egs/java.awt.image/FilterRgb.html
0

Commented:
Yoohoo:
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Commented:
split  betwn me and objects
0

Commented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Split points between akshayxx and objects