【问题标题】:How to reshape cropped face images into 1D image vector in MATLAB?如何在 MATLAB 中将裁剪的人脸图像重塑为一维图像向量?
【发布时间】:2014-01-29 00:14:50
【问题描述】:

我使用函数“fdetect”裁剪出检测到的人脸,现在我正在尝试将获得的 2D 图像重塑为 1D 图像向量。我尝试了以下方法:

for k=1:length(files)
    %read the images in the folder
    imgs=imread(fullfile);
    fdI=fdetect(imgs);

    targetsize=[256 256];
    img_resized=imresize(fdI,targetsize);
    [irow icol]=size(img_resized',irow*icol,1);
    T=[T temp]   %1D image vector
end

但我得到了错误:

函数 IMRESIZE 期望其第一个输入 A 为非空。

我检查了函数“fdetect”的输出及其非空值,它给出了裁剪后的面孔。 任何人都可以指出我的错误或任何其他方式吗? 提前致谢。

【问题讨论】:

标签: matlab image-processing crop


【解决方案1】:

将 2D 向量变为 1D 的最简单方法就是使用冒号运算符:

img_resized(:)  %// or fdI(:), not sure which you want to convert

但你也可以使用 reshape 功能:

reshape(img_resized, [], 1) %// Note that the second parameter specifies how many rows you want. You can be specific if you want, i.e. numel(img_resized), but by passing an empty vector, reshape calculates that dimension for you.

【讨论】:

  • @丹:谢谢。我会试试这个并得到结果。
猜你喜欢
  • 2018-03-07
  • 2016-09-22
  • 2019-06-11
  • 2012-02-12
  • 2020-09-27
  • 2011-11-14
  • 1970-01-01
  • 2016-12-05
相关资源
最近更新 更多