/** * Performs dilation with a ball structuring element by calling the ImageJ * Filters3D.filter method, using Filters3D.MAX option. * * @param image * the 3D stack to process */ @Override public ImageStack dilation(ImageStack image) { float r = (float) this.radius; ImageStack result = Filters3D.filter(image, Filters3D.MAX, r, r, r); result.setColorModel( image.getColorModel() ); return result; }
/** * Performs dilation with a ball structuring element by calling the ImageJ * Filters3D.filter method, using Filters3D.MAX option. * * @param image * the 3D stack to process * @return the result of the dilation */ @Override public ImageStack dilation(ImageStack image) { float rx = (float) this.xRadius; float ry = (float) this.yRadius; float rz = (float) this.zRadius; ImageStack result = Filters3D.filter(image, Filters3D.MAX, rx, ry, rz); result.setColorModel( image.getColorModel() ); return result; }
/** * Performs erosion with a ball structuring element by calling the ImageJ * Filters3D.filter method, using Filters3D.MIN option. * * @param image * the 3D stack to process */ @Override public ImageStack erosion(ImageStack image) { float r = (float) this.radius; ImageStack result = Filters3D.filter(image, Filters3D.MIN, r, r, r); result.setColorModel( image.getColorModel() ); return result; } }
private void setColorModel(ColorModel cm) { ImageProcessor baseImage = imagePlus.getProcessor(); baseImage.setColorModel(cm); if (imagePlus.getStackSize() > 1) { ImageStack stack = imagePlus.getStack(); stack.setColorModel(cm); } } }
/** * Returns a binary image that contains only the largest label. * * @param image * a binary 3D image containing several individual regions * @return a new binary image containing only the largest region from * original image */ public static final ImageStack keepLargestRegion(ImageStack image) { ImageStack labelImage = componentsLabeling(image, 6, 16); ImageStack result = binarize(LabelImages.keepLargestLabel(labelImage)); result.setColorModel(image.getColorModel()); return result; }
/** * Returns a binary image in which the largest region has been replaced by * the background value. * * @param image * a binary 3D image containing several individual particles * @return a new binary image containing all the regions from original image * but the largest one */ public static final ImageStack removeLargestRegion(ImageStack image) { ImageStack labelImage = componentsLabeling(image, 6, 16); LabelImages.removeLargestLabel(labelImage); ImageStack result = binarize(labelImage); result.setColorModel(image.getColorModel()); return result; }
private static void setGrayLUT(ImagePlus ip) { byte[] channel = new byte[256]; for (int i = 0; i < 256; i++) channel[i] = (byte)i; IndexColorModel c = new IndexColorModel(8, 256, channel, channel, channel); ip.getProcessor().setColorModel(c); if (ip.getStackSize() > 1) ip.getStack().setColorModel(c); } }
void invertLookupTable() { int nImages = getStackSize(); ip.invertLut(); if (nImages==1) ip.invert(); else { ImageStack stack2 = getStack(); for (int i=1; i<=nImages; i++) stack2.getProcessor(i).invert(); stack2.setColorModel(ip.getColorModel()); } }
void invertLookupTable() { int nImages = getStackSize(); ip.invertLut(); if (nImages==1) ip.invert(); else { ImageStack stack2 = getStack(); for (int i=1; i<=nImages; i++) stack2.getProcessor(i).invert(); stack2.setColorModel(ip.getColorModel()); } }
private static void setPhysicsLUT(ImagePlus ip) { IndexColorModel c = new IndexColorModel(8, 256, makeColorChannel(redSteps), makeColorChannel(greenSteps), makeColorChannel(blueSteps)); ip.getProcessor().setColorModel(c); if (ip.getStackSize() > 1) ip.getStack().setColorModel(c); }
ImageStack createOutputStack(ImagePlus imp, ImageProcessor ip) { int bitDepth = imp.getBitDepth(); int w2=ip.getWidth(), h2=ip.getHeight(), d2=outputSlices; int flags = NewImage.FILL_BLACK + NewImage.CHECK_AVAILABLE_MEMORY; ImagePlus imp2 = NewImage.createImage("temp", w2, h2, d2, bitDepth, flags); if (imp2!=null && imp2.getStackSize()==d2) IJ.showStatus("Reslice... (press 'Esc' to abort)"); if (imp2==null) return null; else { ImageStack stack2 = imp2.getStack(); stack2.setColorModel(ip.getColorModel()); return stack2; } }
ImageStack createOutputStack(ImagePlus imp, ImageProcessor ip) { int bitDepth = imp.getBitDepth(); int w2=ip.getWidth(), h2=ip.getHeight(), d2=outputSlices; int flags = NewImage.FILL_BLACK + NewImage.CHECK_AVAILABLE_MEMORY; ImagePlus imp2 = NewImage.createImage("temp", w2, h2, d2, bitDepth, flags); if (imp2!=null && imp2.getStackSize()==d2) IJ.showStatus("Reslice... (press 'Esc' to abort)"); if (imp2==null) return null; else { ImageStack stack2 = imp2.getStack(); stack2.setColorModel(ip.getColorModel()); return stack2; } }
ImageStack createOutputStack(ImagePlus imp, ImageProcessor ip) { int bitDepth = imp.getBitDepth(); int w2=ip.getWidth(), h2=ip.getHeight(), d2=outputSlices; int flags = NewImage.FILL_BLACK + NewImage.CHECK_AVAILABLE_MEMORY; ImagePlus imp2 = NewImage.createImage("temp", w2, h2, d2, bitDepth, flags); if (imp2!=null && imp2.getStackSize()==d2) IJ.showStatus("Reslice... (press 'Esc' to abort)"); if (imp2==null) return null; else { ImageStack stack2 = imp2.getStack(); stack2.setColorModel(ip.getColorModel()); return stack2; } }
private static void setPhysicsLUT(ImagePlus ip) { byte[] rLUT = new byte[256]; byte[] gLUT = new byte[256]; byte[] bLUT = new byte[256]; int max = 100; for(int i = 0; i <= max; i++) { double rad = i * Math.PI / (max / 2); rLUT[i]=physicsLUTHelper(rad + Math.PI); gLUT[i]=physicsLUTHelper(rad - Math.PI / 2); bLUT[i]=physicsLUTHelper(rad); } ColorModel c = new IndexColorModel(8, 256, rLUT, gLUT, bLUT); ip.getProcessor().setColorModel(c); if (ip.getStackSize() > 1) ip.getStack().setColorModel(c); }
ImageStack getRGBStack(ImagePlus imp) { ImageProcessor ip = imp.getProcessor(); int w = ip.getWidth(); int h = ip.getHeight(); int size = w*h; byte[] r = new byte[size]; byte[] g = new byte[size]; byte[] b = new byte[size]; ((ColorProcessor)ip).getRGB(r, g, b); ImageStack stack = new ImageStack(w, h); stack.addSlice("Red", r); stack.addSlice("Green", g); stack.addSlice("Blue", b); stack.setColorModel(ip.getDefaultColorModel()); return stack; }
static void transfer(final ImagePlus src, final ImagePlus dst) { // Calibration: dst.setCalibration(src.getCalibration()); // Color model: final ColorModel cm = src.getProcessor().getColorModel(); dst.getProcessor().setColorModel(cm); dst.getStack().setColorModel(cm); // Min and max displaying: dst.setDisplayRange(src.getDisplayRangeMin(),src.getDisplayRangeMax()); }
ImageStack getRGBStack(ImagePlus imp) { ImageProcessor ip = imp.getProcessor(); int w = ip.getWidth(); int h = ip.getHeight(); int size = w*h; byte[] r = new byte[size]; byte[] g = new byte[size]; byte[] b = new byte[size]; ((ColorProcessor)ip).getRGB(r, g, b); ImageStack stack = new ImageStack(w, h); stack.addSlice("Red", r); stack.addSlice("Green", g); stack.addSlice("Blue", b); stack.setColorModel(ip.getDefaultColorModel()); return stack; }
public void setParameters(ImagePlus ip, boolean setCalib) { ip.setProperty("Info", toString()); if (setCalib) setCalibration(ip); ColorModel c = getColorModel(); if (c == null) { byte[] rLUT = new byte[256]; byte[] gLUT = new byte[256]; byte[] bLUT = new byte[256]; for(int i=0; i<256; i++) { rLUT[i]=(byte)i; gLUT[i]=(byte)i; bLUT[i]=(byte)i; } c = new IndexColorModel(8, 256, rLUT, gLUT, bLUT); } ip.getProcessor().setColorModel(c); if (ip.getStackSize() > 1) ip.getStack().setColorModel(c); }
void invertLut() { ImagePlus imp = WindowManager.getCurrentImage(); if (imp==null) {IJ.noImage(); return;} if (imp.getType()==ImagePlus.COLOR_RGB) {IJ.error("RGB images do not use LUTs"); return;} if (imp.isComposite()) { CompositeImage ci = (CompositeImage)imp; LUT lut = ci.getChannelLut(); if (lut!=null) ci.setChannelLut(lut.createInvertedLut()); } else { ImageProcessor ip = imp.getProcessor(); ip.invertLut(); if (imp.getStackSize()>1) imp.getStack().setColorModel(ip.getColorModel()); } imp.updateAndRepaintWindow(); }
void invertLut() { ImagePlus imp = WindowManager.getCurrentImage(); if (imp==null) {IJ.noImage(); return;} if (imp.getType()==ImagePlus.COLOR_RGB) {IJ.error("RGB images do not use LUTs"); return;} if (imp.isComposite()) { CompositeImage ci = (CompositeImage)imp; LUT lut = ci.getChannelLut(); if (lut!=null) ci.setChannelLut(lut.createInvertedLut()); } else { ImageProcessor ip = imp.getProcessor(); ip.invertLut(); if (imp.getStackSize()>1) imp.getStack().setColorModel(ip.getColorModel()); } imp.updateAndRepaintWindow(); }