Marking veins using opencv

2019-07-15 03:08发布

I was trying to figure out a way to mark the veins in an image using OpenCV in Python. Most of the similar articles i came across uses CLAHE to produce a result,I did CLAHE multiple times on grayscale image, and it did make the veins more viewable but i cant figure out a way to mark the vein in a different color. CLAHE also significantly reduces the overall image quality.

My input image:

img

After CLAHE 4 times:

img

Code:

import numpy as np
import cv2

def multi_clahe(img, num):
    for i in xrange(num):
        img = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(4+i*2,4+i*2)).apply(img)
    return img

img = cv2.imread('img.png')

gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

final = multi_clahe(gray, 4)

cv2.imwrite('image.png',final)
cv2.imshow('image',final)

cv2.waitKey(0)
cv2.destroyAllWindows()

1条回答
家丑人穷心不美
2楼-- · 2019-07-15 03:47

Here's the method to follow-

  • Veins cant be found outside hand. So remove the nonsense by converting image to hsv and cv2.inRange() with low, high skin values. Make a track bar if you cant figure out proper values.

This

  • Your skin is smoother compared to the folds on the hand holding it. Use Canny edge with proper parameters, dilate a little and filter out the high frequency portion by and'ing.

enter image description here

  • CLAHE
  • Adaptive Threshold
  • Morphological and noise removal operations.

Suggestion to improve the output:

  1. Get a better image setting, with only arm ideally.
  2. Figure out proper parameters for CLAHE, Thresholding,Canny

enter image description here

查看更多
登录 后发表回答