BinaryImageQ

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

DetailsDetails

  • BinaryImageQ[image] tests that image is of type and contains only a single channel of values.

Background
Background

  • 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 . BinaryImageQ is therefore useful for distinguishing binary (or bi-level or two-level images) that assume possible pixel values of only (black) and (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 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.

ExamplesExamplesopen allclose all

Basic Examples  (4)Basic Examples  (4)

Test whether an image is binary:

In[2]:=
Click for copyable input
Out[2]=

Single-channel images with data type are binary:

In[1]:=
Click for copyable input
Out[1]=

Image by default creates images:

In[1]:=
Click for copyable input
Out[1]=

Test whether a 3D image is binary:

In[1]:=
Click for copyable input
Out[1]=
Introduced in 2008
(7.0)
| Updated in 2012
(9.0)