How can I change a pixel image from black and white to red & blue
조회 수: 3 (최근 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);
댓글 수: 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!