亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用opencv從皮膚圖像中去除毛發?

如何使用opencv從皮膚圖像中去除毛發?

慕哥9229398 2021-07-16 19:15:48
我正在研究皮膚斑點的識別。為此,我使用了許多具有不同噪聲的圖像。這些噪音之一是毛發,因為我在染色區域 (ROI) 上有毛發的圖像。如何減少或消除這些類型的圖像噪聲?下面的代碼減少了毛發所在的區域,但不會去除感興趣區域(ROI)上方的毛發。import numpy as npimport cv2IMD = 'IMD436'# Read the image and perfrom an OTSU thresholdimg = cv2.imread(IMD+'.bmp')gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)ret, thresh =     cv2.threshold(gray,0,255,cv2.THRESH_BINARY_INV+cv2.THRESH_OTSU)# Remove hair with openingkernel = np.ones((2,2),np.uint8)opening = cv2.morphologyEx(thresh,cv2.MORPH_OPEN,kernel, iterations = 2)# Combine surrounding noise with ROIkernel = np.ones((6,6),np.uint8)dilate = cv2.dilate(opening,kernel,iterations=3)# Blur the image for smoother ROIblur = cv2.blur(dilate,(15,15))# Perform another OTSU threshold and search for biggest contourret, thresh =     cv2.threshold(blur,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)contours, hierarchy =     cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)cnt = max(contours, key=cv2.contourArea)# Create a new mask for the result imageh, w = img.shape[:2]mask = np.zeros((h, w), np.uint8)# Draw the contour on the new mask and perform the bitwise operationcv2.drawContours(mask, [cnt],-1, 255, -1)res = cv2.bitwise_and(img, img, mask=mask)# Display the resultcv2.imwrite(IMD+'.png', res)cv2.imshow('img', res)cv2.waitKey(0)cv2.destroyAllWindows()出口:如何去除感興趣區域頂部的毛發?使用的圖像:
查看完整描述

2 回答

  • 2 回答
  • 0 關注
  • 883 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號