Project 1
Binary image of blood cells

To eliminate connected components (cells) that touch the boundary, we proceed as follows:

(a) First introduce a border of 1's along the four sides of the image (i.e. add an extra row/column on all the four sides with value 1).

(b) Label the connected component of this new image.

(c) All the connected components touching the boundary in the original image will be part of the connected component that includes the border of 1's introduced in the preprocessing in step (a).

(d) All these connected components, including the artificial border introduced in step (a) can be eliminated by simply setting all the pixels in this connected component to 0. 

 

If you think about it, the no. of "holes" inside a connected component is simply one less than the no. of connected components in the complement of the image. This is what is stated in the handout and I believe it is self-explanatory (i.e., there is nothing more to add here).

Solution: Matlab Code    Output image