How can I save every 5 images in a loop?
2 views (last 30 days)
Show older comments
I have a binary file that's 256x256x256 pixels, displaying a 3D image of a sphere on an XYZ axis. I am trying to write a loop that will save "sliced" images of this object every 4 pixels, resulting in a slowly-increasing circle in the y-axis. The sphere "floats" on the XYZ axis, visible from y=29 to y=141. So I am trying to slice and save images at y=29, y=34, y=39, etc, until I reach y=141. As of now, it will just start at y=29 and save images at every single pixel value from 29 up till 141, so I'm ending up with 112 different images saved to my PC instead of the desired 28.
My code is below:
load ('sphere.mat');
N=141;
for k=29:N
imagesc(squeeze(sphere(:,k,:)));
k=k+4;
imsave();
end
Answers (0)
See Also
Categories
Find more on Image Data Acquisition in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!