protected ByteImage(final ImagePlus imp) { final ImageStack stack = imp.getStack(); w = imp.getWidth(); final int d = imp.getStackSize(); fData = new byte[d][]; for (int z = 0; z < d; z++) fData[z] = (byte[]) stack.getPixels(z + 1); }
public TestData(ImagePlus imp) { w = imp.getWidth(); h = imp.getHeight(); d = imp.getStackSize(); wh = w * h; re = new float[d][]; im = new float[d][]; for(int z = 0; z < d; z++) { re[z] = (float[])imp.getStack().getPixels(z+1); im[z] = new float[wh]; } }
private void findLabelledSlices() { //we go through every slice looking for a pixel with the same label //this will fill labelledSlices with the indexes of all labelled slices for (int i = 1; i <= labelsData.getStackSize(); i++) { byte[] pixels = (byte[]) labelsData.getStack().getProcessor(i).getPixels(); for (int j = 0; j < pixels.length; j++) { byte pixel = pixels[j]; if (pixel == label) { labelledSlices.add(i); break; } } } }
public ContourFinder(int slice) { this.slice=slice; pixels=(byte[])labels.getStack().getProcessor(slice+1).getPixels(); paths = new GeneralPath[255]; }
public int setup(String arg, ImagePlus imp) { if (imp!=null) { virtualStack = imp.getStack().isVirtual(); if (virtualStack) useOverlay = true; baseOverlay = imp.getOverlay(); flags += virtualStack?0:DOES_STACKS; firstFrame=1; lastFrame=defaultLastFrame=imp.getStackSize(); } this.imp = imp; return flags; }
/** * Multiplies all pixel values in the result image by pixelWidth. This ways * the pixel values represent sample thickness in real units. * * @throws NullPointerException If this.resultImage == null */ private void pixelValuesToCalibratedValues() { if (resultImage == null) { throw new NullPointerException( "The resultImage in LocalThicknessWrapper is null"); } final double pixelWidth = resultImage.getCalibration().pixelWidth; final ImageStack stack = resultImage.getStack(); final int depth = stack.getSize(); for (int z = 1; z <= depth; z++) { stack.getProcessor(z).multiply(pixelWidth); } final StackStatistics stackStatistics = new StackStatistics(resultImage); final double maxPixelValue = stackStatistics.max; resultImage.getProcessor().setMinAndMax(0, maxPixelValue); }
/** * Computes features from an ImagePlus object. * Spatial resolution is read from image Calibration. * * @param imagePlus the label image to analyze * @return the results in a new ResultsTable */ public ResultsTable process(ImagePlus imagePlus) { // Check validity of parameters if (imagePlus==null) return null; // Extract Image Stack and its calibration ImageStack image = imagePlus.getStack(); Calibration calib = imagePlus.getCalibration(); return process(image, calib); }
public void run(String arg) { ImagePlus imp = IJ.getImage(); if (!showDialog(imp)) return; if (imp.getStackSize()==1) Undo.setup(Undo.TYPE_CONVERSION, imp); imp.startTiming(); ImagePlus imp2 = shrink(imp, xshrink, yshrink, zshrink, method); IJ.showTime(imp, imp.getStartTime(), "", imp.getStackSize()); imp.setStack(imp2.getStack()); imp.setCalibration(imp2.getCalibration()); if (zshrink>1) imp.setSlice(1); }
void convertToByte(ImagePlus imp) { ImageProcessor ip; int currentSlice = imp.getCurrentSlice(); ImageStack stack1 = imp.getStack(); ImageStack stack2 = imp.createEmptyStack(); int nSlices = imp.getStackSize(); String label; for(int i=1; i<=nSlices; i++) { label = stack1.getSliceLabel(i); ip = stack1.getProcessor(i); ip.setMinAndMax(0, 255); stack2.addSlice(label, ip.convertToByte(true)); } imp.setStack(null, stack2); imp.setSlice(currentSlice); imp.setCalibration(imp.getCalibration()); //update calibration }
@Override public VolatileIntArray loadArray( final int timepoint, final int setup, final int level, final int[] dimensions, final long[] min ) throws InterruptedException { final int channel = setup + 1; final int slice = ( int ) min[ 2 ] + 1; final int frame = timepoint + 1; final int[] data = ( int[] ) imp.getStack().getProcessor( imp.getStackIndex( channel, slice, frame ) ).getPixels(); return new VolatileIntArray( data, true ); }
public SegmentationViewerCanvas(ImagePlus imp) { super(imp); label_colors = new Color[256]; w=imp.getWidth(); h=imp.getHeight(); d=imp.getStack().getSize(); contours=new Vector[d]; colors=new Vector[d]; indices=new Vector[d]; ImagePlus.addImageListener(new ImageListener() { public void imageOpened(ImagePlus imp) { } public void imageClosed(ImagePlus imp) { } public void imageUpdated(ImagePlus imp) { if (imp == labels) setLabels(labels); } }); }
public void doit(int PATTERN, int REPLACEMENT) { int w = image.getWidth(), h = image.getHeight(); int d = image.getStackSize(); ImageStack stack = image.getStack(); for(int z = 0; z < d; z++) { byte[] b = (byte[])stack.getProcessor(z+1).getPixels(); for(int i = 0; i < w*h; i++) { if(((int)(b[i] & 0xff)) == PATTERN) b[i] = (byte)REPLACEMENT; } } }
private void load(int n) { ImagePlus image = WindowManager .getImage("Displacement_dim" + n); if(image == null) return; for(int z = 0; z < d; z++) { u[n][z] = (float[])image.getStack() .getProcessor(z+1).getPixels(); } }
public int setup(String arg, ImagePlus imp) { if (imp!=null) { virtualStack = imp.getStack().isVirtual(); if (virtualStack) useOverlay = true; baseOverlay = imp.getOverlay(); flags += virtualStack?0:DOES_STACKS; firstFrame=1; lastFrame=defaultLastFrame=imp.getStackSize(); } this.imp = imp; return flags; }
public ImagePlus createOverlay() { ImageStack stack = new ImageStack(w, h); int RED = 0xff0000; for(int z = 0; z < d; z++) { ImageProcessor ip = image.getStack(). getProcessor(z + 1).convertToRGB(); for(int i = 0; i < w * h; i++) { if(minima[z][i] == (byte)MINIMUM) ip.set(i, RED); } stack.addSlice("", ip); } ImagePlus ret = new ImagePlus("overlay", stack); ret.setCalibration(image.getCalibration()); return ret; }
public void despeckle(){ for(int i=0; i<image.getStackSize(); i++){ currentSlide = (byte[])image.getStack(). getProcessor(i+1).getPixels(); despeckleSlide(); } }
/** * Computes features from an ImagePlus object. * Spatial resolution is read from image Calibration. * * @param imagePlus the label image to analyze * @return the results in a new ResultsTable */ public ResultsTable process(ImagePlus imagePlus) { // Check validity of parameters if (imagePlus==null) return null; // Extract Image Stack and its calibration ImageStack image = imagePlus.getStack(); Calibration calib = imagePlus.getCalibration(); return process(image, calib); }
public void run(String arg) { ImagePlus imp = IJ.getImage(); if (!showDialog(imp)) return; if (imp.getStackSize()==1) Undo.setup(Undo.TYPE_CONVERSION, imp); imp.startTiming(); ImagePlus imp2 = shrink(imp, xshrink, yshrink, zshrink, method); IJ.showTime(imp, imp.getStartTime(), "", imp.getStackSize()); imp.setStack(imp2.getStack()); imp.setCalibration(imp2.getCalibration()); if (zshrink>1) imp.setSlice(1); }
void convertToByte(ImagePlus imp) { ImageProcessor ip; int currentSlice = imp.getCurrentSlice(); ImageStack stack1 = imp.getStack(); ImageStack stack2 = imp.createEmptyStack(); int nSlices = imp.getStackSize(); String label; for(int i=1; i<=nSlices; i++) { label = stack1.getSliceLabel(i); ip = stack1.getProcessor(i); ip.setMinAndMax(0, 255); stack2.addSlice(label, ip.convertToByte(true)); } imp.setStack(null, stack2); imp.setSlice(currentSlice); imp.setCalibration(imp.getCalibration()); //update calibration }
@Override public VolatileFloatArray loadArray( final int timepoint, final int setup, final int level, final int[] dimensions, final long[] min ) throws InterruptedException { final int channel = setup + 1; final int slice = ( int ) min[ 2 ] + 1; final int frame = timepoint + 1; final float[] data = ( float[] ) imp.getStack().getProcessor( imp.getStackIndex( channel, slice, frame ) ).getPixels(); return new VolatileFloatArray( data, true ); }