Extracting shapes from BW image

there are plenty of similar messages, all I see are using some libraries and c. I'm using pic mc, writing assembler. The code must be as fast as possible (target is <10ms with 16MHz instruction speed, afterwards pattern recognition will be executed). There is plenty of flash space so I can extend the code as much as I want, also tables are possible. I have a BW image 160x120 pixels (20x120 bytes). There are two shapes inside that I know separated with at least one pixel width column. Under normal circumstances all area outside shapes is white, then there is no problem extracting them. But in some cases there are lines or black regions that has to be eliminated. An advantage of image is that if at any edge there is any black pixel than all shape including that pixel should be discarded. It can be done by floodfilling but it may consume a lot of time. A sample picture is attached. Any idea (algoritm) how to extraxt them, i.e. find the coordinates of the red dots ?160x120 sample image with 2 shapes

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum