this.width = ip.getWidth(); this.height = ip.getHeight(); setup(ip, cal); double minT = ip.getMinThreshold(); double minThreshold,maxThreshold; saveThreshold(minThreshold, maxThreshold, cal); getStatistics(ip, minThreshold, maxThreshold); if ((mOptions&MODE)!=0) getMode(); if ((mOptions&ELLIPSE)!=0 || (mOptions&SHAPE_DESCRIPTORS)!=0) fitEllipse(ip, mOptions); else if ((mOptions&CENTROID)!=0) getCentroid(ip, minThreshold, maxThreshold); if ((mOptions&(CENTER_OF_MASS|SKEWNESS|KURTOSIS))!=0) calculateMoments(ip, minThreshold, maxThreshold); if ((mOptions&MEDIAN)!=0) getMedian(ip, minThreshold, maxThreshold); if ((mOptions&AREA_FRACTION)!=0) calculateAreaFraction(ip);
public static ImageStatistics getStatistics(ImageProcessor ip, int mOptions, Calibration cal) { Object pixels = ip.getPixels(); if (pixels instanceof byte[]) return new ByteStatistics(ip, mOptions, cal); else if (pixels instanceof short[]) return new ShortStatistics(ip, mOptions, cal); else if (pixels instanceof int[]) return new ColorStatistics(ip, mOptions, cal); else if (pixels instanceof float[]) return new FloatStatistics(ip, mOptions, cal); else throw new IllegalArgumentException("Pixels are not byte, short, int or float"); }
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!"); }
mean = sum/pixelCount; umean = mean; calculateStdDev(pixelCount, sum, sum2);
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!"); }
mean = sum/pixelCount; umean = mean; calculateStdDev(pixelCount, sum, sum2);
this.width = ip.getWidth(); this.height = ip.getHeight(); setup(ip, cal); double minT = ip.getMinThreshold(); double minThreshold,maxThreshold; saveThreshold(minThreshold, maxThreshold, cal); getStatistics(ip, minThreshold, maxThreshold); if ((mOptions&MODE)!=0) getMode(); if ((mOptions&ELLIPSE)!=0 || (mOptions&SHAPE_DESCRIPTORS)!=0) fitEllipse(ip, mOptions); else if ((mOptions&CENTROID)!=0) getCentroid(ip, minThreshold, maxThreshold); if ((mOptions&(CENTER_OF_MASS|SKEWNESS|KURTOSIS))!=0) calculateMoments(ip, minThreshold, maxThreshold); if ((mOptions&MEDIAN)!=0) getMedian(ip, minThreshold, maxThreshold); if ((mOptions&AREA_FRACTION)!=0) calculateAreaFraction(ip);
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!"); }
ImageStatistics getStatistics(ImageProcessor ip, int mOptions, Calibration cal) { switch (imageType2) { case BYTE: return new ByteStatistics(ip, mOptions, cal); case SHORT: return new ShortStatistics(ip, mOptions, cal); case FLOAT: return new FloatStatistics(ip, mOptions, cal); case RGB: return new ColorStatistics(ip, mOptions, cal); default: return null; } }
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!"); }
public static ImageStatistics getStatistics(ImageProcessor ip, int mOptions, Calibration cal) { Object pixels = ip.getPixels(); if (pixels instanceof byte[]) return new ByteStatistics(ip, mOptions, cal); else if (pixels instanceof short[]) return new ShortStatistics(ip, mOptions, cal); else if (pixels instanceof int[]) return new ColorStatistics(ip, mOptions, cal); else if (pixels instanceof float[]) return new FloatStatistics(ip, mOptions, cal); else throw new IllegalArgumentException("Pixels are not byte, short, int or float"); }
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!"); }
ImageStatistics getStatistics(ImageProcessor ip, int mOptions, Calibration cal) { switch (imageType2) { case BYTE: return new ByteStatistics(ip, mOptions, cal); case SHORT: return new ShortStatistics(ip, mOptions, cal); case FLOAT: return new FloatStatistics(ip, mOptions, cal); case RGB: return new ColorStatistics(ip, mOptions, cal); default: return null; } }
private void addMean(int column, int start) { double value = Double.NaN; if (start!=-1) { float[] c = column>=0?rt.getColumn(column):null; if (c!=null) { ImageProcessor ip = new FloatProcessor(c.length, 1, c, null); if (ip==null) return; ip.setRoi(start, 0, ip.getWidth()-start, 1); ip = ip.crop(); ImageStatistics stats = new FloatStatistics(ip); if (stats==null) return; value = stats.mean; } } summaryTable.addValue(ResultsTable.getDefaultHeading(column), value); }
private void addMean(int column, int start) { double value = Double.NaN; if (start!=-1) { float[] c = column>=0?rt.getColumn(column):null; if (c!=null) { ImageProcessor ip = new FloatProcessor(c.length, 1, c, null); if (ip==null) return; ip.setRoi(start, 0, ip.getWidth()-start, 1); ip = ip.crop(); ImageStatistics stats = new FloatStatistics(ip); if (stats==null) return; value = stats.mean; } } summaryTable.addValue(ResultsTable.getDefaultHeading(column), value); }