how to display an image's colormap onto its grayscale map?
Show older comments
Hi everyone,
I have biomedical images (.dcm) and I need to display the colormap of each image onto its grayscale map. I.e:
Let's say my image is named as X, and Y is a processed version of X 1) imshow(X); //grayscale 2) image(Y); //colormap
These two resulting figures on top of each other.
Any suggestion would help. Thanks
Answers (1)
Image Analyst
on 20 Jan 2014
Applying a colormap to one grayscale image will apply it to all grayscale images in all axes in the figure. Since that is usually not what you want, you can call freezecolors but it's probably easiest just to convert the grayscale image that you want to apply a colormap to, into a color image with ind2rgb():
imshow(X); % Show first gray scale image.
rgbImage = ind2rgb(Y, yourColorMap); % Convert second gray scale image into a color image.
imshow(rgbImage); % Display the color image.
11 Comments
bazinga
on 20 Jan 2014
Image Analyst
on 20 Jan 2014
It's whatever colormap you had. I didn't say you had a colormap - you did. So I assume you knew what colormap you were talking about. If you don't have one, then you can assign a default one such as gray, jet, winter, etc. or make up your own custom one if you prefer.
bazinga
on 30 Jan 2014
Image Analyst
on 30 Jan 2014
What was the min and max value when it was a double class? Was it between 0 and 1? Or 0 and 255? If so, it will be dark or zero because uint16 goes from 0 to 65535.
bazinga
on 30 Jan 2014
Image Analyst
on 30 Jan 2014
Edited: Image Analyst
on 30 Jan 2014
You need to do
maxGL = max(grayImage(:))
minGL = min(grayImage(:))
otherwise you get the max and min of every column. But it looks like your values are in the range of 0-255 so no wonder they're displaying as all black. Try this:
imshow(grayImage, []);
or else
grayImage16 = uint16(grayImage) * uint16(256);
imshow(grayImage16);
bazinga
on 30 Jan 2014
Image Analyst
on 30 Jan 2014
Make up a small example using a standard MATLAB demo image and post it.
bazinga
on 30 Jan 2014
Edited: Walter Roberson
on 30 Jan 2014
Walter Roberson
on 30 Jan 2014
tempImage = zeros(size(original), 'like', original);
Note: you could also use this code with no loop
tempImage = original;
tempImage(original <= threshold2 | original >= threshold) = 0;
bazinga
on 30 Jan 2014
Categories
Find more on Blue 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!