creating a custom color map

710 visualizaciones (últimos 30 días)
Lisa
Lisa el 25 de Feb. de 2015
Comentada: DGM el 16 de En. de 2023
I'm looking to create a custom color map so that an image appears as various shades of red. I understand that this would require changing the matrix of the RGB image to an image consisting of _,0,0, but I am not sure of the best way to go about this
  2 comentarios
Markus Kokot
Markus Kokot el 29 de Dic. de 2020
is a there a solution?
Image Analyst
Image Analyst el 29 de Dic. de 2020
Yes, two of them. Did youi scroll down and look at them?

Iniciar sesión para comentar.

Respuestas (2)

Image Analyst
Image Analyst el 25 de Feb. de 2015
You don't need an RGB image. In fact RGB images don't even take a colormap. If you want an RGB image, just create one
rgbImage = cat(3, grayImage, zeros(size(grayImage), 'uint8'), zeros(size(grayImage), 'uint8'));
imshow(rgbImage);
Or use a colormap with your grayscale image:
grayImage = imread('moon.tif');
imshow(grayImage);
colorMap = [linspace(0,1,256)', zeros(256,2)]
colormap(colorMap);
colorbar;
  3 comentarios
Image Analyst
Image Analyst el 5 de Mayo de 2020
Try this:
yellowMap = [linspace(0, 255, 256)', linspace(0, 255, 256)', zeros(256, 1)]
colormap(yellowMap);
DGM
DGM el 16 de En. de 2023
I'm not so sure that's a simple false color image. It may be a composite. That possibility aside, here's a better approximation:
% reduced sampling
x0 = [0 0.008889 0.03556 0.08 0.1422 0.2222 0.32 0.4356 0.5644 0.68 0.7778 0.8578 0.92 0.9644 0.9911 1];
CT0 = [0 0 0.1; 0.002914 0.01103 0.1143; 0.01221 0.02996 0.1352; 0.02938 0.04745 0.1489; 0.05622 0.07057 0.1604; ...
0.09753 0.1003 0.1803; 0.1756 0.1568 0.2046; 0.2908 0.2456 0.2395; 0.4299 0.355 0.2906; 0.5757 0.4753 0.3516; ...
0.7288 0.6116 0.427; 0.8555 0.7448 0.5124; 0.9486 0.8541 0.6076; 0.9871 0.9329 0.7081; 0.9983 0.983 0.809; 1 1 0.95];
% generate a new uniform table of desired length
N = 256;
xf = linspace(0,1,N);
CT = interp1(x0,CT0,xf,'pchip');
% use the map to plot something
x = linspace(-pi/2,pi/2,30);
y = x.';
z = sin(x).*sin(y);
surf(x,y,z)
colormap(CT)
colorbar
view(-17,50)
Of course, the dark blue is essentially black against this awful white background, but that's what you get.
Note that even though we might be able to define some trajectory through some color space, there's no information which unambiguously informs us about the rate at which that path is traversed with respect to the mapped variable. Here, we're assuming it's linear.
If you want the map shifted more toward blue or more toward yellow, you can use MIMT ctshift().
% generate some example images using shifted versions of the CT
testsweeps = cat(3,ctshift(CT,-0.67), ...
ctshift(CT,-0.33), ...
ctshift(CT,0), ...
ctshift(CT,0.33), ...
ctshift(CT,0.67));
testsweeps = permute(testsweeps,[3 1 2]);
testsweeps = imresize(testsweeps,[128 256],'nearest');
imshow(testsweeps)

Iniciar sesión para comentar.


Alka Nair
Alka Nair el 25 de Feb. de 2015
Editada: per isakson el 25 de Feb. de 2015
The 'colormapeditor' helps in displaying the current figure's colormap and customizing it. To find more information about colormapeditor, please refer to the documentation at:

Categorías

Más información sobre Red en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by