why the image has no color in this code?
Mostrar comentarios más antiguos
when i run this code the image with title""('rgbimage inside if');"" show as binary image .id don't know why?? here is the code and u can download the mat file from "u.mat" http://www.mediafire.com/?tf3ef09n4it3aa2 and "var.mat" http://www.mediafire.com/?ovn31e28d51eb1c
filename = 'u.mat';
matObj = matfile(filename);
moving = matObj.u;
I2 = matObj.im1;
filename2 = 'var.mat';
matObj = matfile(filename2);
storedColorMap = matObj.storedColorMap;
figure, imshow(moving,[]), title('binary gradient ');impixelinfo;
[rrr ccc] = size(I2);
moving = imresize(moving, [rrr ccc]);
rgbImage = moving;
% Read in image into an array.
[rows columns numberOfColorBands] = size(rgbImage);
% If it's monochrome (indexed), convert it to color.
% Check to see if it's an 8-bit image needed later for scaling).
if strcmpi(class(rgbImage), 'uint8')
% Flag for 256 gray levels.
eightBit = true;
else
eightBit = false;
end
if numberOfColorBands == 1
if isempty(storedColorMap)
% Just a simple gray level image, not indexed with a stored color map.
% Create a 3D true color image where we copy the monochrome image into all 3 (R, G, & B) color planes.
rgbImage = cat(3, rgbImage, rgbImage, rgbImage);
figure,imshow(rgbImage);title('rgbimage inside if');
else
% It's an indexed image.
rgbImage = ind2rgb(rgbImage, storedColorMap);
figure,imshow(rgbImage,[]);title('rgbimage inside esle');
% ind2rgb() will convert it to double and normalize it to the range 0-1.
% Convert back to uint8 in the range 0-255, if needed.
if eightBit
rgbImage = uint8(255 * rgbImage);
end
end
end
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Images en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!