Black pixel representation in the binary image
9 views (last 30 days)
Show older comments
Why sometimes does black pixel in the binary image represent by value 1 sometimes value 0?
0 Comments
Answers (3)
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.
0 Comments
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.
0 Comments
See Also
Categories
Find more on Image Segmentation and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!