Black pixel representation in the binary image

9 views (last 30 days)
Why sometimes does black pixel in the binary image represent by value 1 sometimes value 0?

Answers (3)

Walter Roberson
Walter Roberson on 23 Jun 2012
Sometimes the information is in the white pixels and sometimes the information is in the black pixels.
In a normal photograph we look for the brighter (more white) objects as being the primary information, but when we are looking at (for example) hand-writing, that is black writing on a lighter background and it is the black that holds the information.
In computer programming, it is usually mathematically easier to represent the color of interest with a 1 pixel.

Image Analyst
Image Analyst on 23 Jun 2012
In a binary image, a black pixel is never represented by a value of 1 (true), unless you have changed, for some strange and unnecessary reason, the colormap. Black pixels are always represented by 0 (false).
Perhaps you really meant to say "Why are black pixels in a grayscale image sometimes seen as black, and sometimes as white, in the binary image after the grayscale image has been thresholded?" In that case, if your dark pixels represent the objects of interest, you can threshold this way to have your dark objects show up as white (1, true) in your binary image:
darkObjects = grayImage < 50; % Or whatever threshold you want.
On the other hand if the light portions of your grayscale image were the objects of interest, then you could threshold this way to get the white objects to show up as white (1, true) in your binary image:
lightObjects = grayImage > 50;
In that case, dark objects show up as black (0, false) in your binary image - the opposite of the first example.

Kritsada
Kritsada on 23 Jun 2012
Thank you for you two answers. Sometimes, I resave the image by using Photoshop and the value of black color change from 0 to 1. ( white from 1-> 0) That may be because of gray scale of it.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!