How to change colormap of indexed image to HSV colormap in MATLAB - matlab

I am using an indexed image.How do I programatically obtain the pixel intensity values obtained by changing the colormap to hsv in the imtool? Is there a way to change the colormap of the indexed image to hsv(256)?
I am new to MATLAB, kindly help!
I have attached the image below:
Which channel does the imtool display and what does the value '91' in the imtool stand for? How do I obtain this value?

The Pixel info at the bottom displays the following information:
Pixel info: (X, Y): Pixel Value
Here, we have pixel value of 91 at (309, 510). 91 is the pixel intensity in a range of values (mostly 0 to 255). Only 1 channel is being read because it is a grayscale image.
You can create a hsv image out of an RGB image but it doesnt make sense to talk of a hsv conversion for a gray scale image. What you have is a grayscale image.

Related

How can I display a grayscale raster in color in Matlab?

I have a .tif file of a landmass that denotes elevation. I want to display this raster with a color ramp as opposed to a grayscale ramp. How would I do this in Matlab?
I looked at the information associated with the tiff using:
[Z, R] = geotiffread('Landmass.tif')
which denotes the heading 'ColourType' as 'grayscale'. I tried to change this to 'winter' (one of matlabs in-built color schemes) but it made no difference.
At the moment I am using the following commands to display the tiff:
[Z, R] = geotiffread('Landmass.tif');
e=uint8(Z);
mapshow(e,R);
All the higher areas are white and everything else is black...even around the landmass (which I think I may have to cut/mask the landmass out to get rid of).
All the black colour is making it too difficult for me to display other shapefiles on top of the tiff, so I want to change the color scheme from grayscale to something lighter.
How do I do this?
The reason colormap winter is not working is because the output of mapshow(e,R); is RGB image format.
Even when the displayed image is gray, it is actually RGB, when r=g=b for each pixel.
I took Matlab mapshow example, converted boston image to Grayscale, and used mapshow.
For using colormap winter, I got image using getimage, convert it to Grayscale using rgb2gray, and then colormap winter worked when showing the image.
Check the following example:
[boston, R] = geotiffread('boston.tif');
boston = rgb2gray(boston); %Convert to Grayscale for testing.
figure
mapshow(boston, R);
axis image off
%Get image data, note: size of I is 2881x4481x3 (I is not in Grayscale format).
I = getimage(gca);
%Convert I from RGB (R=G=B) formtat to Grayscale foramt, note: size of J is
%2881x4481 (J is Grayscale format).
%%%%%%%Avoid image being rotated%%%%%%%%%%%%%
%Close old image and open new figure
close Figure 1
Figure
J = rgb2gray(I);
imshow(J);
colormap winter %Now it's working...
Boston with winter colormap:

imshow() displays a white image for a grey image

I have computed an image with values between 0 and 255. When I use imageview(), the image is correctly displayed, in grey levels, but when I want to save this image or display it with imshow, I have a white image, or sometimes some black pixels here and there:
Whereas with imageview():
Can some one help me?
I think that you should use imshow(uint8(image)); on the image before displaying it.
Matlab expects images of type double to be in the 0..1 range and images that are uint8 in the 0..255 range. You can convert the range yourself (but change values in the process), do an explicit cast (and potentially loose precision) or instruct Matlab to use the minimum and maximum value found in the image matrix as the white and black value to scale to when visualising.
See the following example with an uint8 image present in Matlab:
im = imread('moon.tif');
figure; imshow(im);
figure; imshow(double(im));
figure; imshow(double(im), []);
figure; imshow(im2double(im));

Obtaining the pixel values of gray scale image from a binary image

I do binary thresholding on a 16 bit gray scale image.This would help me in segmenting the region of interest.After binary thresholding,i would like to get the individual pixel intensities which are the intensities of the original 16 bit image and not the binary intensity values say 0,65535...
How can i do this?
Find the region of interest in image segmentation using the binary image. After this, use the pixel locations in the 16 bit image for further processing of the image.
To get a image from your original image, I and a binary (logical) segmented image BW:
I2 = I.*BW;
I2 should have the original values in the ROI and 0 elsewhere. Or, to get just a list of pixels and their values, via logical indexing:
I2 = I(BW);
Alternatively, depending on what you're doing, you may want to use regionprops:
stats = regionprops(BW,I,'MeanIntensity','PixelValues');
For a BW image showing the regions of interest, and a greyscale image I this will return the mean intensity and all list of all pixel values in I for each separate region (defined as a connected areas in BW).

how to read th r,g,b values of an quantized image

Merged with how to read and store rgb values of each pixel after image quantization.
i have quantized an image to 64 colors using [IND,map]=rgb2ind(RGB,64)
my question is,how can i read the red pixel intensity,green pixel intensity and blue pixel intesity of each pixel from the quantized image.
thanking you
dev

An explanation for this MATLAB code snippet

Consider:
%# load a grayscale image
img = imread('coins.png');
%# display the image
figure
imshow(img,[]);
%# false-color
colormap('hot')
The above code is from here:
Infrared image processing in Matlab
But I don't understand how figure (what's the difference with/without it?) and colormap (how does it affect the already shown image?) work?
figure is not required, imshow just displays img on it. If a figure hadn't been opened, imshow would've created a new one.
The colormap colors the intensities of the image. The hot map colors values in increasing intensity with black, red, yellow, and white-hot. Another popular colormap is jet which has a number of interesting colors.
False colors
So the matrix you want to see has intensities which can have any range of values. For better visualization, the intensities are displayed in a range of colors or a set of false colors. Normally, a grayscale image will display an image is shades of grey, where white is maximum and black is minimum. False color is an extension of that concept with several colors in between (like jet) and an effect of metal being heated in hot.
Colormap at the pixel level
Suppose you have a matrix with pixel values ranging from [cmin xmax]. Now, normalize the values so that the range is [0,1]. Also, suppose you have a color map, such that a range of colors are mapped to some values from 0 to 1 (e.g. 0.5 is mapped to RGB(100,200,100))- then you get the false color mapping by finding the closest intensity in the map and display the corresponding color.
More on colormap in the MATLAB documentation. I've included some picture from that link here:
Jet
(source: mathworks.com)
Bone
alt text http://www.mathworks.com/access/helpdesk/help/techdoc/ref/bone_spine.gif