Results 1 to 3 of 3

Thread: Nonuniform raster data resampler for QwtPlotSpectrogram (Qwt 5.2)

  1. #1
    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: Nonuniform raster data resampler for QwtPlotSpectrogram (Qwt 5.2)

    I have developed a set of classes for use with QwtPlotSpectrogram that permits the ability to display an x, y array of data that has nonuniform spacing. QwtRasterData expects a uniformly-spaced array, whereas often real-world x,y data is sampled at varying intervals.

    This code uses a technique called "Gaussian splatting" to resample the non-uniform point array onto a uniformly-spaced grid. The technique can be thought of like throwing a snowball against a hard wall. The harder you throw it, the wider the "splat" it makes. In the Gaussian splatting method, the points are thrown against the uniform grid, and the intensity (z value) is sampled in a circular region around each point. There are two parameters: sigma, which is a measure of how hard the point is "thrown" onto the grid; and threshold, which controls how low the z-value is sampled before the algorithm stops expanding the circle. Small sigma means the image remains point-like, larger sigma smears the points out and sums up any overlap among the circles. The GaussianResampler class does this.

    The NonuniformRasterData class is derived from QwtRasterData, and uses the Gaussian resampler. It sets a default grid size of 1000 x 1000 pixels, but this can be adjusted. It uses bilinear interpolation to return interpolated z values from the uniform grid.

    I have developed and tested the code in the attached zip file against Qwt 5.2. It is not yet working with Qwt 6.x - for some reason the image does not appear, so I will have to investigate that and repost the code once I have it fixed.

    The attached ZIP file contains the source code along with .pro and .pri files. Please note that I use Qwt as a static library and I rename it to qwt5.lib, so you will probably have to edit the .pro file to get it working for you.

    The attached images show some of the plots it generates. The "+" symbols in some plots mark the locations of the original data points. Constructive feedback is always appreciated.

    This code is released under the terms of the Qwt License, Version 1.0.

    GaussianSplatter.zip

    Image1.jpg

    Image2.jpg

    Image3.jpg

    Image4.jpg


    Added after 38 minutes:


    I now have this working with Qwt 6.0. Please use the code in the attached zip file, which should be compatible with both Qwt 5.2 and Qwt 6.0.

    GaussianSplatter_6_0_Update.zip
    Last edited by d_stranz; 31st March 2012 at 21:37.

  2. The following 2 users say thank you to d_stranz for this useful post:

    Foul Ole Ron (23rd February 2016), pabose (7th January 2013)

  3. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Nonuniform raster data resampler for QwtPlotSpectrogram (Qwt 5.2)

    Quote Originally Posted by d_stranz View Post
    The NonuniformRasterData class is derived from QwtRasterData, and uses the Gaussian resampler. It sets a default grid size of 1000 x 1000 pixels, but this can be adjusted. It uses bilinear interpolation to return interpolated z values from the uniform grid.
    I'm not sure if resampling from non uniform raster data to a matrix has to be done more than once ?


    • If not you could convert your data into a matrix and use QwtPlotMatrixData then.
    • If true you could calculate the matrix by your resampler in YourRasterData::initRaster() and then use one of the implemented resampling algos ( well, there are no so many today ). In such an implementation resampling would be done twice for each image, but the expensive one in your resampler would be much faster as you could process all your values in one loop instead of the overhead you have from the point by point resampling of the spectrogram framework.


    Uwe

  4. #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: Nonuniform raster data resampler for QwtPlotSpectrogram (Qwt 5.2)

    I'm not sure if resampling from non uniform raster data to a matrix has to be done more than once ?
    The resampling from the point cloud (the non-uniform raster data) is done only once, in the "splatting" operation. This is dependent only on the size of the resampling grid held by the NonuniformRasterData class, not the screen pixel dimensions.

    Imagine the resampling grid as a window screen attached to a flat board (so nothing can go through it). Each original data point is a rotten tomato, and each one has a different size. Throw each tomato at the screen with the same force. Depending on the size of the tomato, it makes a bigger or smaller "splat". When you have thrown all of the tomatoes, examine the screen. At each grid crossing in the screen, measure the thickness of the tomato mush. These are the new z-values for the screen grid (x,y) positions used in the NonuniformRasterData (derived from QwtRasterData) class.

    The second step is what now happens in Qwt 6's QwtMatrixRasterData, the bilinear interpolation from resampling grid point to screen pixel. In Qwt 5.2, this class does not exist, so that is what my NonuniformRasterData class does. It just combines the two operations of resampling and interpolation. As you suggest, in Qwt 6, I could separate the GaussianResampler and replace the NonuniformRasterData class with QwtMatrixRasterData, using the resampled grid as its input. Good idea, and I will implement that.

    David

Similar Threads

  1. Replies: 0
    Last Post: 17th November 2011, 16:44
  2. Replies: 1
    Last Post: 15th November 2010, 22:46
  3. Plot Raster chart background
    By jmsbc in forum Qwt
    Replies: 3
    Last Post: 8th August 2010, 19:56
  4. Native vs Raster
    By ArlexBee-871RBO in forum Qt Programming
    Replies: 7
    Last Post: 15th February 2010, 22:22
  5. Irregular data and QwtPlotSpectrogram
    By seveninches in forum Qwt
    Replies: 1
    Last Post: 27th January 2008, 10:52

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.