Skip to content

Commit ec7bfcf

Browse files
committed
Use Integer to store tree numbers.
This way we overcome the limitation of Short.MAX_VALUE as the maximum number of trees.
1 parent 1222fd7 commit ec7bfcf

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/main/java/skeleton_analysis/AnalyzeSkeleton_.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import ij.measure.ResultsTable;
1616
import ij.plugin.filter.PlugInFilter;
1717
import ij.process.ByteProcessor;
18+
import ij.process.FloatProcessor;
1819
import ij.process.ImageProcessor;
1920
import ij.process.ShortProcessor;
2021

@@ -1841,15 +1842,15 @@ private ImageStack markTrees(ImageStack taggedImage)
18411842
if(debug)
18421843
IJ.log("=== Mark Trees ===");
18431844
// Create output image
1844-
ImageStack outputImage = new ImageStack(this.width, this.height, taggedImage.getColorModel());
1845+
ImageStack outputImage = new ImageStack( this.width, this.height );
18451846
for (int z = 0; z < depth; z++)
18461847
{
1847-
outputImage.addSlice(taggedImage.getSliceLabel(z+1), new ShortProcessor(this.width, this.height));
1848+
outputImage.addSlice(taggedImage.getSliceLabel(z+1), new FloatProcessor(this.width, this.height));
18481849
}
18491850

18501851
this.numOfTrees = 0;
18511852

1852-
short color = 0;
1853+
int color = 0;
18531854

18541855
// Visit trees starting at end points
18551856
for(int i = 0; i < this.totalNumberOfEndPoints; i++)
@@ -1861,10 +1862,10 @@ private ImageStack markTrees(ImageStack taggedImage)
18611862

18621863
color++;
18631864

1864-
if(color == Short.MAX_VALUE)
1865+
if(color == Integer.MAX_VALUE)
18651866
{
1866-
IJ.error("More than " + (Short.MAX_VALUE-1) +
1867-
" skeletons in the image. AnalyzeSkeleton can only process up to "+ (Short.MAX_VALUE-1));
1867+
IJ.error("More than " + (Integer.MAX_VALUE-1) +
1868+
" skeletons in the image. AnalyzeSkeleton can only process up to "+ (Integer.MAX_VALUE-1));
18681869
return null;
18691870
}
18701871

@@ -1986,7 +1987,7 @@ private ImageStack markTrees(ImageStack taggedImage)
19861987
* @return number of voxels in the tree
19871988
*/
19881989
private int visitTree(Point startingPoint, ImageStack outputImage,
1989-
short color)
1990+
int color)
19901991
{
19911992
int numOfVoxels = 0;
19921993

@@ -2966,10 +2967,10 @@ private void setPixel(ImageStack image, int x, int y, int z, byte value)
29662967
* @param z z- coordinate (in image stacks the indexes start at 1)
29672968
* @param value pixel value
29682969
*/
2969-
private void setPixel(ImageStack image, int x, int y, int z, short value)
2970+
private void setPixel(ImageStack image, int x, int y, int z, float value)
29702971
{
29712972
if(x >= 0 && x < this.width && y >= 0 && y < this.height && z >= 0 && z < this.depth)
2972-
((short[]) image.getPixels(z + 1))[x + y * this.width] = value;
2973+
((float[]) image.getPixels(z + 1))[x + y * this.width] = value;
29732974
} // end setPixel
29742975

29752976

0 commit comments

Comments
 (0)