Help needed to understand Spectrogram.
Please could anyone help me to understand the
Spectrogram,
QwtRasterData,
QwtMatrixRasterData.
I tried to understand it, but i just cant get the logic of how they work and how to play around with them.
The example Spectrogram and resterview, just show how to give values and as i think they assume that x,y are for each pixel of the canvas (for the x/y scales).
how to resample my points,
how can I let the spectrogram know this value is for this x,y position ??
If someone can provide an example to elaborate how pixelHint() and value() methods should be used.
Please help, It could be like a tutorial of how to use them. I think it will be very helpful for all starter like me and give us more understanding about the spectrogram.
Thank you so much.
Re: Help needed to understand Spectrogram.
O.k I will try:
first of all it will help to understand, that a raster item ( spectrogram is one ) creates a QImage. A QImage is a matrix of color values - one for each pixel. The position of the image and its pixels is always aligned to paint device coordinates ( usually the widget ) - not to plot coordinates - simply because a widget has an integer based coordinate system.
Assuming that the geometry and resolution of the image has been calculated somehow then the item iterates over all pixels and does the following steps:
- translate the pixel position into plot coordinates
- request a value at this position.
- scale the value into the range 0 - 1 ( the minimum of the z interval means 0, the maximum 1 )
- translate the scaled value into a color using a color map.
So all what needs to be done in application code is to answer the request: give me a value for a specific position.
How to implement this of course depends:
- the spectrogram example shows a situation, where the value is calculated. Here you always have a value at the requested position.
- more often is the situation, where you have a matrix of values. F.e. elevation of Austria in a resolution of 20x20 meters. Here you need to do something that is called resampling.
The simplest and fastest way of resampling is nearest neigbour, where you simply round the requested position to the nearest position where you have a value: so when you have data pixels of 10mx10m and a value at 100, 100 all request from 95,95 to 105,105 will return this one. Other ways of resampling interpolate somehow between neighbored values.
QwtMatrixRasterData implements 2 standard ways of resampling from a given value matrix. As Qt doesn't offer a class for 2 dimensional arrays you have to use a QVector and a second parameter indicating the number of columns. So when you have a matrix of 20x30 values than you would have to concatenate the rows to a vector of 600 values and 30 would be the number of columns.
When you don't want to return a value at a specific position ( because it is out of a bounds ) you can return a special value ( inside the z interval ! ) that is mapped to a transparent color from your color map.
Uwe
1 Attachment(s)
Re: Help needed to understand Spectrogram.
Thank you for talking time and replying.
Quote:
Assuming that the geometry and resolution of the image has been calculated somehow
do you mean by that geometry the x/y, and the resolution their value ??
Quote:
QwtMatrixRasterData implements 2 standard ways of resampling from a given value matrix.
So as i understand from you explication is that... if I have a matrix of values for a specific area, then I MUST provide a matrix of value for the bounding rect of this area, where points that are out of my interest area and inside the bounding box has a special value that map to transparent color in the color map. see attachment Attachment 8684
Re: Help needed to understand Spectrogram.
Quote:
Originally Posted by
jesse_mark
So as i understand from you explication is that... if I have a matrix of values for a specific area, then I MUST provide a matrix of value for the bounding rect of this area, where points that are out of my interest area and inside the bounding box has a special value that map to transparent color in the color map.
Exactly this - like I told you in a previous thread already. Never forget: a raster item is always about rendering a QImage to be used by QPainter::drawImage().
I would start with using the minimum of your z-interval ( maybe mapped to white ) for the values out of your interest area until you have a first implementation running.
Uwe