Results 1 to 7 of 7

Thread: General question Spectrogram plot

  1. #1
    Join Date
    Dec 2013
    Posts
    11
    Thanks
    8

    Default General question Spectrogram plot

    Hallo everybody,

    I would like to use a spectrogram plot in my application. It is a bigger software-project and due to this I have some "boudary conditions" in the project design which I cannot change.

    For example:
    -The input matrix is a double values matrix and has a maximal size of 192000x140 values.
    -As a minimum the application should show every half second an updated version of the spectrogram. (so faster is better...)

    I want to use bilinear interpolation.

    So the question is:
    What would be the optimal approach for an implementation?
    -->Should I copy the values in a QVectror like in the "rasterview"-example or should i use the values()-function like in the "spectrogram"-example?

    What would be the fastest option? Or is it impossible to show such big images with such a high update-rate?


    Thank you very much!!
    QTim

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

    Default Re: General question Spectrogram plot

    Or is it impossible to show such big images with such a high update-rate
    The size of the rendered image depends on size/resolution of the plot canvas.

    The size of your input matrix is irrelevant, only its resolution might have an effect, when it is below the screen resolution and it is possible to render the image in lower resolution ( scaling it when painting later ).
    In your case this will be the case in vertical direction or horizontally, when you zoom in deep.

    I want to use bilinear interpolation.
    The type of resampling has a significant effect on the performance - so be careful here. F.e. for your use case it looks like a vertical interpolation makes sense, while interpolating horizontally seems to be more or less pointless - at least as long as you don't zoom in deep. So it should be possible to implement something faster than bilinear interpolation - f.e. interpolating vertically only.
    What would be the fastest option?
    As the performance doesn't depend on your matrix ( and its size ) you can check easily in a small test program, what type of resampling is possible for a certain refresh rate on your target system. When it is a multicore CPU you should always enable mutithreading ( QwtPlotItem::setRenderThreadCount() ). As different tiles of an image can be rendered in parallel easily you will see an almost linear effect on the performance.

    What would be the optimal approach for an implementation?
    -->Should I copy the values in a QVectror like in the "rasterview"-example or should i use the values()-function like in the "spectrogram"-example?
    I wouldn't use QwtMatrixRasterData if it means, that you have to copy your samples. Beside a waste of memory, this would be an operation, that depends on the size of your matrix and might be more performance bottleneck than rendering the image itself.

    When implementing YourRasterData::value() you can have a look at the implementation of QwtMatrixRasterData::value(), what might help for your one dimensional interpolation. But always be aware, that YourRasterData::value() is called ( for each pixel of the rendered image ! ) very often and needs to be implemented as fast as possible: everything what can be calculated outside the render loop ( f.e. in YourRasterData::initRaster() ) should be done there.

    Uwe

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

    QTim (17th December 2013)

  4. #3
    Join Date
    Dec 2013
    Posts
    11
    Thanks
    8

    Thumbs up Re: General question Spectrogram plot

    Thank you, Uwe!

    I will try this.

    QTim

  5. #4
    Join Date
    Dec 2013
    Posts
    11
    Thanks
    8

    Question Re: General question Spectrogram plot

    Quote Originally Posted by Uwe View Post
    you can have a look at the implementation of QwtMatrixRasterData::value(), what might help for your one dimensional interpolation.
    Sorry, Uwe. I don't know exactly what you mean. Do you mean, I can have a look at QwtMatrixRasterData::value() to see, how the linear interpolation is done? But if i have a look there, it is just a virtual function. And it's empty. Can you precice your advice a little bit for me?

    Thank you!

    QTim

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

    Default Re: General question Spectrogram plot

    Quote Originally Posted by QTim View Post
    Do you mean, I can have a look at QwtMatrixRasterData::value() to see, how the interpolation is done?
    Yes.
    But if i have a look there, it is just a virtual function. And it's empty.
    No it isn't: QwtMatrixRasterData::value() != QwtRasterData::value().

    Uwe

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

    QTim (20th December 2013)

  8. #6
    Join Date
    Dec 2013
    Posts
    11
    Thanks
    8

    Question Re: General question Spectrogram plot

    Hi Uwe,

    it would be cool, if you could help me again with two questions:

    1.
    I have implemented the spectrogram plot, just like you did. But now, the plot area does not fit completly. There is some space between the borders of the plot and the beginnig of the spectrogram. I have no clue how to fix it. Please have a look in the screenshot (I marked it red):
    qwt_spec_quest.jpg

    I set the interval:
    Qt Code:
    1. setInterval( Qt::XAxis, QwtInterval( -0.5,192000+0.5, QwtInterval::ExcludeMaximum ) );
    2. setInterval( Qt::YAxis, QwtInterval( -10, 10, QwtInterval::ExcludeMaximum ) );
    To copy to clipboard, switch view to plain text mode 

    and scaled the axis:

    Qt Code:
    1. setAxisScale( QwtPlot::xBottom,0,192000 );
    2. setAxisMaxMinor( QwtPlot::xBottom, 1 );
    3. setAxisScale( QwtPlot::yLeft, -9.5,9.5 );
    4. setAxisMaxMinor( QwtPlot::yLeft, 1 );
    To copy to clipboard, switch view to plain text mode 

    What is wrong there?


    2.
    The values on the axes should be different. f.e. the values on the y-axis represent angles with more than one angle between each other. So the vaues in the data matrix represent valuese at the 2nd, 4th, 6th angle. To clear this up: if you have a look in the screenshot again -there is only one value written on the y-axis- but however, this i want this to be a 10, not a 5... How can I change it?

    Thank you very much!!

    QTim

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

    Default Re: General question Spectrogram plot

    What is wrong there?
    Probably nothing: the tick labels need some extra space ( or the canvas margin ), so that there is an margin between the ticks and the border of the canvas, where you don't have values.
    To avoid this effect you can add the following line to your code:

    Qt Code:
    1. plot->plotLayout()->setAlignCanvasToScales( true );
    To copy to clipboard, switch view to plain text mode 

    The values on the axes should be different. f.e. the values on the y-axis represent angles with more than one angle between each other. So the vaues in the data matrix represent valuese at the 2nd, 4th, 6th angle. To clear this up: if you have a look in the screenshot again -there is only one value written on the y-axis- but however, this i want this to be a 10, not a 5... How can I change it?
    Have a look at the various QwtPlot::setAxisXY() methods.

    Uwe

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

    QTim (7th January 2014)

Similar Threads

  1. Rendering a qwt plot spectrogram
    By moijhd in forum Qwt
    Replies: 4
    Last Post: 23rd July 2013, 11:06
  2. Replies: 23
    Last Post: 9th January 2013, 07:27
  3. General destroy question
    By qlands in forum Qt Programming
    Replies: 2
    Last Post: 16th September 2011, 08:10
  4. Replies: 2
    Last Post: 12th October 2009, 21:17
  5. Spectrogram Plot Hints
    By shargath in forum Qwt
    Replies: 2
    Last Post: 25th February 2009, 11:11

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.