Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 在matlab中将图像存储到单元格中_Arrays_Image_Matlab_Cell - Fatal编程技术网

Arrays 在matlab中将图像存储到单元格中

Arrays 在matlab中将图像存储到单元格中,arrays,image,matlab,cell,Arrays,Image,Matlab,Cell,我知道以前也有人问过类似的问题,但我尝试过其他的解决方案,但运气不佳。非常感谢您的帮助 我想1.加载一个图像文件,2.使用imread读取它们,3.将其放入单元格,4.在单元格中的每个数组上逐步运行我的函数 这是我的1个图像/文件的函数 function sym_file(filename) %this calls for the image file name j=im2double(rgb2gray(imread(filename))); %reads the image, turns in

我知道以前也有人问过类似的问题,但我尝试过其他的解决方案,但运气不佳。非常感谢您的帮助

我想1.加载一个图像文件,2.使用imread读取它们,3.将其放入单元格,4.在单元格中的每个数组上逐步运行我的函数

这是我的1个图像/文件的函数

function sym_file(filename) %this calls for the image file name
j=im2double(rgb2gray(imread(filename)));
%reads the image, turns int into grayscale and double

if rem(size(j,2),2)~=0,j(:,1)=[];
if rem(size(j,1),2)~=0,j(1,:)=[];
end
end                                      
%this made sure the rows and columns are even

jr=fliplr(j);
left=(j(:,1:size(j,2)/2));
right=(jr(:,1:size(j,2)/2));
t=sum(left,2);
u=sum(right,2);
symmetry= (left-right)./255;
symmetry2=reshape(symmetry,1,(numel(symmetry)));
imbalance=mean(symmetry2)
asymmetry=sqrt(mean(symmetry2.^2))

%runs calculations on image

figure('Name',num2str(filename),'NumberTitle','off')
subplot(3,2,1)
histogram(symmetry2,200)
title(['symmetry:' num2str(asymmetry)])
subplot(3,2,2)
imshow(j)
title(['imbalance:' num2str(imbalance)])
subplot(3,2,3)
imshow(left) 
title('left')
subplot(3,2,4)
imshow(fliplr(right)) 
title('right')
impixelinfo;
subplot(3,2,5)
plot(1:length(t),t,'-r',1:length(u),u,'-b')
title('results,red=left/blue=right')

%printing results in a figure

所以我想用一个图像文件来做这件事,而不是一个文件一个文件地做。最好的办法是什么?另外,如果有人知道如何将数据/图形存储在文件中,那也是一个额外的好处。

让我看看我是否明白了这一点:你有一组图像,你将它们存储在一个单元格中。然后,您希望对每个图像应用一个函数(换句话说:对单元格的每个元素)

如果是这样,就使用

例如:

X = imread('http://sipi.usc.edu/database/preview/aerials/3.2.25.png','png');
Y = imread('http://sipi.usc.edu/database/preview/misc/5.3.01.png','png');

my_cell{1} = X;
my_cell{2} = Y;

my_fftcell = cellfun(@fft2,my_cell,'UniformOutput', false)
在本例中,我加载了两个图像X和Y,并将它们存储到我的_单元中(括号{}向MATLAB/Octave指示它是一个单元)。然后我创建了另一个名为my_fftcell的单元格,它是应用于每个图像的fft2

要从一个文件夹/目录中获取多个文件,只需循环该目录中的每个文件并将其存储到单元格中即可。大概是这样的:


在我给出的那个例子中,只需做一些类似于:octave:4>my_cell{1}=X的事情,我想你误解了这个问题。我在问我怎么把图像放进手机里?你认为我已经把它们储存在一个牢房里了,但这正是我需要帮助的地方。谢谢要添加图像(或任何其他类型的变量,在本例中,图像是矩阵),您只需像向向量添加元素一样进行添加,但使用括号即可。谢谢!这个例子很有帮助!你知道如何把整个文件放进去而不是一张一张地打印出来吗?我会用uigetfile吗?无论如何谢谢你的帮助!定义“整个文件”的含义。这些图像如何存储在此文件中?你有一个满是图像文件的目录吗?