How can I change a pixel image from black and white to red & blue
1 次查看(过去 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)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/806264/image.png)
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);
0 个评论
回答(1 个)
Robert U
2021-11-19
Hi Yik lok Chan,
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
2021-12-1
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;
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!