Results 1 to 17 of 17

Thread: Check perfomance of QwtPlotCurve with setPaintAttribute for displaying large data

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2019
    Posts
    31
    Thanks
    8
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Check perfomance of QwtPlotCurve with setPaintAttribute for displaying large data

    I think I'm talking about something different.
    My plotted curves have some specific features. They are like deviation from some vertical baseline (and each curve has a baseline).
    Lets suppose that canvas width is 500 pixels. Every curve has QPen width equal to 1 and if all curves are settled equidistantly on the canvas then there is no much sense to plot more than 500 my "pseudovertical" curves.
    So if I try to plot 5000 curves then I can choose every tenth (0, 10, 20, ...) curve and then plot it.

    And the same for Y axis. Every point of every of my curves is settled equidistantly (Y axis of every point is something like : 0, 2, 4, 6, 8 ...). So linear interpolation is fast and could improve plot perfomance when number of points much bigger than canvas height

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

    Default Re: Check perfomance of QwtPlotCurve with setPaintAttribute for displaying large data

    Quote Originally Posted by Vasya View Post
    Every curve has QPen width equal to 1 and if all curves are settled equidistantly on the canvas then there is no much sense to plot more than 500 my "pseudovertical" curves.
    So if I try to plot 5000 curves then I can choose every tenth (0, 10, 20, ...) curve and then plot it.
    Not sure if this is a type of optimization, that is common of enough to explicitely support it in Qwt - curve points are usually not only shifted by the distance of the baselines. But nobody prevents you from doing so - simply hide/show curves depending on scale ranges.

    Quote Originally Posted by Vasya View Post
    Every point of every of my curves is settled equidistantly (Y axis of every point is something like : 0, 2, 4, 6, 8 ...). So linear interpolation is fast and could improve plot perfomance when number of points much bigger than canvas height
    Being equidistant does not make anything faster and I'm not sure what you mean by "interpolation" here. But clipping ( skipping points being outside the canvas ) and making use of the fact, that you can unite points, that are mapped to the same position, when drawing to an integer coordinate based paint device ( screen ) can have an significant effect. But the second ( = QwtPlotCurve::FilterPointsAggressive ) optimization won't be very effective, when you only have 1000 points. Drawing 1000 points to a canvas having a height of 1000 pixels does not reduce the number of points significantly.

    Uwe

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

    Vasya (1st April 2020)

  4. #3
    Join Date
    Nov 2019
    Posts
    31
    Thanks
    8
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Check perfomance of QwtPlotCurve with setPaintAttribute for displaying large data

    Quote Originally Posted by Uwe View Post
    Not sure if this is a type of optimization, that is common of enough to explicitely support it in Qwt - curve points are usually not only shifted by the distance of the baselines. But nobody prevents you from doing so - simply hide/show curves depending on scale ranges.
    Yes thank you for the hint, I'm going to try to make optimization based on the show/hide (curve->setEnabled(true/false)) properties. That should not be much difficult.

    About vertical resolution:
    Probably that is not so necessary but depending on plotted data each curve may have up to 5000 points (usually it is 2000-5000 points but may vary). In this case QwtPlotCurve::FilterPointsAggressive may be useful I think (or at least it should not consume much time to execute if number of points is small, less than 1000, I'm going to test it).

    And what about vertical linear interpolation:
    I think in this case interpolation for curves that reduces the number of plotted points is inapropriate, sorry for confusing you. But sometime ago I found this algo in Matlab: https://www.mathworks.com/matlabcent...40790-plot-big
    But that time I needed something like that to plot 2D data (spectrogram) with the same 1000 by 20000 points (or more) in each direction (the data is the same as for my curves but plotted NOT as curves but as spectrogram). And I wrote matlab code that choses points in X and Y direction before plotting Z data. I think in QWT spectrogram with big data could be useful also. Maybe FilterPointsAggressive could find some application at spectrogram?
    This is just an idea wich came to my mind now but probably QWT already has something similar (I didn't work with QWT spectrogram yet but I'm going to).

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

    Default Re: Check perfomance of QwtPlotCurve with setPaintAttribute for displaying large data

    Quote Originally Posted by Vasya View Post
    I think in QWT spectrogram with big data could be useful also.
    The impact of the data size depends on the type of resampling being used - for example with nearest neighbor ( = default ) the performance does not depend on the data size.
    But the opposite is true: when the resolution of the data is smaller, than the one on screen rendering will be faster as in situations, where you have to calculate all pixels.
    Quote Originally Posted by Vasya View Post
    Probably that is not so necessary but depending on plotted data each curve may have up to 5000 points (usually it is 2000-5000 points but may vary). In this case QwtPlotCurve::FilterPointsAggressive may be useful I think (or at least it should not consume much time to execute if number of points is small, less than 1000, I'm going to test it).
    The algo calculates 4 points for each pixel: enter, min, max, leave. So when having 5K points and 1K pixels you will have almost no effect in reducing the number of lines to be painted.
    But the algo is fast and should not hurt that much.

    HTH,
    Uwe
    Last edited by Uwe; 1st April 2020 at 14:09.

  6. #5
    Join Date
    Nov 2019
    Posts
    31
    Thanks
    8
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Check perfomance of QwtPlotCurve with setPaintAttribute for displaying large data

    I think I misunderstood something but this interesting to know
    Quote Originally Posted by Uwe View Post
    The impact of the data size depends on the type of resampling being used - for example with nearest neighbor ( = default ) the performance does not depend on the data size.
    Does this only concernes to the situation when number of pixels is more than number of data points (say canvas size = [500, 500] and data size = [100, 100])? In this case we have to apply nearest neighbor interpolation to resize our data from [100, 100] to [500, 500] does it correct?

    And the opposite, when canvas size [500, 500] and the data is [5000, 5000]. In this case we can only plot 10% of our data. I don't know wether such software like QWT does the resampling of our data before plotting or it shows all the 5000*5000 points on the 500*500 screen?

    I've always been interesting about that beacause in Matlab my nearest-neighbor resampling improoved the plotting perfomance compared to plotting raw data.
    In Matlab I was using this function after I resample the data: https://www.mathworks.com/help/matlab/ref/imagesc.html

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

    Default Re: Check perfomance of QwtPlotCurve with setPaintAttribute for displaying large data

    Does this only concernes to the situation when number of pixels is more than number of data points (say canvas size = [500, 500] and data size = [100, 100])? In this case we have to apply nearest neighbor interpolation to resize our data from [100, 100] to [500, 500] does it correct?
    In case of nearest neighbor Qwt would create a 100x100 image - scaling to the paint device resolution will happen later. Resizing the data is not necessary for no type of interpolation.

    And the opposite, when canvas size [500, 500] and the data is [5000, 5000]. In this case we can only plot 10% of our data. I don't know wether such software like QWT does the resampling of our data before plotting or it shows all the 5000*5000 points on the 500*500 screen?
    The application has full control over the resampling. Note, that there is a class specifically supporting data being stored as a 2x2 array ( https://qwt.sourceforge.io/class_qwt...ster_data.html ), but in general the data can be hold in any way. See the spectrogram example, that does not even store the data at all.

    I've always been interesting about that beacause in Matlab my nearest-neighbor resampling improoved the plotting perfomance compared to plotting raw data.
    QwtPlotSpectrogram does not iterate over the data - it iterates over the pixels of the image and for nearest neighbor it picks the corresponding values.

    When shrinking the size of the data below the resolution of the screen you will have an effect on the performance as Qwt would not create an image in a resolution, where no corresponding data exists and less pixels need to be calculated. Otherwise your type of resampling would have no effect on the performance - see above.

    You can enable DEBUG_RENDER in qwt_plot_spectrogram.cpp and do some tests with the spectrogram example. Actually the performance of plotting will heaviliy depend on your implementation of QwtPlotRasterData::value(). This one is called for every pixel of the resulting image ( this is the resampling ) and having expensive calculations there will slow down rendering.

    Uwe

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

    Vasya (2nd April 2020)

  9. #7
    Join Date
    Nov 2019
    Posts
    31
    Thanks
    8
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Check perfomance of QwtPlotCurve with setPaintAttribute for displaying large data

    Thank you for explanation. I need to practice it more and less question I will have.

Similar Threads

  1. Replies: 3
    Last Post: 15th February 2017, 09:57
  2. Storing and displaying "large" amount of data
    By FreddyKay in forum Qt Programming
    Replies: 4
    Last Post: 27th November 2014, 19:31
  3. Replies: 2
    Last Post: 3rd January 2012, 15:00
  4. Replies: 4
    Last Post: 18th August 2009, 19:53
  5. QScrollArea not displaying large number of images
    By lpkincaid in forum Qt Programming
    Replies: 1
    Last Post: 31st May 2009, 09:58

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
  •  
Qt is a trademark of The Qt Company.