Menu

#433 cntrparam to set minimal required contour length

open
nobody
None
5
2015-12-09
2015-12-06
No

Hi,

at times it would be helpful to have an option to discard all plotted contours with a length (number of points) less than a threshold.

I have high resolution data that I plot as a surface map with visible contours. There is some noise in the data that I cannot easily filter (and actutally do not want to). Yet in these positions very short black lines or black dots apear - unnecessary contours that increase file size and decrease readability of the plot. Currently I use every 5:5 in the splot command to somewhat mitigate the problem by decreasing the resolution of the data.

An additional parameter for cntrparam would probably provide a much cleaner solution.

Johannes

Discussion

  • Hans-Bernhard Broeker

    There is some noise in the data that I cannot easily filter (and actutally do not want to).

    Then that feature you're looking for would do exactly what you say you don't want. Because such a change to the output is, for all intents and purposes, a low-pass filter.

     
  • Johannes Kneer

    Johannes Kneer - 2015-12-09

    Not quite.
    I'm plotting the high fidelity data as a plot image, overlaying it with pm3d contours to increase contrast.
    (The data matrix has about 2500x1900 datapoints, so just plotting a straight eps create HUGE files. Just plotting pngs still creates big files at mediocre quality.)

    Also I have well defined regions of NaNs in the data, at their edges very short non-closed contours are created. At the same time I have some thing longly streched features in the data.
    And in order to get rid of the short contours, I would also smooth away my small features.

    So no, filtering the contours based on their length is is not the same as low-pass filtering the data.

     
    • Hans-Bernhard Broeker

      I'm plotting the high fidelity data as a plot image, overlaying it with pm3d contours to increase contrast.

      There is no such thing as a pm3d contour. There's contours (which are lines), and there's pm3d output (consisting of quadrangles).

      So no, filtering the contours based on their length is is not the same as low-pass filtering the data.

      Oh, it's a low-pass filter alright ... it's just a rather bad one.

       
      • Johannes Kneer

        Johannes Kneer - 2015-12-09

        :)

        In fact a lot of work has gone into the postprocessing of this experimental data. I tried different smoothing / filtering approaches, but due to the structures in the data this is quite difficult and the result is not satisfying. So for some of the quantities I cannot smooth them and retain the details I need.

        Getting rid of the short contours is mainly for improving estetics and readability. I'm fully aware that just getting rid of the short contours is a pretty pragmatic approach.

         
  • Ethan Merritt

    Ethan Merritt - 2015-12-09

    The behaviour of contour lines in the presence of NaN values is undefined, so I am not surprised that you end up with some non-closed contour lines. Why would filtering on length remove them? I don't see any reason that a NaN value would interrupt only short contours. Is this something specific to your data?

    A 2500x 1900 pixel PNG image is not particularly large - that's only about the size of a photo from a digital camera. So I do not understand why you would get anything less than perfect resolution by representing the matrix as an image, and the PNG terminals (png or pngcairo) should handle the NaN values correctly.

     
  • Johannes Kneer

    Johannes Kneer - 2015-12-09

    The immediate resulting graphics file looks good. The problem is the printing process for the resulting document. Fine features in bitmaps (such as contours) just look bad in the resulting print, so I really need those to be in a vector format.
    But I guess this is not the place to discuss this. Let's keep it on topic.

     
  • Ethan Merritt

    Ethan Merritt - 2015-12-09

    The svg and tikz terminals can produce vector output with an embedded png image. The pdf (cairo) terminal would also give you vector contours and a bitmap image, although I am not certain that it preserves the full resolution of the image.

     

Log in to post a comment.