我正在检测图像中的椭圆,并希望在检测后将它们从图像中删除。在处理图像时,我首先打开、阈值、创建二进制文件,然后使用 regionprops。
openimage = opening(image,footprint)
thres = threshold_otsu(openimage)
binary = openimage> thres
labeledopened = label(binary)
regionopen = regionprops(labeledopened)
for region in regionopen:
if region.minor_axis_length >= 50 and region.minor_axis_length <= 70\
and region.solidity > 0.955 and region.major_axis_length <= 190 and region.centroid[0]<= len(openimage)-100\
and region.centroid[1]<= len(openimage[0])-100:
orient = region.orientation
y0,x0 = region.centroid
minor = region.minor_axis_length*0.5
major = region.major_axis_length*0.5
rr,cc = ellipse(y0,x0,major,minor,rotation=orient)
openimage[rr,cc] = int(0)
出于某种原因,IndexError: index 2812 is out of bounds for axis 1 with size 2812
发生了错误,尽管一切似乎都是从零开始的,我正在粘贴到我从中复制的图像中。
有任何想法吗?