【发布时间】:2020-02-02 23:43:10
【问题描述】:
我正在尝试使用 canny 检测和使用 opencv 查找计数来裁剪视网膜图像。我正在使用下面的代码,但我没有得到裁剪的图像,而是得到像
.
以下代码有什么问题。。
原图是这样的
import cv2
# Load image, convert to grayscale, and find edges
image = cv2.imread('IDRiD_001.jpg')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
canny = cv2.Canny(gray, 120, 255, 1)
# Find contour and sort by contour area
cnts = cv2.findContours(canny, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
cnts = cnts[0] if len(cnts) == 2 else cnts[1]
cnts = sorted(cnts, key=cv2.contourArea)
# Find bounding box and extract ROI
for c in cnts:
x,y,w,h = cv2.boundingRect(c)
ROI = image[y:y+h, x:x+w]
break
cv2.imwrite('retinal_image.jpg',ROI)
【问题讨论】:
-
能否请您也添加原图?