Question about rgb image
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Elsie
el 5 de Jun. de 2014
Comentada: Image Analyst
el 13 de Jun. de 2014
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.
0 comentarios
Respuesta aceptada
Image Analyst
el 5 de Jun. de 2014
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 comentarios
Image Analyst
el 13 de Jun. de 2014
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().
Más respuestas (0)
Ver también
Categorías
Más información sobre Blue en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!