首页 文章

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

提问于
浏览
0

我有一个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 .

现在,当我的字体大小略小或字母有点紧密间隔时,我发现生成的绘图以某种方式"squeezed"以适合窗口大小 . 有关错误的输出,请参阅here .

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

EDIT

我必须提一下,最终的情节图是通过将几个较小的图添加到一个图中而形成的 . 然后使用 frame2im 转换最终的图 . 由于每个较小的情节都是"appended",图像的其余部分"squeezes"本身为更新的情节腾出空间 . 因此,最终的图像完全被挤压在一起 .


我认为Adjusting size of plot in Matlab so that graph does not get cut off by edge of plot window可能是重复的,但在那种特殊情况下,情节被截断了 . 在我的情况下,我发现情节得到"squeezed"适合该地区 .

1 回答

  • 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
    

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

相关问题