/** Opens a new image. <code>Type</code> should contain "8-bit", "16-bit", "32-bit" or "RGB". In addition, it can contain "white", "black" or "ramp". <code>Width</code> and <code>height</code> specify the width and height of the image in pixels. <code>Depth</code> specifies the number of stack slices. */ public static void newImage(String title, String type, int width, int height, int depth) { ImagePlus imp = createImage(title, type, width, height, depth); if (imp!=null) { macroRunning = true; imp.show(); macroRunning = false; } }
/** Opens a new image. <code>Type</code> should contain "8-bit", "16-bit", "32-bit" or "RGB". In addition, it can contain "white", "black" or "ramp". <code>Width</code> and <code>height</code> specify the width and height of the image in pixels. <code>Depth</code> specifies the number of stack slices. */ public static void newImage(String title, String type, int width, int height, int depth) { ImagePlus imp = createImage(title, type, width, height, depth); if (imp!=null) { macroRunning = true; imp.show(); macroRunning = false; } }
/** Creates a new ImageStack. * @param width width in pixels * @param height height in pixels * @param depth number of images * @param bitdepth 8, 16, 32 (float) or 24 (RGB) */ public static ImageStack create(int width, int height, int depth, int bitdepth) { ImageStack stack = IJ.createImage("", width, height, depth, bitdepth).getStack(); if (bitdepth==16 || bitdepth==32) { stack.min = Double.MAX_VALUE; stack.max = 0.0; } return stack; }
/** Creates a new ImageStack. * @param width width in pixels * @param height height in pixels * @param depth number of images * @param bitdepth 8, 16, 32 (float) or 24 (RGB) */ public static ImageStack create(int width, int height, int depth, int bitdepth) { ImageStack stack = IJ.createImage("", width, height, depth, bitdepth).getStack(); if (bitdepth==16 || bitdepth==32) { stack.min = Double.MAX_VALUE; stack.max = 0.0; } return stack; }
/** Creates a new hyperstack. * @param title image name * @param type "8-bit", "16-bit", "32-bit" or "RGB". May also * contain "white" , "black" (the default), "ramp", "composite-mode", * "color-mode", "grayscale-mode or "label". * @param width image width in pixels * @param height image height in pixels * @param channels number of channels * @param slices number of slices * @param frames number of frames */ public static ImagePlus createImage(String title, String type, int width, int height, int channels, int slices, int frames) { if (type.contains("label")) type += "ramp"; if (!(type.contains("white")||type.contains("ramp"))) type += "black"; ImagePlus imp = IJ.createImage(title, type, width, height, channels*slices*frames); imp.setDimensions(channels, slices, frames); int mode = IJ.COLOR; if (type.contains("composite")) mode = IJ.COMPOSITE; if (type.contains("grayscale")) mode = IJ.GRAYSCALE; if (channels>1 && imp.getBitDepth()!=24) imp = new CompositeImage(imp, mode); imp.setOpenAsHyperStack(true); if (type.contains("label")) HyperStackMaker.labelHyperstack(imp); return imp; }
/** Creates a new hyperstack. * @param title image name * @param width image width in pixels * @param height image height in pixels * @param channels number of channels * @param slices number of slices * @param frames number of frames * @param bitdepth 8, 16, 32 (float) or 24 (RGB) */ public static ImagePlus createHyperStack(String title, int width, int height, int channels, int slices, int frames, int bitdepth) { ImagePlus imp = createImage(title, width, height, channels*slices*frames, bitdepth); imp.setDimensions(channels, slices, frames); if (channels>1 && bitdepth!=24) imp = new CompositeImage(imp, IJ.COMPOSITE); imp.setOpenAsHyperStack(true); return imp; }
/** Creates a new hyperstack. * @param title image name * @param width image width in pixels * @param height image height in pixels * @param channels number of channels * @param slices number of slices * @param frames number of frames * @param bitdepth 8, 16, 32 (float) or 24 (RGB) */ public static ImagePlus createHyperStack(String title, int width, int height, int channels, int slices, int frames, int bitdepth) { ImagePlus imp = createImage(title, width, height, channels*slices*frames, bitdepth); imp.setDimensions(channels, slices, frames); if (channels>1 && bitdepth!=24) imp = new CompositeImage(imp, IJ.COMPOSITE); imp.setOpenAsHyperStack(true); return imp; }
private static ImagePlus createMaskImage(final VoltexVolume image) { final ImagePlus maskI = IJ.createImage("Mask", "8-bit white", image.xDim, image.yDim, image.zDim); maskI.setCalibration(image.getImagePlus().getCalibration().copy()); return maskI; }
public static ImagePlus FloatArrayToImagePlus(FloatArray2D image, String name, float min, float max) { ImagePlus imp = IJ.createImage(name,"32-Bit Black", image.width, image.height, 1); FloatProcessor ip = (FloatProcessor)imp.getProcessor(); FloatArrayToFloatProcessor(ip, image); if (min == max) ip.resetMinAndMax(); else ip.setMinAndMax(min, max); imp.updateAndDraw(); return imp; }
final static public ImagePlus FloatArrayToImagePlus( final FloatArray2D image, final String name, final float min, final float max ) { final ImagePlus imp = IJ.createImage( name, "32-Bit Black", image.width, image.height, 1 ); final FloatProcessor ip = ( FloatProcessor )imp.getProcessor(); floatArray2DToFloatProcessor( image, ip ); if ( min == max ) ip.resetMinAndMax(); else ip.setMinAndMax( min, max ); imp.updateAndDraw(); return imp; }
final static public ImagePlus FloatArrayToImagePlus( final FloatArray2D image, final String name, final float min, final float max ) { final ImagePlus imp = IJ.createImage( name, "32-Bit Black", image.width, image.height, 1 ); final FloatProcessor ip = ( FloatProcessor )imp.getProcessor(); floatArray2DToFloatProcessor( image, ip ); if ( min == max ) ip.resetMinAndMax(); else ip.setMinAndMax( min, max ); imp.updateAndDraw(); return imp; }
/** * This method converts my FloatArray2D to an ImageJ ImagePlus * * @param image The image as FloatArray2D * @param name The name of the ImagePlus * @param min Lowest brightness value that will be displayed (see Brightness&Contrast in Imagej) * @param max Highest brightness value that will be displayed (set both to zero for automatic) * @return ImagePlus The ImageJ image */ public static ImagePlus FloatArrayToImagePlus(FloatArray2D image, String name, float min, float max) { ImagePlus imp = IJ.createImage(name,"32-Bit Black", image.width, image.height, 1); FloatProcessor ip = (FloatProcessor)imp.getProcessor(); FloatArrayToFloatProcessor(ip, image); if (min == max) ip.resetMinAndMax(); else ip.setMinAndMax(min, max); imp.updateAndDraw(); return imp; }
/** * This method converts my FloatArray2D to an ImageJ ImagePlus * * @param image The image as FloatArray2D * @param name The name of the ImagePlus * @param min Lowest brightness value that will be displayed (see Brightness&Contrast in Imagej) * @param max Highest brightness value that will be displayed (set both to zero for automatic) * @return ImagePlus The ImageJ image * * @author Stephan Preibisch */ private ImagePlus FloatArrayToImagePlus(FloatArray2D image, String name, float min, float max) { ImagePlus imp = IJ.createImage(name, "32-Bit Black", image.width, image.height, 1); FloatProcessor ip = (FloatProcessor) imp.getProcessor(); FloatArrayToFloatProcessor(ip, image); if (min == max) ip.resetMinAndMax(); else ip.setMinAndMax(min, max); imp.updateAndDraw(); return imp; }
private ImagePlus FloatArrayToImagePlus(FloatArray2D image, String name, float min, float max) { int width = image.width; int height = image.height; ImagePlus impResult = IJ.createImage(name, "32-Bit Black", width, height, 1); ImageProcessor ipResult = impResult.getProcessor(); float[] sliceImg = new float[width * height]; for (int x = 0; x < width; x++) for (int y = 0; y < height; y++) sliceImg[y * width + x] = image.get(x, y); ipResult.setPixels(sliceImg); if (min == max) ipResult.resetMinAndMax(); else ipResult.setMinAndMax(min, max); impResult.updateAndDraw(); return impResult; } }
public static ImagePlus DoubleArrayToStack(double[] image, int width, int height, int nstacks, String name, float min, float max) { ImageStack stack = new ImageStack(width, height); for (int slice = 0; slice < nstacks; slice++) { ImagePlus impResult = IJ.createImage("Result", "32-Bit Black", width, height, 1); ImageProcessor ipResult = impResult.getProcessor(); float[] sliceImg = new float[width * height]; for (int x = 0; x < width; x++) for (int y = 0; y < height; y++) sliceImg[y * width + x] = (float)image[x + width * (y + slice * height)]; ipResult.setPixels(sliceImg); if (min == max) ipResult.resetMinAndMax(); else ipResult.setMinAndMax(min, max); stack.addSlice("Slice " + slice, ipResult); } return new ImagePlus(name, stack); }
public static ImagePlus FloatArrayToStack(FloatArray3D image, String name, float min, float max) { int width = image.width; int height = image.height; int nstacks = image.depth; ImageStack stack = new ImageStack(width, height); for (int slice = 0; slice < nstacks; slice++) { ImagePlus impResult = IJ.createImage("Result", "32-Bit Black", width, height, 1); ImageProcessor ipResult = impResult.getProcessor(); float[] sliceImg = new float[width * height]; for (int x = 0; x < width; x++) for (int y = 0; y < height; y++) sliceImg[y * width + x] = image.get(x,y,slice); ipResult.setPixels(sliceImg); if (min == max) ipResult.resetMinAndMax(); else ipResult.setMinAndMax(min, max); stack.addSlice("Slice " + slice, ipResult); } return new ImagePlus(name, stack); }
private ImagePlus FloatArrayToStack(FloatArray3D image, String name, float min, float max) { int width = image.width; int height = image.height; int nstacks = image.depth; ImageStack stack = new ImageStack(width, height); for (int slice = 0; slice < nstacks; slice++) { ImagePlus impResult = IJ.createImage("Result", "32-Bit Black", width, height, 1); ImageProcessor ipResult = impResult.getProcessor(); float[] sliceImg = new float[width * height]; for (int x = 0; x < width; x++) for (int y = 0; y < height; y++) sliceImg[y * width + x] = image.get(x, y, slice); ipResult.setPixels(sliceImg); if (min == max) ipResult.resetMinAndMax(); else ipResult.setMinAndMax(min, max); stack.addSlice("Slice " + slice, ipResult); } return new ImagePlus(name, stack); } }
private ImagePlus resizeZ(ImagePlus imp, int newDepth, int interpolationMethod) { ImageStack stack1 = imp.getStack(); int width = stack1.getWidth(); int height = stack1.getHeight(); int depth = stack1.getSize(); int bitDepth = imp.getBitDepth(); ImagePlus imp2 = IJ.createImage(imp.getTitle(), bitDepth+"-bit", width, height, newDepth); if (imp2==null) return null; ImageStack stack2 = imp2.getStack(); ImageProcessor ip = imp.getProcessor(); ImageProcessor xzPlane1 = ip.createProcessor(width, depth); xzPlane1.setInterpolationMethod(interpolationMethod); ImageProcessor xzPlane2; Object xzpixels1 = xzPlane1.getPixels(); IJ.showStatus("Z Scaling..."); for (int y=0; y<height; y++) { IJ.showProgress(y, height-1); for (int z=0; z<depth; z++) { // get xz plane at y Object pixels1 = stack1.getPixels(z+1); System.arraycopy(pixels1, y*width, xzpixels1, z*width, width); } xzPlane2 = xzPlane1.resize(width, newDepth, averageWhenDownsizing); Object xypixels2 = xzPlane2.getPixels(); for (int z=0; z<newDepth; z++) { Object pixels2 = stack2.getPixels(z+1); System.arraycopy(xypixels2, z*width, pixels2, y*width, width); } } return imp2; }
void newImage() { String title = getFirstString(); String type = getNextString(); int width = (int)getNextArg(); int height = (int)getNextArg(); int depth = (int)getNextArg(); int c=-1, z=-1, t=-1; if (interp.nextToken()==')') interp.getRightParen(); else { c = depth; z = (int)getNextArg(); t = (int)getLastArg(); } if (width<1 || height<1) interp.error("Width or height < 1"); if (c<0) IJ.newImage(title, type, width, height, depth); else { ImagePlus imp = IJ.createImage(title, type, width, height, c, z, t); imp.show(); } resetImage(); }
void newImage() { String title = getFirstString(); String type = getNextString(); int width = (int)getNextArg(); int height = (int)getNextArg(); int depth = (int)getNextArg(); int c=-1, z=-1, t=-1; if (interp.nextToken()==')') interp.getRightParen(); else { c = depth; z = (int)getNextArg(); t = (int)getLastArg(); } if (width<1 || height<1) interp.error("Width or height < 1"); if (c<0) IJ.newImage(title, type, width, height, depth); else { ImagePlus imp = IJ.createImage(title, type, width, height, c, z, t); imp.show(); } resetImage(); }