【发布时间】:2017-07-30 17:29:09
【问题描述】:
我是图像处理的新手,开始学习 scikit-image。我正在尝试检测矩形的角,然后将整个图像裁剪到它。但是我迷失在大量的分割和检测算法中,不知道我需要哪一种以及如何去做。
此代码生成示例图像。我想将它裁剪为绿色矩形。我需要做什么?
从 matplotlib 导入 pyplot 作为 pyplot
import numpy as np
import skimage
from skimage import draw
img = np.zeros((500, 500, 3), dtype=np.double)
poly = np.array([[25, 25],
[25, 75],
[75, 75],
[75, 25]])
rr, cc = draw.polygon(poly[:, 0], poly[:, 1], img.shape)
img[rr, cc, 1] = 1
plt.imshow(img)
plt.show()
任务是检测矩形(多边形阵列)的边缘并将图像裁剪到它。
我尝试了 harris 角点检测、canny 边缘检测和许多其他方法,但我完全糊涂了。这似乎是一项简单的任务,但我不明白。
使用 OpenCV 会更容易吗?请帮忙!
【问题讨论】:
-
是的。你应该使用 OpenCV,检查this SO post。
标签: python image-processing edge-detection scikit-image