提高图像识别:种植绿色像素

2024-06-09 00:50:00 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用python和simpleCV来提取图像的绿色像素数。最后我做了一些计算来得到植物的叶面积。在

我的问题是图片的质量有时不是很高,导致没有检测到像素。在

在simpleCV中,相关设置为:

green = plant.hueDistance(color=Color.GREEN, minsaturation=55, minvalue=55).binarize(70).invert()

改变minsaturation和minvalue没有多大帮助,因为我得到了太多错误的像素识别。所以我想事先做些图像编辑。在

有人能想出一种方法让像素更容易被检测吗?在

原图

{1美元^

simpleCV后的图片


Tags: 图像质量图片green像素植物color绿色
2条回答

对于其他有相同问题的人,我使用带“-level”的imagemagick(convert)得到了一些不错的结果

我的批处理文件

for %%f in (*.JPG) do ( convert.exe %%f -level 0,25%% "%%~nf.png" )

在Imagemagick中,您可以选择H、C和L颜色空间中的阈值范围。然后使用连接的组件删除小区域。Unix语法。在

convert green.jpg -colorspace HCL -separate \
\( -clone 0 -fuzz 7% -fill white -opaque "gray(66)" \
   -fill black +opaque white \) \
\( -clone 1 -fuzz 10% -fill white -opaque "gray(46)" \
   -fill black +opaque white \) \
\( -clone 2 -fuzz 7% -fill white -opaque "gray(87)" \
   -fill black +opaque white \) \
-delete 0-2 -compose multiply -composite tmp1.png

enter image description here

^{pr2}$

enter image description here

这两个命令可以组合成一个长命令。在

convert green.jpg -colorspace HCL -separate \
\( -clone 0 -fuzz 7% -fill white -opaque "gray(66)" \
   -fill black +opaque white \) \
\( -clone 1 -fuzz 10% -fill white -opaque "gray(46)" \
   -fill black +opaque white \) \
\( -clone 2 -fuzz 7% -fill white -opaque "gray(87)" \
   -fill black +opaque white \) \
-delete 0-2 -compose multiply -composite \
-define connected-components:verbose=true \
-define connected-components:area-threshold=5160 \
-define connected-components:mean-color=true \
-connected-components 4 \
result.png

相关问题 更多 >