Pixel values returned with getPixels() are wrong format

Discussion in 'Java' started by Alex, Apr 1, 2004.

  1. Alex

    Alex Guest

    Hi,
    I am a novice to image analysis, and trying to retrieve pixel values
    using the PixelGrabber class. When I print the int array pixel values
    obtained as below, I get this :

    -10592163 -9144717 -5855067
    -15921396 -15658224 -13750227
    -16579326 -16776960 -15789810
    -16776960 -16710912 -13881813
    -14934501 -13158090 -8026236

    That is, the number of pixels is correct and the magnitude of each
    pixel value scales with the darkness of a pixel it represents... but,
    they are negative and don't look like the values you'd exepct for a
    256-bit, black and white, jpeg image. In case this helps, when I print
    the ColorModel, I get this:

    DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=ff000000

    but I don't know what these symbols mean.

    I've already tried to save getPixels() output into a byte[] array
    instead of int[], then convert into int[]. Also, I used Byte class and
    its intValue() to do the same. No success either.

    Can anyone suggest what I am doing wrong? Thanks in advance!

    Here's the code:
    /***********************************************/
    // This class extends PixelGrabber, which is what "super" refers to

    AM_PixelGrabber(Image img) //Constructor
    {
    super(img, 0, 0, -1, -1, true);
    {

    public void extractPixels() // the method to extract pixels
    {
    try
    {
    if (grabPixels())
    pixelsArr = (int[])getPixels(); // save pixels into a 1D int
    array
    }
    catch(InterruptedException e) {}
    System.out.println(getColorModel());
    }
    /***********************************************/

    //The main method does this:

    File f = new File("bw-15.jpg"); // Open the image file.
    BufferedImage bufi = ImageIO.read(f); // Store image in buffer.
    AM_PixelGrabber apg = new AM_PixelGrabber(bufi); // Constructor call
    apg.extractPixels(); // Extract the pixels and store them in an array
    // Then, I print the int array.
    Alex, Apr 1, 2004
    #1
    1. Advertising

  2. Alex wrote:
    > Hi,
    > I am a novice to image analysis, and trying to retrieve pixel values
    > using the PixelGrabber class. When I print the int array pixel values
    > obtained as below, I get this :


    Do not multipost (and don't crosspost either). You question has been
    answered in another group. Now go hunting for the answer.

    You might want to make yourself familiar with the basics of using
    newsgroups.

    /Thomas
    Thomas Weidenfeller, Apr 1, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jty202

    Problem with indexed pixel format/

    jty202, Jan 23, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    8,711
    griggsfw
    Jun 16, 2008
  2. José Mª
    Replies:
    1
    Views:
    1,116
    David Zimmerman
    Jun 30, 2003
  3. Jon Berg
    Replies:
    1
    Views:
    1,703
    Leif K-Brooks
    Feb 3, 2005
  4. Replies:
    3
    Views:
    355
  5. André Wagner

    Fastest pixel by pixel operation

    André Wagner, Mar 17, 2008, in forum: Java
    Replies:
    12
    Views:
    1,025
    Larry A Barowski
    Mar 19, 2008
Loading...

Share This Page