CLIJ2 statisticsOfLabelledPixels bounding box bug

Hey folks and @haesleinhuepf,

I’m having some issues with the bounding box in the resultsTable output from clij2.statisticsOfLabelledPixels and clij2.statisticsOfBackgroundAndLabelledPixels . On 2D images, such as blobs.gif, I get correct bounding box statistics. On stacks no matter what I do, I always get BOUNDING_BOX_X/Y/Z values of zero. This means the BOUNDING_BOX_WIDTH/HEIGHT/DEPTH values are always just BOUNDING_BOX_END_X/Y/Z +1. I’m pretty sure this isn’t expected behaviour.

Minimal example (edited from a CLIJxAssistant script :wink: )

# To make this script run in Fiji, please activate 
# the clij and clij2 update sites in your Fiji 
# installation. Read more:

# Generator version:

from ij import IJ
from ij import WindowManager
from net.haesleinhuepf.clij2 import CLIJ2
from ij.measure 			import ResultsTable

# Init GPU
clij2 = CLIJ2.getInstance()

# Load image from disc 
imp = IJ.getImage()
# Push temp1612966471976.tif to GPU memory
image1 = clij2.push(imp);

# Copy
image2 = clij2.create(image1)
clij2.copy(image1, image2)

result = clij2.pull(image2)
result.setDisplayRange(16.0, 248.0)

# Gaussian Blur2D
image3 = clij2.create(image2)
sigma_x = 2
sigma_y = 2
clij2.gaussianBlur2D(image2, image3, sigma_x, sigma_y)

result = clij2.pull(image3)
result.setDisplayRange(26.0, 247.0)

# Threshold Otsu
image4 = clij2.create(image3)
clij2.thresholdOtsu(image3, image4)

result = clij2.pull(image4)
result.setDisplayRange(0.0, 1.0)

# Connected Components Labeling Box
image5 = clij2.create(image4.getDimensions(), clij2.Float )

clij2.connectedComponentsLabelingBox(image4, image5)

clij2.statisticsOfLabelledPixels(image1, image5, results)

result = clij2.pull(image5)
result.setDisplayRange(0.0, 61.0), "glasbey_on_dark", "")


Jim Rowe

1 Like

Hey @JimageJ1 ,

good catch! I can confirm that’s a bug in clij. It may also have affected minimum intensity measurements in labels. If just fixed it. The bugfix will come by next week with the next mini release. If you need it urgently, feel free to download (808.9 KB) and replace your clij2…jar in Fijis plugins folder with it. If you have time to test it and confirm that it also works for you now, that would be fantastic.

Thanks a lot! You made clij better today! :heart:

Let me know if you see anything else that’s suspicious.


1 Like

Thanks for fixing it so quickly, it’s working perfectly!

1 Like

When my baby (clij) has an “Ouch”, I’m happy to take care of it while attending webinars :wink:

Thank you again!