is there any difference between grey scale image and binary image? - image

is there any difference between grey scale image and binary image?

Yes, the one is grayscale, e.g. gray scales from 0.255, the binary imange is binary, that means black(0) or white(1).
EDIT: Convert grayscale to binary. Directly converting color images (like RGB) to binary is not that easy, because you have to handle every color channel within the image seperatly.
Converting to binary is done using a ceratin threshold. E.g. you can say, all pixels with gray > 125 will become white, the others black.
There are several thresholding algorithm out there, but maybe the most common is Otsu. You can find it here Thresholding by Otsu

Yes, but I'm not sure what this has to do with C++ or programming. A binary image could be an image where pixels are only either red or blue.
Binary Image: http://en.wikipedia.org/wiki/Binary_image
Grayscale Image: http://en.wikipedia.org/wiki/Grayscale

A binary image has only two values for each pixel, 0 and 1 corresponding to black and white (or vice versa). A gray scale image has a certain number (probably 8) bits of information per pixel, hence, 256 possible grey values.
Of course, a grey scale image has a binary representation, but the smallest size of information is not a bit, so we don't call it a binary image.
edit Assuming you want to convert in Matlab, use im2bw. If you're not using Matlab, the idea of binarization is explained on that page as well. It's not difficult to port, it boils down to comparing every pixel to a threshold value.

Black and White image contains only two levels.
Gray image represent by black and white shades or combination of levels for e.g.
8 bit gray image means total 2^8 levels form black to white 0 = black and 255 is White.

Yes,
A binary image is one that consists of pixels that can have one of exactly two colors, usually black and white. It is also called bi-level or two-level.
A gray scale image is a kind of black and white or gray monochrome are composed exclusively of shades of gray.

Yes
Binary Image
A binary image is a black and white image where each pixel value is either 0 or 1. The value 0 represents background or black and the value 1 represents foreground or white.
Grayscale Image
A grayscale image is a black and white image with various shades of gray. The pixel value of a grayscale image is represented as an 8 bit signed integer. i.e values between 0 and 255. The pixel value of the grayscale image represents the brightness of the pixel. The value 0 is black, the value 255 is white, and the values in between makeup different shades of gray.

Related

Grayscale, monochrome, binary image in matlab

In Matlab,
An 8-bit gray scale image has pixel values ranging from 0 to 255. The pixel depth may vary (16-bit, 32-bit, etc)
A binary image has pixel values, either 0 or 1 (logical)
My question is that, is monochrome image, a binary image or a gray scale image as per points 1 and 2. I need clarification because I want to be 100 % sure about monochrome image.
(As per 'Digital Image Processing Using Matlab' by Gonzalez, Woods, Eddins, a monochrome image is a grayscale image. (Topic 3.2, pg no. 66))
Monochrome and grayscale are mostly interchangeable. Monochrome data has only one color, but it's not always gray. For example digital x-ray data is monochrome because it has only intensity. The printout is typically grayscale but you could also use any other color.
Sepia images are also monochrome, but strictly speaking not grayscale.

Matlab: How can I find the number of black pixels in a color image?

I wish to find the number of black pixels in a color image using MATLAB, how can I do it?
Thanks.
Use nnz like this -
nnz(all(im==0,3))
where im is your image data.
Alternatives - sum(reshape(all(im==0,3),[],1)) and sum(sum(all(im==0,3))).
The assumption here is that black pixels are triplets (0,0,0).
Instead if you define black pixels as pixels that have values in the interval [0 th] for the same pixel location across all channels, use this -
nnz(all(im<=th,3))

How to expand a black region in a boolean image in matlab?

I have a binary image in a matrix that I obtained by some image processing. When I say Binary Image I mean it has zeros and ones indicating complete black and complete white pixels. The image is mostly white and has some black spots. I now want to expand this black spots by some factor. How can I do it?
Have you tried dilate?
imdilate(1-binary_image, SE)
Where SE is the structural element.

White binary image in Matlab

in Matlab,
if I do:
output = false(5, 5);
imshow(output);
it will show me a black square instead of a white binary square image. Is there any reason to this? How can I output a white binary square?
The reason is that false is mapped to 0, and true is mapped to 1.
Also, when showing images, higher number is shown by higher intensity. White has more intensity than black.
Another way to think about it, is that usually you have 256 values - 0-255. 0 is totally black and 255 is totally white. Now, imagine that you do a quantization to two colors. It is now obvious that 0 should be black.
In order to show white square, use
output = true(5,5)
You could use imcomplement
imshow(imcomplement(false(5, 5)))
or modify the default color mapping (quoting from imshow's documentation)
imshow(X,map)
displays the indexed image X with the colormap map. A color map matrix may have any number of rows, but it must have exactly 3 columns. Each row is interpreted as a color, with the first element specifying the intensity of red light, the second green, and the third blue. Color intensity can be specified on the interval 0.0 to 1.0.
You could also change the figure's colormap to customize how MATLAB maps values to colors:
BW = [false,true;true,false];
imshow(BW)
set(gcf, 'Colormap',[1,1,1;0,0,0])

How to convert gray scale image which assigned threshhold value in some pixel of original RGB image to RGB?

I have original RGB image.
then, I convert it to gray scale.
then, I assign new threhold value into some pixel.
then, I need to convert the gray scale image from step#3 to RGB image.
I am trying on the step#4. Could you help to advise?
Check out rgb2hsv and hsv2rgb in matlab. Then threshold on the value matrix. This makes more sense to me.
Another possibility is to convert to grey scale but keep the original colour image. Then create a mask by thresholding the grey scale image and use that mask to discard the pixels above/below your threshold on the colour matrix.

Resources