Reputation: 1639
I have an image for which I have the green border as the segmentation mask's outline. I'm looking to refine this outline based on contours found on the original image, to get a mask like the in 2nd image - where the edges of the hair are more refined.
I've tried combinations of dilation & erosion of the segmentation mask, but it didn't feel like a generic solution - since it involves manually tuning the kernel size.
Are there better approaches?
Upvotes: 0
Views: 959
Reputation: 163
There is no generic solution. Parameter tuning is always required to get the desired output. For getting more refined fine edges of the hairs, you can apply thresholding as below:
import cv2 as cv
from matplotlib import pyplot as plt
im = cv2.imread("model.jpg",0)
plt.imshow(im)
thresh = cv2.adaptiveThreshold(im,255,cv2.ADAPTIVE_THRESH_MEAN_C,\
cv2.THRESH_BINARY_INV,31,3)
plt.imshow(thresh)
Note: The color changes are due to 'matplotlib'.
Upvotes: 1