Binary images are images whose pixels have only twopossible intensity values. They are normally displayed asblack and white. Numerically, the two values are often 0 for black,and either 1 or 255 for white.
Binary images are often produced by thresholding agrayscale or color image, in order toseparate an object in the image from the background. The color of theobject (usually white) is referred to as the foreground color.The rest (usually black) is referred to as the backgroundcolor. However, depending on the image which is to be thresholded,this polarity might be inverted, in which case the object isdisplayed with 0 and the background is with a non-zero value.
Some morphological operators assume a certain polarityof the binary input image so that if we process an image with inversepolarity the operator will have the opposite effect. For example, ifwe apply a closing operator to a black text on whitebackground, the text will be opened.