Re: Optimizing the creation of an array of correllation coefficents



"Kyle " <lynchkp09@xxxxxxxxx> wrote in message <g1sij9$qse
$1@xxxxxxxxxxxxxxxxxx>...
Hey everyone, I am trying to optimize the creation of a correllation matrix
for
a technique called the Method of Snapshots for POD. Im using a 3d data set
(220 pixel x 220 pixel x 68 pixel), and converting it to a one-dimensional
array. The problem I am having is that it is very I/O bound, with each .mat
file
composed of doubles. Therefore, it takes about 30 hours to run. Is there
any
way for me to optimize this so I do not have to do as many I/O calls, or can
I
use a better storage method? Ive included my code below.

load([savedir,'AvgImage'],'image_avg');
image_avg = reshape(image_avg,length,1);

C = zeros(nfiles,nfiles);

for rowcount = 1:nfiles
fprintf('Correlating Image: %d \n',rowcount)
load([savedir,'Sequence',num2str(rowcount)],'image');
image = reshape(image,length,1);
x1 = image - image_avg; %Row colcount
for colcount=1:nfiles
if (rowcount > colcount)
C(rowcount,colcount) = C(colcount,rowcount);
else
load([savedir,'Sequence',num2str(colcount)],'image');
image = reshape(image,length,1);
x2 = image - image_avg; %Col j
tic
C(rowcount,colcount)=sum(x1.*x2); %Row i times Col j
toc
end
end
end

break;
C = C ./ nfiles;
--------------
There are three crucial numbers you haven't given us: 1) the value of
'length', 2) the value of 'nfiles', and 3), most importantly, the size of the
largest array you have room for in your matlab memory. My guess on 1) is
3,291,200, but I have no idea about 2) or 3).

It is obvious that a predominant part of your computer time is spent on the
repeated loadings of your images, with more than nfiles^2/2 loadings
altogether. That's an awful waste of time.

Besides the above difficulties, there is an aspect of the theory of your
procedure that bothers me. If two 3D images are of essentially the same
content but shifted in location within the 3D image frame, this similarity may
not show up as a strong correlation between the two 1D arrays as you are
computing them. Your computation provides no measure of a correlation
between points which are at differing, though nearby, locations in the image
frame.

Roger Stafford

.



Relevant Pages


Loading