Results 1 to 4 of 4

Thread: How to create a smooth image from data?

  1. #1
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to create a smooth image from data?

    Hi,

    I have a 2D data matrix and a colormap that I can convert each data point to a QColor, with that I create a Format_ARGB32 image.

    When I zoom in the image, the image appears very rough with square blocks (see attachment).

    How can I create a smooth image from the raw data? Is it possible to use QGradient for that?

    An example is very much appreciated.

    Thanks!
    Attached Images Attached Images
    • File Type: png 1.png (1.4 KB, 16 views)

  2. #2
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: How to create a smooth image from data?

    Implement "on fly" blur. Try to take visible area of the image (i.e. zoomed in/out) and apply blur filter on this area only. Depending on the filter (gaussian, linear etc.) speed can vary.
    You can also use pixel shader to speed up process (but that will require hw ps support).

    As for blur filter implementation just type c++ blur filter in google and there will be more then enough examples.

    And QRadient is not for this task.
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to create a smooth image from data?

    Have a look at Qwt, particularly the spectrogram plot. With bilinear interpolation this will do exactly what you want, especially if your 2D data matrix is computed (i.e. not an image) and is appropriate for interpolation.

    No sense in reinventing wheels. Talei's advice, while also correct, is overkill for solving this problem. Even if you don't want to use Qwt, bilinear interpolation is the way to go to solve this. Either use the code from Qwt or google for it. Plenty of implementations to choose from.

  4. #4
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to create a smooth image from data?

    Thanks!

    I look at the qwt implementation, and I think I am doing very similar, except:
    Qwt create image on the fry from data with interpolation done in the data, but what I do is to create the QImage first from data, for instance, if I have an 1000x800 data, I first create QImage( 1000, 800, Format_ARGB32 ).

    Then when I zoom in, I dig out the exposed sub image, such as at QRect( 400, 500, 60, 70 ), this sub image has to map to the screen, say with QSize( 700, 600 ). I use bilinear interpolation of 4 corner image data to compute QRgba in between.

    I split the image's QRgba into QRed, QGreen, QBlue, QAlpha, then interpolate each component, and merge back using QRgba( r, g, b, a ). However, the image quality is still poor.

    If I interpolate from data just like Qwt using same interpolation method, then create the image from the interpolated data, result look good.

    So what do I do wrong? I thought QColor's r/g/b/a components can do linear interpolation?

    (I can't use Qwt due to many reasons).

Similar Threads

  1. smooth panning and zooming an image, to use OpenGL or not?
    By scarleton in forum Qt Programming
    Replies: 0
    Last Post: 27th August 2010, 22:25
  2. Create Transparent PNG Image
    By hvitual in forum Qt Programming
    Replies: 1
    Last Post: 2nd August 2009, 14:35
  3. Replies: 1
    Last Post: 31st January 2009, 23:00
  4. Using a 2d data array to create an image
    By dbrmik in forum Newbie
    Replies: 20
    Last Post: 28th October 2008, 17:22
  5. Create pixmap image from string
    By Morea in forum Qt Programming
    Replies: 5
    Last Post: 17th November 2006, 16:38

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.