2 import ij.measure.Calibration;
11 this(ip, AREA+MEAN+MODE+MIN_MAX, null);
21 int minThreshold,maxThreshold;
23 {minThreshold=0; maxThreshold=255;}
26 float[] cTable = cal!=null?cal.
getCTable():null;
28 getCalibratedStatistics(minThreshold,maxThreshold,cTable);
30 getRawStatistics(minThreshold,maxThreshold);
31 if ((mOptions&MIN_MAX)!=0) {
33 getCalibratedMinAndMax(minThreshold, maxThreshold, cTable);
35 getRawMinAndMax(minThreshold, maxThreshold);
37 if ((mOptions&ELLIPSE)!=0)
39 else if ((mOptions&CENTROID)!=0)
40 getCentroid(ip, minThreshold, maxThreshold);
41 if ((mOptions&CENTER_OF_MASS)!=0)
42 getCenterOfMass(ip, minThreshold, maxThreshold, cTable);
45 void getCalibratedStatistics(
int minThreshold,
int maxThreshold,
float[] cTable) {
52 for (
int i=minThreshold; i<=maxThreshold; i++) {
58 sum2 += (value*value)*count;
64 area = pixelCount*pw*ph;
65 mean = sum/pixelCount;
66 umean = (double)isum/pixelCount;
68 calculateStdDev(pixelCount,sum,sum2);
73 void getCentroid(ImageProcessor ip,
int minThreshold,
int maxThreshold) {
74 byte[] pixels = (byte[])ip.getPixels();
75 byte[] mask = ip.getMaskArray();
76 boolean limit = minThreshold>0 || maxThreshold<255;
77 int count=0, xsum=0, ysum=0,i,mi,v;
78 for (
int y=ry,my=0; y<(ry+rh); y++,my++) {
81 for (
int x=rx; x<(rx+rw); x++) {
82 if (mask==null||mask[mi++]!=0) {
85 if (v>=minThreshold&&v<=maxThreshold) {
99 xCentroid = ((double)xsum/count+0.5)*pw;
100 yCentroid = ((double)ysum/count+0.5)*ph;
103 void getCenterOfMass(ImageProcessor ip,
int minThreshold,
int maxThreshold,
float[] cTable) {
104 byte[] pixels = (byte[])ip.getPixels();
105 byte[] mask = ip.getMaskArray();
107 double dv, count=0.0, xsum=0.0, ysum=0.0;
108 for (
int y=ry,my=0; y<(ry+rh); y++,my++) {
111 for (
int x=rx; x<(rx+rw); x++) {
112 if (mask==null || mask[mi++]!=0) {
114 if (v>=minThreshold&&v<=maxThreshold) {
115 dv = ((cTable!=null)?cTable[v]:v)+Double.MIN_VALUE;
124 xCenterOfMass = (xsum/count+0.5)*pw;
125 yCenterOfMass = (ysum/count+0.5)*ph;
128 void getCalibratedMinAndMax(
int minThreshold,
int maxThreshold,
float[] cTable) {
129 min = Double.MAX_VALUE;
130 max = -Double.MAX_VALUE;
132 for (
int i=minThreshold; i<=maxThreshold; i++) {
133 if (histogram[i]>0) {