Can morphology.remove_small_objects be used to remove small noise?
My binary image has lots of noise (small white blobs about 3-6 pixels in area). Can the function skimage.morphology.remove_small_objects() be used to remove these small blobs? In my experimentation, the function leaves the image unchanged. Am I using the function incorrectly or is the function not suited to what I want to achieve? src = cv2.imread('plan4.png') src = cv2.GaussianBlur(src, (3,3), 1) edges = get_edges(src.copy()) noise_reduced = morphology.remove_small_objects(edges .copy(), 2,) cv2.imshow('src', src) cv2.imshow('noise_reduced', noise_reduced) cv2.imshow('edges ', edges ) Below is the original with small white blobs (that I want to remove) and the result of remove_small_objects() notice they are the same and no blobs are removed. *Note: morphological closing or opening the image would remove these small blobs but it also degrades my lines too much. I really prefer finding blobs whose area is ~6 pixels and deleting those. https://i.stack.imgur.com/u1HdN.jpg
Hi, and thanks for your interest in scikit-image! I answered on StackOverflow. [1] Briefly: you need to call `skimage.measure.label` on your edges array, because each value in your input image is considered one "object". ..[1] https://stackoverflow.com/questions/58552860/can-morphology-remove-small-obj...
On 26 Oct 2019, at 9:25 am, samzielkeryner@gmail.com wrote:
My binary image has lots of noise (small white blobs about 3-6 pixels in area). Can the function skimage.morphology.remove_small_objects() be used to remove these small blobs?
In my experimentation, the function leaves the image unchanged. Am I using the function incorrectly or is the function not suited to what I want to achieve?
src = cv2.imread('plan4.png') src = cv2.GaussianBlur(src, (3,3), 1)
edges = get_edges(src.copy())
noise_reduced = morphology.remove_small_objects(edges .copy(), 2,)
cv2.imshow('src', src) cv2.imshow('noise_reduced', noise_reduced) cv2.imshow('edges ', edges )
Below is the original with small white blobs (that I want to remove) and the result of remove_small_objects() notice they are the same and no blobs are removed. *Note: morphological closing or opening the image would remove these small blobs but it also degrades my lines too much. I really prefer finding blobs whose area is ~6 pixels and deleting those.
https://i.stack.imgur.com/u1HdN.jpg _______________________________________________ scikit-image mailing list -- scikit-image@python.org To unsubscribe send an email to scikit-image-leave@python.org
participants (2)
-
Juan Nunez-Iglesias
-
samzielkeryner@gmail.com