# Thread: Interpolation of data in Qwt Raster Matrix Data

1. Beginner
Join Date
Nov 2015
Posts
2
Qt products
Platforms

## Interpolation of data in Qwt Raster Matrix Data

Hi all,

I am using Qwt Raster Matrix Data to develop spectrogram plot. Data that is used for presenting contours is data from file. Usually, it is the matrix of around 50 - 100 rows and 5 - 20 columns. After attaching it to the Qwt Raster Matrix Data, I use it produce spectrogram using Spectrogram Class. Then I attach spectrogram to Qwt Plot.

Everything works fine, values of spectrogram are ok. But beacause data used is not very dense, my contour is filled with bunch of rectangulars of different colours. When I use Octave for displaying same data, I get very smooth, "non - pixelised" contours.

From what I read in documentation of Qwt Raster Matrix Data, it uses by default next neighbour interpolation algorithm. My question is: Am I missing a point here and next neighbour interpolation in QwtRasterMatrixData isn't used for smoothing the contour plot and some seperate algorithm should be used for it?

2. Uwe
Expert
Join Date
Feb 2006
Location
Munich, Germany
Posts
3,306
Thanked 879 Times in 827 Posts
Qt products
Platforms

## Re: Interpolation of data in Qwt Raster Matrix Data

Originally Posted by burger_major
Am I missing a point here and next neighbour interpolation in QwtRasterMatrixData isn't used for smoothing ... ?
Next neighbour is not interpolating between values by definition: see https://en.wikipedia.org/wiki/Bicubic_interpolation ( the rasterview example shows exactly the data given in the article ).

There is only one algo implemented, that interpolates between data point: bilinear interpolation ( see QwtMatrixRasterData::BilinearInterpolation ).
For more advanced methods you would have to overload QwtRasterData::value() and write some code - but this is usually a trade of between performance and the quality of the interpolation.

Uwe

3. Beginner
Join Date
Nov 2015
Posts
2
Qt products
Platforms

## Re: Interpolation of data in Qwt Raster Matrix Data

Uwe,

Thank you for your reply. According to the article, Bilinear interpolation is what I am looking for, but I have troubles with switching from default nearest neighbour resampling mode to the bilinear interpolation.

Qt Code:
`QVector <double> values;    for(int i=-25; i<25; i++)    {    values.push_back(i*i);    }    QwtMatrixRasterData *m = new QwtMatrixRasterData;    m->setValueMatrix(values,5);    m->setResampleMode(m->BilinearInterpolation);`
To copy to clipboard, switch view to plain text mode

changing resample mode in that way doesn't seem to give any changes to data presentation.

4. Uwe
Expert
Join Date
Feb 2006
Location
Munich, Germany
Posts
3,306
Thanked 879 Times in 827 Posts
Qt products
Platforms

## Re: Interpolation of data in Qwt Raster Matrix Data

Originally Posted by burger_major
...but I have troubles with switching from default nearest neighbour resampling mode to the bilinear interpolation.
Check the example.

Uwe