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

5 Ansichten (letzte 30 Tage)
Yik lok  Chan
Yik lok Chan am 19 Nov. 2021
Kommentiert: yanqi liu am 1 Dez. 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);

Antworten (1)

Robert U
Robert U am 19 Nov. 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 Kommentar
yanqi liu
yanqi liu am 1 Dez. 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;

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Images finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by