/** Copies the calibration of the specified image to this image. */ public void copyScale(ImagePlus imp) { if (imp!=null && globalCalibration==null) setCalibration(imp.getCalibration()); }
boolean validDialogValues() { Calibration cal = imp.getCalibration(); double pw=cal.pixelWidth, ph=cal.pixelHeight; if (width/pw<1 || height/ph<1) return false; if (xRoi/pw>imp.getWidth() || yRoi/ph>imp.getHeight()) return false; return true; }
public ShellsCanvas(ImagePlus imagePlus, double centre_x, double centre_y, double centre_z) { super(imagePlus); this.imagePlus = imagePlus; this.centre_x = centre_x; this.centre_y = centre_y; this.centre_z = centre_z; System.out.println("Creating canvas with shells centred around: " + centre_x + "," + centre_y + "," + centre_z); radii = new ArrayList<Double>(); Calibration c = imagePlus.getCalibration(); x_spacing = c.pixelWidth; y_spacing = c.pixelHeight; z_spacing = c.pixelDepth; width = imagePlus.getWidth(); height = imagePlus.getHeight(); depth = imagePlus.getStackSize(); } private double x_spacing;
/** Converts a Lab stack to RGB. */ public void convertLabToRGB() { if (imp.getStackSize()!=3) throw new IllegalArgumentException("3-slice 32-bit stack required"); ColorSpaceConverter converter = new ColorSpaceConverter(); ImagePlus imp2 = converter.LabToRGB(imp); imp2.setCalibration(imp.getCalibration()); imp.setImage(imp2); }
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); }
public ImagePlus getResultAsByteImage() { ImageStack stack = new ImageStack(w, h); for(int d = 0; d < z; d++) { int[] p = (int[])result.getStack().getPixels(d+1); byte[] b = new byte[w*h]; for(int i = 0; i < b.length; i++) { if(p[i] == -1) b[i] = (byte)255; else b[i] = (byte)p[i]; } stack.addSlice("", new ByteProcessor(w, h, b, null)); } ImagePlus res = new ImagePlus("Classified", stack); res.setCalibration(image.getCalibration()); return res; }
/** * 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); }
/** * Test method for {@link inra.ijpb.measure.IntrinsicVolumes3D#meanBreadthDensity(ij.ImageStack, ij.measure.Calibration, int, int)}. */ @Test public void testMeanBreadthDensity() { String fileName = getClass().getResource("/files/microstructure3D_10x10x10.tif").getFile(); ImagePlus imagePlus = IJ.openImage(fileName); // basic check up assertNotNull(imagePlus); assertTrue(imagePlus.getStackSize() > 0); // get image stack and calibration ImageStack image = imagePlus.getStack(); Calibration calib = imagePlus.getCalibration(); // compare with a value computed with Matlab (2018.09.11) double meanBreadthDensity = IntrinsicVolumes3D.meanBreadthDensity(image, calib, 13, 8); assertEquals(-0.014, meanBreadthDensity, .001); }
/** * Instructs the Sholl Analysis plugin to analyze the profile sampled by * . */ public void analyzeWithShollAnalysisPlugin(final String exportDir, final double primaryBranches) { final Sholl_Analysis sa = new Sholl_Analysis(); sa.setDescription("Tracings for " + originalImage.getTitle(), false); final Calibration cal = originalImage.getCalibration(); if (cal != null) { final int pX = (int) cal.getRawX(x_start); final int pY = (int) cal.getRawY(y_start, originalImage.getHeight()); final int pZ = (int) (z_start / cal.pixelDepth + cal.zOrigin); sa.setCenter(pX, pY, pZ); sa.setUnit(cal.getUnit()); } sa.setStepRadius(sphereSeparation); sa.setPrimaryBranches(primaryBranches); sa.setExportPath(exportDir); sa.analyzeProfile(sampled_distances, sampled_counts, !twoDimensional); }
/** Converts the current cursor location to a string. */ public String getLocationAsString(int x, int y) { Calibration cal = getCalibration(); if (getProperty("FHT")!=null) return getFFTLocation(x, height-y, cal); String xx="", yy=""; if (cal.scaled()) { xx = " ("+x+")"; yy = " ("+y+")"; } String s = " x="+d2s(cal.getX(x)) + xx + ", y=" + d2s(cal.getY(y,height)) + yy; if (getStackSize()>1) { Roi roi2 = getRoi(); if (roi2==null || roi2.getState()==Roi.NORMAL) { int z = isDisplayedHyperStack()?getSlice()-1:getCurrentSlice()-1; String zz = cal.scaled()&&cal.getZ(z)!=z?" ("+z+")":""; s += ", z="+d2s(cal.getZ(z))+zz; } } return s; }
public Inverse( ImagePlus template, ImagePlus model ) { modelWidth = model.getWidth(); modelHeight = model.getHeight(); modelDepth = model.getStackSize(); modelCalibration = model.getCalibration(); if( modelCalibration != null ) { modelPixelWidth = modelCalibration.pixelWidth; modelPixelHeight = modelCalibration.pixelHeight; modelPixelDepth = modelCalibration.pixelDepth; } templateWidth = template.getWidth(); templateHeight = template.getHeight(); templateDepth = template.getStackSize(); templateCalibration = template.getCalibration(); if( templateCalibration != null ) { templatePixelWidth = templateCalibration.pixelWidth; templatePixelHeight = templateCalibration.pixelHeight; templatePixelDepth = templateCalibration.pixelDepth; } templateX = new short[modelDepth][modelWidth*modelHeight]; templateY = new short[modelDepth][modelWidth*modelHeight]; templateZ = new short[modelDepth][modelWidth*modelHeight]; }
boolean validDialogValues() { Calibration cal = imp.getCalibration(); double pw=cal.pixelWidth, ph=cal.pixelHeight; if (width/pw<1 || height/ph<1) return false; if (xRoi/pw>imp.getWidth() || yRoi/ph>imp.getHeight()) return false; return true; }
/** Converts a Lab stack to RGB. */ public void convertLabToRGB() { if (imp.getStackSize()!=3) throw new IllegalArgumentException("3-slice 32-bit stack required"); ColorSpaceConverter converter = new ColorSpaceConverter(); ImagePlus imp2 = converter.LabToRGB(imp); imp2.setCalibration(imp.getCalibration()); imp.setImage(imp2); }
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); }
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; }
/** Copies the calibration of the specified image to this image. */ public void copyScale(ImagePlus imp) { if (imp!=null && globalCalibration==null) setCalibration(imp.getCalibration()); }
/** * 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); }
/** * Test method for {@link inra.ijpb.measure.IntrinsicVolumes3D#surfaceAreaDensity(ij.ImageStack, ij.measure.Calibration, int)}. */ @Test public void testSurfaceAreaDensity() { String fileName = getClass().getResource("/files/microstructure3D_10x10x10.tif").getFile(); ImagePlus imagePlus = IJ.openImage(fileName); // basic check up assertNotNull(imagePlus); assertTrue(imagePlus.getStackSize() > 0); // get image stack and calibration ImageStack image = imagePlus.getStack(); Calibration calib = imagePlus.getCalibration(); // compare with a value computed with Matlab (2018.09.11) double surfaceDensity = IntrinsicVolumes3D.surfaceAreaDensity(image, calib, 13); assertEquals(0.56, surfaceDensity, .001); }
/** Converts the current cursor location to a string. */ public String getLocationAsString(int x, int y) { Calibration cal = getCalibration(); if (getProperty("FHT")!=null) return getFFTLocation(x, height-y, cal); String xx="", yy=""; if (cal.scaled()) { xx = " ("+x+")"; yy = " ("+y+")"; } String s = " x="+d2s(cal.getX(x)) + xx + ", y=" + d2s(cal.getY(y,height)) + yy; if (getStackSize()>1) { Roi roi2 = getRoi(); if (roi2==null || roi2.getState()==Roi.NORMAL) { int z = isDisplayedHyperStack()?getSlice()-1:getCurrentSlice()-1; String zz = cal.scaled()&&cal.getZ(z)!=z?" ("+z+")":""; s += ", z="+d2s(cal.getZ(z))+zz; } } return s; }
public TransformationAttempt( double cubeSide, ImagePlus croppedTemplate, NamedPointWorld templatePoint, ImagePlus newImage, NamedPointWorld guessedPoint, int similarityMeasure, FineTuneProgressListener listener, ProgressWindow progressWindow ) { this.cubeSide = cubeSide; this.croppedTemplate = croppedTemplate; this.templatePoint = templatePoint; this.newImage = newImage; this.guessedPoint = guessedPoint; this.listener = listener; this.progressWindow = progressWindow; this.similarityMeasure = similarityMeasure; minTranslation = -cubeSide; // Find what the maximum translation could be: Calibration c=newImage.getCalibration(); maxTranslation = 0; double max_x = newImage.getWidth() * c.pixelWidth; double max_y = newImage.getHeight() * c.pixelHeight; double max_z = newImage.getStackSize() * c.pixelDepth; if( max_x > maxTranslation ) maxTranslation = max_x; if( max_y > maxTranslation ) maxTranslation = max_y; if( max_z > maxTranslation ) maxTranslation = max_z; maxTranslation += cubeSide; }