Reputation: 315
I have a palm print image taken using ink and paper which looks like below (a). What I need is to highlight the creases of it preserving the width and orientation of them see figure (b).
I tried using edge detectors like Canny, Laplacian and Sobel operators with different threshold values but couldn't come up with a clear crease map as in (b). But when above mention edge detectors are used all the black lines are detected as edges. What i want is only to highlight the thicker white lines of image (a). I am using OpenCV 2.4.5. Can anyone help? Thank you.
Upvotes: 6
Views: 2438
Reputation: 11359
This is the method I came up with:
cv::Mat im; //Already loaded
cv::Mat grey;
cv::cvtColor(im, grey, CV_BGR2GRAY);
cv::Mat binary;
cv::threshold(grey, binary, 0, 255, cv::THRESH_OTSU);
//Create a mask of the hand region
cv::Mat mask;
cv::Mat kern = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(20,20)); //Large kernel to remove all interior detail
cv::morphologyEx(binary, mask, cv::MORPH_OPEN, kern);
cv::threshold(mask, mask, 128, 255, cv::THRESH_BINARY_INV); //Invert colors
cv::imshow("", mask);
//Remove thin lines
cv::Mat blurred;
cv::GaussianBlur(grey, blurred, cv::Size(9,9), 0);
cv::threshold(blurred, binary, 0, 255, cv::THRESH_OTSU);
cv::morphologyEx(binary, binary, cv::MORPH_OPEN, cv::noArray());
cv::Mat result;
binary.copyTo(result, mask);
Which gives this result:
There are some artifacts at the edges from the mask, which could be remedied by using a more complex masking method. The kernel sizes for blurring and morphological operations can obviously be modified for different levels of detail.
Upvotes: 2
Reputation: 7929
Firstly you can convert the image to binary using thresholding.
Then you can apply some morphological operations like erosion, so that thin lines can be filtered, there is a builtin method in openCV for this operation.
Finally, you can use one of the edge detectors you mentioned.
Upvotes: 1