1 Attachment(s)

Processing an Image with csimage

Hi, I was wondering if anyone can help me out. Here is what I need to do:

Quote:

Using the UberImage and UberColor classes from csimage_beta1.jar, write a program that applies the following transformation to any JPEG or PNG file:

Convert all pixels in the image that are within distance D of pure red (i.e. UberColor.RED) to a shade of gray that is proportional to the brightness of the image’s red value.

Experiment with different values for the distance D to find out what values produce what effects. Run your program on real images.

Some helpful hints:

• In RGB, there are 256 shades of gray denoted by triples of the form (c, c, c), where 0 <= c < 256.

• The distance D between two RGB colors (a, b, c) and (x, y, z) is given by D = sqrt((a − x)2 + (b − y)2 + (c − z))^2.

I have attached csimage_beta1.jar (in a zip file) if anyone is willing to help

This is what I have so far in my code:

Code:

`package csimage;`

public class ImgRead {

public static void main(String[] args) {

UberImage img = UberImage.fromURL(args[0]);

for(int x = 0; x < img.getWidth(); x++)

for(int y = 0; y < img.getHeight(); y++)

}

}

The next part should do something for each x,y coordinate in the image. I know I need to check the distance between the RGB value at x,y and the RGB value of UberColor.RED, but I am having trouble specifically with how to do this.

Any ideas?

Thank you!