/** 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); }
static void setMetadata( Dataset ds, ImagePlus imp ) { imp.setOpenAsHyperStack(imp.getNDimensions() > 3); final FileInfo fileInfo = getFileInfo( ds, imp ); imp.setFileInfo(fileInfo); setSliceLabels( imp, fileInfo ); fillInfo(imp, ds.getImgPlus()); }
public FloatImagePlus( final long[] dim, final int entitiesPerPixel ) { super( dim, entitiesPerPixel ); if ( entitiesPerPixel == 1 ) { final ImageStack stack = new ImageStack( width, height ); for ( int i = 0; i < numSlices; ++i ) stack.addSlice( "", new FloatProcessor( width, height ) ); imp = new ImagePlus( "image", stack ); imp.setDimensions( channels, depth, frames ); if ( numSlices > 1 ) imp.setOpenAsHyperStack( true ); mirror.clear(); for ( int t = 0; t < frames; ++t ) for ( int z = 0; z < depth; ++z ) for ( int c = 0; c < channels; ++c ) mirror.add( new FloatArray( ( float[] )imp.getStack().getProcessor( imp.getStackIndex( c + 1, z + 1 , t + 1 ) ).getPixels() ) ); } else { imp = null; mirror.clear(); for ( int i = 0; i < numSlices; ++i ) mirror.add( new FloatArray( width * height * entitiesPerPixel ) ); } }
public ByteImagePlus( final long[] dim, final int entitiesPerPixel ) { super( dim, entitiesPerPixel ); if ( entitiesPerPixel == 1 ) { final ImageStack stack = new ImageStack( width, height ); for ( int i = 0; i < numSlices; ++i ) stack.addSlice( "", new ByteProcessor( width, height ) ); imp = new ImagePlus( "image", stack ); imp.setDimensions( channels, depth, frames ); if ( numSlices > 1 ) imp.setOpenAsHyperStack( true ); mirror.clear(); for ( int t = 0; t < frames; ++t ) for ( int z = 0; z < depth; ++z ) for ( int c = 0; c < channels; ++c ) mirror.add( new ByteArray( ( byte[] )imp.getStack().getProcessor( imp.getStackIndex( c + 1, z + 1 , t + 1 ) ).getPixels() ) ); } else { imp = null; mirror.clear(); for ( int i = 0; i < numSlices; ++i ) mirror.add( new ByteArray( width * height * entitiesPerPixel ) ); } }
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 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; }
/** 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; }
@Override public void render() { initialROI = imp.getRoi(); if ( initialROI != null ) { imp.killRoi(); } clear(); imp.setOpenAsHyperStack( true ); if ( !imp.isVisible() ) { imp.show(); } addOverlay( spotOverlay ); addOverlay( trackOverlay ); imp.updateAndDraw(); registerEditTool(); }
@Override public void render() { initialROI = imp.getRoi(); if ( initialROI != null ) { imp.killRoi(); } clear(); imp.setOpenAsHyperStack( true ); if ( !imp.isVisible() ) { imp.show(); } addOverlay( spotOverlay ); addOverlay( trackOverlay ); imp.updateAndDraw(); registerEditTool(); }
/** * Creates a new {@link ImageStack} of data from a {@link ImageDisplay} and * assigns it to given {@link ImagePlus} * * @param display * @param imp */ private void rebuildImagePlusData(final ImageDisplay display, final ImagePlus imp) { final ImagePlus newImp = legacyService.getImageMap().registerDisplay(display); imp.setStack(newImp.getStack()); final int c = newImp.getNChannels(); final int z = newImp.getNSlices(); final int t = newImp.getNFrames(); imp.setDimensions(c, z, t); imp.setOpenAsHyperStack(imp.getNDimensions() > 3); LegacyUtils.deleteImagePlus(newImp); }
/** * This can be used to clone one stack into another. * * @param infileImage * @param target */ private void cloneStack(ImagePlus infileImage, ImagePlus target, boolean hyperStack) { // Now, 'clone' this image plus back to the one implemented // by this plugin. target.setStack(infileImage.getTitle(), infileImage.getStack()); target.setCalibration(infileImage.getCalibration()); Object objInfo = infileImage.getProperty(INFO_PROPERTY); if (objInfo != null) { target.setProperty(INFO_PROPERTY, objInfo); } target.setFileInfo(infileImage.getFileInfo()); if (hyperStack) { target.setDimensions(infileImage.getNChannels(), infileImage.getNSlices(), infileImage.getNFrames()); } target.setOpenAsHyperStack(hyperStack); }
newimp = new CompositeImage(newimp); } else { newimp.setOpenAsHyperStack(true);
void convertHSToStack(ImagePlus imp) { if (!(imp.isHyperStack()||imp.isComposite())) return; ImagePlus imp2 = imp; if (imp.isComposite()) { ImageStack stack = imp.getStack(); imp2 = imp.createImagePlus(); imp2.setStack(imp.getTitle(), stack); int[] dim = imp.getDimensions(); imp2.setDimensions(dim[2], dim[3], dim[4]); ImageProcessor ip2 = imp2.getProcessor(); ip2.setColorModel(ip2.getDefaultColorModel()); } imp2.setOpenAsHyperStack(false); if (imp.getWindow()!=null || imp!=imp2) new StackWindow(imp2); if (imp!=imp2) { imp2.setOverlay(imp.getOverlay()); imp.hide(); } }
private ImagePlus extractChannel(ImagePlus imp, int channel) { int width = imp.getWidth(); int height = imp.getHeight(); int zslices = imp.getNSlices(); int frames = imp.getNFrames(); FileInfo fileInfo = imp.getOriginalFileInfo(); // create empty stack ImageStack stack2 = new ImageStack(width, height); // create new ImagePlus for selected channel ImagePlus imp2 = new ImagePlus(); imp2.setTitle("C" + channel + "-" + imp.getTitle()); // copy slices for (int t = 1; t <= frames; t++) for (int z = 1; z <= zslices; z++) { int slice = imp.getStackIndex(channel, z, t); stack2.addSlice("", imp.getStack().getProcessor(slice)); } imp2.setStack(stack2); imp2.setDimensions(1, zslices, frames); if (zslices*frames > 1) imp2.setOpenAsHyperStack(true); imp2.setFileInfo(fileInfo); return imp2; }
private ImagePlus extractZSlice(ImagePlus imp, int zslice) { int width = imp.getWidth(); int height = imp.getHeight(); int channels = imp.getNChannels(); int frames = imp.getNFrames(); FileInfo fileInfo = imp.getOriginalFileInfo(); // create empty stack ImageStack stack2 = new ImageStack(width, height); // create new ImagePlus for selected frame ImagePlus imp2 = new ImagePlus(); imp2.setTitle("Z" + zslice + "-" + imp.getTitle()); // copy slices for (int f = 1; f <= frames; f++) for (int c = 1; c <= channels; c++) { int slice = imp.getStackIndex(c, zslice, f); stack2.addSlice("", imp.getStack().getProcessor(slice)); } imp2.setStack(stack2); imp2.setDimensions(channels, 1, frames); if (channels*frames > 1) imp2.setOpenAsHyperStack(true); imp2.setFileInfo(fileInfo); return imp2; }
void convertHSToStack(ImagePlus imp) { if (!(imp.isHyperStack()||imp.isComposite())) return; ImagePlus imp2 = imp; if (imp.isComposite()) { ImageStack stack = imp.getStack(); imp2 = imp.createImagePlus(); imp2.setStack(imp.getTitle(), stack); int[] dim = imp.getDimensions(); imp2.setDimensions(dim[2], dim[3], dim[4]); ImageProcessor ip2 = imp2.getProcessor(); ip2.setColorModel(ip2.getDefaultColorModel()); } imp2.setOpenAsHyperStack(false); if (imp.getWindow()!=null || imp!=imp2) new StackWindow(imp2); if (imp!=imp2) { imp2.setOverlay(imp.getOverlay()); imp.hide(); } }