zoukankan      html  css  js  c++  java
  • matlab subplot(figure)如何设置使得图像最终显示出来不一样大小

    1. 问题描述

    figure
    subplot(1, 2, 1), imshow(A)
    subplot(1, 2, 2), imshow(B)

    无论 A 和 B 的 size 是否一致,最终显示出来的 figure 中的两幅图像大小都是相同的。

    2. 原因及解决

    之所以第二个图看起来和第一张图等大,是因为第二个 subplot 的 XY 轴的单位长度比第一个subplot中的要长(二者的比例尺不同)。所以简单一点的解决方法是:将第二个 subplot 的 XLim 和 YLim 属性设为和第一个 subplot 中的对应属性值。

    3. demo:图像金字塔变换

    % 加载图像数据到内存
    I = imread('cameraman.tif');
    size(I)
    
    % reduce ==> {2, 4, 8}
    I1 = impyramid(I, 'reduce'); size(I1)
    I2 = impyramid(I1, 'reduce'); size(I2)
    I3 = impyramid(I2, 'reduce'); size(I3)
    
    figure
    a1 = subplot(1, 4, 1); imshow(I),  
    xs = get(a1, 'xlim'); ys = get(a1, 'ylim');
    a2 = subplot(1, 4, 2); imshow(I1),
    set(a2, 'xlim', xs, 'ylim', ys);
    a3 = subplot(1, 4, 3); imshow(I2),
    set(a3, 'xlim', xs, 'ylim', ys);
    a4 = subplot(1, 4, 4); imshow(I3)
    set(a4, 'xlim', xs, 'ylim', ys);
    
    I1 = impyramid(I, 'expand'); size(I1)
    I2 = impyramid(I1, 'expand'); size(I2)
    I3 = impyramid(I2, 'expand'); size(I3)
    
    figure
    a1 = subplot(1, 4, 1); imshow(I3),  
    xs = get(a1, 'xlim'); ys = get(a1, 'ylim');
    a2 = subplot(1, 4, 2); imshow(I2),
    set(a2, 'xlim', xs, 'ylim', ys);
    a3 = subplot(1, 4, 3); imshow(I1),
    set(a3, 'xlim', xs, 'ylim', ys);
    a4 = subplot(1, 4, 4); imshow(I)
    set(a4, 'xlim', xs, 'ylim', ys);
  • 相关阅读:
    又到一年高考时
    嵌套母版页中的控件访问
    用临时表改善嵌套SQL语句的执行速度
    利用图片进行定位
    CSS样式嵌套
    触摸MVP
    抱SQL SERVER大腿之从巨大表中提炼非重复数据
    用参数来控制用户控件的缓存
    Understand static/global data completely in C++
    VS资源(基础)
  • 原文地址:https://www.cnblogs.com/mtcnn/p/9421365.html
Copyright © 2011-2022 走看看