【问题标题】:What kind of image processing techniques which i can deploy to remove eye lashes and eyebrows from a human eye image?我可以部署什么样的图像处理技术来去除人眼图像中的睫毛和眉毛?
【发布时间】:2022-08-05 17:15:41
【问题描述】:

我一直在尝试处理人眼图像以获得虹膜尺寸过去一个月。我使用这张图片作为我的输入,并且在某种程度上我能够实现我想要做的事情,但在检测轮廓和获取我的感兴趣区域(虹膜)时仍然没有效率。

其背后的潜在原因是,因为人眼图像包含眉毛和睫毛通常是黑暗的当我申请时阈值在它上面,它们在精明的处理过程中被包含在内,当我尝试在它们上绘制轮廓时,它们会干扰我感兴趣的区域,即虹膜,它们会返回一个区域的混乱--->

我很不确定如何从中获得投资回报率。所以我试着不使用轮廓,而是选择了霍夫圆但他们的结果是不能接受的因为虹膜不是完美的圆,而是椭圆.

轮廓似乎是最好的选择,因为我可以轻松地在轮廓上绘制边界框并获取其尺寸但我的图像处理知识有限,我需要找到一种方法来消除所有噪声和伪影以获得 ROI,即人类虹膜

所以我的问题是:我可以部署什么样的图像处理技术来去除人眼图像中的睫毛和眉毛?

替代问题:如何从已处理的图像中提取我的感兴趣区域(人体虹膜)?处理后的图像:

原因:当我尝试从图像中获取轮廓时,不需要的眉毛/睫毛会干扰我的感兴趣区域(虹膜),因此 ROI 通常与我发现难以处理/移除的眉毛/睫毛合并以计算虹膜尺寸。

这是代码:


#Libraries
import cv2
import numpy as np

#show image
def display_image(name,current_image):
    cv2.imshow(name,current_image)
    cv2.waitKey(0)

def image_processing(current_image):
    
    
    #Grayscaling
    grayscaled_image = cv2.cvtColor(current_image, cv2.COLOR_BGR2GRAY)
    #display_image(\"Gray\",grayscaled_image)

    #Inverting
    inverted_image = cv2.bitwise_not(grayscaled_image)
    #display_image(\"Invert\",inverted_image)

    #Removing Reflection
    kernel = np.ones((5, 5), np.uint8)
    blackhat_image = cv2.morphologyEx(inverted_image,cv2.MORPH_BLACKHAT,kernel)
    #display_image(\"Backhat\",blackhat_image)

    removed_refection = cv2.addWeighted(src1=inverted_image,alpha=0.5,src2=blackhat_image,beta=0.5,gamma=0)
    #display_image(\"Removed reflection\",removed_refection)

    image_without_reflection =  cv2.medianBlur(removed_refection, 5)
    #display_image(\"No reflection\",image_without_reflection)

    #Thresholding
    _,thresholded_image= cv2.threshold(image_without_reflection,100,255,cv2.THRESH_BINARY)
    #display_image(\"Thresholded\",thresholded_image)

    #Canny
    region_of_interest = cv2.bitwise_not(thresholded_image)
    canny_image = cv2.Canny(region_of_interest, 200, 100)

    return canny_image

def iris_detection(image):
    
    
    circles = cv2.HoughCircles(processed_image, cv2.HOUGH_GRADIENT, 1, 20, param1 = 200, param2 = 20, minRadius = 0)
    
    if circles is not None:
        
        #fifth step mark circles co-ordinates
        inner_circle = np.uint16(np.around(circles[0][0])).tolist()
        cv2.circle(current_image, (inner_circle[0], inner_circle[1]), inner_circle[2], (0, 255, 0), 1)
        display_image(\"Final\",current_image)
        x, y,_ = current_image.shape
        
    radius = inner_circle[2]*0.2645833333
    diameter = radius * 2

    print(\"The Radius of the iris is:\",radius,\"mm\")
    print(\"The Diameter of the iris is:\",diameter,\"mm\")
    
def contour_detection(image):
    
    #Countours are less effective
    contours,hierarchy = cv2.findContours(image,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
    return cv2.drawContours(new_image, contours, -1, (0,255,0), 3)
    
    
#input
current_image = cv2.imread(\"eye.jpg\", 1)
display_image(\"Original\",current_image)

#Copy of the original image
new_image = current_image.copy()

#Image pre-processing
processed_image = image_processing(current_image)
display_image(\"Processed Image\",processed_image)

#Iris Detection using Hough circles
iris_detection(processed_image)
contoured_image = contour_detection(processed_image)
display_image(\"Contours\",contoured_image)


cv2.destroyAllWindows() 

    标签: python opencv image-processing opencv-contour


    【解决方案1】:

    与此同时,我想出了自己的解决方案,它给了我最好的结果。可能有一些高级图像处理功能,但最简单的方法是在空白图像上掩盖感兴趣的区域

    我的解决方案是应用面具略大于使用找到的半径HoughCircles 函数并将背景替换为选择的颜色。在这里,我将背景蒙版为白色,以便稍后处理较暗的虹膜区域。基本上去除了在后期处理过程中干扰的东西,例如睫毛和眉毛。

    white_image = np.full((img.shape[0], img.shape[1]), 255, dtype=np.uint8)
    cv2.circle(white_image, (inner_circle[0], inner_circle[1]), inner_circle[2]+30, (0, 0, 0), -1)
    roi = cv2.bitwise_or(median,white_image)
    #median is the processed binary image
    

    【讨论】:

      猜你喜欢
      • 2011-04-04
      • 2014-04-06
      • 2020-09-03
      • 2012-04-11
      • 1970-01-01
      • 2011-05-10
      • 1970-01-01
      • 2017-05-27
      • 2018-11-11
      相关资源
      最近更新 更多