I have an image where I need to remove “white” artifacts that do not represent the detected curve. I want to keep white pixels that represent the curve, but remove pixel outliers that are far from the curve. After removing the artifacts, I would like to place a smooth curve at the points in the image.
This is my image:

The image is an 8-bit grayscale image with only black and white dots. The white pixels in the “curve” represent the region of interest, and most of them are just one pixel thick. Some white pixels are connected to each other, but not all of them. Some white pixels are dotted. I would like to remove these white pixels, since they do not contribute to the overall shape, because I want to put their smooth curve.
So far, I have been trying to execute dilation, followed by operations erosion, closingand black hat. None of them seem to give me the result that I expect. I also tried iterating over all points of the image, finding bright points, looking in a 3x3 neighborhood around this pixel and setting the value 0if it did not have more than two neighbors that are equal.
What can I apply to achieve the desired result? Also, as soon as I get my final “clean” conclusion, how do I place a smooth curve at points in the image?
source
share