1

我面临一些问题,以获得更平滑的曲线轮廓。经过图像处理后,我得到了这个图像。

在此处输入图像描述 我正在尝试使用此代码获得更平滑的曲线:

imgWithBridgesBw = convert_to_bw(imgWithBridges)

# add later this mask upper
ellipsekernel20 = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (3,3))
enhanceMask = np.ones((InterholesBw.shape[0],InterholesBw.shape[1]) ,dtype="uint8") * 255
enhanceMaskColor = np.ones((InterholesBw.shape[0],InterholesBw.shape[1],3) ,dtype="uint8") * 255

# invert the Layer to get less blank pixels
imgWithBridgesBwInv = 255 - imgWithBridgesBw

imgWithBridgesBwInv_dilate = cv2.dilate(imgWithBridgesBwInv,ellipsekernel20,iterations =1)
imgWithBridgesBwInv_erode = cv2.erode(imgWithBridgesBwInv_dilate, ellipsekernel20, iterations = 1)  

_ ,allCnts, hier = cv2.findContours(imgWithBridgesBwInv_dilate,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)

cv2.drawContours(enhanceMask,allCnts,-1,0,2)
cv2.drawContours(enhanceMaskColor,allCnts,-1,(255,0,0),2)

结果是这样的:

https://dl.dropboxusercontent.com/u/710615/testEhhancBwColor_.jpg

正如您在这张图片中看到的那样,这是一个“缩放”,我没有取得任何成功。

在此处输入图像描述

4

0 回答 0