How to extract palm lines?
I'm studying OpenCV with python by working on a project which aims to detect the palm lines.
What I have done is basically use Canny edge detection and then apply Hough line detection on the edges but the outcome is not so good.
Here is the source code I am using:
original = cv2.imread(file)
img = cv2.cvtColor(original, cv2.COLOR_BGR2GRAY)
save_image_file(img, "gray")
img = cv2.equalizeHist(img)
save_image_file(img, "equalize")
img = cv2.GaussianBlur(img, (9, 9), 0)
save_image_file(img, "blur")
img = cv2.Canny(img, 40, 80)
save_image_file(img, "canny")
lined = np.copy(original) * 0
lines = cv2.HoughLinesP(img, 1, np.pi / 180, 15, np.array([]), 50, 20)
for line in lines:
for x1, y1, x2, y2 in line:
cv2.line(lined, (x1, y1), (x2, y2), (0, 0, 255))
save_image_file(lined, "lined")
output = cv2.addWeighted(original, 0.8, lined, 1, 0)
save_image_file(output, "output")
I tried different parameter sets of Gaussian kernel size and Canny low/high thresholds, but the outcome is either having too much noises, or missing (part of) major lines. Below picture is already the best I get, so far..
Is there anything I should do to get result improved, or any other approach would get better result? Any help would be appreciated!!
-------- updated 2019-09-25 --------
original picture attached:
could you post the original image
@sturkmen hi, the original image has been attached, thanks in advance!
We all go the same way in solving this problem. I also added dilate() and erode() functions after the Canny's algorithm to rid off of some noise, but still, not even close to the satisfying result
import cv2
import numpy as np
kernel = np.ones((5,5),np.uint8)
original = cv2.imread("Canny.jpg")
original = cv2.dilate(original, kernel, iterations = 10)
original = cv2.erode(original, kernel, iterations = 11)
cv2.imwrite("result.jpg", original)
@RomanBrajnikoff Hi, yes those two more filters bring no significant improvement, but thanks all the same :)