This is a module for the Insight Toolkit (ITK) that provides filters to replace regions within a masked region with the surrounding labels.
Project description
ITKDissolve
Overview
This is a module for the Insight Toolkit (ITK) that provides functionality to discard pixels within a masked region. Unlike masking, the pixels in the masked region are replaced (dissolved) by their nearest pixels outside the mask. This can be useful to clean-up label fields, e.g. to remove small islands/holes or remove entire labels, and replace them by the adjacent labels.
The module includes a filter called DissolveMaskImageFilter.
import itk
labels = itk.imread('path/to/labels.mha').astype(itk.US)
mask = itk.imread('path/to/mask.mha').astype(itk.UC)
ImageType = type(labels)
MaskType = type(mask)
dissolve = itk.DissolveMaskImageFilter[ImageType, MaskType].New()
dissolve.SetInput(labels)
dissolve.SetMaskImage(mask)
dissolve.Update()
modified_labels = dissolve.GetOutput()
itk.imwrite(modified_labels, 'modified_labels2.mha')
Or using the pythonic API:
import itk
labels = itk.imread('path/to/labels.mha').astype(itk.US)
mask = itk.imread('path/to/mask.mha').astype(itk.US)
modified_labels = itk.dissolve_mask_image_filter(labels, mask_image=mask)
itk.imwrite(modified_labels, 'path/to/modified_labels.mha')
Installation
To install the binary Python packages:
python -m pip install itk-dissolve
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for itk_dissolve-1.0.5-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ea6c950693fc4e28f333988e966285e0906186bf05fadf47a9a7794fbcc1107 |
|
MD5 | ccdfd5fbe044bc88ebf63c345649ad37 |
|
BLAKE2b-256 | 972a467bb7223bef6c21b066ced9cdffc8f01cfa61ef233a39e4756bad0e87cd |
Hashes for itk_dissolve-1.0.5-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6eb097e7688c48c1f7c3c4cbf109575a56bfe6f10c8f7b24255cedef6f01b633 |
|
MD5 | 010117519721be6eb3168059e094a3fc |
|
BLAKE2b-256 | c4f6f6e71adbdf784ed1d172d127429413da36f8860c4c85dee818978bf75996 |
Hashes for itk_dissolve-1.0.5-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 100e011cc19bee5f4a9b758aac279095bf2cda167c868f0fa1f775e7647e4212 |
|
MD5 | 0654eab13a52d2e926642d7127110bb2 |
|
BLAKE2b-256 | d2d440a4087409c559b8634dfb5eb4c9e98e7e1c999aafe30898d574280aaf6f |
Hashes for itk_dissolve-1.0.5-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6986d63ee24106a4dfec51b527f049294d07451c5b2307cd92a80c327f5a811b |
|
MD5 | 47346b147a42832429ec39deaff85854 |
|
BLAKE2b-256 | a0131c320f699fba73a1dd3471ba00ae3aee8a6721ab245ab21dac4a3c01e568 |
Hashes for itk_dissolve-1.0.5-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccfb97a0f72f836873b74ab3e019224f54293e324ebb0b930d00196a6ef7435e |
|
MD5 | 538b2a7a2199fee6d564cc18ff6b8a18 |
|
BLAKE2b-256 | 7acc9efba8a0273589a8ca5857e2ab1f628b8e917f180a4da6e46576a6f3a2cc |
Hashes for itk_dissolve-1.0.5-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a1544f9dda041ab3a72ce9b85e6cc54b39dda53da81ec3a9dfe8b7dab60113a |
|
MD5 | bba72ed48b6192b0c4eabfdd7b1b7e85 |
|
BLAKE2b-256 | f1878973c794c73c6ab164e5c17b1a6987520e182dd6e3b0c4ac22475f5d9df0 |
Hashes for itk_dissolve-1.0.5-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6cf72d400645583266ac8160e759d0c1e0bbc6040d0557e5a32a210cb9a09afd |
|
MD5 | ae21bda80301d1d8253dad84e831ebe0 |
|
BLAKE2b-256 | adb5ced8bf9442f069ba421ec3dbd4e16170c8eac6e82ccbcc737b0a6dbf4d33 |
Hashes for itk_dissolve-1.0.5-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ecd31333f37eb549adaa1f1aa74b17c14ce54e677daefa66db4de436378f29d9 |
|
MD5 | c54b0259abd01ee331ff9c742ef44a9e |
|
BLAKE2b-256 | 4a14cc0a6d0a205e005cc9205295712aeb8c00acaf71ee491a908a9862de04fe |
Hashes for itk_dissolve-1.0.5-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f0a87b244a7d3ef4be718f6349b4945d99ecaa4a7e690c93e2647982d8bb3c2 |
|
MD5 | 9c812900b76eaf39ea60c13593adcfc7 |
|
BLAKE2b-256 | 442f2db932c853e52da1cb03199ffecef4d794e849caf28ee05920a8cdf43b63 |
Hashes for itk_dissolve-1.0.5-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d23d35bf968b9f672485ebac62e737a9b808fb38878034c1086621660b13bd03 |
|
MD5 | 1fedfe1157c7f8c3023686c3bfa73d34 |
|
BLAKE2b-256 | ac1d15e0a9f952833d9ea1bd15675f193bd87ec11f2f852657ccd07d235c96b2 |