The Math Forum

Search All of the Math Forum:

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

Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 23
Registered: 8/13/09
Speedup Help
Posted: Jul 23, 2014 3:59 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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
rad = M(jj,4);
if abs(oo-(Height-M(jj,3))) < rad
front = ceil(Depth - M(jj,1) + rad);
back = floor(Depth - M(jj,1) - rad)+1;
left = floor(M(jj,2) - rad)+1;
right = ceil(M(jj,2) + rad);
for nn = back:front
for kk = left:right
if ((kk - M(jj,2))^2+(nn-(Depth-M(jj,1)))^2+ ...
I(nn,kk) = 1;
imwrite(logical(I),['data' num2str(oo,'%04d') 'r.tif']);
['File number ',num2str(oo,'%04d'),' has been processed']

Thanks a bunch.


Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.