Connectivity implements PlugIn { public double getConnDensity(final ImagePlus imp, final double connectivity) { setDimensions(imp); final Calibration cal = imp.getCalibration(); final double vW = cal.pixelWidth; final double vH = cal.pixelHeight; final double vD = cal.pixelDepth; final double stackVolume = width * height * depth * vW * vH * vD; final double connDensity = connectivity / stackVolume; return connDensity; }  @Override void run(final String arg); double getConnDensity(final ImagePlus imp, final double connectivity); double getConnectivity(final double deltaChi); double getDeltaChi(final ImagePlus imp, final double sumEuler); double getSumEuler(final ImagePlus imp);  }
@Test public void testGetConnDensity() { final ImagePlus imp = boxFrame(32, 64, 128); final Calibration cal = imp.getCalibration(); cal.pixelDepth = 0.2; cal.pixelHeight = 0.2; cal.pixelWidth = 0.2; final double stackVolume = (32 + 64) * (64 + 64) * (128 + 64) * (0.2 * 0.2 * 0.2); final double sumEuler = conn.getSumEuler(imp); final double deltaChi = conn.getDeltaChi(imp, sumEuler); final double connectivity = conn.getConnectivity(deltaChi); final double connD = conn.getConnDensity(imp, connectivity); assertEquals(5 / stackVolume, connD, 1e-12); }