How do I create a colormap?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I've been having problems creating a colormap in the Staff version of Matlab (Matlab R2013b). I want to create a colormap of the type "jet", so I typed in the Command Window:
myColorMap = jet(256);
colormap(myColorMap);
colorbar
However, when I press enter, a window (called "Figure 1") pops up with a colormap, but with no picture in it. I've imported the picture (filename: Picture1Edit.jpg) into the program, I can see it in the sidebar "Current folder" left of my Command Window, so I know it's definetely there. Could anyone help me creating this colormap?
0 comentarios
Respuestas (2)
Bjorn Gustavsson
el 29 de En. de 2014
That's the way you create a colormap. The colorbar command forces the creation of an axes, that forces the creation of a figure (unless the figure and an axes already exists). To display the image you'll have to use some of the image display-functions: imshow, image, imagesc; or even surf/pcolor if you want some more complex warping of the image. Then you can put a colorbar on the side of those displays.
HTH
0 comentarios
Image Analyst
el 29 de En. de 2014
Try this:
% Get full file name.
baseFileName = 'Picture1Edit.jpg';
folder = pwd; % Current folder
% Display if it exists, warn and exit if not.
if exist(fullFileName, 'file')
grayImage = imread(fullFileName);
imshow(grayImage);
else
message = sprintf('Error: %s not found', fullFileName);
uiwait(warndlg(message));
return;
end
% Apply colormap.
myColorMap = jet(256);
colormap(myColorMap);
colorbar
0 comentarios
Ver también
Categorías
Más información sobre Color and Styling 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!