在MATLAB中显示没有图形压缩的图?

时间:2014-06-01 01:19:52

标签: matlab image-processing matlab-figure

我有一个MATLAB代码,我正在为图像中的某些单词生成边界图。 然后使用从bwboundaries函数生成的点绘制,然后使用生成的绘图创建我稍后在代码中使用的图像。

以下是代码段:

%GET 8-NEIGHBOURHOOD BOUNDARIES
[B,L,N] = bwboundaries(z,'noholes');

%PLOT THE BOUNDARY FIGURE FOR EACH WORD
figure;
hold on;
for k=1:length(B),
    boundary = B{k};
    if(k > N)
        plot(boundary(:,2),boundary(:,1),'g','LineWidth',2);
    else
        plot(boundary(:,2),boundary(:,1),'r','LineWidth',2);
    end
    set(gca, 'visible', 'off');
    F = getframe(gcf);
    [X, Map] = frame2im(F);
end

现在,正常的文字有一个稍大的字体,我正如预期的那样得到完美的结果。请参阅here以获取正确的输出。

现在,当我的字体尺寸略小或字母间隔很小时,我发现生成的图形以某种方式“挤压”以适合窗口大小。如果输出错误,请参阅here

我希望绘图占用尽可能多的空间来显示整个边界图像,如果需要可以调整自身大小。 否则,frame2im正在捕获完全错误的图像,这会影响我的进一步计算。

修改

我必须提到最终的情节图是通过在一个图中附加几个较小的图而形成的。然后使用frame2im转换最终的图。 随着每个较小的地块被“追加”,图像的其余部分“挤压”自身以为更新的地块腾出空间。因此,最终的图像完全被挤压在一起。


我认为Adjusting size of plot in Matlab so that graph does not get cut off by edge of plot window可能是重复的,但在特定情况下,情节会被截断。在我的情况下,我发现情节被“挤压”以适应该区域。

1 个答案:

答案 0 :(得分:0)

我不确定这是否是您正在寻找的,但它可能会有所帮助。 这是一个测试

%Simulation of a binary L and proper visualization
A=zeros(100,100);
A(80:90,10:60)=1;
A(10:90,10:20)=1;
figure,imagesc(A)

% concatenation of 20 binary L's and the shrink visualization
num=20;
A2=repmat(A,1,num);
figure,
imagesc(A2)

%correction of the visualization through the definition of the axes dimensions
figure,
axes('unit','normalized','position',[0.1 0.1 0.8 0.8/10])
imagesc(A2)

%correction of the visualization through the definition of the axis dimensions
figure,
imagesc(A2)
axis ([0,1000,0,100]) % axis image

您可以使用此模板更改图像的外观,从而纠正收缩。