我想提取图像的轮廓,我正在尝试使用MatplotLib的轮廓函数.这是我的代码:
from PIL import Image
from pylab import *
# read image to array
im = array(Image.open('HOJA.jpg').convert('L'))
# create a new figure
figure()
# show contours with origin upper left corner
contour(im, origin='image')
axis('equal')
show()
Run Code Online (Sandbox Code Playgroud)
这是我原来的形象:
这是我的结果:
但我只想展示外部轮廓,轮廓.只是这个例子中的读取行.
我该怎么做?我阅读了轮廓功能的文档,但我无法得到我想要的东西.
如果您在Python中知道更好的方法,请告诉我!(MatplotLib,OpenCV等)