MATLAB: How to remove unnecessary pixels on a line on a binary image

#edgeanalyze#lineanalyze#morphologicalimagebinaryImage Processing Toolboxskeleton

Hello guys, I need to remove (change the color to black) unnecessary pixels like I showed in red border in order to analyze the boundary of morphological image conveniently. My point is, there can only be 1 or 2 white neighbours (pixels) of a white pixel around it on such a line on the image.

Best Answer

bwmorph(BW,'skel',Inf); should do the trick.