本文整理汇总了Java中ij.measure.Calibration.getCValue方法的典型用法代码示例。如果您正苦于以下问题:Java Calibration.getCValue方法的具体用法?Java Calibration.getCValue怎么用?Java Calibration.getCValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.measure.Calibration
的用法示例。
在下文中一共展示了Calibration.getCValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getValueAsString
import ij.measure.Calibration; //导入方法依赖的package包/类
private String getValueAsString (
final int x,
final int y
) {
final Calibration cal = mainImp.getCalibration();
final int[] v = mainImp.getPixel(x, y);
final int mainImptype=mainImp.getType();
if (mainImptype==mainImp.GRAY8 || mainImptype==mainImp.GRAY16) {
final double cValue = cal.getCValue(v[0]);
if (cValue==v[0]) {
return(", value=" + v[0]);
}
else {
return(", value=" + IJ.d2s(cValue) + " (" + v[0] + ")");
}
} else if (mainImptype==mainImp.GRAY32) {
return(", value=" + Float.intBitsToFloat(v[0]));
} else if (mainImptype==mainImp.COLOR_256) {
return(", index=" + v[3] + ", value=" + v[0] + "," + v[1] + "," + v[2]);
} else if (mainImptype==mainImp.COLOR_RGB) {
return(", value=" + v[0] + "," + v[1] + "," + v[2]);
} else {
return("");
}
}
示例2: getValueAsString
import ij.measure.Calibration; //导入方法依赖的package包/类
/**
* Get a pixel value as string.
*
* @param x x- coordinate of the pixel
* @param y y- coordinate of the pixel
* @return pixel value in string form
*/
private String getValueAsString (
final int x,
final int y)
{
final Calibration cal = mainImp.getCalibration();
final int[] v = mainImp.getPixel(x, y);
final int mainImptype=mainImp.getType();
if (mainImptype==ImagePlus.GRAY8 || mainImptype==ImagePlus.GRAY16) {
final double cValue = cal.getCValue(v[0]);
if (cValue==v[0]) {
return(", value=" + v[0]);
}
else {
return(", value=" + IJ.d2s(cValue) + " (" + v[0] + ")");
}
} else if (mainImptype==ImagePlus.GRAY32) {
return(", value=" + Float.intBitsToFloat(v[0]));
} else if (mainImptype==ImagePlus.COLOR_256) {
return(", index=" + v[3] + ", value=" + v[0] + "," + v[1] + "," + v[2]);
} else if (mainImptype == ImagePlus.COLOR_RGB) {
return(", value=" + v[0] + "," + v[1] + "," + v[2]);
} else {
return("");
}
}
示例3: getTAC
import ij.measure.Calibration; //导入方法依赖的package包/类
/**
* @param x x coordinate
* @param y y coordinate
* @param slice slice coordinate
* @param t Number of time frames
* @param imp {@link ImagePlus} object.
* @param is {@link ImageStack} object (taken from {@code imp}).
* @param cal {@link Calibration} object (taken from {@code imp}).
* @return The calibrated time-activity curve for these coordinates.
*/
public static double [] getTAC(int x, int y, int slice, int t,
ImagePlus imp, ImageStack is,
Calibration cal) {
// Alloc space for the result
double[] result = new double[t];
// Set the desired slice and iterate through the frames
for (int frame = 1; frame <= t; frame++) {
// Use first channel
int stack_number = imp.getStackIndex(1, slice, frame);
// Use calibration to return true value
result[frame - 1] = cal.getCValue(
is.getVoxel(x, y, stack_number - 1));
}
return result;
}
示例4: setDefaultThreshold
import ij.measure.Calibration; //导入方法依赖的package包/类
/**
* Set up default thresholds and report them to the user as HU values if the
* image has HU calibration or plain values if not. Used as a first guess
* for dialogs that have to handle both HU and uncalibrated images.
*
* @param imp an image.
* @return double[2] containing minimum and maximum thresholds
*/
public static double[] setDefaultThreshold(final ImagePlus imp) {
final Calibration cal = imp.getCalibration();
double min = 0;
double max = 0;
if (!ImageCheck.huCalibrated(imp)) {
// set some sensible thresholding defaults
final int[] histogram = StackStats.getStackHistogram(imp);
final int histoLength = histogram.length;
int histoMax = histoLength - 1;
for (int i = histoLength - 1; i >= 0; i--) {
if (histogram[i] > 0) {
histoMax = i;
break;
}
}
min = imp.getProcessor().getAutoThreshold(histogram);
max = histoMax;
if (cal.isSigned16Bit() && cal.getCValue(0) == 0) {
min += Short.MIN_VALUE;
max += Short.MIN_VALUE;
}
} else {
// default bone thresholds are 0 and 4000 HU
min = airHU + 1000;
max = airHU + 5000;
}
final double[] thresholds = { min, max };
return thresholds;
}
示例5: huCalibrated
import ij.measure.Calibration; //导入方法依赖的package包/类
/**
* Guess whether an image is Hounsfield unit calibrated
*
* @param imp an image.
* @return true if the image might be HU calibrated
*/
public static boolean huCalibrated(final ImagePlus imp) {
final Calibration cal = imp.getCalibration();
final double[] coeff = cal.getCoefficients();
if (!cal.calibrated() || cal == null || (cal.getCValue(0) == 0 && coeff[1] == 1)
|| (cal.getCValue(0) == Short.MIN_VALUE && coeff[1] == 1))
return false;
return true;
}
示例6: getValueAsString
import ij.measure.Calibration; //导入方法依赖的package包/类
private String getValueAsString(final int x, final int y)
{
final Calibration cal = imp.getCalibration();
final int[] v = imp.getPixel(x, y);
switch (imp.getType())
{
case ImagePlus.GRAY8:
case ImagePlus.GRAY16:
{
final double cValue = cal.getCValue(v[0]);
if (cValue == v[0])
{
return (", value=" + v[0]);
} else
{
return (", value=" + IJ.d2s(cValue) + " (" + v[0] + ")");
}
}
case ImagePlus.GRAY32:
{
return (", value=" + Float.intBitsToFloat(v[0]));
}
case ImagePlus.COLOR_256:
{
return (", index=" + v[3] + ", value=" + v[0] + "," + v[1]
+ "," + v[2]);
}
case ImagePlus.COLOR_RGB:
{
return (", value=" + v[0] + "," + v[1] + "," + v[2]);
}
default:
{
return ("");
}
}
}
示例7: run
import ij.measure.Calibration; //导入方法依赖的package包/类
@Override
public void run(String arg0) {
ImagePlus imp = IJ.getImage();
int [] dim = imp.getDimensions();
// If not a HyperStack, return
if (dim[4] < 2) {
IJ.error("Not a HyperStack", "This plugin needs a HyperStack");
return;
}
// Create dialog to obtain the first and last frames for the averaging
int lastframe = dim[4], initframe, endframe;
String[] choices = new String[lastframe];
for (int i = 0; i < choices.length; i ++) {
choices[i] = (i + 1) + "";
}
GenericDialog gd = new GenericDialog(
"Choose first and last frame to average");
gd.addChoice("First frame:", choices, "1");
gd.addChoice("Last frame:", choices, lastframe + "");
gd.showDialog();
// If user canceled, return
if (gd.wasCanceled()) return;
initframe = Integer.parseInt(gd.getNextChoice());
endframe = Integer.parseInt(gd.getNextChoice());
// Create result image
String src_title = imp.getTitle();
String res_title = src_title + String.format(" (average %d - %d)",
initframe, endframe);
ImagePlus result = IJ.createImage(res_title, "32-bit", dim[0], dim[1],
1, dim[3], 1);
// Compute the mean frame value and set on the original image
ImageStack source = imp.getStack();
ImageStack target = result.getStack();
Calibration cal = imp.getCalibration();
result.setCalibration(cal); // FIXME: values are not calibrated
double [] values = new double[endframe - initframe + 1];
for (int z = 0; z < dim[3]; z++) {
// Update progress bar indicator
IJ.showProgress(z, dim[3]);
for (int x = 0; x < dim[0]; x++) {
for (int y = 0; y < dim[1]; y++) {
for (int f = initframe; f <= endframe; f++) {
int stackindex = imp.getStackIndex(1, z + 1, f);
values[f - initframe] = cal.getCValue(
source.getVoxel(x, y,
stackindex - 1));
} // end f
target.setVoxel(x, y, z, _mean(values));
} // end y
} // end x
} // end z
result.show();
}