I am coding a specific edge detection algorithm. The image is black and red as given below. I am trying to extract red points that make a horizontal or vertical line and trying to get rid of anything that doesn't make a line shape. Some odd shapes are the ones that I later circled in yellow. The problem is that I cannot define the shapes exactly. The thing is they are 'thick'. They can be solid as in the upper left yellow circle or in pieces like the one below it. The only thing is they do not help me making a horizontal and vertical line on the image.
I am coding in Matlab, but any idea of algorithms are also welcome.