Change a color in an image

I am using getPixel() and setPixel() to process the whole image to change one of the colors, is there more efficient way to do that with 2D or Jai?
thanks.

Use java.awt.image.ImageFilter. My example code converts a colour image to greyscale, but you can easily change that to check for the colour you're interested in and otherwise return rgb.
Image img, out_img;
// Code to set up img here
// Get an image producer for the image
ImageProducer ip = img.getSource();
// Construct a suitable filter
RGBImageFilter filter = new RGBImageFilter()
    boolean canFilterIndexColorModel = true;
    public int filterRGB(int x, int y, int rgb)
        // Extract the individual fields
        int red = ((rgb & 0x00ff0000) >> 16);
        int green = ((rgb & 0x0000ff00) >> 8);
        int blue = (rgb & 0x000000ff);
        // Get the HSB equivalent values
        float[] hsb;
        hsb = Color.RGBtoHSB(red, green, blue, null);
        // Use the brightness to code up a grey
        int return_value = Color.HSBtoRGB(0.0f,
                                          0.0f,
                                          hsb[2]);
        return return_value;
// Create an image producer for the filtered image
ImageProducer filt_ip = new FilteredImageSource(ip,
                                                filter);
// Produce the output image
out_img = getToolkit().createImage(filt_ip);

Similar Messages

  • How can we change the  color of the image for product display for different

    Hi All,
    How can we change the  color of the image for product display for different colors, to be displayed on site.
    jeff

    Hi priya,
    The requirement that you have stated is not a standard feature in ISA CRM. In order to do the same, you will need to modify the standard ISA code in Java. A common path for the solution would be as follows:
    1. Colours
        a. Maintain a text type for Color under the object - PCAT_ITM in Customizing.
        b. Modify the standard search of ISA to search within your new text type as well. (In standard it only searches in Description.
       c. Maintain all shirts colour data in the new type created in step a.
       d. Your requirement will be done!
    2. Price
      a. Use list prices for your shop and assign the appropriate condition type, acces in your catalog.
      b. Modify the standard search of ISA to search on the list prices as well.
      c. This too will be done!
    3. Accessories - This is very tricky, and will require some exploration. However, here's my opinion,
    a. Search for the standard function module, which will return the accessories when provided the product as an input.
    b. Modify this function module according to your requirement and ensure that it can be accessed remotely.
    c. Modify the JSP as in steps 1b and 2b above to call this new remote-enabled function module.
    d. Now you're done!!
    The ISA modification part is not so simple, you need a really good guy like "Sateesh Chandra" who'll be able to handle your requirements. This is all I could manage, hope it is some help to you!
    Thanks & Regards,
    Nelson.

  • How do I create a duplicate image inside the same page? Then how do I change the color of that image

    how do I create a duplicate image inside the same page? Then how do I change the color of that image from black to red?

    Hello there!
    Here is one way to create a duplicate image and colorize it. As you can see below, I have one image right now, that I want to duplicate.
    My layers panel looks like below.
    To duplicate your image, click the downward arrow on the right side of your Layer Panel.
    Select Duplicate Layer. This will duplicate the layer that the image is on.
    Select "OK" to approve the duplication.
    As you can now see in the Layers panel, the image is duplicated. The new layer is now at the top of the Layer panel.
    Now to colorize your image, go to Window > Adjustments.
    The Adjustments panel will now be opened. Select the Hue and Saturation icon as seen circled in red.
    The Hue and Saturation propertied panel will be opened. I selected "Colorize", and adjusted the hue and saturation bar to achieve the level red in my photo.
    As you can see below, the image is now red.
    Now i want to make sure only ONE of my image layers is red. I moved the Hue and Saturation layer to only be on top of the bottom layer. The image on the top layer now will not be affected by the red.
    Select the move tool, so I can now move the image layers so we can see both of them.
    With each image layer selected, you can take the move tool and move the images. I moved mine on top of eachother and you can see my red layer (bottom) and the non red layer (top).
    I hope that helps. i have also included helpful links.
    Please post back with any questions,
    Janelle

  • Can I change the color of an image to a specific color code?

    Since I was unable to do this in Photoshop, I was wondering if there was a way in Flash to simply change the color of an image to a speciifc color code.  The image is more or less a simple line with rounded corners.  It is only composed of 1 color.  Does anyone know if it can be done with Flash?

    Shouldn't be a problem to do it in Photoshop or Flash. Since you couldn't do it in PS, I'm guessing that there is more to it than you are making obvious here.
    But in Flash you would import it, make it into a movieclip or graphic. Then apply a tint from the color effect portion of the properties panel.

  • Changing the color of an image in EPS format using Illustrator

    How do I change the color of an image in EPS format using Illustrator? Once I do this how do I change the format of the image from EPS to something I can select onto a website like JPG, JPEG or PNG? I plan to print the image onto a T-shirt.

    start here:
    http://help.adobe.com/en_US/illustrator/cs/using/WS714a382cdf7d304e7e07d0100196cbc5f-6519a .html

  • Changing Fill Color on pasted images

    I am try to change the color of an image I got off the internet, however, I used the Instant Alpha feature to remove all the other "junk" that was in the pic. Now I have a clean image, but I would like to create multiples of the image, but make them different colors. Is there any way to do this? I have been pulling out what little hair I have left in an attempt to figure it out. Thanks for any help offered

    You can do different "monochrome" colors by taking the Saturation down to zero, then messing with the Temperature and Tint to get the color you want. The "black" parts of the picture will change to the color you want, and other shades will be lighter or darker.

  • How can I change the color of interactive image label box background.

    Interactive image labels are a bit overwhelming in appearance. Can I change the label background color or make it partially transparent? I have tried several things and looked this up on Lynda.com training but no info.

    don't know how much this might help but you can change some colors using the Inspector as follows:
    from the text menu you can control paragraph and character colors, from the text menu you can control the text color.
    hope this helps...

  • How can I change a color of an image without affecting the texture, but based on a pantone pick?

    Here is an image of a paintbrush stroke that shows the texture of the paint.  I want to change the color to a specific pantone green in order to match a specific color pallet.  Rather than just using hue saturation to "guess" at the color (no pantone number), is there a way I can actually set a base color without losing the texture?

    You can only use the picker values as a guide on an image with many tones.
    I presume you are going to print as cmyk, so find the mix of the target colour and make a 'solid colour' adjustment layer and choose that mix. Then set the adj layer properties to 'hue' which should do it.
    Otherwise, add a 'hue/saturation' layer (and click on colorize in the adj layer palette) and move the slider to suit.
    If you convert to greyscale, you could colorize the pic with the spot colour too.

  • Can you change the color of an image without changing it in photoshop first?

    I have created a link for Indesign using Photoshop. It is basically a plain black graphic that is placed over an aerial to highlight the represented water. It is possible to change the color of this graphic without actually going back into photoshop?

    Another option is to make a path around the image, so that you have a vector shape with full control over fill and transparency.
    You can do the path in Ps, save as clipping path, bring into InD, position, convert clipping path to frame, select and delete content, fill, fade...
    It may be easier to do the path in InD, but perhaps accurate positioning over the area you're after would be an issue.

  • How do I change the colors of this image?

    I want to change the color scheme of this image, not just re-color it one color.  I have the original file, this is just the shutterstock preview image. I'm a beginner with Illustrator.
    Any tips would be much appreciated! Thanks

    Select it, and click the Recolor Artwork button in the Options Bar.

  • How can I change the colors of this image?

    I want to change the color scheme of this image, not just re-color it one color.  I have the original file, this is just the shutterstock preview image.
    Any tips would be much appreciated! Thanks

    colored image like this one, the Hue/Saturation function can be used to alter specific ranges of colors.  For example, altering the Hue and Saturation of Cyans and Yellows...
    -Noel

  • How do I change the color of an image

    I have some photos that I would like to change the color of, so that I can have the same image in multiple colors. How do I do this using Photoshop CS4?

    Using a Solid Color Layer set to the Blend Mode Color is one of several options in general …
    But maybe you could post a screenshot and elaborate one what you are trying to achieve.

  • How do I change the color of an image while still keeping some detail within the image

    I am trying to take a handprint such as the one below and change the color of the handprint to say a light pink (or any color) but I want to keep most of the detail of the fine lines that make this handprint unique.  The lines could even just come out as white as below.  The main thing is to change the overall color while maintaining the fine details.  I have been trying to accomplish this for over a week now in Photoshop Elements 11 and I have been unsuccessful as anything I do just totally color fills the image, which does not keep any details of the handprint.  Thank you to anyone who may be able to help me. 

    Hello again,
    Unfortunately, I am not getting the same result as you and I was wondering if you would take a look at what I'm doing and maybe you could tell me what I'm doing wrong.
    I go to file, open and bring in my file
    Go to Select, Layer, New, Layer
    Name = Layer 1
    Mode = color
    ok
    Two things then seem to go wrong:
    1.  I chose my foreground color, but when I go to paint, a smart brush setting takes over so I had to change my paint color in that setting - to pink.  also my foreground box color will then change to gray
    2.  So then I do have a pink handprint, but when I change the opacity, it only effects the pink - and not the black on the handprint (pic below).  I want the black to go away and have only the color there with the unique lines of the handprint which you were able to do.
    I'm not that handy in layering so maybe i'm doing something wrong there - just not real sure.
    Can you help?  I liked the way your handprint came out - if I could copy that with any color that would be great and exactly what I'm looking to do.
    Thank you so much.
    Tami

  • How can I change the color on an image in illustrator?

    I am creating my wedding invites in Illustrator and downloaded a banner to add at the bottom. The banner is very colorful and I want to change the colors to white. Is there a way to do this? This is the banner:
    Thanks in advance!!!!!

    no, it is a jpeg image, I copied and pasted in to illustrator. I have never worked with this program before, so i'm learning as I go along!!

  • How to change the color of an image....

    I have a logo that I use that has a
    white background with black lettering. I would like to use that logo sometimes with white lettering. How can I change that using PSE 7?
    I am creating postcards with a picture on the left and a color block on the right that compliments that picture on the left. I would also like to implement a gradient of some sort from the picture to the color block. Any tips on how to do that as well? I would like it to go from left to right....

    We'll use the image you posted.
    1. Use the black and white icon in your layers palette to make a pink solid color fill adjustment layer.
    Since the mask is white the entire image will be covered by the pink color.
    2. Now, we are going to hide the entire effect (pink solid color fill adjustment layer) by filling it with black. With the solid color fill layer highlighted in the layers palette, you can use the paint bucket or just invert the white mask by pressing Ctrl + I.
    Here we see that the entire pink solid color fill layer is hidden. We are now looking at your background layer.
    We are going to use a different gradient this time and make it easier to understand. I think I used linear last time. I think it will be easier to understand going this route for this particular situation.
    3. Set your foreground color chip to white then select the gradient tool. With the gradient tool selected, open the gradient editor and select the white to transparent preset. (To open gradient editor, double click the gradient window in your options bar.
    Above is what you need to look for in the options bar to double click to gain access to the gradient editor.
    The second preset should be foreground to transparent. If white to transparent isn't available, you need to change your tool box's foreground color to white as the gradient's foreground color will be whatever is selected as the foreground color in the tool box.
    4. Here is a screen shot of my gradient tool settings that I used.
    I pulled from right to left because I do not have reverse checked. If I had reverse checked, I would have pulled left to right. Notice the gradient style I have selected and that the tool is in normal blend mode and that transparency has been enabled.
    I should also mention that I pulled from pretty close to where the two images join and only pulled maybe a centimeter worth of drag.
    Yellow line shows start and stop point of tool drag. *You can drag more than once if the gradient is too thin at the join.
    The reason you want to hold in the shift key as you drag the gradient is because this gives you an even pull...makes a straight line. Without using the shift key you can get a wonky uneven join.

Maybe you are looking for

  • Error Message When Installing Download Helper 4.8.2 Add-On

    I've updated to Firefox 3.6.13. The Add-on tab shows that there are add-on updates to be installed. When I download these flash download updates (Download Helper and Flash Video Downloader) and then try to install them I get an error message saying t

  • SAP F&R:: Service Levels & Forecast Frequency

    Hi, while modelling some user requirements, I have come to figure out some kind of a "dynamic" link between the service levels "determined" for a location-product and the forecast frequency assigned to the said location product. Please find my observ

  • Workflow is starting with status Error.

    Hi All, I am trigerring my workflow from an custom event, my workflow is getting trigerred but the status is showing as ERROR. I have already checked SWEL to check event creation, even in event simulation i am able to see that my workflow has been tr

  • Thinkpad Twist S230U - Battery Issue (Only 1 hour on full charge)

    Hello all, I'm desperate here. I purchased my Twist from eBay and from that time I've had a battery issue. I was only getting approximately 1 hour and 15 minutes off a full charge before it died. I mostly just tolerated it and had to keep close to an

  • IMporting Video Clips

    Hello everyone, just got my second Mac and I was trying to mess around with iMovie and was hoping if anyone can help me with my problem. Ok I'm trying to import video clips from my digital camera that I recorded and make it into one long video...was