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


Java Calibration.setFunction方法代码示例

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


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

示例1: scanco

import ij.measure.Calibration; //导入方法依赖的package包/类
private void scanco(final ImagePlus imp) throws IllegalArgumentException {
	final String manufacturer = DicomTools.getTag(imp, "0008,0070");
	if (manufacturer == null || !manufacturer.contains("SCANCO")) {
		throw new IllegalArgumentException("File is not a SCANCO Medical DICOM");
	}
	final double slope = Double.parseDouble(DicomTools.getTag(imp, "0029,1004"));
	final double intercept = Double.parseDouble(DicomTools.getTag(imp, "0029,1005"));
	final double scaling = Double.parseDouble(DicomTools.getTag(imp, "0029,1000"));
	final double c = intercept - 32768 * slope / scaling;
	final double m = slope / scaling;
	final double[] coef = { c, m };
	final Calibration cal = imp.getCalibration();
	cal.setFunction(Calibration.STRAIGHT_LINE, coef, "mg HA/ccm");
	imp.setCalibration(cal);
	imp.updateAndDraw();
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:17,代码来源:DensityCalibrator.java

示例2: 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


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