Results 1 to 3 of 3
  1. #1
    coldfire is offline Member
    Join Date
    Jan 2009
    Rep Power

    Default Processing an Image with csimage

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

    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:

    Java 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!
    Attached Files Attached Files

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Colombo, Sri Lanka
    Blog Entries
    Rep Power


    You are using different jar file that the default one in JDK package. From where you find that? Did you find the doc related to that jar file? May be that doc explain clearly about all methods.

  3. #3
    coldfire is offline Member
    Join Date
    Jan 2009
    Rep Power


    Well, I am only using the and classes and I have looked through both and I am pretty sure I have to use the UberColor getColor method.

    This is the problem I have as I do not know how to separate the r,g,b values into variables so that I can compare it with another color. For example, the output of the getColor method returns: csimage.UberColor[r=255,g=255,b=255]

Similar Threads

  1. Image Processing
    By Josh_FL in forum Advanced Java
    Replies: 4
    Last Post: 12-30-2008, 02:45 AM
  2. image processing
    By sathish natrajan in forum Java 2D
    Replies: 2
    Last Post: 11-06-2008, 05:13 PM
  3. Replies: 1
    Last Post: 01-15-2008, 07:12 PM
  4. Replies: 0
    Last Post: 01-08-2008, 05:29 PM
  5. Image Processing in J2ME
    By mobeenkhan in forum CLDC and MIDP
    Replies: 1
    Last Post: 08-02-2007, 05:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts