Spltting an image into its red green and blue components

Hi,
I need to split an image into 3 images, one the red component of the original image, one the green component, and one the blue.
Any idea how this can be done?

Hi,
something along these lines:
Robot robot = new Robot();
// loop: get color for each pixel in image
Color pixelColor = robot.getPixelColor(x, y);
int red = pixelColor.getRed();
int green = pixelColor.getGreen();
int blue = pixelColor.getBlue();
// do your stuff with these values
Cheers,
Jim

Similar Messages

  • Problem extracting red, green and blue from ColorModel

    Hi everyone,
    I'm attempting to write a piece of code to extract the red, green and blue components from an image using the ColorModel class. When I attempt to run my code below, I get the following error: Exception in thread "main" java.lang.IllegalArgumentException: More than one component per pixel. Does anyone know how to extract an integer representation of the red in a pixel in order to solve the problem? Here's the code snippet:
    public void getRGBValues()
              String imageFilename = new String("C:\\Documents and Settings\\David\\My Documents\\My Pictures\\blue hills1.jpg");
             PlanarImage image = JAI.create("fileload", imageFilename);
             //Get the color model for that particular image
             ColorModel imageColorModel = image.getColorModel();
             //ints to store the appropriate values for each colour component
             int totalRed = 0;
             int totalGreen = 0;
             int totalBlue = 0;
             int averageRed = 0;
             int averageGreen = 0;
             int averageBlue = 0;
             int pixelNumber = 0;
             int pixelCount = 0;
             //Loop to extract the colour values out of each pixel in an image passed into the class
             for(int i = 0; i < image.getWidth(); i++)
                  for (int j = 0; j < image.getHeight(); j++)
                       totalRed += imageColorModel.getRed(pixelNumber);
                       totalGreen += imageColorModel.getGreen(pixelNumber);
                       totalBlue += imageColorModel.getBlue(pixelNumber);
                       pixelCount++;
                       pixelNumber++;
                  pixelCount++;
                  pixelNumber++;
             averageRed = Math.round(totalRed / pixelCount);
              averageGreen = Math.round(totalGreen / pixelCount);
              averageBlue = Math.round(totalBlue / pixelCount);
              System.out.println("Average red is " + averageRed);
              System.out.println("Average green is " + averageGreen);
              System.out.println("Average blue is " + averageBlue);
    }

    You are misunderstanding the ColorModel methods. The color model can translate between colors and pixels, but it doesn't know or hold pixel data.
    I don't know the JAI, but if you use J2SE classes like BufferedImage, this is easy to do:
    BufferedImage im = ImageIO.read(input);
    int argb = im.getRGB(x, y);
    int r = 0xff & (argb>>16);
    int g = 0xff & (argb >>8);
    int b = 0xff & argb;

  • Why my phone doesn't have that Red Green and Blue circles on camera, I have an iPhone4 v7.1.1

    My classmate has an iPhone 4/4s, the camera has Red Green and Blue circles while mine doesn't have that circles.

    Does your classmate have an iPhone 4? Or a 4S? There is no such thing as a 4/4S. Even with the same version of iOS, different models may have different features. As far as I know, the live filters are only available on the iPhone 5 and later.

  • Red, green and blue to RGB integer val

    Hello all,
    I have three colour values for e.g.
    Red : 100
    Green: 255
    Blue: 100
    How can I convert these into a value that setRGB(int x, int y, int rgb) can use?
    I understand that setRGB is looking for a value like 0xFF00FF00.
    Please help!

    int red = ...;
    int green = ...;
    int blue =...;
    int rgb = red + (green >> 8) + (blue >> 16);
    that should work. I may have the shifters the wrong way tho :)

  • Mac stuck at Gray apple screen that turns red, green and blue.

    A month ago I was playing world of warcraft on my powerbook when the entire screen froze up and pixelated. I forced shut down and powered it back up. Now I only get the gray screen with the apple and the spinning wheel. The gray screen changes color to blue, then green then red and lines flicker horizontally up and down my screen. After a minute the little wheel stops spinning. I have tried all of the various resets, booting into safe mode, hooking it up to an external monitor and none of those options worked. I booted into target disk mode and ran checks on my hd and it is fine. If I try to boot from my installer cd the screen just goes gray. Do you think this could be a sign of logic board failure?

    Welcome to the Apple discussions.
    Sorry to hear about your system. You've done some good troubleshooting, however, I'd suggest you take it to an Apple store or Apple Authorized Service Provider, to get their take. It does sound likely that the logic board has issues. You can find the closest store/provider at http://www.apple.com/buy/locator/service/ . Assuming it is a logic board issue, you can buy and replace it yourself, however, it is very involved. You can see how to do it at http://www.ifixit.com/Guide/Mac/PowerBook-G4-Al-12-Inch/Logic-Board/53/16/

  • Suddenly have red, green and blue splotches on video clips

    It looks like something to do with exposure but I don't know how it appeared, why it appeared, not how to get rid of it. It's driving me crazy, how do I turn it off?  It's hard to see but the splotches are a red one on the pan on the right top, and a green one on the woman's armpits and under her collar. There are more but that's an example.

    Hi, I had a similar problem with clips that were ok in FC PRO but had colour artefacts in FCP X. Drove me to distraction.
    I then discovered that by moving the FCP X window to another monitor (I have 3 monitors) the colour artefacts disappeared.
    My main monitor is a 24"' IPS, calibrated FOR PRINT with ColourMonkey hardware and software, and the other 2 are TN monitors.
    Anyhow, since my clips appeared ok on the 2 TN monitors i chose a different colour profile for the main (IPS) monitor and, voila...problem solved!
    I am certainly no expert in things FCP so i may be wrong, but it could be worth a try?

  • The red, green and yellow buttons in the upper left corner of the screen disappear whenever I open Safari.  I cannot minimize the Safari window which I often need to do if I am coordinating multiple windows.  Does anyone know how to get those buttons back

    The red, green and yellow buttons in the upper left corner of the screen disappear whenever I open Safari.  I cannot minimize the Safari window which I often need to do if I am coordinating multiple windows between different applications.  Does anyone know how to get those buttons back?  I guess I could just switch betwen appliations, but I am used to doing it the other way.

    You're welcome 
    You had Safari in full screen mode.

  • I just bought a new iphone 4S and its has green and purple striiples on the screen when not in use, I took it back to store and they said it was the display protector that is making the striples?

    I just bought a new apple iphone 4S and its has green and purple striples on it when not in use, is this norm? I took it back to the Verizonwirless and they said it was from the display protector on the screen?

    it was from the display protector on the screen?
    Most likely that is the reason.  I have a screen protector on and see similar issues when the iPhone is not on.  They're not noticeable when turned on.  Remove it and see the difference.

  • Phone went green and blue with lines and then switched off, apple symbol now appear on and off, any ideas?

    My phone while using went green and blue and then switched off, now apple symbol flashes on and off , any ideas as to what is wrong?

    NNo seriously, you have to restore it to its last backup, it froze in the middle of something and now it is malfuning

  • Screen covered with green and blue pixels (visible on dark colors)

    Hello,
    I have this tablet since beginning of April, and since few days I've noticed the little dots on the top of the screen.
    From far away it looks like dust behind the screen, but by having a closer look, it's like pixels that stay green and blue when the rest of the image is dark.It's very visible when I'm using the tablet with no lights around me. i've tried to restart the tablet, and even when It's loading with the SONY sign, I have that! what should I do ? Did people had that issue before ?  
    (BTW, The screen is also unresponsive when plugged to charge)

    I encounter the same problem. I bought my Z2 tablet 16GB from the Singapore Sony Store. I got it for one month and the same pixel problem appeared.   I send it in for servicing at the Singapore Sony care centre at 313 somerset outlet.. One week went by and nothing happened. The service was bad, no reply from the customer care or technician. They gave me a website so i can check the status of the servicing but all it shown on the page was pending.. one full week and still pending. I had to call them once and asked them what happened, the Sony personal over the line could only say they can check and get back to me. The next day i called again to check if any technician has even start and immediately right after that they called me to go down to collect. Turn out they are giving me a new tablet. And the screen protector was not refund to me as they said that the device was still in the service centre.. had to buy a new one for myself. Such a disappointment in the servicing.. and now the current one i am holding as the same freaking problem.. also i notice the corners of the screen has some yellowish hue.    

  • Qosmio F30-117 - green and blue lines on the screen

    So my F30-117 has been working well recently until I turned it on and had green and blue lines (sort of like scan lines) overlapping the screen.
    I tried to install new drivers from nvidia, but that didn't work, as Vista just picked them up as unknown.
    Anyone got a solution? Do you think the graphics card needs to be reseated?
    Thanks in advance!
    - Shayde Zehetbauer.

    You can easy determine what the reason is for this.
    Do you know how?
    Just connect an external monitor to the notebook and check the picture on it.
    If you have the same issue on the external monitor the reason is the graphic card and/or mainboard, if not its an internal display issue.
    Check this!
    Furthermore you should only use the drivers from Toshiba. The Nvidia drivers dont have an overheat protection so the graphic chip could be damaged. Its on your own risk.
    So try to install the drivers from Toshiba.

  • Green and blue dots around all the screen

    I have noticed that green and blue dots appear around the screen of my tablet, i have send to sony service, can anyone have this issue too? it has only 1 month of use...

    Same problem on my tablet (second one, first i already replaced) green dots all over screen.Two months of use.
     Model is sgp511 b2/b 14w16. Sony (if any of you guys reading this) please do something about that, your tablet is not cheap to have this problems. 

  • My iPad color changed?the background is now green and blue .what should I have to do?

    My iPad color changed?the background is now green and blue .what should I have to do?

    go to settings. press on background and wallpaper. choose your new wallpaper. your friends might have changed it on yours or something.

  • Green and blue patchwork

    I woke my Mac and the screen had gone green and blue patchwork!
    what's that all about?
    I have an Apple 20" LCD screen

    I get the same thing sometimes as well, rather disturbing when that happens hey!
    I have a 23in cinema display hooked up to a PowerMac

  • Auto import images into aperture...and continue importing...

    i know that there is a script to import images into aperture, but i need to use this with a tethered camera....so i use a canon app to shoot files to a folder and as the files come in, i need them to get imported as they keep coming in....i am only referencing them, so they are actually staying within the folder....i can import the files but i don't know how to/which command "keeps checking the folder for new files that came in" hope this makes sense....
    i know that there is a "hot folder" app available which seems to be a automator app, but it is superslow and only brings in every 4th or 5th image (and sometimes just brings everything to a halt...)

    i know that there is a script to import images into aperture, but i need to use this with a tethered camera....so i use a canon app to shoot files to a folder and as the files come in, i need them to get imported as they keep coming in....i am only referencing them, so they are actually staying within the folder....i can import the files but i don't know how to/which command "keeps checking the folder for new files that came in" hope this makes sense....
    i know that there is a "hot folder" app available which seems to be a automator app, but it is superslow and only brings in every 4th or 5th image (and sometimes just brings everything to a halt...)

Maybe you are looking for

  • I am unable to accept a .doc file from a sender

    FILE TRANSFER ERROR: Could not receive file "FAIR v. Rumsfeld.doc" from Tiggsfrnpooh26: An error occurred. This is what comes up when i try to recieve it. I have had no trouble with sending and recieving files in the past, though this is the first ti

  • How do you make room on your start up disk.  i am trying to do the update but don't have enough space

    how do you make room on your start up disk.  i am trying to do the update but don't have enough space

  • Help, iTunes refusing to install!

    I've been trying to install the new update for iTunes for nearly a week now and for some reason, I can't. Every time I try to do it, an error message pops up saying 'Apple Application Support was not found'. Can I ask what this even is? It's driving

  • MDM 7.1 : Not able to connect to repository

    Hello, I am facing problem while connecting to repository via MDM Console. It gives below error. Repository connection failed. Error : Access to syncronization data is locked for master repository. Same error I am getting when I try to connect to new

  • Epubs and equations in InDesign

    In ID CS6, is there a way type/insert/import equations so that they will be maintained upon epub conversion? I have some experience with InDesign, but minimal with equations so as much detail as possible would be great!