Putting a legend on a fused image

조회 수: 3 (최근 30일)
Stacy Genovese
Stacy Genovese 2022년 4월 10일
댓글: Stacy Genovese 2022년 4월 10일
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
  댓글 수: 1
Stacy Genovese
Stacy Genovese 2022년 4월 10일
Thank you so much! This worked.

댓글을 달려면 로그인하십시오.

채택된 답변

DGM
DGM 2022년 4월 10일
편집: DGM 2022년 4월 10일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by