8 public int[] histogram;
17 public double xCentroid;
18 public double yCentroid;
19 public double xCenterOfMass;
20 public double yCenterOfMass;
21 public double roiX, roiY, roiWidth, roiHeight;
31 public double histMin;
32 public double histMax;
34 public int nBins = 256;
35 public double binSize = 1.0;
37 protected int width, height;
38 protected int rx, ry, rw, rh;
39 protected double pw, ph;
55 void getRawMinAndMax(
int minThreshold,
int maxThreshold) {
56 int min = minThreshold;
57 while ((histogram[min] == 0) && (min < 255))
61 int max = maxThreshold;
62 while ((histogram[max] == 0) && (max > 0))
67 void getRawStatistics(
int minThreshold,
int maxThreshold) {
73 for (
int i=minThreshold; i<=maxThreshold; i++) {
78 sum2 += (value*value)*count;
84 area = pixelCount*pw*ph;
85 mean = sum/pixelCount;
88 calculateStdDev(pixelCount, sum, sum2);
93 void calculateStdDev(
int n,
double sum,
double sum2) {
96 stdDev = (n*sum2-sum*sum)/n;
98 stdDev = Math.sqrt(stdDev/(n-1.0));
106 void setup(ImageProcessor ip, Calibration cal) {
107 width = ip.getWidth();
108 height = ip.getHeight();
109 Rectangle roi = ip.getRoi();
125 ph = cal.pixelHeight;
137 void getCentroid(ImageProcessor ip) {
138 byte[] mask = ip.getMaskArray();
139 int count=0, xsum=0, ysum=0,mi;
140 for (
int y=ry,my=0; y<(ry+rh); y++,my++) {
142 for (
int x=rx; x<(rx+rw); x++) {
143 if (mask==null||mask[mi++]!=0) {
150 xCentroid = ((double)xsum/count+0.5)*pw;
151 yCentroid = ((double)ysum/count+0.5)*ph;
154 void fitEllipse(ImageProcessor ip) {
156 ef =
new EllipseFitter();
158 double psize = (Math.abs(pw-ph)/pw)<.01?pw:0.0;
168 public void drawEllipse(ImageProcessor ip) {