How can I change a pixel image from black and white to red & blue

2 visualizaciones (últimos 30 días)
Yik lok  Chan
Yik lok Chan el 19 de Nov. de 2021
Comentada: yanqi liu el 1 de Dic. de 2021
How can I change a pixel image from black and white to red & blue? The image present a letter 'H' with black and white but I want to change the colour into red & blue. ( testmap is my martix name)
0.2143 0.3395 0.4173 0.3642 0.4025 0.5045
0.4403 1.0000 0.2445 0.2729 1.0000 0.4498
0.4804 1.0000 0.2292 0.2102 1.0000 0.4223
0.3724 1.0000 1.0000 1.0000 1.0000 0.3090
0.4783 1.0000 0.5504 0.3024 0.5916 0.3535
0.5192 1.0000 0.2271 0.3599 1.0000 0.4186
0.3193 0.2616 0.4490 0.2360 0.3270 0.5178
imshow(testmap(:,:,1), 'InitialMagnification' ,2000);

Respuestas (1)

Robert U
Robert U el 19 de Nov. de 2021
Hi Yik lok Chan,
one way to do so is to utilize colormap()-command:
corn_gray = imread('corn.tif',3);
imshow(corn_gray)
map = [linspace(1,0,256)', zeros(256,1), linspace(0,1,256)'];
figure;
imshow(corn_gray,'Colormap',map)
Kind regards,
Robert
  1 comentario
yanqi liu
yanqi liu el 1 de Dic. de 2021
yes,sir,use Robert U method,can get
clc; clear all; close all;
testmap=[0.2143 0.3395 0.4173 0.3642 0.4025 0.5045
0.4403 1.0000 0.2445 0.2729 1.0000 0.4498
0.4804 1.0000 0.2292 0.2102 1.0000 0.4223
0.3724 1.0000 1.0000 1.0000 1.0000 0.3090
0.4783 1.0000 0.5504 0.3024 0.5916 0.3535
0.5192 1.0000 0.2271 0.3599 1.0000 0.4186
0.3193 0.2616 0.4490 0.2360 0.3270 0.5178];
imagesc(testmap(:,:,1));
% red & blue
map=[linspace(1,0,256)', zeros(256,1), linspace(0,1,256)'];
colormap(map); axis equal; axis off;

Iniciar sesión para comentar.

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by