void openRGB48(ImagePlus imp) { isRGB48 = false; int stackSize = imp.getStackSize(); imp.setDimensions(3, stackSize/3, 1); imp = new CompositeImage(imp, IJ.COMPOSITE); imp.show(); }
public static final void userCheckImpDimensions( final ImagePlus imp ) { final int[] dims = imp.getDimensions(); if ( dims[ 4 ] == 1 && dims[ 3 ] > 1 ) { switch ( JOptionPane.showConfirmDialog( null, "It appears this image has 1 timepoint but " + dims[ 3 ] + " slices.\n" + "Do you want to swap Z and T?", "Z/T swapped?", JOptionPane.YES_NO_CANCEL_OPTION ) ) { case JOptionPane.YES_OPTION: imp.setDimensions( dims[ 2 ], dims[ 4 ], dims[ 3 ] ); final Calibration calibration = imp.getCalibration(); calibration.frameInterval = 1; calibration.setTimeUnit( "frame" ); break; case JOptionPane.CANCEL_OPTION: return; } } }
void openRGB48(ImagePlus imp) { isRGB48 = false; int stackSize = imp.getStackSize(); imp.setDimensions(3, stackSize/3, 1); imp = new CompositeImage(imp, IJ.COMPOSITE); imp.show(); }
public static final void userCheckImpDimensions( final ImagePlus imp ) { final int[] dims = imp.getDimensions(); if ( dims[ 4 ] == 1 && dims[ 3 ] > 1 ) { switch ( JOptionPane.showConfirmDialog( null, "It appears this image has 1 timepoint but " + dims[ 3 ] + " slices.\n" + "Do you want to swap Z and T?", "Z/T swapped?", JOptionPane.YES_NO_CANCEL_OPTION ) ) { case JOptionPane.YES_OPTION: imp.setDimensions( dims[ 2 ], dims[ 4 ], dims[ 3 ] ); final Calibration calibration = imp.getCalibration(); calibration.frameInterval = 1; calibration.setTimeUnit( "frame" ); break; case JOptionPane.CANCEL_OPTION: return; } } }
/** 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; }
void setDimensions(ImagePlus img) { int c = (int)getFirstArg(); int z = (int)getNextArg(); int t = (int)getLastArg(); img.setDimensions(c, z, t); if (img.getWindow()==null) img.setOpenAsHyperStack(true); }
void setDimensions(ImagePlus img) { int c = (int)getFirstArg(); int z = (int)getNextArg(); int t = (int)getLastArg(); img.setDimensions(c, z, t); if (img.getWindow()==null) img.setOpenAsHyperStack(true); }
/** Converts an RGB image to a HSB (hue, saturation and brightness) stack. */ public void convertToHSB() { if (type!=ImagePlus.COLOR_RGB) throw new IllegalArgumentException("Image must be RGB");; ColorProcessor cp; if (imp.getType()==ImagePlus.COLOR_RGB) cp = (ColorProcessor)imp.getProcessor(); else cp = new ColorProcessor(imp.getImage()); ImageStack stack = cp.getHSBStack(); imp.trimProcessor(); imp.setStack(null, stack); imp.setDimensions(3, 1, 1); }
/** Converts an RGB image to a HSB (hue, saturation and brightness) stack. */ public void convertToHSB() { if (type!=ImagePlus.COLOR_RGB) throw new IllegalArgumentException("Image must be RGB");; ColorProcessor cp; if (imp.getType()==ImagePlus.COLOR_RGB) cp = (ColorProcessor)imp.getProcessor(); else cp = new ColorProcessor(imp.getImage()); ImageStack stack = cp.getHSBStack(); imp.trimProcessor(); imp.setStack(null, stack); imp.setDimensions(3, 1, 1); }
public ImagePlus imageplus() { final ImageStack imagestack = new ImageStack(dims.x,dims.y); for (int t=0; t<dims.t; ++t) for (int z=0; z<dims.z; ++z) for (int c=0; c<dims.c; ++c) imagestack.addSlice("",elements[c][t][z]); final Calibration cal = new Calibration(); cal.pixelWidth = aspects.x; cal.pixelHeight = aspects.y; cal.pixelDepth = aspects.z; cal.frameInterval = aspects.t; ImagePlus imageplus = new ImagePlus(name,imagestack); imageplus.setDimensions(dims.c,dims.z,dims.t); imageplus.setCalibration(cal); return imageplus; }
public ImagePlus imageplus() { final ImageStack imagestack = new ImageStack(dims.x,dims.y); for (int t=0; t<dims.t; ++t) for (int z=0; z<dims.z; ++z) for (int c=0; c<dims.c; ++c) imagestack.addSlice("",elements[c][t][z]); final Calibration cal = new Calibration(); cal.pixelWidth = aspects.x; cal.pixelHeight = aspects.y; cal.pixelDepth = aspects.z; cal.frameInterval = aspects.t; ImagePlus imageplus = new ImagePlus(name,imagestack); imageplus.setDimensions(dims.c,dims.z,dims.t); imageplus.setCalibration(cal); return imageplus; }
public static void show( final RandomAccessibleInterval< FloatType > img, final String title ) { ImagePlus imp = ImageJFunctions.wrapFloat( img, title ); imp.setDimensions( 1, imp.getStackSize(), 1 ); imp.setSlice( imp.getStackSize() / 2 ); imp.resetDisplayRange(); imp.show(); }
public static final ImagePlus makeEmptyImagePlus(final int width, final int height, final int nslices, final int nframes, final double[] calibration) { final RandomAccessible< UnsignedByteType > randomAccessible = Views.extendBorder( ArrayImgs.unsignedBytes( new long[] { 1, 1, 1, 1 } ) ); final Interval interval = new FinalInterval( width, height, nslices, nframes ); final RandomAccessibleInterval< UnsignedByteType > view = Views.interval( randomAccessible, interval ); final ImagePlus imp = ImageJFunctions.wrap(view, "blank"); imp.getCalibration().pixelWidth = calibration[0]; imp.getCalibration().pixelHeight = calibration[1]; imp.getCalibration().pixelDepth = calibration[2]; imp.setDimensions(1, nslices, nframes); imp.setOpenAsHyperStack(true); return imp; }
public static void save( final Img< FloatType > img, final String file ) { final ImagePlus imp = ImageJFunctions.wrap( img, "" ).duplicate(); final FileSaver s = new FileSaver( imp ); if ( img.numDimensions() == 3 ) { imp.setDimensions( 1, (int)img.dimension( 2 ), 1 ); s.saveAsTiffStack( file ); } else { s.saveAsTiff( file ); } imp.close(); }
public static final ImagePlus makeEmptyImagePlus(final int width, final int height, final int nslices, final int nframes, final double[] calibration) { final RandomAccessible< UnsignedByteType > randomAccessible = Views.extendBorder( ArrayImgs.unsignedBytes( new long[] { 1, 1, 1, 1 } ) ); final Interval interval = new FinalInterval( width, height, nslices, nframes ); final RandomAccessibleInterval< UnsignedByteType > view = Views.interval( randomAccessible, interval ); final ImagePlus imp = ImageJFunctions.wrap(view, "blank"); imp.getCalibration().pixelWidth = calibration[0]; imp.getCalibration().pixelHeight = calibration[1]; imp.getCalibration().pixelDepth = calibration[2]; imp.setDimensions(1, nslices, nframes); imp.setOpenAsHyperStack(true); return imp; }
/** This method has been replaced by IJ.createHyperStack(). */ public ImagePlus createHyperStack(String title, int channels, int slices, int frames, int bitDepth) { int size = channels*slices*frames; ImageStack stack2 = new ImageStack(width, height, size); // create empty stack ImageProcessor ip2 = null; switch (bitDepth) { case 8: ip2 = new ByteProcessor(width, height); break; case 16: ip2 = new ShortProcessor(width, height); break; case 24: ip2 = new ColorProcessor(width, height); break; case 32: ip2 = new FloatProcessor(width, height); break; default: throw new IllegalArgumentException("Invalid bit depth"); } stack2.setPixels(ip2.getPixels(), 1); // can't create ImagePlus will null 1st image ImagePlus imp2 = new ImagePlus(title, stack2); stack2.setPixels(null, 1); imp2.setDimensions(channels, slices, frames); imp2.setCalibration(getCalibration()); imp2.setOpenAsHyperStack(true); return imp2; }
private void showOutput() { if (interrupted) return; if (outStack!=null) { outImp = new ImagePlus(TITLE_PREFIX[processType]+imp.getShortTitle(), outStack); int[] d = imp.getDimensions(); outImp.setDimensions(d[2], d[3], d[4]); for (int i=1; i<=imp.getStackSize(); i++) outStack.setSliceLabel(imp.getStack().getSliceLabel(i), i); } if (outImageType != BYTE_OVERWRITE) { ImageProcessor ip = outImp.getProcessor(); if (!Prefs.blackBackground) ip.invertLut(); ip.resetMinAndMax(); outImp.show(); } }
private void showOutput() { if (interrupted) return; if (outStack!=null) { outImp = new ImagePlus(TITLE_PREFIX[processType]+imp.getShortTitle(), outStack); int[] d = imp.getDimensions(); outImp.setDimensions(d[2], d[3], d[4]); for (int i=1; i<=imp.getStackSize(); i++) outStack.setSliceLabel(imp.getStack().getSliceLabel(i), i); } if (outImageType != BYTE_OVERWRITE) { ImageProcessor ip = outImp.getProcessor(); if (!Prefs.blackBackground) ip.invertLut(); ip.resetMinAndMax(); outImp.show(); } }
private void showOutput() { if (interrupted) return; if (outStack!=null) { outImp = new ImagePlus(TITLE_PREFIX[processType]+imp.getShortTitle(), outStack); int[] d = imp.getDimensions(); outImp.setDimensions(d[2], d[3], d[4]); for (int i=1; i<=imp.getStackSize(); i++) outStack.setSliceLabel(imp.getStack().getSliceLabel(i), i); } if (outImageType != BYTE_OVERWRITE) { ImageProcessor ip = outImp.getProcessor(); if (!Prefs.blackBackground) ip.invertLut(); ip.resetMinAndMax(); outImp.show(); } }