How to determine color of an image with code.

Hello,
I need to determine if an image is of a particular color. Ideally I might eventually like to determine what percentage of the image is of a particular color. For example if you have a picture of a redish, yellow and blue sky, it would be nice to know what percentage of the image is red. Or if determining the percentage takes up too much processing time, I could just determine if a rectangular sub region of the image is red.
How can this be done? Here are two of the line of code I am using to store the image.
private Image myImage;
myImage = getImage(getDocumentBase(), "SkyImg.gif");
Also, does anyone know if this takes up much processing time?
I need to repeatedly check the color at various times in a particular
time period and I need the process to be as fast as possible. I would
sincerely appreciate the help.

HI,
would be something along these lines:
    public void color_finder() {
        Image temp = null;
        int width = temp.getWidth();
        int height = temp.getHeight();
        int[] image_array = new int[width*height];
        try {
            temp = ImageIO.read(getClass().getResource("image.gif"));
        } catch (IOException ioe) {}
        MediaTracker tracker = new MediaTracker(this);
        tracker.addImage(temp,0);
        try   {tracker.waitForID(0);}
        catch (InterruptedException e){}
        pg = new PixelGrabber(tempmap,0,0,width,height,image_array,0,width);
        try { pg.grabPixels(); }
        catch (InterruptedException e) {}
        int count = 0;
        for (int i = 0; i < width*height; i++) {
            if (image_array.isLegalColor()) count++;
int percent = (count/(width*height))*100;
//blah blah

Similar Messages

  • How do I achieve browser width images with scroll motion set to 0?

    How do I achieve browser width images with scroll motion set to 0?
    An example can be seen here with the green image: http://www.qooqee.com/templates/aroma
    I can get the rectangle to stretch the width of the browser but not the image fill. (see - http://www.tomwellsassociates.com)
    My Muse fill settings:
    Fill type: Solid
    Colour: None
    Fitting: Tile vertically
    Position: Bottom Centre
    Scroll motion: On (Up - 0)
    Image Size:
    3311 x 3311 px
    Display: Apple imac 27"
    Any suggestions/help would be much appreicated...

    Please check out: http://forums.adobe.com/message/5701908
    Cheers,
    Vikas

  • I need to replace a color on my image with a specific color from another part of the image.  How?!

    I have spent over 2 hours trying to figure out how to replace a color on one part of my image with a specific color shown on another part of the image.  So far I have been able to go to "Replace Color" on my Adobe Photoshop version, but it seems that I can only change the hue and brightness of the color that it currently is.  I need to use a specific color so this does not help me.  Does anyone know how to complete the task I am referring to?
    Also, please keep in mind that I am using Adobe Photoshop 6.0, not a fancy cs version or anything.  So it's pretty old school...
    Any help/feedback is greatly appreciated!  Thank you.

    Hi brookehelene,
    You might consider making a selection the object and using a color fill layer set to the color blend mode instead of replace color.
    I used the same picture as kendallplant did and changed the color on the same flower by sampling the pink color from the flower to the right)
    (click on the screenshots below for larger views)
    1. Select>Color Range
       (i used color range because the dialog is somewhat similar to the replace color dialog, except one is making a selection instead of replacing a color)
       (there are many other ways to make the selection such as the magic wand, so if your more familar with the other selection tools you can use those instead to make your selection)
    2. Use the eyedroppers and fuzziness slider in the color range dialog to make the selection of the object.
       (in the screenshot below the white areas are selected and black areas are not)
       (your selection probably won't be perfect, but you can paint on the layer mask to refine the selection)
    3. After you press the okay in the color range dialog you'll see the selection (marching ants)
       At the bottom of the layers palette press the Create New Fill or Adjustment Layer icon
       to reveal a list and choose Solid Color.
       Then use the eyedropper to sample a color from your image and press ok.
       Change the Blend mode for the color fill layer to Color (top of the layers palette)
    4. As you can see a lot has been selected besides the flower.
        To refine the areas of color, paint on the layer mask with the paintbrush tool.
        Use white to add the color or black to subtract the color
        You can press the D key on the keyboard to get the default colors (black and white) in the toolbox
        and press the X key to switch between the two when painting on the layer mask.
    Even though the above takes longer you can easily change the color or modify the areas that you want to change the color on.
    To change the color you can double click on the color fill icon in the layers panel.
    You can also use other layer blend modes besides color such as hue, so you might try some of the others and see what they do.

  • How to convert color of bitmap image?

    I am programming with Acrobat 7.
    I'd like to change color of all object to CMYK color or gray.
    In case of plain object like path or font,
    I need to seek CMYK color from the object's RGB color.
    and I change the property of the object color space and value with it.
    but in case of bitmap image, i don't know how to at all.
    it has numerous colors.
    I hope your advice.

    Thank you both of you.
    by the way, Leonard, Could you tell me that APIs more detailly?
    I have look into the document for long time. it is still hard to find proper API.
    I have to say this again. I am trying to find APIs based on version 7.
    I am using custom function ACEconvertColorProfile which is placed in snippetrunner. it consists of these APIS ACMakeColorTransform, ACApplyTransform, and so on.
    but I can't find the way to convert bitmaps once and for all.
    I hope you give more hint.
    Thanks again.

  • Color correct CMYK Image with RGB Image

    1. anybody please tell me is it possible to perform color correction in CMYK image with RGB reference image
    2. how to do that i mean what are the details i have to watch for?
    ADVANCE THANKS

    Your match using my color profile(similar to North American General Purpose) would be 29c 100m 83y 35k. Convert a sample swatch, using your color workflow/profile.
    Some RGB colors won't convert well to cmyk (eg 0R 255B 0G). In that case your problem is not using a RGB reference image for CMYK color correction, but the cropped color gamut in the color conversion itself.
    In those cases of saturated RGB colors you may have to do some handtoning to surrounding colors, to help create the illusion of RGB saturation to the troublesome color you are matching.

  • How do i use my own image with keying (or green screen)

    how do i use my own image witrh keying (or green screen)

    Put your sky clip on a layer below the clip you want to key. One or the other will be a connected clip. Apply  the Keying filter to foreground clip (the one with the green screen). The green will be seen as transparent and the sky will show through as the BG. Adjust as necessary in the Inspector.
    Good luck.
    Russ

  • How do you select a single image with the keyboard?

    I can use the "/" key to deselecting the current photo but how do I select the current photo with the keyboard? Usually the space bar is used for this but that displays the image. Is the only way to select the current photo by using the mouse?

    OK, now that the question has been clarified....
    Pressing and holding the Shift key as you move through the grid with the arrow keys will individually multi-select them, but that breaks down if you want non-contiguous selections, i.e. lifting off the shift key to skip a photo will cause all previous selections to be lost when you use the arrow key to advance. I think the only way for non-contiguous selection is ctrl-click.

  • How to determine if class was compiled with debugging information?

    How may I determine if class was compiled with debugging information? Aside from actually executing the class in a debugger.

    As known, when compiling "javac -g ..." the class
    files contain debugging information.
    my Naive question is WHAT is this information?
    could you please add any links to articles about this
    debugging information?http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#22856
    http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#5956

  • How to compare any type of image with any Palette ?

    How can I compare any image with any Palette file (ex. sample.pal file) ?
    If that image don't satisified selected Palette file then show me exception or any kind of message.
    Plz reply me with proper guidence or any hints.
    Thanks
    Harshal

    How can I compare any image with any Palette file (ex. sample.pal file) ?
    If that image don't satisified selected Palette file then show me exception or any kind of message.
    Plz reply me with proper guidence or any hints.
    Thanks
    Harshal

  • How to I create a screenshot image with a Mac?

    Hi,
    I'm relatively new to Macs. I have yet to learn now to make a screenshot image with a Mac. There doesn't seem to be a Print screen button. How do I do this? Can it be done in the Mac OS? Or, is there a need to install some software to do this?
    Thanks much!

    It's all built in!
    Go to the Help menu in Finder and enter 'Screenshot' and press enter.
    Lots of articles there, including this one:
    To take a picture of the whole screen, press Command-Shift-3.
    To take a picture of part of the screen, press Command-Shift-4, then drag to select the area you want in the picture.
    To take a picture of a window, the menu bar, the Dock, or other area, press Command-Shift-4, then press the Space bar. Move the pointer over the area you want so that it's highlighted, then click. If you decide you want to drag to select the area, press the Space bar again.
    If you press Command-Shift-4 and decide you don't want to take the screen shot, press the Escape key.
    Screen shots are saved as files on the desktop. If you want to put the screen shot in the Clipboard, rather than create a file, hold down the Control key when you press the other keys. You can then paste the picture into a document.
    You can also take pictures of the screen using the Grab application (in the Utilities folder).
    Some applications, such as DVD Player, may not let you take pictures of the screen

  • IPhone: How to get the original photo image with  Picker

    Hi!
    I'm trying to pick and send (via HTTP) the original image taken by the camera, the 1,600 x 1,2000 image that's available in iPhoto after syncing.
    As far as I gathered, the UIImage doesn't help me here, since it's scaled down to 640x480, probably to safe memory. But one should supposedly be able to access the underlying CIImage.
    Here's what I'm doing right now:
    I'm setting up an ImagePickerController in my
    - (void)viewDidLoad
    imagePickerController = [[UIImagePickerController alloc] init];
    imagePickerController.delegate = self;
    imagePickerController.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
    [self refreshView:self];
    and process the picked image with
    - (void)imagePickerController:(UIImagePickerController )picker didFinishPickingImage:(UIImage )image editingInfo:(NSDictionary )editingInfo
    CGImageRef imgRef = image.CGImage;
    CGFloat owidth = CGImageGetWidth(imgRef);
    CGFloat oheight = CGImageGetHeight(imgRef);
    NSLog(@"Original size = %f %f",owidth,oheight);
    NSData imageData = [NSData dataWithData: UIImagePNGRepresentation(image)];//(image, 1.0)
    However, I still get the following output:
    2008-07-25 11:44:58.543 myApplication[1564:20b] Original size = 640.000000 480.000000
    Obviously still scaled down - but there must be a way to access the original.
    What am I doing wrong?

    Yes, I'm trying on the iPhone, as the camera is unavailable on the simulator.
    Here is the code I'm using:
    // In my main code, to initialise the picker
    UIImagePickerController *picker;
    // Check if camera is available
    if ( ![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] )
    UIAlertView *alertView = [[UIAlertView alloc]
    initWithTitle:@"Can't access camera" message:@"The camera is unavailable!" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil ];
    [alertView show];
    [alertView release];
    return;
    picker = [[UIImagePickerController alloc] init];
    picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    picker.delegate = self;
    [_myView addSubview:picker.view];
    [_myView performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:NO];
    // The delegate methods
    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
    NSLog( @"Image dimensions: %fx%f", image.size.width, image.size.height );
    // Remove the picker interface and release the picker object.
    [picker.view removeFromSuperview];
    [picker release];
    - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
    // Remove the picker interface and release the picker object.
    [picker.view removeFromSuperview];
    [picker release];
    }

  • How to send byte array of image with 300dpi.

    Hello fiends
                       i am making an application in which i have to send the byte array of an image with 300dpi.
    so i am using image snapshot class for that and use that code.
                        var snapshot:ImageSnapshot = ImageSnapshot.captureImage(cnvParent,300);
                        var bdata:String = ImageSnapshot.encodeImageAsBase64(snapshot);
    but when i send that bdata to php end using httpService.The size at other end of image increases surprisingly.i means it will increase its actual height and actual width.so is there any way to overcome this increase in size when i bitmapped image at 300 dpi?
    if there any way then please tell me.waiting for your reply.
    Thanks and Regards
        Vineet Osho

    Thanks david for such a quick reply.the link is really helpful.So we have to calculate the screendpi thruogh our code and then set the height and width of image.is there any simple way to sort out my problem.i just want to print my image at 300dpi but i am using image snapshot class so its taking the snap of my container(image) and save the image at 96 dpi which is dpi of my screen(monitor).so is there any way or any class in flex through which i got the image at its original dpi.i am not stick on 300 dpi but i m getting image from backend through xml at 300dpi.thats why i want the byte array i am sending should be at 300dpi.i am totally confused now.so please help me.
    Thanks and regards
      Vineet osho

  • How Get the column name of LOV with code??

    Hi i now that exist a SET_COLUMN and i cant change the value the any column, now i want to know the value column in the LOV in any moment. Somebody us made that? i contact a metalink and their tell me that is not possible that not exist a GET....
    Thanks.

    yea but i am not used record group only a LOV with values static. you thiks that i know the values is true but i need with code change the values but before i need know the value.

  • Uniform Color across 50+ images with Kodak color bar

    Hi,
    I shoot 50+ paintings using a Kodak color bar at the bottom of each image, thing is during the shoot the light change from start to finish as the sun moved around, (dumb I know), so is there anyway to get the images to be uniform color across the whole collection. I want to acheive where the color bar is exactly the same in each image?
    I shot everything in RAW...
    Thanks
    SEan

    You're going to have to do an individual gray balance on a white or gray patch on every image, as it will not be the same correction for each image. As the light changes it changes color, which is going to be the biggest factor. The changing angles of light reflecting off the paintings can also affect the color rendition. In the end, it really depends on how accurately you need to reproduce the color in the paintings. The more accurate you need to be, the more you will need to make individual corrections in Ps for each image.
    When I do this, I correct to the actual painting viewed under a Solux lamp 90 degrees away from my monitor. The best and most accurate color I've seen to date is processing the raw files in CaptureOne and gray balancing to a portion of the white seamless paper in the background. Even complicated paint pigments came right into line with a single click. The input profiles in C1 are truly amazing now.
    You may run into problems also with the Kodak color bars themselves. Far too often when you get them looking right, your painting is way off. The pigments used in the color bars react differently to light than the pigments in the painting, and the grayscale steps are never right. They always seem to clip both ends long before you start clipping any detail in your painting.

  • How to Determine Color types in a file?

    How can we tell if a document has any CMYK, RGB or Pantone colors within any object (curves, text, etc.)?  The requires are just to report that the document has any CMYK and/or RGB and/or Pantone colors.  We already can get the color for a bitmap image on the document, it's the other objects on the document.
    Thanks...

    What I do to make a quick check of a Document is open the Document Info panel. If you want to see what is an object, select only that object, if you want to see what is in all objects select all. In the Document Info panel fly out menu (upper right corner of the panel) select Object to see information on number of objects and what colors are used. If you want to see what Spot Colors are used select the Spot Color Objects from this same fly out menu. Hope this helps but it sounds like you may need more robust preflight tools.

Maybe you are looking for