Returns a "flattened" version of this image, or stack slice, in RGB format.
()
| 3322 | |
| 3323 | /** Returns a "flattened" version of this image, or stack slice, in RGB format. */ |
| 3324 | public ImagePlus flatten() { |
| 3325 | if (IJ.debugMode) IJ.log("flatten"); |
| 3326 | ImagePlus impCopy = this; |
| 3327 | if (getStackSize()>1) |
| 3328 | impCopy = crop("whole-slice"); |
| 3329 | ImagePlus imp2 = impCopy.createImagePlus(); |
| 3330 | imp2.setOverlay(impCopy.getOverlay()); |
| 3331 | imp2.setTitle(flattenTitle); |
| 3332 | ImageCanvas ic2 = new ImageCanvas(imp2); |
| 3333 | imp2.flatteningCanvas = ic2; |
| 3334 | imp2.setRoi(getRoi()); |
| 3335 | Overlay overlay2 = getOverlay(); |
| 3336 | if (overlay2!=null && imp2.getRoi()!=null && !(imp2.getRoi() instanceof PointRoi)) { |
| 3337 | imp2.deleteRoi(); |
| 3338 | if (getWindow()!=null) IJ.wait(100); |
| 3339 | } |
| 3340 | setPointScale(imp2.getRoi(), overlay2); |
| 3341 | ImageCanvas ic = getCanvas(); |
| 3342 | if (ic!=null) |
| 3343 | ic2.setShowAllList(ic.getShowAllList()); |
| 3344 | BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); |
| 3345 | Graphics2D g = (Graphics2D)bi.getGraphics(); |
| 3346 | g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, |
| 3347 | antialiasRendering?RenderingHints.VALUE_ANTIALIAS_ON:RenderingHints.VALUE_ANTIALIAS_OFF); |
| 3348 | g.drawImage(getImage(), 0, 0, null); |
| 3349 | ic2.paint(g); |
| 3350 | imp2.flatteningCanvas = null; |
| 3351 | ImagePlus imp3 = new ImagePlus("Flat_"+getTitle(), new ColorProcessor(bi)); |
| 3352 | imp3.copyScale(this); |
| 3353 | imp3.setProperty("Info", getProperty("Info")); |
| 3354 | imp3.setProperties(getPropertiesAsArray()); |
| 3355 | return imp3; |
| 3356 | } |
| 3357 | |
| 3358 | /** Flattens all slices of this stack or HyperStack.<br> |
| 3359 | * @throws UnsupportedOperationException if this image<br> |
no test coverage detected