change Black and White - Image to Black & Red Image
5 ビュー (過去 30 日間)
I have the following problem. I am displaying binary map information, stored in a 100x100 matrix with imshow. This works well. I am also plotting the error between two maps by substracting map A from map B. This leaves us with an new map C. I can plot that with imshow but I want to change the colors to Black & red instead of BW.
Does anyone know how to do that? Any help is appreciated.
回答 (2 件)
Image Analyst 2012 年 7 月 9 日
編集済み: Image Analyst 2012 年 7 月 9 日
See my demo, which handles negative values which will occur. -1 = red, 0 = black, and +1 = blue.
workspace; % Make sure the workspace panel is showing.
% Create two sample images.
fontSize = 22;
binaryImageA = false(200, 300);
binaryImageB = false(200, 300);
% Make two regions that overlap.
binaryImageA(60:140, 100:200) = true;
binaryImageB(100:150, 150:250) = true;
% Display the sample images.
subplot(2, 2, 1);
title('Binary Image A', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
subplot(2, 2, 2);
title('Binary Image B', 'FontSize', fontSize);
% Subtract the two sample images
differenceImage = int32(binaryImageA) - int32(binaryImageB);
% Display the difference image.
title('Difference Image: A - B', 'FontSize', fontSize);
% Make colormap: red for negative, 0 for 0, blue for positive.
cmap = [1 0 0; 0 0 0; 0 0 1];
% Apply colormap