Smoothing binary mask and sort out distortion [closed]
Hi there,
i'm detecting a colored rect in the hsv colorspace by thresholding the single channels. Here is the result of a detected yellow square mask.
colorspace -> HSV
Color to detect: Yellow (used laser printer to print out the marker // CMYK)
In OpenCV I threshold by followed values:
lower_yell = np.array([15, 100, 20])
upper_yell = np.array([40, 265, 255])
A dilation was processed after canny edge
edges_yell_pre = cv2.Canny(mask_yell, 0, 50, apertureSize = 3)
edges_yell = cv2.dilate(edges_yell_pre, None)
How would you guys delete the small distortion. Please note, that this given example here is a 'good' result.
And how to add some robustness for low level detection. How to start here? Hist eq would give me to much problems because I'm dealing with a random changing background.
Thanks
Correction: You detect everything except the yellow square mask and the distortions.
Concerning the small distortions:
Why not using Opening (Wikipedia) after threshold.
And my last annotation:
Doing
cv2.Canny
on an already binarized image makes very little sense. Usingcv2.findContours
will extract all edges from binary image, if needed.