Binary images (black and white) are everywhere in ImageJ, they are required in
Analyze > Analyze Particles
, have their own operators and functions.This post explains what they are and how to use them...
In a binary image, the pixels are in two states: ON or OFF. Better than saying ON and OFF, the TRUE and FALSE keywords are used.
Fig.1:A binary image in black and white. |
What are TRUE and FALSE in a computer ?
In programming languages, a condition returns TRUE or FALSE but behind these two keywords, there are numbers where TRUE equal to 1 (one) and FALSE to 0 (zero) as shown in this small IJ macro/script:
print( (1==1) ); // Display 1 (TRUE)
print( (1==2) ); // Display 0 (FALSE)Now, what about the binary images?
In ImageJ, a binary image is an 8-bit image where FALSE corresponds to a pixel value of 0 (in terms of "color", this is black) and TRUE to a value of 255 (equivalent to white). Thus, a binary image is black and white.2. Conversion
How to convert a gray-level or color images into a binary ?
The simplest way is to threshold your image inImage > Adjust > Threshold...
. Troubleshootings
- The TRUE and FALSE don't always correspond to white and black colors. That can be puzzling and this is explained in this post [Link].- Sometimes, you can't run morphological operations and ImageJ complains about the fact that your image is not binary even though the image looks correct. That means that pixels (or just one) are not equal to 0 or 255 (but are close to these values, I noticed that a value of 2 is often observed).
There are two ways to fix this:
- Rerun a
Process > Binary > Make Binary
- Normalize your image (
Process > Enhance Contrast
and check Normalize)
No comments:
Post a Comment