MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / flattenStack

Method flattenStack

ij/src/main/java/ij/ImagePlus.java:3365–3403  ·  view source on GitHub ↗

Flattens all slices of this stack or HyperStack. @throws UnsupportedOperationException if this image does not have an overlay and the RoiManager overlay is null. Non-RGB stacks are converted to RGB. Copied from OverlayCommands and modified by Marcel Boeglin on 2014.01.08 to work with

()

Source from the content-addressed store, hash-verified

3363 * on 2014.01.08 to work with HyperStacks.
3364 */
3365 public void flattenStack() {
3366 if (IJ.debugMode) IJ.log("flattenStack");
3367 boolean composite = isComposite();
3368 if (getBitDepth()!=24)
3369 new ImageConverter(this).convertToRGB();
3370 Overlay overlay1 = getOverlay();
3371 Overlay roiManagerOverlay = null;
3372 boolean roiManagerShowAllMode = !Prefs.showAllSliceOnly;
3373 ImageCanvas ic = getCanvas();
3374 if (ic!=null)
3375 roiManagerOverlay = ic.getShowAllList();
3376 setOverlay(null);
3377 if (roiManagerOverlay!=null) {
3378 RoiManager rm = RoiManager.getInstance();
3379 if (rm!=null)
3380 rm.runCommand("show none");
3381 }
3382 Overlay overlay2 = overlay1!=null?overlay1:roiManagerOverlay;
3383 if (composite && overlay2==null)
3384 return;
3385 if (overlay2==null || overlay2.size()==0)
3386 throw new UnsupportedOperationException("A non-empty overlay is required");
3387 ImageStack stack2 = getStack();
3388 boolean showAll = overlay1!=null?false:roiManagerShowAllMode;
3389 if (isHyperStack()) {
3390 int Z = getNSlices();
3391 for (int z=1; z<=Z; z++) {
3392 for (int t=1; t<=getNFrames(); t++) {
3393 int image = z + (t-1)*Z;
3394 flattenImage(stack2, image, overlay2.duplicate(), showAll, z, t);
3395 }
3396 }
3397 } else {
3398 for (int s=1; s<=stack2.getSize(); s++) {
3399 flattenImage(stack2, s, overlay2.duplicate(), showAll);
3400 }
3401 }
3402 setStack(stack2);
3403 }
3404
3405 /** Flattens Overlay 'overlay' on slice 'slice' of ImageStack 'stack'.
3406 * Copied from OverlayCommands by Marcel Boeglin 2014.01.08.

Callers

nothing calls this directly

Calls 15

logMethod · 0.95
isCompositeMethod · 0.95
getBitDepthMethod · 0.95
getOverlayMethod · 0.95
getCanvasMethod · 0.95
getShowAllListMethod · 0.95
setOverlayMethod · 0.95
getInstanceMethod · 0.95
runCommandMethod · 0.95
sizeMethod · 0.95
getStackMethod · 0.95
isHyperStackMethod · 0.95

Tested by

no test coverage detected