A Small-Space Algorithm for Removing Small Connected Components from a Binary Image