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

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

问题描述

以下是所需的工作流程:

Here is the desired workflow:


  • 我想将100张图片加载到MATLAB工作区

  • 在图像上运行一堆我的代码

  • 在新数组中保存我的输出(我的代码返回的输出是一个整数数组)

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

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

如何我会这样做吗?

推荐答案

如果你知道他们所在目录的名称,或者你知道那个目录,然后使用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张图片会占用太多内存。例如,如果是uint8 RGB值,则单个1Kx1K图像将需要3兆字节存储。这可能看起来不是很大。

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 GIGAbytes的内存。这将很快占用你的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天全站免登陆