Colorizing grayscale images with tones of specified colors...

11 次查看(过去 30 天)
Hello; I need your very helps about my project in University. I need to colorize X-ray images. I have writed a simple code about it. But i have several problems. Since we do not have a good x-gun, every one of the images are different from one another,I need to colorize these images using 4 colors i mean, there are 4 different color regions. Red and its tones for for example low valued pixels; yellow and its tones for another pixel value region and so on.. But i do not know how can i distribute tones of a color to different pixel values :( I can just colorize specified pixel value regions with one,two,three ( i mean countable) tones. And i need to optimize each picture i mean same materials must be in same color region but since we do not have a good environment, for even same material, pixel values can be different from each other in two taken images.
I can send you the code i wrote but i think its useless.Since that gui can only colorize specified 3 pixel regions i mean for example a color for values between 0-100 and another one for 100-155 and another one for 155-255 ( just for example )
Here is the link for the code i wrote: http://speedy.sh/CZKbb/Grayscale-Colorization.rar
I need your advices on how can i solve these 2 problems. Please help me ...
Sincerely Abarairenji
  4 个评论
Abarairenji
Abarairenji 2012-7-18
Hello Matt, Thank you for your help. I can say that i may collect images at 12 or 16 bit i guess. I dont know what are dicom images.About the colorization; For example in a x image, i want to colorize most dark regions (for example between 0-50) with the continious tones of blue,dark regions with the tones of red (for example 50-75), middle intensity regions with continious tones of brown (for ex. 75-155),less dense regions with green and lessers with yellows and its continous tones...
Image Analyst
Image Analyst 2012-7-18
Did you scroll down far enough to see my answer below? Where I recommended ind2rgb() or colormap()?

请先登录,再进行评论。

采纳的回答

Image Analyst
Image Analyst 2012-7-18
编辑:Image Analyst 2012-7-19
You can use a colormap to change how the image looks, or you can create a colormap and apply it to the image with ind2rgb() to get an RGB image out.
That will let you somewhat arbitrarily colorize your images. But if you want the color to correspond to the actual physical real-world mass of your objects, then that's a different story. Say you want red to be where your sample density is 20 grams per square centimeter, but that can happen at 50 gray levels for some images and 170 gray levels in other images because you don't have control over your exposure (dosage). In that case, your only hope is if you have similar images (say, all chest x-rays) and you can assume that the intensity values (the histograms) should all be the same. In that case, you can use my Histogram shaping code in my File Exchange ( http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862) to match all your images histograms to one master image. If your x-ray source varies in its dosage, and your samples also vary (say, you have mice in one image and truck engine crankcases in another) then you're out of luck, unless you have a standard embedded in the image such as a aluminum step wedge.
  6 个评论
Image Analyst
Image Analyst 2012-7-19
I don't understand why you can't simply use imshow() to display your image and then use colormap() to apply some colormap. It does work. Maybe though you need different colormaps on different axes. In that case, read this: http://www.mathworks.com/support/solutions/en/data/1-GNRWEH/index.html;jsessionid=ffe53d91f96d08d777ac29499393
Abarairenji
Abarairenji 2012-7-20
Thank you a lot (: It worked. If i can do anything for you, please remind me Mr.

请先登录,再进行评论。

更多回答(1 个)

obaldia
obaldia 2017-1-26
this has already been answered, but there is no solution for changing the tone of the image to an arbitrary color and not temper with the colormaps.
To change a grayscale image to a tone-scale one could use the HSV color space.
[im ~] = imread('cameraman.tif'); %im is a one dimensional grayscale image
[imRGB] = cat(3, im, im, im); %convert grayscale image to RGB
[imHSV] = rgb2hsv(imRGB);
Now we just have to change the "hue" of the HSV color space to a specific color. For example, petrol. Petrol has a chroma (hue) of 163°
imHSV(:,:,1) = 163./360; %Change the "hue" of the image, norm to 360 degrees
imHSV(:,:,2) = 1 - imHSV(:,:,2) %invert the saturation axis
The result is a petrolscale image!
res = hsv2rgb(imHSV);
  1 个评论
Image Analyst
Image Analyst 2017-1-26
I'm attaching a related program, in case anyone is interested. It increases the saturation (color vividness/purity) for a particular color range in the image (e.g. blue is "enhanced") and other colors remain the same.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Blue 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by