Zoom in on two images simultaneously displayed using imshowpair

조회 수: 39 (최근 30일)
BC
BC 2021년 2월 9일
댓글: Adam Danz 2022년 12월 21일
I have two images of the same dimensions. I'm using the code below to display them side by side.
imshowpair(imageA, imageB, "montage")
Currently if I zoom into an area of imageA in the figure ouput, it zooms solely into this area, treating the two images as one image. I want to be able to zoom into an area in imageA, and for the display to also zoom into the corresponding area of imageB at the same time, so I can compare the same areas of both images when zooming in.
Can I do this using imshowpair, the tools in the figure output, or some other way?
Thanks for the help!

채택된 답변

Adam Danz
Adam Danz 2021년 2월 9일
편집: Adam Danz 2021년 2월 9일
> If I zoom into an area of imageA in the figure ouput, it zooms solely into this area, treating the two images as one image
That's because the two images are merged into one image on the same axes.
To achieve a dual display with independent axis tools, you need to plot the images in different axes. Then use linkaxes to yoke the axis limits when zooming/panning.
% Read in demo image
img = imread('cameraman.tif');
fig = figure();
ax(1) = axes('Units','normalized','Position', [ .1 .1 .4 .8]);
ax(2) = axes('Units','normalized','Position', [ .5 .1 .4 .8]);
imshow(img, 'Parent', ax(1))
imshow(img, 'Parent', ax(2))
linkaxes(ax)
  댓글 수: 4
Siddharth Pantoji
Siddharth Pantoji 2022년 12월 21일
편집: Siddharth Pantoji 2022년 12월 21일
Hi Adam,
I cant seem to get my annotations (red lines) to appear on both the images. Any suggestions?
Hold didnt work either
fig = figure();
ax(1) = axes('Units','normalized','Position', [ .1 .1 .4 .8]);
ax(2) = axes('Units','normalized','Position', [ .5 .1 .4 .8]);
imshow(ReferenceImage2, 'Parent', ax(1))
line([0 2464],[MW_lowerlimit-1 MW_lowerlimit-1],get(gca,'Ylim'),'Color',[1 0 0],'linewidth',0.5);
line([0 2464], [MW_upperlimit+1 MW_upperlimit+1],get(gca,'Ylim'),'Color',[1 0 0],'linewidth',0.5);
line([MW_leftlimit-1 MW_leftlimit-1],[0 2056],get(gca,'Ylim'),'Color',[1 0 0],'linewidth',0.5);
line([MW_rightlimit+1 MW_rightlimit+1],[0 2056],get(gca,'Ylim'),'Color',[1 0 0],'linewidth',0.5);
line([CenterLinePosition CenterLinePosition],[0 2056],get(gca,'Ylim'),'Color',[1 0 0],'linewidth',0.5,'LineStyle','--');
imshow(ReferenceImage1, 'Parent', ax(2))
line([0 2464],[MW_lowerlimit-1 MW_lowerlimit-1],get(gca,'Ylim'),'Color',[1 0 0],'linewidth',0.5);
line([0 2464], [MW_upperlimit+1 MW_upperlimit+1],get(gca,'Ylim'),'Color',[1 0 0],'linewidth',0.5);
line([MW_leftlimit-1 MW_leftlimit-1],[0 2056],get(gca,'Ylim'),'Color',[1 0 0],'linewidth',0.5);
line([MW_rightlimit+1 MW_rightlimit+1],[0 2056],get(gca,'Ylim'),'Color',[1 0 0],'linewidth',0.5);
line([CenterLinePosition CenterLinePosition],[0 2056],get(gca,'Ylim'),'Color',[1 0 0],'linewidth',0.5,'LineStyle','--');
linkaxes(ax)
Adam Danz
Adam Danz 2022년 12월 21일
You need to specify which axis the lines should be added to .
line(ax(1), ...)
line(ax(2), ...)

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by