필터 지우기
필터 지우기

Question about rgb image

조회 수: 2 (최근 30일)
Elsie
Elsie 2014년 6월 5일
댓글: Image Analyst 2014년 6월 13일
Hi, i have question regarding to imshow a rgb image:
rect =[ ...];
i=image_newC+abs(min(min(image_newC))); % i is a grayscale image
i=imcrop(i,rect);
n = size(unique(reshape(i,size(i,1)*size(i,2),size(i,3))),1);
rgb = ind2rgb(gray2ind(i,n),jet(n));
imshow(rgb,[]); *???why output image is entirely red?*
The purpose is to convert grayscale image to rgb image, i don't know why outcome is not expected. One more thing, is i tried to show it in this way:
imshow(i,[]);
colormap(jet(255));
but i don't know how to access the rgb image if i want to further perform some operations on it. Any way to store it in a variable? Sorry, i am new to Matlab.
Thanks a lot for your help.

채택된 답변

Image Analyst
Image Analyst 2014년 6월 5일
Wow! That's about the most complicated, convoluted way of converting a gray scale image to RGB I've ever seen. If image_newC is a unint8 gray scale image, you can simply do
rgbImage = cat(3, image_newC, image_newC, image_newC);
If you want an RGB image with some colormap applied, just as jet(256), do this:
rgbImage = ind2rgb(image_newC, jet(256));
Please see my attached demos if you want to colorize a portion of the image but not the whole image.
  댓글 수: 3
Elsie
Elsie 2014년 6월 13일
Hi, Image Analyst, is it possible to get the image after colomap? i want the colomapped image...
Image Analyst
Image Analyst 2014년 6월 13일
With the demos I posted, you know the color map in advance. You specified it so of course you already know it.
For RGB images there is no color map - it simply does not apply or make sense.
If you want to convert an RGB image to an indexed image, you can use rgb2ind() and it will give you a color map. There is no guarantee that the color map it applies will be anything like the color map you specified when you created the RGB image with ind2rgb().

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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