Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Speedup Help
Replies: 8   Last Post: Jul 28, 2014 7:56 AM

 Messages: [ Previous | Next ]
 Matt Posts: 23 Registered: 8/13/09
Speedup Help
Posted: Jul 23, 2014 3:59 PM

Hi, All --

I am cycling through some geometry in 3D space and writing images that are essentially slices from the volume. The image generation routine is shown below. As you can see, it has several for loops and is quite slow. Any suggestions on speeding this thing up?

for oo = 1:Height
I = zeros(Depth,Width,'int8');
for jj = 1:r
front = ceil(Depth - M(jj,1) + rad);
back = floor(Depth - M(jj,1) - rad)+1;
for nn = back:front
for kk = left:right
if ((kk - M(jj,2))^2+(nn-(Depth-M(jj,1)))^2+ ...
I(nn,kk) = 1;
end
end
end
end
end
imwrite(logical(I),['data' num2str(oo,'%04d') 'r.tif']);
['File number ',num2str(oo,'%04d'),' has been processed']
end

Thanks a bunch.

Matt

Date Subject Author
7/23/14 Matt
7/24/14 Bruno Luong
7/24/14 Matt
7/24/14 Bruno Luong
7/24/14 Matt
7/25/14 Bruno Luong
7/25/14 Matt
7/26/14 Bruno Luong
7/28/14 Robert Miethe