Refine search
/** * Gets the number of slices or frames available in the image, * depending on whit is tracked. */ protected int getMaxPosition(ImagePlus img) { if (trackZ) return img.getNSlices(); else return img.getNFrames(); }
public boolean validDimensions() { int c = imp.getNChannels(); int z = imp.getNSlices(); int t = imp.getNFrames(); //IJ.log(c+" "+z+" "+t+" "+nChannels+" "+nSlices+" "+nFrames+" "+imp.getStackSize()); int size = imp.getStackSize(); if (c==size && c*z*t==size && nSlices==size && nChannels*nSlices*nFrames==size) return true; if (c!=nChannels||z!=nSlices||t!=nFrames||c*z*t!=size) return false; else return true; }
public ImageStackImageLoader( final T type, final ImagePlus imp, final Function< Object, A > wrapPixels ) { this.type = type; this.imp = imp; this.wrapPixels = wrapPixels; this.dim = new long[] { imp.getWidth(), imp.getHeight(), imp.getNSlices() }; final int numSetups = imp.getNChannels(); setupImgLoaders = new ArrayList<>(); for ( int setupId = 0; setupId < numSetups; ++setupId ) setupImgLoaders.add( new SetupImgLoader( setupId ) ); }
public boolean validDimensions() { int c = imp.getNChannels(); int z = imp.getNSlices(); int t = imp.getNFrames(); //IJ.log(c+" "+z+" "+t+" "+nChannels+" "+nSlices+" "+nFrames+" "+imp.getStackSize()); int size = imp.getStackSize(); if (c==size && c*z*t==size && nSlices==size && nChannels*nSlices*nFrames==size) return true; if (c!=nChannels||z!=nSlices||t!=nFrames||c*z*t!=size) return false; else return true; }
public static String testRegistrationCompatibility( final ImagePlus imp1, final ImagePlus imp2 ) { // test time points final int numFrames1 = imp1.getNFrames(); final int numFrames2 = imp2.getNFrames(); if ( numFrames1 != numFrames2 ) return "Images have a different number of time points, cannot proceed..."; // test if both have 2d or 3d image contents final int numSlices1 = imp1.getNSlices(); final int numSlices2 = imp2.getNSlices(); if ( numSlices1 == 1 && numSlices2 != 1 || numSlices1 != 1 && numSlices2 == 1 ) return "One image is 2d and the other one is 3d, cannot proceed..."; return null; } }
/** set an ImagePlus' position relative to ZCT ordering (rather than default CZT) */ private void setZctPosition(ImagePlus imp, int z, int c, int t) { // zct order int sliceNumber = z + (c*imp.getNSlices()) + (t*imp.getNSlices()*imp.getNChannels()); imp.setSlice(sliceNumber+1); }
private HyperStackIterator(final ImagePlus image) { this.image = image; nChannels = image.getNChannels(); nSlices = image.getNSlices(); nFrames = image.getNFrames(); System.out.println("nFrames = " + nFrames); w = image.getWidth(); h = image.getHeight(); }
public static String testRegistrationCompatibility( final ImagePlus imp1, final ImagePlus imp2 ) { // test time points final int numFrames1 = imp1.getNFrames(); final int numFrames2 = imp2.getNFrames(); if ( numFrames1 != numFrames2 ) return "Images have a different number of time points, cannot proceed..."; // test if both have 2d or 3d image contents final int numSlices1 = imp1.getNSlices(); final int numSlices2 = imp2.getNSlices(); if ( numSlices1 == 1 && numSlices2 != 1 || numSlices1 != 1 && numSlices2 == 1 ) return "One image is 2d and the other one is 3d, cannot proceed..."; return null; }
/** set an ImagePlus' position relative to CZT ordering (matches imp.setPosition()) */ private void setCztPosition(ImagePlus imp, int z, int c, int t) { // czt order : should match the .setPosition(c,z,t) code int sliceNumber = c + (z*imp.getNChannels()) + (t*imp.getNSlices()*imp.getNChannels()); imp.setSlice(sliceNumber+1); }
private void setDefaultBounds() { int stackSize = imp.getStackSize(); int channels = imp.getNChannels(); int frames = imp.getNFrames(); int slices = imp.getNSlices(); isHyperstack = imp.isHyperStack()||( ij.macro.Interpreter.isBatchMode()&&((frames>1&&frames<stackSize)||(slices>1&&slices<stackSize))); simpleComposite = channels==stackSize; if (simpleComposite) isHyperstack = false; startSlice = 1; if (isHyperstack) { int nSlices = imp.getNSlices(); if (nSlices>1) stopSlice = nSlices; else stopSlice = imp.getNFrames(); } else stopSlice = stackSize; }
int updateIndex(int n) { if (imp.getNFrames()>1) return (int)(n*((double)(imp.getNFrames())/imp.getStackSize())); else if (imp.getNSlices()>1) return (int)(n*((double)(imp.getNSlices())/imp.getStackSize())); else return n; }
protected VirtualStackImageLoader( final ImagePlus imp, final CacheArrayLoader< A > loader, final T type, final V volatileType ) { this.loader = loader; dimensions = new long[] { imp.getWidth(), imp.getHeight(), imp.getNSlices() }; cellDimensions = new int[] { imp.getWidth(), imp.getHeight(), 1 }; final int numSetups = imp.getNChannels(); cache = new VolatileGlobalCellCache( 1, 1 ); setupImgLoaders = new ArrayList<>(); for ( int setupId = 0; setupId < numSetups; ++setupId ) setupImgLoaders.add( new SetupImgLoader( setupId, type, volatileType ) ); }
private void setDefaultBounds() { int stackSize = imp.getStackSize(); int channels = imp.getNChannels(); int frames = imp.getNFrames(); int slices = imp.getNSlices(); isHyperstack = imp.isHyperStack()||( ij.macro.Interpreter.isBatchMode()&&((frames>1&&frames<stackSize)||(slices>1&&slices<stackSize))); simpleComposite = channels==stackSize; if (simpleComposite) isHyperstack = false; startSlice = 1; if (isHyperstack) { int nSlices = imp.getNSlices(); if (nSlices>1) stopSlice = nSlices; else stopSlice = imp.getNFrames(); } else stopSlice = stackSize; }
int updateIndex(int n) { if (imp.getNFrames()>1) return (int)(n*((double)(imp.getNFrames())/imp.getStackSize())); else if (imp.getNSlices()>1) return (int)(n*((double)(imp.getNSlices())/imp.getStackSize())); else return n; }
public String toString() { return "img[\""+getTitle()+"\" ("+getID()+"), "+getBitDepth()+"-bit, "+width+"x"+height+"x"+getNChannels()+"x"+getNSlices()+"x"+getNFrames()+"]"; }
/** * Checks if image to be analyzed is valid. * * @param imp * the image being analyzed * @return true, if valid (8/16 bit, 2D/3D, single or multi-channel) */ public boolean validateImage(final ImagePlus imp) { return (imp != null && imp.getBitDepth() < 24 && imp.getNDimensions() <= 4 && !(imp.getNSlices() > 1 && imp.getNFrames() > 1)); }
public String toString() { return "img[\""+getTitle()+"\" ("+getID()+"), "+getBitDepth()+"-bit, "+width+"x"+height+"x"+getNChannels()+"x"+getNSlices()+"x"+getNFrames()+"]"; }
public static float[] computeMinMax( final ImagePlus imp, final int channel ) { final int size = imp.getWidth() * imp.getHeight(); float min = Float.MAX_VALUE; float max = -Float.MAX_VALUE; IJ.log( "Computing min/max over " + imp.getNSlices() + " slices and " + imp.getNFrames() + " frames for channel " + channel ); for ( int z = 0; z < imp.getNSlices(); ++z ) for ( int t = 0; t < imp.getNFrames(); ++t ) { final ImageProcessor ip = imp.getStack().getProcessor( imp.getStackIndex( channel, z + 1, t + 1 ) ); for ( int i = 0; i < size; ++i ) { final float f = ip.getf( i ); min = Math.min( min, f ); max = Math.max( max, f ); } } return new float[]{ min, max }; }
public static ImagePlus makeSubhyperstack(ImagePlus input, String cString, String zString, String tString) { ArrayList<Integer> cList = parseList(cString, input.getNChannels()); ArrayList<Integer> zList = parseList(zString, input.getNSlices()); ArrayList<Integer> tList = parseList(tString, input.getNFrames()); return makeSubhyperstack(input, cList, zList, tList); }
/** Builds dialog to query users for projection parameters. @param start starting slice to display @param stop last slice */ protected GenericDialog buildControlDialog(int start, int stop) { GenericDialog gd = new GenericDialog("ZProjection"); gd.addNumericField("Start slice:",startSlice,0/*digits*/); gd.addNumericField("Stop slice:",stopSlice,0/*digits*/); gd.addChoice("Projection type", METHODS, METHODS[method]); if (isHyperstack && imp.getNFrames()>1&& imp.getNSlices()>1) gd.addCheckbox("All time frames", allTimeFrames); return gd; }