在 MATLAB 中加载多个图像 [英] Loading multiple images in MATLAB

查看:22
本文介绍了在 MATLAB 中加载多个图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是所需的工作流程:

  • 我想将 100 张图像加载到 MATLAB 工作区
  • 在图像上运行我的一堆代码
  • 将我的输出(我的代码返回的输出是一个整数数组)保存在一个新数组中

到最后,我应该有一个数据结构来存储图像 1-100 的代码输出.

By the end I should have a data structure storing the output of the code for images 1-100.

我该怎么做?

推荐答案

如果您知道它们所在目录的名称,或者如果您 cd 到该目录,则使用 dir 获取图像名称列表.

If you know the name of the directory they are in, or if you cd to that directory, then use dir to get the list of image names.

>

现在它只是一个加载图像的 for 循环.将图像存储在元胞数组中.例如...

Now it is simply a for loop to load in the images. Store the images in a cell array. For example...

D = dir('*.jpg');
imcell = cell(1,numel(D));
for i = 1:numel(D)
  imcell{i} = imread(D(i).name);
end

注意这 100 张图片会占用太多内存.例如,单个 1Kx1K 图像将需要 3 兆字节来存储,如果它是 uint8 RGB 值.这可能看起来不是很大.

BEWARE that these 100 images will take up too much memory. For example, a single 1Kx1K image will require 3 megabytes to store, if it is uint8 RGB values. This may not seem like a huge amount.

但是,其中 100 个图像将需要 300 MB 的 RAM.真正的问题是,如果您对这些图像的操作将它们变成双倍,那么它们现在将占用 2.4 GB 的内存.这将很快耗尽您拥有的 RAM 量,尤其是当您使用的不是 64 位版本的 MATLAB 时.

But then 100 of these images will require 300 MB of RAM. The real issue comes about if your operations on these images turn them into doubles, then they will now take up 2.4 GIGAbytes of memory. This will quickly eat up the amount of RAM you have, especially if you are not using a 64 bit version of MATLAB.

这篇关于在 MATLAB 中加载多个图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆