Returns the perimeter length.
()
| 369 | |
| 370 | /** Returns the perimeter length. */ |
| 371 | public double getLength() { |
| 372 | double pw=1.0, ph=1.0; |
| 373 | if (imp!=null) { |
| 374 | Calibration cal = imp.getCalibration(); |
| 375 | pw = cal.pixelWidth; |
| 376 | ph = cal.pixelHeight; |
| 377 | } |
| 378 | double perimeter = 2.0*width*pw + 2.0*height*ph; |
| 379 | if (cornerDiameter > 0) { //using Ramanujan's approximation for the circumference of an ellipse |
| 380 | double a = 0.5*Math.min(cornerDiameter, width)*pw; |
| 381 | double b = 0.5*Math.min(cornerDiameter, height)*ph; |
| 382 | perimeter += Math.PI*(3*(a + b) - Math.sqrt((3*a + b)*(a + 3*b))) -4*(a+b); |
| 383 | } |
| 384 | return perimeter; |
| 385 | } |
| 386 | |
| 387 | /** Returns Feret's diameter, the greatest distance between |
| 388 | any two points along the ROI boundary. */ |