Hello~everyone~
I had a problem while using the segment geometry module.
The module would work sometimes, but it will not work most of the time and show me an error message as below…
Slicer has caught an application error, please save your work and restart.
If you have a repeatable sequence of steps that causes this message, please report the issue following instructions available at http://slicer.org
The message detail is:
Exception thrown in event: D:\D\P\Slicer-0-build\ITK\Modules\Segmentation\ConnectedComponents\include\itkConnectedComponentImageFilter.hxx:145:
ITK ERROR: ConnectedComponentImageFilter(000002D6F17C9430): Number of objects (754) greater than maximum of output pixel type (255).
Does anyone have an idea why this might be happening?
This error message suggests that your input segmentation is extremely noisy (contains many disconnected islands). You can apply Smoothing effect or Islands effect’s Keep largest island operation, or use more appropriate segmentation tools, which generate less noisy segment.
Hi. I’m creating a thresholdedImagesArray by thresholding an image with a fixed max value and an array of min values, then I do islandsMath effect and then another threshold to keep the largest island to each imageElement of the array.
If the number of islands is big while processing an element of the array I wouldn’t need it (i.e. numberOfIslands>255). And I want this because processing a unsignedChar image should be order of magnitudes faster than processing an unsignedShort image.
But I cannot batch process this because Slicer keeps throwing the itk exception, could you help?
Thresholding speed on unsigned char/short should be both very fast. Do you have any performance measurement results that shows how much faster unsigned char thresholding is? I would expect that it is 20-30% faster, not magnitudes (1000-10000%) faster.
Islands effect needs to be able to assign unique labels to each island, so if you have more than 255 islands then I don’t think you can use unsigned char.
However, you can both reduce the number of islands and hugely increase processing speed by processing the image at lower resolution (or at multiple resolutions).
I think some of the previous post talk about about the exception being annoying and not useful… I would rather have the number of islands to be extracted that the exception informs rather than the overflow exception itself.
The exception is problematic because it doesn’t allow batch processing.
Do you have any idea to on how to skip processing (and avoid the exception) while creating the labelMapsArray I described using unsigned char images?
I think there should be a way to handle the exception on IslandMath filter definition on C++ at least
Or maybe I could use itk connectivity filter on python myself. Would that allow me to manage the exception?
If you use vtkITKIslandMath from your own script and use an unsigned char input then you can run into the problem that the ITK exception is not caught. I agree that it would be better to catch the exception and log a VTK error instead (that can be captured in Python using an error sink). See an example here. If you have time, please make this change, check if it works for you and if it does then send a pull request.
Note that (depending on how the algorithm is implemented) more than 255 label values might be needed temporarily, even if in the final contains less than 255 islands.