Results 1 to 6 of 6

Thread: QImage-Greyscale-8-bits-pixel

  1. #1
    Join Date
    Aug 2008
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy QImage-Greyscale-8-bits-pixel

    Hello, I am currently doing my thesis and I am using QT4, I have the following problem: I want to open an image (. Tiff), which has only one dimension, that is, in greyscale (band of a satellite, which is why only in one dimension), and I need to see it as a matrix for porder apply an algorithm, the problem is not how to do to see the values of the pixel in a matrix where the range of these pixel is 0-255, the image is 32-bit, I suppose we must transform to 8. thank you very much.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Convert an image as 32-bit 8bits

    What exactly is the problem? You don't know how to transform an image from 32 bpp to 8 bpp greyscale?


    P.S. Please don't start more than one thread on the same topic.
    Last edited by jacek; 2nd August 2008 at 23:42.

  3. #3
    Join Date
    Aug 2008
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QImage-Greyscale-8-bits-pixel

    Hi, I did this:

    Qt Code:
    1. QString fileName = QFileDialog::getOpenFileName(this, title,QString(),tr("Images (*.tif)"));
    2. if (!fileName.isEmpty())
    3. im_banda1.load(fileName);
    4. QImage ban;
    5. ban=im_banda1.convertToFormat(QImage::Format_Indexed8);
    6.  
    7. int matrix[100][100];
    8. for(int i=0;i<100;i++){
    9. for(int j=0;j<100;j++){
    10. matrix[i][j]=ban.pixel(i,j);
    11. }
    12. }
    To copy to clipboard, switch view to plain text mode 
    and works, the problem is that the pixels are not the same as the original image, ie in the original image I have values 0-255, here too but only 4 wide range, which would seem to lose informaicion.
    Last edited by jpn; 3rd August 2008 at 13:13. Reason: missing [code] tags

  4. #4
    Join Date
    Aug 2008
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QImage-Greyscale-8-bits-pixel

    sorry, what I'm wrong, the line (*) is well: matrix[i][j]=ban.pixelIndex(i,j);

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QImage-Greyscale-8-bits-pixel

    You have converted your image to an indexed format, which means that pixel() doesn't return a color, but an index in the color table (see QImage::color()). If that image is grayscale, you don't have to convert it, just take one of the color components from the pixels:
    Qt Code:
    1. matrix[i][j] = qRed( im_banda1.pixel( i, j ) );
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Aug 2008
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Talking Re: QImage-Greyscale-8-bits-pixel

    Hello friend, now if it worked, really a million thanks, I've saved it, had already stopped 2 days, I will continue. I have another doubt but that I can ask you later. deverdad to thank you very much. God bless you

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.