本文整理汇总了Java中ij.measure.Measurements类的典型用法代码示例。如果您正苦于以下问题:Java Measurements类的具体用法?Java Measurements怎么用?Java Measurements使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Measurements类属于ij.measure包,在下文中一共展示了Measurements类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: identifyGoodCores
import ij.measure.Measurements; //导入依赖的package包/类
/**
* Identify regions in a binary image likely to correspond to complete TMA cores,
* based both on size and circularity.
* @param bp - The binary image to process; 0 should be background, 255 foreground
* @param minArea - Minimum area of a region to keep (in pixels)
* @param maxArea - Maximum area of a region to keep (in pixels)
* @param minCircularity - Minimum circularity of a region to keep.
* @param labelCores - TRUE if the output should be a labelled image (unique integer value per core), otherwise a binary image will be returned
* @param polyCentroids - A Polygon to which the centroids of the detected regions will be added (if not null).
* @return Binary or labelled image showing containing only the regions of bp with shapes & sizes corresponding to likely complete TMA cores.
*/
private static ImageProcessor identifyGoodCores(ByteProcessor bp, double minArea, double maxArea, double minCircularity, boolean labelCores, Polygon polyCentroids) {
// Create a binary image of only the roundest structures of approximately the correct area
bp.setThreshold(127, 512, ImageProcessor.NO_LUT_UPDATE);
int options = labelCores ? ParticleAnalyzer.SHOW_ROI_MASKS : ParticleAnalyzer.SHOW_MASKS;
int measurements = Measurements.CENTROID;
ResultsTable rt = new ResultsTable();
ParticleAnalyzer pa = new ParticleAnalyzer(options, measurements, rt, minArea, maxArea, minCircularity, 1.0);
pa.setHideOutputImage(true);
pa.analyze(new ImagePlus("Temp", bp), bp);
if (polyCentroids != null) {
for (int i = 0; i < rt.getCounter(); i++) {
int x = (int)(rt.getValueAsDouble(ResultsTable.X_CENTROID, i) + .5);
int y = (int)(rt.getValueAsDouble(ResultsTable.Y_CENTROID, i) + .5);
polyCentroids.addPoint(x, y);
}
}
return pa.getOutputImage().getProcessor();
}
示例2: set
import ij.measure.Measurements; //导入依赖的package包/类
/**
* @param stats_mode can be 0==stack histogram, 1==each image's histogram, and 2==reference Patch histogram.
*
**/
public void set(double saturated, boolean normalize, boolean equalize, int stats_mode, boolean use_full_stack, boolean from_existing_min_and_max, boolean visible_only) throws Exception {
if (null == reference && 2 == stats_mode) throw new IllegalArgumentException("Need a non-null reference Patch to use 2==stats_mode !");
this.saturated = saturated;
set("saturated", saturated);
this.normalize = normalize;
set("normalize", normalize);
this.equalize = equalize;
set("equalize", equalize);
this.stats_mode = stats_mode;
this.use_full_stack = use_full_stack;
if (from_existing_min_and_max && null != reference) {
// recreate reference_stats
ImageProcessor ip = reference.getImageProcessor();
ip.setMinAndMax(reference.getMin(), reference.getMax());
reference_stats = ImageStatistics.getStatistics(ip, Measurements.MIN_MAX, reference.getLayer().getParent().getCalibrationCopy());
}
this.from_existing_min_and_max = from_existing_min_and_max;
this.visible_only = visible_only;
}
示例3: average2Dcorr
import ij.measure.Measurements; //导入依赖的package包/类
/**
* Wrapper calculating average 2D spatial correlation with specified delay in frames
*/
ImageProcessor average2Dcorr(int nDelay, int nStackSize)
{
ImageProcessor finalip, ip1,ip2;
ImageStack crosscorrstack;
int i,j;
i=1; j=i+nDelay;
crosscorrstack = new ImageStack(nCorrW,nCorrW);
while(j<=nStackSize)
{
imp.setSliceWithoutUpdate(i);
ip1 = getFloatversion(imp);
imp.setSliceWithoutUpdate(j);
ip2 = getFloatversion(imp);
//subtract average intensity value
//in general, something else can be here, like background value
ip1.subtract(ImageStatistics.getStatistics(ip1,Measurements.MEAN,null).mean);
ip2.subtract(ImageStatistics.getStatistics(ip2,Measurements.MEAN,null).mean);
if(nCalcMethod==0)
{finalip = x2D.calcDirectCorrelationImage(ip1,ip2);}
else
{finalip = x2D.calcFFTCorrelationImage(ip1, ip2);}
crosscorrstack.addSlice(null, finalip);
i++; j++;
}
//do average projection
Zproj.setImage(new ImagePlus("", crosscorrstack));
Zproj.setMethod(ZProjector.AVG_METHOD);
Zproj.doProjection();
finalip=Zproj.getProjection().getProcessor();
return finalip;
}
示例4: enhanceContrast
import ij.measure.Measurements; //导入依赖的package包/类
/**
* Enhance contrast in low-contrast thumbnail images.
*
* @param img
* @return BufferedImage
*/
public BufferedImage enhanceContrast(BufferedImage img) {
ImagePlus ip = ManipulationUtils.toImagePlus(PlanarImage.wrapRenderedImage(img), null, border);
ImageStatistics stats = ImageStatistics.getStatistics(ip.getProcessor(), Measurements.MIN_MAX, null);
double diff = Math.abs(stats.max - stats.min);
stats.histMin = Math.max(8, stats.histMin);
if (diff < 80 && diff > 4) {
contrastEnhancer.stretchHistogram(ip.getProcessor(), d, stats);
img = ManipulationUtils.toPlanarImage(ip.getProcessor()).getAsBufferedImage();
}
return img;
}
示例5: max
import ij.measure.Measurements; //导入依赖的package包/类
protected double max(Object param) {
RetVal val = arg.eval(param);
if(val.isMatrix()) { // FloatProcessor
return (FloatStatistics.getStatistics((FloatProcessor)val.get(), Measurements.MIN_MAX, null)).max;
} else if(val.isVector()) {
return VectorMath.max((Number[])val.get()).doubleValue();
} else if(val.isValue()) { // Double
return ((Double)val.get()).doubleValue();
}
throw new FormulaParserException("Variables can be only scalars, vectors, or matrices!");
}
示例6: min
import ij.measure.Measurements; //导入依赖的package包/类
protected double min(Object param) {
RetVal val = arg.eval(param);
if(val.isMatrix()) { // FloatProcessor
return (FloatStatistics.getStatistics((FloatProcessor)val.get(), Measurements.MIN_MAX, null)).min;
} else if(val.isVector()) {
return VectorMath.min((Number[])val.get()).doubleValue();
} else if(val.isValue()) { // Double
return ((Double)val.get()).doubleValue();
}
throw new FormulaParserException("Variables can be only scalars, vectors, or matrices!");
}
示例7: std
import ij.measure.Measurements; //导入依赖的package包/类
protected double std(Object param) {
RetVal val = arg.eval(param);
if(val.isMatrix()) { // FloatProcessor
return (FloatStatistics.getStatistics((FloatProcessor)val.get(), Measurements.STD_DEV, null)).stdDev;
} else if(val.isVector()) {
return VectorMath.stddev((Number[])val.get()).doubleValue();
} else if(val.isValue()) { // Double
return ((Double)val.get()).doubleValue();
}
throw new FormulaParserException("Variables can be only scalars, vectors, or matrices!");
}
示例8: mean
import ij.measure.Measurements; //导入依赖的package包/类
protected double mean(Object param) {
RetVal val = arg.eval(param);
if(val.isMatrix()) { // FloatProcessor
return (FloatStatistics.getStatistics((FloatProcessor)val.get(), Measurements.MEAN, null)).mean;
} else if(val.isVector()) {
return VectorMath.mean((Number[])val.get()).doubleValue();
} else if(val.isValue()) { // Double
return ((Double)val.get()).doubleValue();
}
throw new FormulaParserException("Variables can be only scalars, vectors, or matrices!");
}
示例9: median
import ij.measure.Measurements; //导入依赖的package包/类
protected double median(Object param) {
RetVal val = arg.eval(param);
if(val.isMatrix()) { // FloatProcessor
return (FloatStatistics.getStatistics((FloatProcessor)val.get(), Measurements.MEDIAN, null)).median;
} else if(val.isVector()) {
return VectorMath.median((Number[])val.get()).doubleValue();
} else if(val.isValue()) { // Double
return ((Double)val.get()).doubleValue();
}
throw new FormulaParserException("Variables can be only scalars, vectors, or matrices!");
}
示例10: calculateSummary
import ij.measure.Measurements; //导入依赖的package包/类
private final float[] calculateSummary(ResultsTable rt, ImagePlus image) {
float[] summaries = null;
if(defaultAnalysisOptions.isMeasureRgb()) {
summaries = new float[RESULTS_COLUMNS.length+11]; //9 for RGB and 2 for area & %area
}
else {
summaries = new float[RESULTS_COLUMNS.length+2];
}
float areaSum = calculateSum(rt.getColumn(RESULTS_COLUMNS[ResultsTable.AREA]));
Calibration calibration = image.getCalibration();
ImageProcessor ip = image.getProcessor();
Rectangle r = ip.getRoi();
ImageProcessor mask = ip.getMask();
double totalArea = 0;
if(mask != null) {
totalArea = ImageStatistics.getStatistics(ip, Measurements.AREA, calibration).area;
}
else {
totalArea = r.width*calibration.pixelWidth*r.height*calibration.pixelHeight;
}
float pctArea = areaSum*100.0f/(float)totalArea;
summaries[0] = areaSum;
summaries[1] = new BigDecimal(pctArea).round(MC).floatValue();
for(int i=0; i < RESULTS_COLUMNS.length; i++) {
float[] columnData = rt.getColumn(RESULTS_COLUMNS[i]);
float sumAvg = calculateSumAverage(columnData);
summaries[i+2] = new BigDecimal(sumAvg).round(MC).floatValue();
}
return summaries;
}
示例11: particleAnaylis
import ij.measure.Measurements; //导入依赖的package包/类
/**
* Realiza uma analise de particulas na imagem do bullet. Estes resultados serao analizados juntamente com as outras imagens de bullets de alternativas.
* @param bi
* @return
*/
protected ResultsTable particleAnaylis(BufferedImage bi) {
// wrapper de imagem do ImageJ para analise
ImagePlus ip = new ImagePlus("bullet", bi);
// prepara imagem para analise
contrastImageThresholds(ip, JazzOMRImageParser.THRESHOLD_HUANG);
// cria tabela de resultados
ResultsTable rt = new ResultsTable();
// determina parametros de analise
double area = bi.getHeight() * bi.getWidth();
double minArea = area * bulletMinAreaFactor;
double maxArea = area * bulletMaxAreaFactor;
/*
private double bulletMinAreaFactor = 0.10;
private double bulletMaxAreaFactor = 0.95;
private double bulletMinCirc = 0.30;
*/
// cria analizador de particulas para bullets
ParticleAnalyzer jpa = new ParticleAnalyzer(0, Measurements.AREA+Measurements.CIRCULARITY, rt, minArea, maxArea, bulletMinCirc, JazzOMRImageParser.MAX_CIRCULARITY);
// executa analise
jpa.analyze(ip);
// testa se foram encotradas particulas
//boolean checked = rt.getCounter() > 0;
//imageDocLogger.logBullet(checked,bi,rt);
//if(log.isDebugEnabled()){
//}
return rt;
}
示例12: particleAnaylis
import ij.measure.Measurements; //导入依赖的package包/类
/**
* Realiza uma analise de particulas na imagem do bullet. Estes resultados serao analizados juntamente com as outras imagens de bullets de alternativas.
*
* @param bi
* @return
*/
private ResultsTable particleAnaylis(BufferedImage bi) {
// wrapper de imagem do ImageJ para analise
ImagePlus ip = new ImagePlus("bullet", bi);
// prepara imagem para analise
contrastImageThresholds(ip, JazzOMRImageParser.THRESHOLD_HUANG);
// cria tabela de resultados
ResultsTable rt = new ResultsTable();
// determina parametros de analise
double area = bi.getHeight() * bi.getWidth();
double minArea = area * bulletMinAreaFactor;
double maxArea = area * bulletMaxAreaFactor;
/*
* private double bulletMinAreaFactor = 0.10; private double bulletMaxAreaFactor = 0.95; private double bulletMinCirc = 0.30;
*/
// cria analizador de particulas para bullets
ParticleAnalyzer jpa = new ParticleAnalyzer(0, Measurements.AREA + Measurements.CIRCULARITY, rt, minArea, maxArea, bulletMinCirc, JazzOMRImageParser.MAX_CIRCULARITY);
// executa analise
jpa.analyze(ip);
// testa se foram encotradas particulas
boolean checked = rt.getCounter() > 0;
if (log.isDebugEnabled()) {
imageDocLogger.logBullet(checked, bi, rt);
}
return rt;
}
示例13: run
import ij.measure.Measurements; //导入依赖的package包/类
public void run(String arg) {
ImagePlus current = IJ.getImage();
Analyzer.setMeasurement(Measurements.LABELS, true);
for (int i=0; i<current.getStackSize(); i++) {
current.setSlice(i+1);
IJ.showProgress(i+1, current.getStackSize());
IJ.run(current, "Measure", "");
}
}
示例14: updateMinAndMax
import ij.measure.Measurements; //导入依赖的package包/类
private void updateMinAndMax(ImagePlus imp, double[] limits)
{
ImageStack stack = imp.getImageStack();
for (int slice = 1; slice <= stack.getSize(); slice++)
{
ImageStatistics stats = ImageStatistics.getStatistics(stack.getProcessor(slice), Measurements.MIN_MAX,
null);
if (limits[0] > stats.min)
limits[0] = stats.min;
if (limits[1] < stats.max)
limits[1] = stats.max;
}
}
示例15: ContrastEnhancerWrapper
import ij.measure.Measurements; //导入依赖的package包/类
public ContrastEnhancerWrapper(final Patch reference) {
this.reference = reference;
if (null != reference) {
ImageProcessor ip = reference.getImageProcessor();
reference_stats = ImageStatistics.getStatistics(ip, Measurements.MIN_MAX, reference.getLayer().getParent().getCalibrationCopy());
}
}