change Black and White - Image to Black & Red Image
19 views (last 30 days)
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.
Image Analyst on 9 Jul 2012
Edited: Image Analyst on 9 Jul 2012
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