Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have the below method to create a greyscale image of a Jpeg... I would like to

ID: 3634374 • Letter: I

Question

I have the below method to create a greyscale image of a Jpeg...

I would like to know how to create an emboss filter and a negative filter...

/**
* Greyscale Filter
* Apply this filter to an image.
*
* The image to be changed by this filter.
*/
public void apply(OFImage image)
{
int height = image.getHeight();
int width = image.getWidth();
for(int y = 0; y < height; y++) {
for(int x = 0; x < width; x++) {
Color pix = image.getPixel(x, y);
int avg = (pix.getRed() + pix.getGreen() + pix.getBlue()) / 3;
image.setPixel(x, y, new Color(avg, avg, avg));
}
}
}

Explanation / Answer

Dear..

//negativeFilter.java

public class negativeFilter extends Filter
{

public negativeFilter(String name)
    {
        ......
}

   
    public void apply(OFImage image)
    {
        int height = image.getHeight();
        int width = image.getWidth();
        for(int y = 0; y < height; y++) {
            for(int x = 0; x < width/2; x++) {
                Color left = image.getPixel(x, y);
                image.setPixel(x, y, image.getPixel(width-1-x, y));
                image.setPixel(width-1-x, y, left);
            }
        }
    }
}