public double[] getXValues() { double[] values = new double[stats.nBins]; for (int i=0; i<stats.nBins; i++) values[i] = cal.getCValue(stats.histMin+i*stats.binSize); return values; }
public double[] getXValues() { double[] values = new double[stats.nBins]; for(int i = 0; i < stats.nBins; i++) { values[i] = cal.getCValue(stats.histMin + i * stats.binSize); } return values; }
void calculateMedian(int[] hist, int first, int last, Calibration cal) { //ij.IJ.log("calculateMedian: "+first+" "+last+" "+hist.length+" "+pixelCount); if (pixelCount==0) { median = Double.NaN; return; } double sum = 0; int i = first-1; double halfCount = pixelCount/2.0; do { sum += hist[++i]; } while (sum<=halfCount && i<last); median = cal!=null?cal.getCValue(i):i; }
public double[] getXValues() { double[] values = new double[stats.nBins]; for (int i=0; i<stats.nBins; i++) values[i] = cal.getCValue(stats.histMin+i*stats.binSize); return values; }
void calculateMedian(int[] hist, int first, int last, Calibration cal) { //ij.IJ.log("calculateMedian: "+first+" "+last+" "+hist.length+" "+pixelCount); if (pixelCount==0) { median = Double.NaN; return; } double sum = 0; int i = first-1; double halfCount = pixelCount/2.0; do { sum += hist[++i]; } while (sum<=halfCount && i<last); median = cal!=null?cal.getCValue(i):i; }
double getMode(Calibration cal) { long count; long longMaxCount = 0L; for (int i=0; i<nBins; i++) { count = longHistogram[i]; if (count>longMaxCount) { longMaxCount = count; mode = i; } } if (longMaxCount<=Integer.MAX_VALUE) maxCount = (int)longMaxCount; else maxCount = Integer.MAX_VALUE; double tmode = histMin+mode*binSize; if (cal!=null) tmode = cal.getCValue(tmode); return tmode; }
/** Converts a raw pixel value to a density calibrated value. */ public double getCValue(double value) { if (function==NONE) return value; else { if (function>=STRAIGHT_LINE && function<=EXP_RECOVERY && coefficients!=null) { double v = CurveFitter.f(function, coefficients, value); if (zeroClip && v<0.0) return 0.0; else return v; } else return getCValue((int)value); } }
/** Converts a raw pixel value to a density calibrated value. */ public double getCValue(double value) { if (function==NONE) return value; else { if (function>=STRAIGHT_LINE && function<=EXP_RECOVERY && coefficients!=null) { double v = CurveFitter.f(function, coefficients, value); if (zeroClip && v<0.0) return 0.0; else return v; } else return getCValue((int)value); } }
protected void copyToClipboard() { Clipboard systemClipboard = null; try {systemClipboard = getToolkit().getSystemClipboard();} catch (Exception e) {systemClipboard = null; } if (systemClipboard==null) {IJ.error("Unable to copy to Clipboard."); return;} IJ.showStatus("Copying histogram values..."); CharArrayWriter aw = new CharArrayWriter(stats.nBins*4); PrintWriter pw = new PrintWriter(aw); for (int i=0; i<stats.nBins; i++) pw.print(ResultsTable.d2s(cal.getCValue(stats.histMin+i*stats.binSize), digits)+"\t"+histogram[i]+"\n"); String text = aw.toString(); pw.close(); StringSelection contents = new StringSelection(text); systemClipboard.setContents(contents, this); IJ.showStatus(text.length() + " characters copied to Clipboard"); }
protected void showList() { StringBuilder sb = new StringBuilder(); String vheading = stats.binSize == 1.0 ? "value" : "bin start"; if(cal.calibrated() && !cal.isSigned16Bit()) { for(int i = 0; i < stats.nBins; i++) { sb.append(i).append("\t").append(ResultsTable.d2s(cal.getCValue(stats.histMin + i * stats.binSize), digits)).append("\t").append(histogram[i]).append("\n"); } TextWindow tw = new TextWindow(getTitle(), "level\t" + vheading + "\tcount", sb.toString(), 200, 400); } else { for(int i = 0; i < stats.nBins; i++) { sb.append(ResultsTable.d2s(cal.getCValue(stats.histMin + i * stats.binSize), digits)).append("\t").append(histogram[i]).append("\n"); } TextWindow tw = new TextWindow(getTitle(), vheading + "\tcount", sb.toString(), 200, 400); } }
protected void copyToClipboard() { Clipboard systemClipboard = null; try {systemClipboard = getToolkit().getSystemClipboard();} catch (Exception e) {systemClipboard = null; } if (systemClipboard==null) {IJ.error("Unable to copy to Clipboard."); return;} IJ.showStatus("Copying histogram values..."); CharArrayWriter aw = new CharArrayWriter(stats.nBins*4); PrintWriter pw = new PrintWriter(aw); for (int i=0; i<stats.nBins; i++) pw.print(ResultsTable.d2s(cal.getCValue(stats.histMin+i*stats.binSize), digits)+"\t"+histogram[i]+"\n"); String text = aw.toString(); pw.close(); StringSelection contents = new StringSelection(text); systemClipboard.setContents(contents, this); IJ.showStatus(text.length() + " characters copied to Clipboard"); }
final String getIndex(int index) { if (bitDepth==8) return (""+index); ImageProcessor ip = imp.getProcessor(); double min = ip.getMin(); double max = ip.getMax(); Calibration cal = imp.getCalibration(); min = cal.getCValue(min); max = cal.getCValue(max); double value = min + (index/255.0)*(max-min); int digits = (max-min)<100?2:0; return (index+" ("+IJ.d2s(value,digits)+")"); }
final String getIndex(int index) { if (bitDepth==8) return (""+index); ImageProcessor ip = imp.getProcessor(); double min = ip.getMin(); double max = ip.getMax(); Calibration cal = imp.getCalibration(); min = cal.getCValue(min); max = cal.getCValue(max); double value = min + (index/255.0)*(max-min); int digits = (max-min)<100?2:0; return (index+" ("+IJ.d2s(value,digits)+")"); }
private void applyRoiAsFilter() { Rectangle roi = this.imp.getProcessor().getRoi(); int left = max(frame.x, roi.x) - frame.x; int right = min((frame.x + frame.width - 1), (roi.x + roi.width - 1)) - frame.x; int indexLeft = (int) (left * ((double) histogram.length) / HIST_WIDTH); int indexRight = (int) (right * ((double) histogram.length) / HIST_WIDTH); double leftVal = cal.getCValue(stats.histMin + indexLeft * stats.binSize); // param > val double rightVal = cal.getCValue(stats.histMin + indexRight * stats.binSize); // param < val IJResultsTable.getResultsTable().tableWindow.getFilter().addNewFilter(paramName, leftVal, rightVal); } }
void getMinAndMax() { Variable min = getFirstVariable(); Variable max = getLastVariable(); ImagePlus imp = getImage(); double v1 = imp.getDisplayRangeMin(); double v2 = imp.getDisplayRangeMax(); Calibration cal = imp.getCalibration(); v1 = cal.getCValue(v1); v2 = cal.getCValue(v2); min.setValue(v1); max.setValue(v2); }
void getMinAndMax() { Variable min = getFirstVariable(); Variable max = getLastVariable(); ImagePlus imp = getImage(); double v1 = imp.getDisplayRangeMin(); double v2 = imp.getDisplayRangeMax(); Calibration cal = imp.getCalibration(); v1 = cal.getCValue(v1); v2 = cal.getCValue(v2); min.setValue(v1); max.setValue(v2); }
public String getValueAsStringI5d(final int x, final int y) { if (win != null && win instanceof PlotWindow) return ""; final Calibration cal = getCalibration(); final int v = getProcessor().getPixel(x, y); final int type = getType(); switch (type) { case GRAY8: case GRAY16: final double cValue = cal.getCValue(v); if (cValue == v) return ("" + v); return ("" + IJ.d2s(cValue) + " (" + v + ")"); case GRAY32: return ("" + Float.intBitsToFloat(v)); default: return (""); } }
void getThreshold() { Variable lower = getFirstVariable(); Variable upper = getLastVariable(); ImagePlus imp = getImage(); ImageProcessor ip = getProcessor(); double t1 = ip.getMinThreshold(); double t2 = ip.getMaxThreshold(); if (t1==ImageProcessor.NO_THRESHOLD) { t1 = -1; t2 = -1; } else { Calibration cal = imp.getCalibration(); t1 = cal.getCValue(t1); t2 = cal.getCValue(t2); } lower.setValue(t1); upper.setValue(t2); }