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

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.

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.

`matlab` extracting blue channel from 3D image into a 2D monochrome matrix

I have an RGB image of which i want to extract the blue channel by doing
new_image = image(:,:,3);
this is now a 2 dimensional matrix, however I want to apply a filter on it using the filter2() function and displaying this filtered image using image() or imshow(). when using the imshow() to display the image, the display is grayscale. how can i arrange this so that i will have blue filtered monochrome image?
Either put it back into an RGB matrix with the R and G channels set to zero or create a colormap.

Why does imagesc change colormap (MATLAB)

I want to use imagesc to crop and display a black and white (grayscale?) image. However, it keeps displaying the image in rgb, making it look like it came from an infra-red camera! Any tips for preserving the original colors?
You need to change the color map. After you run imagesc use colormap('Gray'). You can set default colormap to current colormap using colormap('default')

View pixel intensities of an image

How to view the pixel intensities of an image in matlab by moving the mouse pointer over the image?
I used:
imshow(imread('image.jpg'));
But there is no option to view the pixel intensities of each pixel in the image.
For example,
In MS-paint, while moving the mouse pointer
over the image we can see the location of
the pixel such as (20, 117) at the status bar.
But I need to see the pixel intensity instead.
Is there any other option to view it. Or I need to code to view it?
One other option which is more interactive is
imtool(imread('image.jpg')); % For GrayScale Image
imtool(rgb2gray(imread('image.jpg'))); % For RGB Image
If you want to create an intensity map, you can use MATLAB's rgb2gray. This will convert the n-by-m-by-3 RGB array you got from imread to an n-by-m matrix which contains the pixel intensities.
You can then point the interactive data cursor to this intensity matrix for the current mouse coordinates.
you have impixelinfo and impixelinfoval for showing interactive information.

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