获取使用GNU绘图轮廓函数自动生成的轮廓级别 [英] Get the contour levels that are auto generated using gnu plot contour function

查看:42
本文介绍了获取使用GNU绘图轮廓函数自动生成的轮廓级别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何使用gnuplot生成图像文件的轮廓.

I know how to generate contours of an image file using gnuplot.

set autoscale noextend
set view map
set contour surface
set cntrparam levels 15
set key outside title "Contour levels"
splot 'sampleImage.png' binary filetype=png with lines nosurface title ""

等高线相对于最大255(例如255、250、245等)在图像上绘制.如何在gnuplot中读取这些关键值?

The contours are plotted over the image with respect to a maximum of 255, like at 255, 250, 245 etc. How can I read these key values in gnuplot?

推荐答案

假设我正确理解了您的问题,以下代码将灰度值和轮廓值放入表中.您可以在其中找到所有信息.

Assuming I understood your question correctly, the following code puts both the greyscale values and the contour values into tables. There you find all information.

输入:( Input.png )

代码:

### get greyscale pixel data and contour data
reset session

FILE = 'Input.png'

set view map
set size square
set tics out

set table $Dummy
    set contour
    splot FILE binary filetype=png
    unset contour
set table $Data
    plot $Dummy u 1:2:3 index 0 w table
set table $Contour
    plot $Dummy u 1:2:3 index 1::1 w table
unset table

# print a few grey values
print sprintf("Number of data points:    %d",|$Data|)
do for [i=1:40000:2500] { print $Data[i] }

# print a few contour values
print sprintf("Number of contour points: %d",|$Contour|)
do for [i=700:710] { print $Contour[i] }

set multiplot layout 1,2
    set autoscale noextend
    splot FILE binary filetype=png  with rgbimage notitle

    set key outside title "Contour levels"
    set contour surface
    set cntrparam levels 15
    splot FILE binary filetype=png with lines nosurface title ""
unset multiplot
### end of code

结果 :(只是表的摘录)

Result: (just a few excerpt of the tables)

Number of data points:    40000
 0       0       4
 100     12      46
 0       25      4
 100     37      152
 0       50      6
 100     62      168
 0       75      19
 100     87      165
 0       100     30
 100     112     186
 0       125     31
 100     137     171
 0       150     22
 100     162     127
 0       175     11
 100     187     70

Number of contour points: 1328
 54.5    163     100
 55      163.5   100
 56      164     100
 110     20      100
 109     20.4    100
 108     20.6    100
 107     20.8333         100
 106     21      100
 105     21.4    100
 104     21.8    100
 103.5   22      100

添加:

也许这正朝着理想的方向发展.我不确定这是否是最有效的方法.

Maybe this is going to the desired direction. I'm not sure whether this is the most efficient way.

代码:

### plot normalized contour from PNG
reset session

FILE = 'Input.png'

set view map
set size square
set tics out

set table $Dummy
    set contour
    set cntrparam levels 15
    splot FILE binary filetype=png
    unset contour
set table $Contour
    splot $Dummy u 1:2:($3/255) index 1::1
unset table

plot $Contour u 1:2:3 w l lc palette notitle
### end of code

结果:

这篇关于获取使用GNU绘图轮廓函数自动生成的轮廓级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆