Results 1 to 4 of 4

Thread: Help needed to understand Spectrogram.

  1. #1
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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.

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

    Default 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:


    1. translate the pixel position into plot coordinates
    2. request a value at this position.
    3. scale the value into the range 0 - 1 ( the minimum of the z interval means 0, the maximum 1 )
    4. 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

  3. The following user says thank you to Uwe for this useful post:

    jesse_mark (6th February 2013)

  4. #3
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Help needed to understand Spectrogram.

    Thank you for talking time and replying.

    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 ??


    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 Spect.jpg
    Last edited by jesse_mark; 6th February 2013 at 22:52.

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

    Default Re: Help needed to understand Spectrogram.

    Quote Originally Posted by jesse_mark View Post
    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

  6. The following user says thank you to Uwe for this useful post:

    jesse_mark (7th February 2013)

Similar Threads

  1. trying to understand qsettings ...
    By kerim in forum Newbie
    Replies: 7
    Last Post: 28th April 2011, 14:30
  2. Something i am not understand about Qt.
    By HeX0R in forum Newbie
    Replies: 8
    Last Post: 12th February 2010, 05:37
  3. need help .not able to understand.......
    By sh123 in forum Qt Programming
    Replies: 1
    Last Post: 20th January 2009, 02:50
  4. don't understand Qt's setCodecForCStrings
    By ber_44 in forum Qt Programming
    Replies: 1
    Last Post: 9th July 2007, 02:19
  5. QFontMetrics, i can't understand
    By pakulo in forum Qt Programming
    Replies: 11
    Last Post: 24th June 2007, 18:59

Tags for this Thread

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.