Qt World Summit: Register Today!

QMatrix, QColor wishlist

  • I love Qt! Qt Creator with UI Designer are awesome. I can make a KDE/Plasma utility faster than in any other environment. Easy to incorporate assembler, too. [Those who ask why assembler, in a 720x480 loop over a hundred image files, saving 20 cycles in the inner loop makes things go faster.]
    Would that QColor supported CIELCh or even CIEXYZ or CIELAB color spaces. Have to convert RGB to sRGB by dividing each color triplet by 255 for [0..1], then apply a gamma for various white points, D66. D50. Then apply a transform matrix to get [X, Y, Z], then convert to Lab* before converting that into LHc. The images I'm working on are easy to lighten up by reducing the L value from 100+ to less than 20, with only a few H and c. Images extracted from 200+ mp4 movies using ffmpeg, unless I find a way to do that with Qt.
    Would that QMatrix was more robust. Had to write my own library to multiply a 3x3 transform matrix by a 1x3 column matrix.
    When I get back to analyzing FITs signals from radio telescopes, there'll probably be more wishes. As it is, throwing up a quick gui representation of complex data makes my projects a lot easier. Kudos to the Qt Development team! The more I read the documentation, the more tools I add to my toolbox. Gotta love Qt!

  • To multiply a 3x3 by a 1x3, I can use a QMatrix4x4 and place '1's in the unused rows/columns, then use the matrix multiply function.

    Might be a way to getHslF or getHsvF to make the transformation to LHc quicker. Still getting smart on the relevant ICC and CIE documents that seem difficult for duckduckgo.com to find. GIMP and lots of on-line tools convert RGB to LHc only one point at a time.

  • Lifetime Qt Champion

    @Psnarf If you have any improvements ideas you should go to developers mailing list or file a change request in Qt bug tracker as this forum is mainly for Qt users.

  • Thank for directing me to the correct forum. I did not know about the mailing list. I don't consider the lack of CIELCH, CIEXYZ, or CIELAB support a bug. Not much call for edge detection and signal analysis.

  • @Psnarf You may want to look into OpenColorIO for doing colorspace conversions. Everything you are suggesting sounds nice, but 99% of app developers are never going to care about things like white point correction, so it'll probably always be best to use more specialized libraries for some of the work.

    OpenColorIO even supports GPU acceleration for some operations, so it may manage to beat some of your ASM for colorspace conversions in some cases.

    As for extracting images from ffmpeg, that'll be harder that you are hoping with Qt. A lot of the underlying code is there, but the main usecase of Qt multimedia stuff is basically around providing an easy wrapper for realtime video playback. So, it provides an easy way to take advantage of hardware acceleration, but that doesn't always provide an easy way to extract the decoded frame and copy it back from the accelerator's address space into CPU memory where you can poke at it. For a really convenient wrapper on FFMPEG that handles decoding to a convenient image in CPU memory, I like a library called FFMS2. Once you get it set up, getting an arbitrary frame frame a video file is just

    const FFMS_Frame *curframe = FFMS_GetFrame(videosource, framenumber, &errinfo);

    With no need to manually handle the funkiness of seeking across I-frames like with bare ffmpeg. It's waaaay more straightforward than setting up probes to intercept decode signals onto AbstractVideoSurface subclasses with QtMultimedia.

  • Thank you for your suggestion. OpenColorIO saved a lot of work. I am cleaning up calligraphy videos produced without 3-point lighting. The shadows cover the entire paper, creating a gray paper. I'm processing over 400 images per movie. The LCH color space shows the greatest difference in the lightness value. To get LCh from QRgb: QRgb to sRGB (normalized 0-100), sRGB to CIEXYZ, XYZ to Lab*, then finally LAB to LCH. One step involves multiplying a 3x3 matrix of doubles by a column matrix. Corrected LCh[720][480][3] back to QRGb in order to use the QImage pixel() and bit() functions. Directly applying the corrected L value of an LCh tuple would be nice. But, like you said, few of your target customers would need it.
    I also use Qt to process FITS images from radio telescopes. Scientific image analysis might be a profitable new customer base. I'd rather use C++ in Qt to create GUI interfaces than bang on Fortran code. It's been over 40 years since I used Fortran on Holerith cards and paper tape.

  • Lifetime Qt Champion


    Note that there is nothing wrong mixing in other libraries for image processing and only do the display with Qt.
    You might also want to consider OpenCV for exemple.

    If you take the Krita project for example, the core of the application is Qt but they are using also other tools for image processing.

Log in to reply