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

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
Asked:
Yoohoo
2 Solutions
 
akshayxxCommented:
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
 
YoohooAuthor Commented:
I'm confused with 'newpixel'. What is that?
0
 
YoohooAuthor Commented:
I'm confused with 'newpixel'. What is that?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
akshayxxCommented:
well new pixel is nothing but another pixel array ,
in your case
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
 
objectsCommented:
Java already provides classes for filtering images.
Here's an example:

http://javaalmanac.com/egs/java.awt.image/FilterRgb.html
0
 
CleanupPingCommented:
Yoohoo:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
akshayxxCommented:
split  betwn me and objects
0
 
girionisCommented:
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

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

girionis
EE Cleanup Volunteer
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now