- BinaryImageQ[image] tests that image is of type "Bit" and contains only a single channel of values.
Background & Context
- BinaryImageQ is an image test function that returns True if a 2D or 3D image consists of binary data values only and False otherwise. More specifically, BinaryImageQ returns True only for single-channel images of ImageType "Bit". BinaryImageQ is therefore useful for distinguishing binary (or bi-level or two-level images) that assume possible pixel values of only 0 (black) and 1 (white) from images consisting of different data types and numbers of channels.
- Some care is needed with terminology since the terms "black and white" and "monochrome" are sometimes used to refer to binary images, but more frequently used to mean grayscale images.
- BinaryImageQ does not inspect actual data values. Therefore, while an image of type "Real" may contain only 0s and 1s, the image is not considered a "binary" image and BinaryImageQ will return False. BinaryImageQ will return True on the outputs for binary segmentation functions such as Binarize, MorphologicalBinarize, and RegionBinarize, since these functions all return binary images.
- More details about the structure of an Image or Image3D can be obtained using the functions ImageChannels and ImageType. An expression can be tested to see if it is an image using ImageQ. The contents of an image are returned by ImageData.
Examplesopen allclose all
Basic Examples (4)
Image by default creates "Real" images:
Wolfram Research (2008), BinaryImageQ, Wolfram Language function, https://reference.wolfram.com/language/ref/BinaryImageQ.html (updated 2012).
Wolfram Language. 2008. "BinaryImageQ." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2012. https://reference.wolfram.com/language/ref/BinaryImageQ.html.
Wolfram Language. (2008). BinaryImageQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/BinaryImageQ.html