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
Bookmarks