Images appear black and white instead of coloured
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jason
am 20 Feb. 2015
Bearbeitet: Jason
am 23 Feb. 2015
I plot a montage of images onto a UIPanel and it worked fine when the images were tiffs. My images are now jpgs and I notice that the coloured images now appear black and white. I can't see why this would be the case. Here is my code
This is in a loop for all images.
hp = handles.uipanelM;
h=subplot('Position',positionVector,'Parent',hp); %to enable deleting use handles
colormap (jet);
% update handle array
hSubplots = [hSubplots ; h]; %Concatenate
axis off;
hold off;
%Create thumbnail sized image
IM1=imresize(IM, 0.05);
allImgs{y1,x1} = IM1 ;
imagesc(Image,[mlo mhi])
colormap (jet);
axis off;
set(gca,'ytick',[]);
set(gca,'xtick',[]);
drawnow;

4 Kommentare
Akzeptierte Antwort
Image Analyst
am 20 Feb. 2015
Bearbeitet: Image Analyst
am 21 Feb. 2015
JPG images are usually color, even if they appear as gray scale - it's just that all the color channels are the same. Try:
imshow(IM1, []); % Display color image
Or extract one of the color channels:
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
imshow(redChannel, []); % Display one monochrome color channel
colormap(jet(256));
Or convert to grayscale if the color channels are NOT all identical:
grayImage = rgb2gray(IM1);
imshow(grayImage); % Display converted image.
colormap(jet(256));
colorbar;
7 Kommentare
Image Analyst
am 21 Feb. 2015
Jason: That won't do it. First of all, Image was not even defined in your code. You should use the red channel of IM or IM1. Second, Image is a bad name since image() is the name of a built in function. I know MATLAB is case sensitive, but nonetheless it's not a wise idea to use variables with the same names as the built in functions, even if the case of some of the letters is different.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Blue finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!