这是一个例子。你需要有 opencv 包来运行它。
那里有一个中断,因为图像有伪影。如果您使用更高质量的图像,它可能会更好。如果您无法获得更高质量的图像,则可以使用形态学操作来连接小间隙并去除四分之一圆形突起。

import cv2
import numpy as np
img = cv2.imread('c:/data/floor.jpg')
gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
gray=255-gray
contours,hierarchy = cv2.findContours(gray,cv2.RETR_LIST ,cv2.CHAIN_APPROX_NONE )
for cnt in contours:
area = cv2.contourArea(cnt)
if area>9000 and area<40000:
cv2.drawContours(img,[cnt],0,(255,0,0),2)
cv2.imshow('img',img)
cv2.waitKey()
编辑
做了一些预处理来修复中断
import cv2
import numpy as np
img = cv2.imread('c:/data/floor.jpg')
img=cv2.resize(img,(1700,700))
gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
gray=255-gray
gray=cv2.threshold(gray,4,255,cv2.THRESH_BINARY)[1]
gray=cv2.blur(gray,(15,1))
contours,hierarchy = cv2.findContours(gray,cv2.RETR_LIST ,cv2.CHAIN_APPROX_NONE )
for cnt in contours:
area = cv2.contourArea(cnt)
if area>150000 and area<500000:
cv2.drawContours(img,[cnt],0,(255,0,0),2)
cv2.imshow('img',img)
cv2.waitKey()
