Can I use the GPU to speed gaussian fit on a large array of vectors?

5 views (last 30 days)
Hi all, I'm trying to write a script that will analyze a group of video frames on a pixel-by-pixel basis. So, I have 200 640x480 images. I pull them in so I have one big 640x480x200 matrix. Thus far I have been using nested loops (and parfor) to analyze each 200 element vector in the 640x480 array. I need to do a Gaussian fit on the vector and return the peak of the Gaussian fit (coefficient b1). My current problem is that it takes a long time to run (over 1 hr) and I'm only able to halve the time using parfor on a dual core CPU.
So my questions are: Can I use the GPU to do more operations in parallel? The fit function is not supported for GPU. Can I use it in arrayfun? Do you have any other tips that would speed this calculation?
I've done some timing and the fit function is the slowest part of the script. I tried to speed it up by limiting iterations and function evaluation. But mostly it's repeating the calculation 307200 times that is taking so long. Eventually, I need to use this script to analyze data with more than 5000 frames so any speed would help greatly.
Here's my code:
if true
%FA is a 640x480x200 double
for j = 1:640
parfor k = 1:480
data=squeeze(-FA(j,k,:)); %extracts z-vector from single pixel
[pks,locs] = findpeaks(data); %smooths peaks over interference fringe modulation
pks = pks + abs(min(pks)); %moves baseline to zero
[mx, mxloc] = max(pks); %IDs location of maximum
f = fit(locs, pks,'gauss1','MaxIter', 1, 'MaxFunEvals', 3, 'Exclude', locs < mxloc - 5 & locs > mxloc + 5);
fitcoeff = coeffvalues(f);
CellArray(j,k) = fitcoeff(1,2); %returns b1 fit coefficient to array
end
end
end
Thanks in advance!

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!