Putting a legend on a fused image

11 views (last 30 days)
I have the following code:
figure()
total_grid = imfuse(pB_grid, pA_grid, "falsecolor");
imshow(total_grid,'InitialMagnification', 800)
title("Initial placement of cells")
Is there anyway to add a legend to this to make clear which points are from the pB_grid and which are from the pA_grid?
Thanks

Accepted Answer

DGM
DGM on 10 Apr 2022
Edited: DGM on 10 Apr 2022
Here's one way to work around the issue:
A = imread('cameraman.tif');
B = fliplr(A);
F = imfuse(A,B,'falsecolor');
imshow(F); hold on
% use empty scatter objects to give legend() something to use
ha = scatter([],[],10,[0 1 0],'filled');
hb = scatter([],[],10,[1 0 1],'filled');
legend([ha hb],{'image A','image B'})
Depending on the object content of the images being used, the result may be totally counterintuitive. In the above example, the legend is correct. Image A is represented in green, but the primary feature is a man in dark clothing, so he's filled with the bright regions of image B. As a consequence, he's apparently the exact opposite of the color indicated by the legend. Using imfuse() like this is a great way to make things confusing unless all your objects are positive (bright) features.

More Answers (0)

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!