Problems in the image after apply CLAHE during vein detection.

asked 2018-08-01 15:23:12 -0600

pipeecs780 gravatar image

updated 2018-08-01 15:31:21 -0600

Hello, I'm currently working in a project in that I have to do a vein detector using IR images and live capture. after apply CLAHE there are some "waves" on the images (inside the redbox), first I didn't know what could be, but after talking with my teachers probably the problem its the amount of black on the image what probably cause a saturation in the image, thus the waves. But we don't know how to remove those waves. I tried a bigger ROI wich helps, but just reduced the waves, and then I tried a smaller ROI just to capture an arm section to see the veins, but nothing works. I think that the webcam also could be a part of the problem, I'm using a Genius Facecam 1000HD but I don't know if it can really affect the waves.

I hope you can help me with this problem, I tried many things but nothing resolve completly the problem.

Greetings.

image description

import matplotlib.pyplot as plt
import matplotlib.image as img
import numpy as np
import cv2

kernel = np.ones((3,3),np.uint8)
kernel[0,0]=0
kernel[0,2]=0
kernel[2,0]=0
kernel[2,2]=0
print(kernel)

#-----Reading the image-----------------------------------------------------
camera = cv2.VideoCapture(1)
while cv2.waitKey(1)==-1:
    retval, img = camera.read()    
    gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
    cv2.imshow('byn',gray)
    retval,mask = cv2.threshold(final,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
    gray = cv2.bitwise_and(final,final,mask = mask)

##-----PROCESAMIENTO----------------------------------- 
    #Def. ROI
    nf,nc=gray.shape
    CAP1 = gray.copy() #con ROI
    #Ecualización
    clahe = cv2.createCLAHE(clipLimit=20.0, tileGridSize=(8,8))
    gray= clahe.apply(gray)
    CAP2 = gray.copy()
    gray = cv2.medianBlur(gray,3) #Filtro Mediana
    CAP3 = gray.copy()
    cv2.imshow('BLUR',CAP3)
    retval,CAP4 = cv2.threshold(gray,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
    mask1=(CAP4>0)*gray #pixeles grises
    mask2=(CAP4==0)*int(CAP3.mean()+40) #Fondo Promedio
    gray=np.uint8(mask1+mask2) #conviente a formato int
    CAP5 = gray.copy()
    retval,gray = cv2.threshold(gray,120,255,cv2.THRESH_BINARY_INV+cv2.THRESH_OTSU)
    gray = (CAP1>0)*gray    
    CAP6 = gray.copy()
    gray = cv2.erode(gray,kernel,iterations = 2)
    gray = cv2.morphologyEx(gray, cv2.MORPH_OPEN, kernel)
    CAP7 = gray.copy()
    cv2.imshow('PROMEDIO',CAP5)
    cv2.imshow('CLAHE',CAP7)


cv2.destroyAllWindows()
camera.release()
edit retag flag offensive close merge delete

Comments

I believe you can not avoid "waves" when using CLAHE,as CLAHE is a “block" method,(for example it first divide the image into 8*8,and do "ahe").But CLAHE DO enhance the vein.So you can do something after CLAHE to get the vein,for example Frangi methold. have a look at this: https://github.com/ntnu-bioopt/libfrangi

jsxyhelu gravatar imagejsxyhelu ( 2018-08-03 01:56:03 -0600 )edit