Hello ImageJ,
I would like to save images with the ROI imprinted on them. Here is the scenario:
-- I have 30 images displayed in a single stack.
-- I draw a circular ROI and the ROI is seen on all the images when I scroll through the images in stack window.
-- Now I would like to get the image capture of the following images with the ROI: 1st, 10th, 20th and 30th slices in the stack.
When I call the following code in my program, I do get the flattened image for the currently active image, but how do I flatten for other slices which are not currently active?
ImagePlus img =
WindowManager.getCurrentImage();
flattenedImg = img.flatten(); // when I save flattenedImg (using ImagePlus.saveAs(...)), the ROI is available in the saved file.
I tried the following code snippet to flatten and save other slices in the stack and it seems to work, but the display also changes and this is not the desired behaviour.
ImagePlus img = WindowManager.getCurrentImage();
img.setSlice(desigedSliceNumber); // Set the desired slicenumber which needs to be flattened (1,10,20,30)
flattenedImg = img.flatten(); Also sometimes the there is an overlap of images on the saved files (threading issue?) when I call the above code in a 'for loop'. I have to put
Sleep for 500ms in-between to avoid this problem.
Please let me know if there is a good way to flatten a stack of images without changing the display. Will using overlay help?
For your information: I am using ImageJ programmatically for my application.
Thanks for any help.
Best regards,
netvidya