AI Glossary / Computer vision and multimodal AI / Beginner

Binary image

Definition

A binary image is an image whose pixels have only two possible values. These usually represent two classes, such as foreground and background, and are commonly displayed as black and white. The stored values may be 0 and 1, 0 and 255, or another explicitly defined pair.

What it means

A normal photograph records many levels of brightness and color. A binary image keeps only a two-way distinction at each pixel. That makes it useful for expressing where something is, which pixels meet a condition, or which areas a later operation should process.

The interpretation belongs to the application. White might mean text, an object, a valid measurement or a selected region. Black might mean the opposite. Reversing the display colors does not change the underlying idea, provided the meaning of each value is recorded.

Binary does not mean that the picture has only two objects. A binary mask can contain hundreds of disconnected regions, all using the same foreground value. Nor does a black-and-white photograph necessarily qualify: a grayscale photograph normally contains many intermediate shades.

How it works

One common creation method is thresholding. Each grayscale pixel is compared with a chosen threshold and assigned one of two output values. A global threshold uses the same rule everywhere; an adaptive threshold can vary according to local image information.

Binary images can also come from model predictions, geometric shapes or logical combinations of existing masks. For example, intersecting a product mask with a permitted inspection region produces a new two-valued selection.

Later operations may count foreground pixels, identify connected regions, trace boundaries or apply morphological processing. These operations depend on conventions such as whether diagonal neighbors count as connected. A technically valid two-valued image can still represent the intended objects poorly.

Three practical examples

1. Document scanning: A system converts dark printing and pale paper into a two-valued image for part of its processing pipeline. Shadows and faint letters can make a single threshold unsuitable.

2. Product inspection: A mask identifies pixels suspected of showing a surface mark. Counting selected pixels helps describe the region, but does not by itself establish the mark's cause.

3. Photo editing: A user creates a selection mask indicating where an adjustment may operate. A strictly binary mask has hard selection boundaries; a soft mask with intermediate strengths is a different representation.

Think of it this way

Think of a stencil whose surface is either open or closed at each location. The openings tell a later operation where it may act, without describing the full colors or textures that were originally there.

The analogy has limits. Digital pixels are discrete samples, and their connectivity depends on software rules. A binary image can also label abstract conditions rather than physical openings.

Worked example

Consider a 3 × 3 grayscale image with rows [40, 150, 180], [90, 130, 70] and [200, 110, 160]. Define the rule explicitly: values greater than 120 become 1; all other values become 0.

The output rows are [0, 1, 1], [0, 1, 0] and [1, 0, 1]. Five of the nine pixels are foreground, giving a foreground fraction of 5/9, approximately 55.6%.

This fraction measures selected image area, not automatically the proportion of real-world surface covered. Perspective, pixel scale and the accuracy of the threshold can affect that interpretation. A pixel equal to 120 would be 0 under this rule; using “greater than or equal to” would define a different boundary convention.

Illustrative case study

Fictional case: Oak Archive digitizes old membership cards. Its team makes binary versions to support a text-extraction experiment. A threshold that works on clean cards loses faded writing and turns shadows on yellowed cards into false foreground.

The team compares local thresholding with the original method and keeps the grayscale scans for reference. It evaluates whether characters remain readable rather than judging only how white the page background looks. It also documents that foreground means printed marks in this workflow. The fictional project illustrates why discarding intermediate tones should be a deliberate processing decision, not an automatic replacement for the source image.

Common misconceptions and mistakes

A binary image is not necessarily stored using exactly one bit per pixel. Software may use a byte or larger value for convenience, even though only two values occur.

Black-and-white appearance alone is not proof of binary data. A displayed image can contain gray values, antialiased edges or compression artifacts.

Thresholding does not automatically find meaningful objects. Lighting and background variation can dominate the selected regions.

Resizing a label mask with a blending interpolator can create intermediate values. Choose a suitable method and check the stored values, rather than assuming that the output remains binary because the input was binary.

Business use

Binary images are useful where downstream work needs an explicit selection or two-class region map. They can simplify counting, shape analysis and logical combinations of conditions. Their clarity also helps nontechnical reviewers inspect what a vision pipeline has selected.

The main business risk is treating the clean output as stronger evidence than the source supports. Store the original image, the rule or model version and the foreground convention together. Evaluate errors where the image was uncertain, including shadows, reflections, faint marks and boundaries.

People also ask

Is a binary image the same as grayscale?

No. A grayscale image can contain many brightness levels; a binary image permits only two values.

Does white always mean foreground?

No. That is a common display convention, not a universal requirement.

Can a neural network produce a binary image?

Yes. For example, a probability map can be thresholded into a mask. The probability map itself remains a different, more informative representation.

Check your understanding

A mask contains pixel values 0, 128 and 255 after resizing. Is it still a strictly binary image?

Answer: No. It contains three values. The pipeline must either retain that result as a soft or intermediate representation or apply an explicitly chosen rule to obtain two values again. The correct choice depends on what the mask means.

Related terms

  • thresholding
  • segmentation mask
  • grayscale image
  • mathematical morphology
  • connected components
  • foreground
  • adaptive thresholding

Learn next

Create a tiny grayscale grid and convert it with two different thresholds. Count the foreground pixels and inspect which structures disappear or join. Then compare four-neighbor and eight-neighbor connectivity to see why the same binary pixels can produce different counts of connected regions.

More in Computer vision and multimodal AI

  • Bilinear interpolation - Bilinear interpolation estimates a value between four neighboring samples on a rectangular grid by interpolating in two directions.
  • Bilinear transform - The bilinear transform is a mathematical substitution used to convert a continuous-time filter description into a discrete-time filter.
  • Binary decision - A binary decision is a choice between two defined alternatives, such as yes or no, accept or reject, or object present or absent.
  • Binocular disparity - Binocular disparity is the difference between the positions of corresponding scene features in two views taken from separated viewpoints.
  • Binocular stereopsis - Binocular stereopsis is the perception of depth from differences between the images received by the two eyes.
  • Birchfield - Tomasi dissimilarity - Birchfield - Tomasi dissimilarity is a local image-matching cost designed to reduce sensitivity to how a continuous image signal is sampled onto pixel grids.

Sources

Primary documentation: OpenCV, “Image Thresholding,” https://docs.opencv.org/4.13.0/d7/d4d/tutorial_py_thresholding.html ; and “Basic Thresholding Operations,” https://docs.opencv.org/5.0/tutorials/imgproc/threshold/threshold.html . Relevant threshold definitions were reviewed. The grid example uses an explicitly stated rule and is independent of any library's defaults.

Previous: Binary Decomposition Next: Binary independence model

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer