举个例子,我抄袭了一篇论文,PDF pg 24:
https://uknowledge.uky.edu/cgi/viewcontent.cgi?article=1055&context=cs_etds

我想使用‘转换’来获得'x‘配置文件,'y’配置文件,或同时获得"x,y“配置文件。配置文件是每个像素存储桶中数据的像素计数,我们分别处于灰度或黑/白模式0,1或{0,1}。
附件是"projection-profile“的PNG示例。
convert pp.png pp.txt

有什么想法吗?
发布于 2021-09-02 16:10:24
我从你的猜测命令中假设你想要一个文本输出,所以在66行投影中试试这个:
magick pp.png -threshold 50% -negate -crop x1 -format "%[fx:w*h*mean]\n" info:输出
0
0
0
0
0
0
0
0
0
0
0
0
0
25
33
38
41
40
36
29
18
18
18
18
96
150
214
232
226
171
160
150
149
151
167
167
139
135
138
135
134
138
135
140
160
212
233
181
18
18
18
18
17
17
17
17
17
30
34
31
2
0
0
0
0
0该命令应该非常简单明了。-negate的作用是反转图像并计算黑色像素而不是白色像素。-crop x1将把图像分成几行,以便随后的format命令对每行运行一次。-format命令将行中像素的平均值与行的面积相乘,以获得设置的像素数。
下面是399列投影:
magick pp.png -threshold 50% -negate -crop 1x -format "%[fx:w*h*mean]\n" info:如果需要图形直方图样式的输出,可以通过管道连接到gnuplot。以下是垂直投影示例:
magick pp.png -threshold 50% -negate -crop 1x -format "%[fx:w*h*mean]\n" info: | gnuplot -e 'plot "-" using 1: xtic(1) with histogram' -persist

请注意,您可以一次完成水平和垂直投影,但它可能不值得麻烦和复杂性。您可以在计数前面加上h或v,然后在gnuplot中对其进行过滤。或者,您可以将水平投影写入fd:3,将垂直投影写入fd:4,然后将shell中的这两个投影分别重定向到不同的gnuplot实例
https://stackoverflow.com/questions/69032468
复制相似问题