【问题标题】:how can i retrieve multiple images which are stored in the .mat format in matlab?(convert .mat to image)如何在 matlab 中检索以 .mat 格式存储的多个图像?(将 .mat 转换为图像)
【发布时间】:2012-01-27 09:07:43
【问题描述】:

我有 70 张人脸图像,它们存储在一个名为 (sub1.mat) 的 .mat 文件中,大小为 8064*70 ,每个图像都存储在“sub.mat”的列向量中,现在我想将每一列转换为图像格式(灰色图像),下面是我写的代码,但它没有给我正确的图像,有人可以告诉我是什么问题吗?感谢您的帮助。(我所知道的关于图像的唯一信息是:图像的大小为 100*100)

load sub1       % a .mat format with the size of 8064*70
%the first image, size 8064*1
a=sub1(:,1)    %each column is an image of an individual
%convert the column matrix to 100*100 image
b=imresize(a,[100 100]);
im=mat2gray(b)
imwrite(im,'im1.pgm');

【问题讨论】:

  • 尝试查看不同阶段的图像以缩小故障位置。例如。 imagesc(b) 计算后的 b 或 imagesc(im)

标签: image matlab


【解决方案1】:

通过这样做,matlab 将尝试将 8064x1 的图像调整为 100x100 的图像。为此,matlab 将拉伸向量以使其适合 100x100 的尺寸。这很可能看起来很糟糕。

这不是你想做的。 您应该找到一种方法来了解图像的原始尺寸,然后使用reshape

im=reshape(sub1(:,1),originalSize);

如果您不知道原始大小,则无法重建图像。

但是,如果您真的不知道原始尺寸,我为您计算了所有可能性,您应该测试它们:

[96 84]
[112 72]
[126 64]
[128 63]
[144 56]
[168 48]
[84 96]
[72 112]
[64 126]
[63 128]
[56 144]
[48 168]

【讨论】:

    猜你喜欢
    • 2016-04-27
    • 2015-02-17
    • 1970-01-01
    • 1970-01-01
    • 2015-10-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-15
    相关资源
    最近更新 更多