Grayscale, monochrome, binary image in matlab - image

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.

Related

There have any process to detect an image is a black&white image or a colored image?

I need to detect an image is a color image or black&white image. But don't understand what will be the process or there have any function to detect it. If there have no function to detect it then what will be the process?
Image file has mode, which tells if it is RGB, grayscale or B&W.
I assume you know that and you are trying to examine a RGB image to see if it only has black / white color. In this case you can calculate the histogram of the image in all R/G/B channels, the black and white will have two sharp peaks in all three channels.
Please use a image editing software like GIMP and experiment.

How to seprate RGB planes as three different gray scale images?

I want to seprate RGB planes of a color image as three gray scale image in MATLAB. But they are colored. How can I do it? I use the below code:
red = I(:,:,1); % Red channel
green = I(:,:,2); % Green channel
Using image will show the matrix as an image with the default colour map of whatever version of MATLAB you are using. For version R2014b and higher, it will show this in the parula colour map and other versions show this in the jet colour map. If you wish to visualize this as a grayscale image, you must use colormap gray; after you call image.
However, if you have the Image Processing Toolbox, you can simply use imshow and single channel images default to showing the contents as 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 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.

is there any difference between grey scale image and binary 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.

Resources