Hi,
I am trying to find the mean and variance of 64 samples of images between each same pixel location of my image database. Each image is 192×164 resolution which I call from a directory to read in a cell variable 'data'. Then using for loop, I read and conver each image into column vector, double and store in variable 'M2' so it's dimension is 32256×64. Each column consist of pixel of each image sample. Now when I try to find mean along rows by applying mean2=mean(M2,2); matlab is giving this error Index in position 1 is invalid. Array indices must be positive integers or logical values.
A = dir('Input Folder'); TotalFiles = length(A);data = cell(1, TotalFiles);for k = 1:TotalFiles data{k} = imread(A(k).name); end% first=cell2mat(data([1]));
% [row col]=size(first);
% M=double(zeros(Size(1),Size(2)));
% M1=M(:); Size=size(first);
for i=1:TotalFiles M=double(cell2mat(data(i)));% M1(1:row*col,1)=M(:)+M1;
M2(:,i)=M(:); end % mean=(1/TotalFiles)*M1;
% mean1=reshape(mean,[192,168]);
mean2= mean(M2,2);
I don't understand why it is giving this error. Same way if I tried to find variance of this matrix, var2=var(M2,2), it gives same error. Kindly someone help me what is that I am doing wrong. I am using doule class for integers, Thanks
Best Answer