Results 1 to 3 of 3

Thread: Extracting RGB

  1. #1

    Thread Starter
    Hyperactive Member Greyskull's Avatar
    Join Date
    Dec 2003
    Location
    somewhere in England
    Posts
    382

    Extracting RGB

    Hello,

    I've developing an application which needs to extract RGB for each pixel in an image then later do some calculations with chromaticityu using some formulae.

    I can do d calculations but i do not know where to start. I can save an image onto the computer's memory but im stuck as i dnt knw how to extract pixels and RGB...

    can anyone help?

    Thanks in advance

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Extracting RGB

    I think the class java.awt.image.BufferedImage is the answer to your problem.
    take a look at it, it has a method called "getRGB" that requires x,y in offsets and returns an integer representation for the RGB color in that pixel.
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3

    Thread Starter
    Hyperactive Member Greyskull's Avatar
    Join Date
    Dec 2003
    Location
    somewhere in England
    Posts
    382

    Resolved Re: [Solved] Extracting RGB

    I've actually found two ways to extract it and save its values to an array.

    These two methods are using Raster and using the following:

    int red = (pixel >> 16) & 0xff;
    int green = (pixel >> 8) & 0xff;
    int blue = (pixel) & 0xff;

    where pixel = getPixel(image.getRGB(x,y))

    I've used the latter one but I heard that the Raster method is quicker.

    Thanks for the advice tho

Posting Permissions

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



Click Here to Expand Forum to Full Width