python怎么编写对称图案_如何使用opencvpython识别图像的形状是对称的还是不对称的?...
我正在研究圖像特征的提取,在這個過程中,我試圖確定某個圖像是否對稱。我使用opecv-python開發(fā)這項工作。在
下面的代碼用于標識感興趣區(qū)域的中心和直徑。你怎么知道這個圖像是否對稱?在import cv2
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.offsetbox import AnchoredText
IMG = '015'
thresh = cv2.imread(IMD+'.png',0)
_, contours,hierarchy = cv2.findContours(thresh,2,1)
print (len(contours))
cnt = contours
for i in range (len(cnt)):
(x,y),radius = cv2.minEnclosingCircle(cnt[i])
center = (int(x),int(y))
radius = int(radius)
cv2.circle(thresh,center,radius,(0,255,0),2)
print ('Circle: ' + str(i) + ' - Center: ' + str(center) + ' - Radius: ' + str(radius))
plt.text(x-21, y+15, '+', fontsize=25, color = 'red')
plt.text(10, -10, 'Centro: '+str(center), fontsize=11, color = 'red')
plt.text(340, -10, 'Diametro: '+str((radius*2)/100)+'mm', fontsize=11, color = 'red')
plt.Circle((10, -10), 7.2, color='blue')
plt.imshow(thresh, cmap='gray')
#plt.savefig(IMG+'-diam.png')
plt.show()
退出:
在這種情況下,我想分類,如果我正在分析的點是對稱的,下面的圖像,視覺上可以注意到它不是對稱的,而上面的圖的第一個圖像是對稱的。在
總結
以上是生活随笔為你收集整理的python怎么编写对称图案_如何使用opencvpython识别图像的形状是对称的还是不对称的?...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Widows(win10等等)使用过程中
- 下一篇: OLTP、OLAP与HTAP