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

2 次查看(过去 30 天)
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);

回答(1 个)

Robert U
Robert U 2021-11-19
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 个评论
yanqi liu
yanqi liu 2021-12-1
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;

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by