Combining methods from set theory, topology and discrete mathematics, mathematical morphology provides a powerful approach to processing images and other discrete data.
Mathematica includes an extensive and efficient implementation of mathematical morphology, fully integrated with
Mathematica's general image and data processing.
Binarize — convert any image to black and white
ColorNegate — flip black and white
MorphologicalComponents — identify connected components
CornerNeighbors — option to specify neighborhood configuration