diff --git a/Legacy/bonej/src/main/java/org/bonej/plugins/ConnectedComponents.java b/Legacy/bonej/src/main/java/org/bonej/plugins/ConnectedComponents.java index af92b853e..d58e0053e 100644 --- a/Legacy/bonej/src/main/java/org/bonej/plugins/ConnectedComponents.java +++ b/Legacy/bonej/src/main/java/org/bonej/plugins/ConnectedComponents.java @@ -84,7 +84,9 @@ public class ConnectedComponents { /** Background value */ public static final int BACK = 0; /** 2^23 - greatest integer that can be represented precisely by a float */ - static final int MAX_LABEL = 8388608; + public static final int MAX_FINAL_LABEL = 8388608; + /** maximum label value to use during intermediate processing */ + static final int MAX_LABEL = Integer.MAX_VALUE; /** number of particle labels */ private static int nParticles; diff --git a/Legacy/bonej/src/main/java/org/bonej/plugins/ParticleCounter.java b/Legacy/bonej/src/main/java/org/bonej/plugins/ParticleCounter.java index 92925c86a..1afb4d852 100644 --- a/Legacy/bonej/src/main/java/org/bonej/plugins/ParticleCounter.java +++ b/Legacy/bonej/src/main/java/org/bonej/plugins/ParticleCounter.java @@ -236,6 +236,9 @@ public void run(final String arg) { final int[][] particleLabels = (int[][]) result[1]; final long[] particleSizes = (long[]) result[2]; final int nParticles = particleSizes.length; + + if (nParticles > ConnectedComponents.MAX_FINAL_LABEL) + IJ.log("Number of particles ("+nParticles+") exceeds the accurate display range (2^23) of the 32-bit float particle image"); final double[] volumes = ParticleAnalysis.getVolumes(imp, particleSizes);