yields True if image has the form of a binary Image or Image3D object, and False otherwise.


  • 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.


open allclose all

Basic Examples  (4)

Test whether an image is binary:

Click for copyable input

Single-channel images with data type "Bit" are binary:

Click for copyable input

Image by default creates "Real" images:

Click for copyable input

Test whether a 3D image is binary:

Click for copyable input

Properties & Relations  (1)

See Also

ImageChannels  ImageType  ImageData  Binarize  ColorConvert  ImageQ

Introduced in 2008
| Updated in 2012