当前位置: 首页>>代码示例>>Java>>正文


Java Calibration.setUnit方法代码示例

本文整理汇总了Java中ij.measure.Calibration.setUnit方法的典型用法代码示例。如果您正苦于以下问题:Java Calibration.setUnit方法的具体用法?Java Calibration.setUnit怎么用?Java Calibration.setUnit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ij.measure.Calibration的用法示例。


在下文中一共展示了Calibration.setUnit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testRun

import ij.measure.Calibration; //导入方法依赖的package包/类
@Test
public void testRun() throws Exception {
	// SETUP
	final String expectedTitle = "Skeleton of Test";
	final ImagePlus imagePlus = NewImage.createImage("Test", 5, 5, 5, 8, 1);
	final Calibration calibration = new Calibration();
	calibration.setUnit("my unit");
	imagePlus.setCalibration(calibration);

	// EXECUTE
	final CommandModule module = IMAGE_J.command().run(SkeletoniseWrapper.class,
		true, "inputImage", imagePlus).get();

	// VERIFY
	final ImagePlus skeleton = (ImagePlus) module.getOutput("skeleton");
	assertNotNull("Skeleton image should not be null", skeleton);
	assertEquals("Skeleton has wrong title", expectedTitle, skeleton
		.getTitle());
	assertEquals("Skeleton should have same calibration", "my unit", skeleton
		.getCalibration().getUnit());
       assertNotSame("Original image should not have been overwritten",
		imagePlus, skeleton);
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:24,代码来源:SkeletoniseWrapperTest.java

示例2: getCalibration

import ij.measure.Calibration; //导入方法依赖的package包/类
Calibration getCalibration(int dimension)
{
	Calibration c = new Calibration();
	c.setUnit("nm");
	switch (dimension)
	{
		case Projection.X:
			c.pixelWidth = settings.getNmPerSlice() / magnification;
			c.pixelHeight = nmPerPixel / magnification;
			break;
		case Projection.Y:
			c.pixelWidth = nmPerPixel / magnification;
			c.pixelHeight = settings.getNmPerSlice() / magnification;
			break;
		case Projection.Z:
			c.pixelWidth = nmPerPixel / magnification;
			c.pixelHeight = nmPerPixel / magnification;
			c.pixelDepth = settings.getNmPerSlice() / magnification;
			break;
	}
	return c;
}
 
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:23,代码来源:PSFCreator.java

示例3: addScale

import ij.measure.Calibration; //导入方法依赖的package包/类
public static ImagePlus addScale(final ImagePlus tempImage, final double pixelSpacing) {
	// System.out.println("Adding scale");
	final Calibration cal = new Calibration();
	cal.setUnit("mm");
	// System.out.println("w and h");
	cal.pixelWidth = cal.pixelHeight = pixelSpacing;
	tempImage.setCalibration(cal);
	tempImage.getProcessor().setColor(new Color(255, 0, 0));
	// System.out.println("drawLine");
	tempImage.getProcessor().drawLine(5, 5, (int) (5.0 + 10.0 / pixelSpacing), 5);
	tempImage.getProcessor().drawString("1 cm", 5, 20);
	return tempImage;
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:14,代码来源:ResultsImage.java

示例4: testResults

import ij.measure.Calibration; //导入方法依赖的package包/类
@Test
public void testResults() throws Exception {
	// SETUP
	final ImagePlus imagePlus = NewImage.createByteImage("", 2, 2, 2, 1);
	final Calibration calibration = new Calibration();
	calibration.setUnit("mm");
	imagePlus.setCalibration(calibration);
	final String[] expectedHeaders = { "Tb.Th Mean (mm)", "Tb.Th Std Dev (mm)",
		"Tb.Th Max (mm)", "Tb.Sp Mean (mm)", "Tb.Sp Std Dev (mm)",
		"Tb.Sp Max (mm)" };
	final String[][] expectedValues = { { "", "NaN" }, { "", "NaN" }, { "",
		"NaN" }, { "10.392304420471191", "" }, { "0.0", "" }, {
			"10.392304420471191", "" } };

	// EXECUTE
	final CommandModule module = IMAGE_J.command().run(ThicknessWrapper.class,
		true, "inputImage", imagePlus, "mapChoice", "Both", "maskArtefacts",
		false, "cropToRois", false, "showMaps", false).get();

	// VERIFY
	@SuppressWarnings("unchecked")
	final Table<DefaultColumn<String>, String> table =
		(Table<DefaultColumn<String>, String>) module.getOutput("resultsTable");
	assertNotNull(table);
	assertEquals("Results table has wrong number of columns", 7, table.size());
	for (int i = 0; i < 6; i++) {
		final DefaultColumn<String> column = table.get(i + 1);
		assertEquals(expectedHeaders[i], column.getHeader());
		for (int j = 0; j < 2; j++) {
			assertEquals("Column has an incorrect value", expectedValues[i][j],
				column.getValue(j));
		}
	}
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:35,代码来源:ThicknessWrapperTest.java

示例5: testGetUnitHeaderImagePlusReturnsEmptyIfUnitEmpty

import ij.measure.Calibration; //导入方法依赖的package包/类
@Test
public void testGetUnitHeaderImagePlusReturnsEmptyIfUnitEmpty()
	throws Exception
{
	final ImagePlus imagePlus = new ImagePlus();
	final Calibration calibration = new Calibration();
	calibration.setUnit("");
	imagePlus.setCalibration(calibration);

	final String unitHeader = ResultUtils.getUnitHeader(imagePlus);

	assertEquals("", unitHeader);
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:14,代码来源:ResultUtilsTest.java

示例6: testGetUnitHeaderImagePlusReturnsEmptyIfUnitUnit

import ij.measure.Calibration; //导入方法依赖的package包/类
@Test
public void testGetUnitHeaderImagePlusReturnsEmptyIfUnitUnit()
	throws Exception
{
	final ImagePlus imagePlus = new ImagePlus();
	final Calibration calibration = new Calibration();
	calibration.setUnit("unit");
	imagePlus.setCalibration(calibration);

	final String unitHeader = ResultUtils.getUnitHeader(imagePlus);

	assertEquals("", unitHeader);
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:14,代码来源:ResultUtilsTest.java

示例7: testGetUnitHeaderImagePlus

import ij.measure.Calibration; //导入方法依赖的package包/类
@Test
public void testGetUnitHeaderImagePlus() throws Exception {
	final ImagePlus imagePlus = new ImagePlus();
	final Calibration calibration = new Calibration();
       final String unit = "mm";
       calibration.setUnit(unit);
	imagePlus.setCalibration(calibration);

	final String unitHeader = ResultUtils.getUnitHeader(imagePlus);

	assertEquals("(" + unit + ")", unitHeader);
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:13,代码来源:ResultUtilsTest.java

示例8: calibrateImagePlus

import ij.measure.Calibration; //导入方法依赖的package包/类
/**
 * Set an ImagePlus's Calibration and FileInfo properties based on a RegionRequest and PathImageServer.
 * It is assumed at the image contained in the ImagePlus has been correctly read from the server.
 * 
 * @param imp
 * @param request
 * @param server
 */
public static void calibrateImagePlus(final ImagePlus imp, final RegionRequest request, final ImageServer<BufferedImage> server) {
	// Set the file info & calibration appropriately		
	// TODO: Check if this is correct!  And consider storing more info regarding actual server...
	Calibration cal = new Calibration();
	double downsampleFactor = request.getDownsample();

	double pixelWidth = server.getPixelWidthMicrons();
	double pixelHeight = server.getPixelHeightMicrons();
	if (!Double.isNaN(pixelWidth + pixelHeight)) {
		cal.pixelWidth = pixelWidth * downsampleFactor;
		cal.pixelHeight = pixelHeight * downsampleFactor;
		cal.pixelDepth = server.getZSpacingMicrons();
		if (server.nTimepoints() > 1) {
			cal.frameInterval = server.getTimePoint(1);
			if (server.getTimeUnit() != null)
				cal.setTimeUnit(server.getTimeUnit().toString());
		}
		cal.setUnit("um");
	}

	// Set the origin
	cal.xOrigin = -request.getX() / downsampleFactor;
	cal.yOrigin = -request.getY() / downsampleFactor;

	// Need to set calibration afterwards, as it will be copied
	imp.setCalibration(cal);


	FileInfo fi = imp.getFileInfo();
	File file = new File(server.getPath());
	fi.directory = file.getParent() + File.separator;
	fi.fileName = file.getName();
	String path = server.getPath();
	if (path != null && path.toLowerCase().startsWith("http"))
		fi.url = path;
	imp.setFileInfo(fi);

	imp.setProperty("Info", "location="+server.getPath());
}
 
开发者ID:qupath,项目名称:qupath,代码行数:48,代码来源:IJTools.java

示例9: calibrate

import ij.measure.Calibration; //导入方法依赖的package包/类
private void calibrate(ImagePlus imp)
{
	// Calibrate
	Calibration cal = new Calibration();
	cal.setUnit("um");
	cal.pixelWidth = cal.pixelHeight = nmPerPixel / 1000;
	cal.pixelDepth = nmPerSlice / 1000;
	imp.setCalibration(cal);
}
 
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:10,代码来源:NucleusMask.java

示例10: displayImage

import ij.measure.Calibration; //导入方法依赖的package包/类
static ImagePlus displayImage(String title, ImageProcessor ip, double nmPerPixel)
{
	ImagePlus imp = Utils.display(title, ip);
	Calibration cal = new Calibration();
	cal.setUnit("um");
	cal.pixelWidth = cal.pixelHeight = nmPerPixel / 1000;
	imp.setCalibration(cal);
	return imp;
}
 
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:10,代码来源:PCPALMMolecules.java

示例11: read

import ij.measure.Calibration; //导入方法依赖的package包/类
/**
 * Read a file in the given directory. The fileName field must be set.
 *
 * @param directory
 * @throws Exception
 */
private void read(final String directory) throws Exception {
	final File fileIn = new File(directory + fileName);
	final long fileLength = fileIn.length();
	byte[] fileData;
	try {
		final BufferedInputStream inputStream = new BufferedInputStream(new FileInputStream(fileIn));
		final DataInputStream dataInputStream = new DataInputStream(inputStream);
		// Allocate memory for reading the file into memory
		fileData = new byte[(int) fileLength];
		// Read the data to memory
		dataInputStream.read(fileData, 0, (int) fileLength);
		// Close the file after reading
		dataInputStream.close();
	} catch (final Exception e) {
		throw new UnsupportedDataTypeException("Could not read input file.");
	}
	// Read some data from the file Header
	if (fileLength > 1609) {
		Device = new String(fileData, 1051, fileData[1050]);
	} else {
		throw new UnsupportedDataTypeException("Apparently not a Stratec file, file length < 1609 bytes.");
	}

	if (fileLength > 1609 && Device.toLowerCase().indexOf(".typ") >= 0) {
		readHeader(fileData);
	} else {
		throw new UnsupportedDataTypeException("Apparently not a Stratec file, device string not found.");
	}
	// Create ImageJ image
	final ImagePlus tempImage = NewImage.createShortImage(fileName + " " + Double.toString(VoxelSize), PicMatrixX,
			PicMatrixY, 1, NewImage.FILL_BLACK);
	this.setImage(tempImage.getImage());
	this.setProcessor(fileName, tempImage.getProcessor());
	// Set ImageJ image properties
	setProperties(directory);
	final short[] pixels = (short[]) this.getProcessor().getPixels();
	int min = (int) Math.pow(2, 16);
	int max = 0;
	for (int j = 0; j < PicMatrixY; ++j) {
		for (int i = 0; i < PicMatrixX; ++i) {
			final int offset = 1609 + 2 * (i + j * PicMatrixX);
			int value = ((short) (((fileData[offset + 1] & 0xFF)) << 8 | ((short) (fileData[offset] & 0xFF)) << 0));

			if (value >= 0) {
				value = (int) -Math.pow(2, 15) + value;
			} else {
				value = (int) Math.pow(2, 15) - 1 + value;
			}
			final int tempVal = value & 0xFFFF;
			if (tempVal < min) {
				min = tempVal;
			}
			if (tempVal > max) {
				max = tempVal;
			}
			pixels[i + j * PicMatrixX] = (short) value;
		}
	}
	this.setDisplayRange(min, max);
	final Calibration cal = this.getCalibration();
	final double[] coefficients = { -32.768, 0.001 };
	cal.setFunction(Calibration.STRAIGHT_LINE, coefficients, "1/cm");
	cal.setUnit("mm");
	cal.pixelWidth = cal.pixelHeight = cal.pixelDepth = VoxelSize;
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:72,代码来源:Read_Stratec_File.java

示例12: initializeTracingCanvas

import ij.measure.Calibration; //导入方法依赖的package包/类
private void initializeTracingCanvas() {

		if (xy == null)
			xy = new ImagePlus();

		// Define spatial calibration of stack. We must initialize
		// stacks.ThreePanes.xy to avoid a NPE later on
		// (tracing.SimpleNeuriteTracer.makePathVolume() inherits
		// stacks.ThreePanes.xy's calibration)
		final Calibration cal = new Calibration();
		if (tracesFile) {

			if (pathAndFillManager == null || pathAndFillManager.size() == 0)
				throw new RuntimeException(
						"initializeTracingCanvas() was called before successfully loading PathAndFillManager");

			// Read values from loaded traces file
			cal.setUnit(pathAndFillManager.parsed_units);
			cal.pixelWidth = pathAndFillManager.parsed_x_spacing;
			cal.pixelHeight = pathAndFillManager.parsed_y_spacing;
			cal.pixelDepth = pathAndFillManager.parsed_z_spacing;
			width = pathAndFillManager.parsed_width;
			height = pathAndFillManager.parsed_height;
			depth = pathAndFillManager.parsed_depth;

			// Reset offsets
			applyOffset(xOffsetGuessed = 0, yOffsetGuessed = 0, zOffsetGuessed = 0);

		} else {

			// SWC file: we need to calculate image size
			calculateCanvasDimensions(pathAndFillManager);
			if (spacing_units != null && !spacing_units.isEmpty()) {
				cal.setUnit(spacing_units);
				cal.pixelWidth = voxelWidth;
				cal.pixelHeight = voxelHeight;
				cal.pixelDepth = voxelHeight;
			}

		}

		xy.setCalibration(cal);
	}
 
开发者ID:tferr,项目名称:hIPNAT,代码行数:44,代码来源:ImportTracings.java

示例13: run

import ij.measure.Calibration; //导入方法依赖的package包/类
@Override
	public void run() {
		
		QuPathViewer viewer = qupath.getViewer();
		if (viewer == null)
			return;
		
		BufferedImage img = DisplayHelpers.makeSnapshot(qupath, false);
//		Graphics2D g2d;
//		Border border = viewer.getBorder();
//		if (border == null) {
//			img = new BufferedImage(viewer.getWidth(), viewer.getHeight(), BufferedImage.TYPE_INT_RGB);
//			g2d = img.createGraphics();
//		} else {
//			// Shift according to insets to avoid painting the panel border
//			Insets insets = border.getBorderInsets(viewer);
//			img = new BufferedImage(viewer.getWidth()-insets.left-insets.right, viewer.getHeight()-insets.top-insets.bottom, BufferedImage.TYPE_INT_RGB);
//			g2d = img.createGraphics();
//			g2d.translate(-insets.left, -insets.top);
//		}
//		viewer.paintAll(g2d);
		// Try to start up & display ImageJ
		ImageJ ij = IJExtension.getImageJInstance();
		if (ij != null)
			ij.setVisible(true);
		String name = WindowManager.getUniqueName("Screenshot - " + viewer.getServer().getShortServerName());
		ImagePlus imp = new ImagePlus(name, img);
		double pixelWidth = viewer.getDisplayedPixelWidthMicrons();
		double pixelHeight = viewer.getDisplayedPixelHeightMicrons();
		if (!Double.isNaN(pixelWidth + pixelHeight)) {
			Calibration cal = imp.getCalibration();
			cal.pixelWidth = pixelWidth;
			cal.pixelHeight = pixelHeight;
			cal.setUnit("um");
//			// TODO: Set the screenshot origin, if no rotations have been applied
//			cal.xOrigin = -viewer.componentXtoImageX(0) / viewer.getDownsampleFactor();
//			cal.yOrigin = -viewer.componentYtoImageY(0) / viewer.getDownsampleFactor();
		}
		// TODO: Put image path into screenshot images - so they can also be used as whole slide images later
		Interpreter.batchMode = false; // Make sure we aren't in batch mode, so that image will display
		
		SwingUtilities.invokeLater(() -> imp.show());
		
//		new PathImagePlus(viewer.getWholeSlideImageServer().getServerPath(), imp, viewer.getDisplayedImageBounds()).getImage().show();
	}
 
开发者ID:qupath,项目名称:qupath,代码行数:46,代码来源:ScreenshotCommand.java

示例14: AbstractRendering

import ij.measure.Calibration; //导入方法依赖的package包/类
protected AbstractRendering(AbstractBuilder builder) {
    this.xmin = builder.xmin;
    this.xmax = builder.xmax;
    this.ymin = builder.ymin;
    this.ymax = builder.ymax;
    this.resolution = builder.resolution;
    this.imSizeX = builder.imSizeX;
    this.imSizeY = builder.imSizeY;
    this.forceDefaultDX = builder.forceDefaultDX;
    this.forceDefaultDZ = builder.forceDefaultDZ;
    this.defaultDX = builder.defaultDX;
    this.defaultDZ = builder.defaultDZ;
    this.zFrom = builder.zFrom;
    this.zSlices = builder.zSlices;
    this.zStep = builder.zStep;
    this.zTo = builder.zTo;
    this.threeDimensions = builder.threeDimensions;
    this.colorize = builder.colorize;
    this.colorizationLut = builder.colorizationLut;
    slices = new ImageProcessor[zSlices];
    stack = new ImageStack(imSizeX, imSizeY);
    for(int i = 0; i < zSlices; i++) {
        slices[i] = new FloatProcessor(imSizeX, imSizeY);
        stack.addSlice((i * zStep + zFrom) + " to " + ((i + 1) * zStep + zFrom), slices[i]);
    }
    image = new ImagePlus(getRendererName(), stack);
    Calibration calibration = new Calibration();
    double pixelSize = resolution * CameraSetupPlugIn.getPixelSize() / 1000;
    calibration.pixelHeight = pixelSize;
    calibration.pixelWidth = pixelSize;
    if(threeDimensions) {
        calibration.pixelDepth = zStep / 1000;
    }
    calibration.setUnit("um");
    image.setCalibration(calibration);
    if(colorize) {
        image.setDimensions(zSlices, 1, 1);
        CompositeImage image2 = new CompositeImage(image);
        image = image2;
        setupLuts();
    }
}
 
开发者ID:zitmen,项目名称:thunderstorm,代码行数:43,代码来源:AbstractRendering.java

示例15: runGenerator

import ij.measure.Calibration; //导入方法依赖的package包/类
private void runGenerator() throws InterruptedException {
    IJ.showStatus("ThunderSTORM is generating your image sequence...");
    IJ.showProgress(0.0);
    //
    IJGroundTruthTable gt = IJGroundTruthTable.getGroundTruthTable();
    gt.reset();
    ImageStack stack = new ImageStack(width, height);
    //FloatProcessor bkg = new DataGenerator().generateBackground(width, height, drift);
    //
    int numThreads = Math.min(Prefs.getThreads(), frames);
    GeneratorWorker[] generators = new GeneratorWorker[numThreads];
    Thread[] threads = new Thread[numThreads];
    processing_frame = 0;
    // prepare the workers and allocate resources for all the threads
    for(int c = 0, f_start = 0, f_end, f_inc = frames / numThreads; c < numThreads; c++) {
        if((c + 1) < numThreads) {
            f_end = f_start + f_inc - 1;
        } else {
            f_end = frames - 1;
        }
        generators[c] = new GeneratorWorker(f_start, f_end/*, bkg*/);
        threads[c] = new Thread(generators[c]);
        f_start = f_end + 1;
    }
    // start all the workers
    for(int c = 0; c < numThreads; c++) {
        threads[c].start();
    }
    // wait for all the workers to finish
    int wait = 1000 / numThreads;    // max 1s
    boolean finished = false;
    while(!finished) {
        finished = true;
        for(int c = 0; c < numThreads; c++) {
            threads[c].join(wait);
            finished &= !threads[c].isAlive();   // all threads must not be alive to finish!
        }
        if(IJ.escapePressed()) {    // abort?
            // stop the workers
            for(int ci = 0; ci < numThreads; ci++) {
                threads[ci].interrupt();
            }
            // wait so the message below is not overwritten by any of the threads
            for(int ci = 0; ci < numThreads; ci++) {
                threads[ci].join();
            }
            // show info and exit the plugin
            IJ.showProgress(1.0);
            IJ.showStatus("Operation has been aborted by user!");
            return;
        }
    }
    processing_frame = 0;
    gt.setOriginalState();
    for(int c = 0; c < numThreads; c++) {
        generators[c].fillResults(stack, gt);   // and generate stack and table of ground-truth data
    }
    gt.insertIdColumn();
    gt.copyOriginalToActual();
    gt.setActualState();
    gt.convertAllColumnsToAnalogUnits();
    //
    ImagePlus imp = IJ.createImage("Artificial dataset", "16-bit", width, height, frames);
    imp.setStack(stack);
    Calibration cal = new Calibration();
    cal.setUnit("um");
    cal.pixelWidth = cal.pixelHeight = Units.NANOMETER.convertTo(Units.MICROMETER, CameraSetupPlugIn.getPixelSize());
    imp.setCalibration(cal);
    imp.show();
    gt.show();
    //
    IJ.showProgress(1.0);
    IJ.showStatus("ThunderSTORM has finished generating your image sequence.");
}
 
开发者ID:zitmen,项目名称:thunderstorm,代码行数:75,代码来源:DataGeneratorPlugIn.java


注:本文中的ij.measure.Calibration.setUnit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。