A core part of the ImageMorphology package is grayscale or binarized images. You have already learned how to create grayscale images. Binary images are those whose pixels are represented by either 1 or 0. Most of the examples you will find in this book and online have the following standard notation:
- 0 or black is used for the background
- 1 or white is used for the foreground, that is, our object
We will use the following code to create a binary image by a simple thresholding of a grayscale, that is, for example, assigning a 1 if the pixel value is over 0.5 and a 0 if it is below 0.5.
Binary and grayscale images are not perfect because they may contain numerous imperfections and are distorted by noise or texture. Morphological image transformations are targeted at removing these imperfections by using the form and structure of the image. These operations rely...