副区的两个图像具有垂直隔板

问题描述 投票:1回答:1

我试图创建与左(原图像)上的图像的数字,右(变形图像)上的图像和垂直线将它们分开,就像这样:

enter image description here

我已经通过创建轴试过这个,没有蜱和标签。然后画一条线从底部到顶部和施加hold on最后subplot两个图像。

我的代码:

origImage = imread('F-original.png');
tform = affine2d([1 0 0; .5 1 0; 0 0 1]);
warpedImage = imwarp(origImage, tform, 'interp', 'bilinear');

axes('Position', [0 0 1 1], 'XTick', NaN, 'YTick', NaN);
line([1/2 1/2], [0 1], 'Color', 'k')
axes(gca)
hold on

subplot(1, 2, 1)
imshow(origImage)

subplot(1, 2, 2)
imshow(warpedImage)

然而,究竟什么情况是:行闪烁的一瞬间,但随后消失,所有可以看到的都是次要情节。

如何使这项工作?

image matlab line matlab-figure subplot
1个回答
4
投票

为了实现这个结果,应使用一个annotation,这是对图中水平的图形对象(即,不局限于特定的轴,所以不需要hold on等)。

下面是一个例子:

function q54617073
% Prepare images:
origImage = imread('ngc6543a.jpg');
tform = affine2d([1 0 0; .5 1 0; 0 0 1]);
warpedImage = imwarp(origImage, tform, 'interp', 'bilinear');
% Create a figure with a white background:
figure('Color','w');
% Plot the two images:
subplot(1, 2, 1); imshow(origImage);
subplot(1, 2, 2); imshow(warpedImage);
% Add the Line
annotation('line', [0.52 0.52], [0.2 0.8], 'Color', 'r', 'LineWidth', 3);

导致:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.