Why is the speed of the improfile function so variable?

3 vues (au cours des 30 derniers jours)
Reed Espinosa
Reed Espinosa le 8 Juin 2013
I have a code in which I process a series of images, each of which I run improfile on a few thousand times. This generally takes only a few seconds per image but I've come across a couple system configurations on which this process takes several minutes. The most recent example of which is my MacBook running OS X 10.6. The code ran quickly on this machine with Matlab version 2010b but when I recently upgraded to 2012b the time it takes to run the same code increased by at least a factor of 20. I don't think the Matlab version is the only factor though because I've seen the code run both fast and slow on different machines both using Matlab version 2011b.
Anyone have any idea why the speed of improfile is so finicky? A snippet from my code is below. Thanks.
num_points = 1000;
% using bilinear below results in about a 4x speed decrease and 1%
% difference in output variable "value"
improfile_method = 'nearest'; % {'nearest'},'bilinear', 'bicubic'
delta = 0.001;
value = zeros(beamsEndX-beamsStartX+1,1);
for xPos = beamsStartX:beamsEndX
valueIndex = xPos - beamsStartX +1;
% find normal line
deriv = (cf_center(xPos+delta) - cf_center(xPos-delta))/(2*delta);
slope = - 1/deriv;
intercept = cf_center(xPos) - slope * xPos;
normLine = @(x) slope*x + intercept;
% build xi and yi if it was not loaded
if length(x_bound)==1 || length(y_bound)==1
[xi, yi] = find_profile_bounds(cf_top, cf_bottom, normLine, xPos);
else
xi = x_bound(xPos - beamsStartX + 1,:);
yi = y_bound(xPos - beamsStartX + 1,:);
end
[~, ~, improf] = improfile(image,xi,yi,num_points, improfile_method);
[more code follows but the bottle neck is improfile]

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by