(boolean calibrated)
| 3995 | } |
| 3996 | |
| 3997 | void getStatistics(boolean calibrated) { |
| 3998 | Variable count = getFirstVariable(); |
| 3999 | Variable mean=null, min=null, max=null, std=null, hist=null; |
| 4000 | int params = AREA+MEAN+MIN_MAX; |
| 4001 | interp.getToken(); |
| 4002 | int arg = 1; |
| 4003 | while (interp.token==',') { |
| 4004 | arg++; |
| 4005 | switch (arg) { |
| 4006 | case 2: mean = getVariable(); break; |
| 4007 | case 3: min = getVariable(); break; |
| 4008 | case 4: max = getVariable(); break; |
| 4009 | case 5: std = getVariable(); params += STD_DEV; break; |
| 4010 | case 6: hist = getArrayVariable(); break; |
| 4011 | default: interp.error("')' expected"); |
| 4012 | } |
| 4013 | interp.getToken(); |
| 4014 | } |
| 4015 | if (interp.token!=')') interp.error("')' expected"); |
| 4016 | ImagePlus imp = getImage(); |
| 4017 | Calibration cal = calibrated?imp.getCalibration():null; |
| 4018 | ImageProcessor ip = getProcessor(); |
| 4019 | ImageStatistics stats = null; |
| 4020 | Roi roi = imp.getRoi(); |
| 4021 | int lineWidth = Line.getWidth(); |
| 4022 | if (roi!=null && roi.isLine() && lineWidth>1) { |
| 4023 | ImageProcessor ip2; |
| 4024 | if (roi.getType()==Roi.LINE) { |
| 4025 | ip2 = ip; |
| 4026 | Rectangle saveR = ip2.getRoi(); |
| 4027 | ip2.setRoi(roi.getPolygon()); |
| 4028 | stats = ImageStatistics.getStatistics(ip2, params, cal); |
| 4029 | ip2.setRoi(saveR); |
| 4030 | } else { |
| 4031 | ip2 = (new Straightener()).straightenLine(imp, lineWidth); |
| 4032 | stats = ImageStatistics.getStatistics(ip2, params, cal); |
| 4033 | } |
| 4034 | } else if (roi!=null && roi.isLine()) { |
| 4035 | ProfilePlot profile = new ProfilePlot(imp); |
| 4036 | double[] values = profile.getProfile(); |
| 4037 | ImageProcessor ip2 = new FloatProcessor(values.length, 1, values); |
| 4038 | if (roi instanceof Line) { |
| 4039 | Line l = (Line)roi; |
| 4040 | if ((l.y1==l.y2||l.x1==l.x2)&&l.x1==l.x1d&& l.y1==l.y1d&& l.x2==l.x2d&& l.y2==l.y2d) |
| 4041 | ip2.setRoi(0, 0, ip2.getWidth()-1, 1); |
| 4042 | } |
| 4043 | stats = ImageStatistics.getStatistics(ip2, params, cal); |
| 4044 | } else { |
| 4045 | ip.setRoi(roi); |
| 4046 | stats = ImageStatistics.getStatistics(ip, params, cal); |
| 4047 | } |
| 4048 | if (calibrated) |
| 4049 | count.setValue(stats.area); |
| 4050 | else |
| 4051 | count.setValue(stats.pixelCount); |
| 4052 | if (mean!=null) mean.setValue(stats.mean); |
| 4053 | if (min!=null) min.setValue(stats.min); |
| 4054 | if (max!=null) max.setValue(stats.max); |
no test coverage detected