Refine search
protected void setPosition(final int channel, final int frame) { if (channel < 1 || channel > imp.getNChannels() || frame < 1 || frame > imp.getNFrames()) throw new IllegalArgumentException("Specified (channel, slice, frame) position is out of range"); this.channel = channel; // 1-based this.frame = frame; // 1-based properties.setProperty(KEY_CHANNEL_POS, String.valueOf(channel)); properties.setProperty(KEY_FRAME_POS, String.valueOf(frame)); }
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; }
private String centerDescription() { final StringBuilder sb = new StringBuilder(); sb.append("X=").append(ShollUtils.d2s(center.x)); sb.append(" Y=").append(ShollUtils.d2s(center.y)); if (!twoD) sb.append(" Z=").append(ShollUtils.d2s(center.z)); if (imp.getNChannels() > 1) sb.append(" C=").append(posC); if (imp.getNFrames() > 1) sb.append(" T=").append(posT); return sb.toString(); }
/** 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 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(); }
protected SetupImgLoader( final BasicSetupImgLoader< S > loader ) { this.loader = loader; }
/** 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); }
public String toString() { return "img[\""+getTitle()+"\" ("+getID()+"), "+getBitDepth()+"-bit, "+width+"x"+height+"x"+getNChannels()+"x"+getNSlices()+"x"+getNFrames()+"]"; }
private void syncWindows(Object source) { if (SyncWindows.getInstance()==null) return; if (source==cSelector) SyncWindows.setC(this, cSelector.getValue()); else if (source==zSelector) { int stackSize = imp.getStackSize(); if (imp.getNChannels()==stackSize) SyncWindows.setC(this, zSelector.getValue()); else if (imp.getNFrames()==stackSize) SyncWindows.setT(this, zSelector.getValue()); else SyncWindows.setZ(this, zSelector.getValue()); } else if (source==tSelector) SyncWindows.setT(this, tSelector.getValue()); else throw new RuntimeException("Unknownsource:"+source); }
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; }
private void syncWindows(Object source) { if (SyncWindows.getInstance()==null) return; if (source==cSelector) SyncWindows.setC(this, cSelector.getValue()); else if (source==zSelector) { int stackSize = imp.getStackSize(); if (imp.getNChannels()==stackSize) SyncWindows.setC(this, zSelector.getValue()); else if (imp.getNFrames()==stackSize) SyncWindows.setT(this, zSelector.getValue()); else SyncWindows.setZ(this, zSelector.getValue()); } else if (source==tSelector) SyncWindows.setT(this, tSelector.getValue()); else throw new RuntimeException("Unknownsource:"+source); }
public String toString() { return "img[\""+getTitle()+"\" ("+getID()+"), "+getBitDepth()+"-bit, "+width+"x"+height+"x"+getNChannels()+"x"+getNSlices()+"x"+getNFrames()+"]"; }
private Overlay projectHyperStackRois(Overlay overlay) { if (overlay==null) return null; int t1 = imp.getFrame(); int channels = projImage.getNChannels(); int slices = 1; int frames = projImage.getNFrames(); Overlay overlay2 = overlay.create(); Roi roi;
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); }
private Overlay projectHyperStackRois(Overlay overlay) { if (overlay==null) return null; int t1 = imp.getFrame(); int channels = projImage.getNChannels(); int slices = 1; int frames = projImage.getNFrames(); Overlay overlay2 = overlay.create(); Roi roi;
/** * -- HACK -- * <p> * Workaround for the fact that if there are less than 7 slices in an * ImagePlus, the CompositeImage constructor will convert those slices * to channels. * </p> * <p> * This method will always construct a CompositeImage with the same * dimensions as the input ImagePlus. * </p> */ public static CompositeImage makeComposite(ImagePlus imp, int mode) { // cache the (correct) channel, frame and slice counts final int channels = imp.getNChannels(); final int frames = imp.getNFrames(); final int slices = imp.getNSlices(); // construct the composite image final CompositeImage cmp = new CompositeImage(imp, mode); // reset the correct dimension counts cmp.setDimensions(channels, slices, frames); return cmp; } }
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; }