Results 1 to 11 of 11

Thread: Image processing via matrix

  1. #1
    jones.79 Guest

    Default Image processing via matrix

    Hello all!

    I am working on a QT-GUI for a scientific camera.

    The camera saves images as jpg, tiff or, which is
    I guess the best for processing the images, as a
    matrix filled with values (photon counts)

    And for this I need to display the matrix
    as an image.
    (first colum is number of horizontal pixel,
    the other colums equal vertical pixels)

    Example:
    400.00009,1962,1974,2007,1966,1920
    401.00009,1978,1968,2024,2010,2028
    402.0001,2012,2019,1983,1996,2019
    403.0001,2090,2045,2087,2053,1998
    404.0001,2075,2037,2091,2087,2043
    405.0001,2129,2159,2107,2113,2088

    The first idea that i thought of,
    was to draw the image pixel by pixel into a QPixMap or QImage
    and use a defined range of grey scales for the "coloring."

    And now my question:
    Has one of you ever had a similar problem or
    knows a better solution?

    Are there functions in QT or other libraries that deal with
    image-matrices?
    Would it be possible/easier to use the CImg-Library?

    Any ideas are very welcome

    Thanks,
    Markus

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Image processing via matrix

    What do these values represent? You want to draw a kind of a histogram?

  3. #3
    jones.79 Guest

    Default Re: Image processing via matrix

    The values in the matrix represent the intensity of light falling on the CCD of
    the camera. So, an image with a linear greyscale would look just like
    a normal image. And this is what I want to view within the GUI.

    Another feature would be to do some image progessing by matrix operations, but
    I guess thats easy to realize, because it could be done with arrays or e.g.
    using parts of the GSL (Gnu Scientific Library).

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Image processing via matrix

    So what exactly is the problem? Create a QImage and fill it with data using QImage::setPixel().

  5. #5
    jones.79 Guest

    Default Re: Image processing via matrix

    Well, there is no problem with that. This is what I thought of, as I wrote above.

    But I wanted to ask, if there is a better way to realize it, like
    treating the complete matrix as one image. This would make it
    easier to display (maybe faster too) and it would be easier
    to calculate with matrices.

    Any ideas?

  6. #6
    jones.79 Guest

    Question Re: Image processing via matrix

    Ok, its working so far. Now I need to set a color table.

    And I don´t understand the syntax of setColorTable.

    void QImage::setColorTable ( const QVector<QRgb> colors )

    I tried running a if-condition that fills the color table with a gradient

    {
    image.setColorTable()[i] = qRgb(i,i,i);
    }

    But it´s not working. I get the following error message:

    no matching function for call to `QImage::setColorTable()'
    candidates are: void QImage::setColorTable(QVector<uint>)

    Can someone tell me whats wrong with the syntax?

  7. #7
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Image processing via matrix

    image.setColorTable()[i] = qRgb(i,i,i);
    what are u trying to do in this line ??? setColorTable doesnt take zero arguments !!

  8. #8
    jones.79 Guest

    Default Re: Image processing via matrix

    Hm, I guess setColorTable is the wrong function,
    because I do not want to use a complete colortable,
    just fill one with colors.

    The right function should be image.setColor(i, qRgb(i,i,i) );

    Is that correct?

  9. #9
    Join Date
    Apr 2008
    Location
    China
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Image processing via matrix

    Could you try loadFromData()?

  10. #10
    Join Date
    Sep 2008
    Posts
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Image processing via matrix

    A QPixMap is your best bet for the class to represent an image array like you have. If you can coax your data into a format recognised by QPixmap::loadFromData() then this will probably be fastest (although in my experience of displaying data from CCDs, the time spent pulling the data off the sensor usually exceeds drawing time by a good deal). From the description of your image data, it shouldn't be too hard to coerce it into Portable Graymap form (PGM), which is one of the file formats recognised by Qt.

  11. #11
    Join Date
    Apr 2008
    Location
    China
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Image processing via matrix

    There is also a function to convert numpy arry to a QImage in Qwt, which you may have a nice look at.

Similar Threads

  1. Image Processing using Qt
    By danielperaza in forum Qt Programming
    Replies: 2
    Last Post: 9th March 2008, 18:15
  2. Finding marks on scanned image for alignment
    By caduel in forum Qt Programming
    Replies: 1
    Last Post: 23rd September 2007, 02:10
  3. how i can add image in my toolbar
    By jyoti in forum Qt Tools
    Replies: 7
    Last Post: 19th December 2006, 14:39
  4. How and when to repaint a widget ?
    By yellowmat in forum Newbie
    Replies: 7
    Last Post: 3rd April 2006, 16:36
  5. Question about updating an image on screen
    By SkripT in forum Qt Programming
    Replies: 1
    Last Post: 24th February 2006, 19:01

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.