本文整理汇总了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();
}
示例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;
}