Registry / ai-ml / itk-segmentation

itk-segmentation

JSON →
library5.4.6pypypi✓ verified 85d ago

ITK is an open-source, cross-platform toolkit for N-dimensional image analysis, segmentation, and registration. The itk-segmentation subpackage provides segmentation algorithms, including level sets, watershed, region growing, and threshold-based methods. Current version 5.4.6 requires Python >=3.8, with ongoing development toward ITK 6.0 (currently in beta). Regular maintenance releases occur approximately quarterly.

pip install itk-segmentation
INSTALL
IMPORT
SIG · ITK-SEGMENTATION
I
itk-segmentation
ai-mlpythonv5.4.6
Install
15.9s avg
Import
542ms
Disk
1352MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v5.4.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
build_error
glibc
py 3.103.95 runs
installs and imports cleanly · install 15.9s · import 0.542s · 1331.2MB
1352MB installed
● package 1352MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

itk.SegmentationLevelSetImageFilter
import itk
from itkSegmentation import SegmentationLevelSetImageFilter
ITK uses a top-level Python module 'itk' and nested classes; never import subpackages directly.
ImageFileReader
import itk; reader = itk.ImageFileReader[type].New()
from itk import ImageFileReader
ImageFileReader is a template class; you must specify the image type via brackets.

Reads an image, applies a binary threshold, and writes the segmentation.

import itk # Read an image (replace with actual file path or use a sample image) image = itk.imread('input.nii.gz', itk.F) # Apply binary threshold segmentation segmented = itk.binary_threshold_image_filter( image, lower_threshold=100, upper_threshold=500, inside_value=255, outside_value=0 ) # Write result itk.imwrite(segmented, 'segmented.nii.gz')
Debug
Known issues
gotchaITK uses snake_case for simple filter wrappers (e.g., itk.binary_threshold_image_filter) but PascalCase for full filter classes (e.g., itk.BinaryThresholdImageFilter).
fix
For quick scripting use itk.function_name; for advanced control use itk.ClassName.New()
affects: 5.x
breakingITK 6.0 requires C++17 compiler; not all legacy systems have it. Python wheels may not be available for all platforms.
fix
Ensure your build environment supports C++17. Consider using conda or pre-built wheels if available.
affects: >=6.0
deprecatedImageIO factory classes like itk.GDCMImageIO are replaced by itk.GDCMImageIO.New() or automatically detected.
fix
Use itk.imread/imwrite without specifying ImageIO. If needed, use itk.ImageIOFactory.CreateImageIO and set manually.
affects: 5.x
gotchaitk.imread assumes fixed integer types (e.g., itk.UC for unsigned char). For floating point, use itk.F or itk.D.
fix
Explicitly specify pixel type: itk.imread('file', itk.F) reads as float.
affects: 5.x
gotchaTemplate parameters in ITK are specified via brackets: filter = itk.BinaryThresholdImageFilter[InputImageType, OutputImageType].New()
fix
Always provide the image types when using class-based filters; use simple wrappers for convenience.
affects: 5.x
Errors
Common errors & fixes
AttributeError: module 'itk' has no attribute 'SegmentationLevelSetImageFilter'
ITK's Python module does not expose all C++ classes directly; some require loading submodules or using different names.
fix
Use functional interface: itk.segmentation_level_set_image_filter(...) or import the specific filter via itk.LevelSetExtension.LevelSetExtensionBase.
RuntimeError: ImportError: libitkcommon.so.6: cannot open shared object file
Missing ITK shared libraries in the system's library path.
fix
Install the 'itk' metapackage or use conda: conda install -c conda-forge itk
TypeError: in method 'New', argument 1 of type 'itk::ImageIOBase::Pointer'
Passing an invalid argument to a filter's New method, often due to wrong template type.
fix
Check that template types and dimensions match. For example: itk.CastImageFilter[InputType, OutputType].New()
ValueError: could not broadcast input array from shape (512,512) into shape (512,512,1)
ITK expects 2D image arrays for 2D images, not 3D with singleton dimension.
fix
Use itk.GetArrayFromImage to get a numpy array, then squeeze: np.squeeze(array) if needed.
Upgrade
Version history
5.4.6latest on PyPI · released Apr 23, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
itk-segmentation — pip install itk-segmentation · libregistry