我想对我感兴趣的区域执行操作..这是中央矩形表,您可以在图像中看到。
我可以手动给出我感兴趣区域的坐标,并裁剪该部分
img = cv2.imread('test12.jpg',0)
box = img[753:1915,460:1315]
但我想自动裁剪这部分,而不需要手动给出像素或坐标。有人能帮我一下吗?
http://picpaste.com/test12_-_Copy-BXqHMAnd.jpg这是我的原始图像。
http://picpaste.com/boxdemo-zHz57dBM.jpg这是我剪下的图像。
为此,我输入了所需区域的坐标并裁剪。
但是,现在我必须处理许多类似的图像,其中我感兴趣的区域的坐标将略有变化。我想要一种方法来检测表(我感兴趣的区域)并裁剪它。
现在我用这个
img = cv2.imread('test12.jpg',0)
box = img[753:1915,460:1315]
裁剪我的图像。
您可以尝试使用openCV模板匹配来查找图像中矩形表的坐标。 Template Matching
下面是一个测试程序,用于查找我试图查找的图像的坐标。
我没有一个完整的解决方案给你。显示的代码基于我用来修复扫描仪输出的一些代码。对我来说,模板解决方案听起来是一种更好的方法,但是下面应该给你一些其他的方法。
产量没有你需要的多。使用各种阈值参数应该可以提高结果。
我建议在
imageThresh
和imageDest
上的不同点使用imshow
,这样您就可以看到代码的每个阶段都发生了什么。希望这能帮助你进步。相关问题 更多 >
编程相关推荐