Can you lend me your Python programming skills? I think this will be an easy one. I will try to be quick.
What I have: I have a stack of images and a macro that does the job for a folder with the individual images (not a stack)
What I wished I had: The program to do the job with a stack instead of individual images.
What this all means: I have bone images (slices) with a thickness of 0,041 mm and I would like to have slices with a thickness of 1 mm (and 3 mm), too. For this I would like to make a new stack of the sum of x images (to set the new thickness) from the original stack to increase the thickness of the slices. That means, to get a 1 mm thick slice I would need x to be 24.
The macro: I did not write this myself and I am still looking where I got this from. Please excuse my stupidity.
from ij import IJ, ImageStack, ImagePlus from ij.plugin import ZProjector, FolderOpener view_size = 24 # Open all images from a folder #opener = FolderOpener() #opener.run("") # Get image stack info, and create a stack to receive the merged images tif_stack = IJ.getImage() image_x_size, image_y_size, null0, stack_size, null1 = tif_stack.getDimensions() new_stack = ImageStack(image_x_size, image_y_size) # Create the Projector that will process the stack portions zp = ZProjector(tif_stack) zp.setMethod(ZProjector.AVG_METHOD) # Now create a slice for each block of size view_size, and add it the the new_stack for view in range(stack_size - view_size + 1): zp.setStartSlice(view+1) zp.setStopSlice(view+view_size) zp.doProjection() new_stack.addSlice(zp.getProjection().getProcessor()) # Create and show the final image stack final_stack = ImagePlus("imp", new_stack) final_stack.show()
Thank you for taking a bit of your time for me. I really appreciate it.