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.3-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3bd50d156bada2fbb7e921617eb85cabfe23437fd4e308914976c1b80d67e479 |
|
MD5 | 67a97dca26b56ec79e40fd56c186dfa3 |
|
BLAKE2b-256 | 158c3233eacb1938c4adbe82d658cc458bb6f4d18e7dc215ffb49e5e1f2e7265 |
Hashes for itk_dissolve-1.0.3-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75768f085b62b2252cde55082fa35b7fd0431536556bbc9a09e1993282b03d06 |
|
MD5 | 93b24430d449756e88bb7e603c057062 |
|
BLAKE2b-256 | b9f8ed71d090d9b40b0ac72fbd94d7f938c2c585f619ccd62028fd4ac5681155 |
Hashes for itk_dissolve-1.0.3-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee690b78370d06e2f735e3210a20ff864b18f19c46e1550f1f05a544f02ab560 |
|
MD5 | 0d10a04464a6fcde00df30413a3b9633 |
|
BLAKE2b-256 | 7f7c49a6078df65ce1e14bafcf2efc0d3cf78a7981c95f880b7bb66603a514a7 |
Hashes for itk_dissolve-1.0.3-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e27c0e7215eaeef8e23e38d815c0b438fc002fcc43d2486a3f48f1ffa021094f |
|
MD5 | bfba89f7ea5d02cbd3fbd249ff44ca1f |
|
BLAKE2b-256 | 8329aa99df72831a3de671164abf072fe8ffe6462f6585388ff3491621553ba4 |
Hashes for itk_dissolve-1.0.3-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b7b5fa9a9d4d6f0045e92ba1f4a1354df54c8d599932131e4eb9a32dfe917ec |
|
MD5 | d821c24c9a16fa38642540352d895f1e |
|
BLAKE2b-256 | 911f6a5507659f67638c977171362222ffef456869eabb91b114cbf2b566903f |
Hashes for itk_dissolve-1.0.3-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aca24fc56f2949ddbb4d0bcbceaa4ff0be9fb90a6e0b4adeeaccc957ceb1689c |
|
MD5 | 22e08193f6dda3cfc1f7411aea09db86 |
|
BLAKE2b-256 | 97aa82fbdb7bfb7f189e10ef0ffaf2274a22fe515862638a586781ef21be9bfc |
Hashes for itk_dissolve-1.0.3-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd545f1ae56a616f438ff4bd2ef9f3b1e03fa30f87251090a9afb90b6b9b625e |
|
MD5 | 84df5f3ec177b6c487568d51ad515d23 |
|
BLAKE2b-256 | e695e6ad9b6b97d1ff7cc0fddd3572cefbe788ad4da69498a778f5af84c9f769 |
Hashes for itk_dissolve-1.0.3-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c203f76b7c7fffd7cb23cda0312ee05a43e54c437c556971edf0011acfe505a |
|
MD5 | cf136e5b760fdb66bf3b5490ace7a3c2 |
|
BLAKE2b-256 | fb4c07e92ca205a404bef7c1b8da3bde839946fed44f74a06da867ae20cfd8ee |
Hashes for itk_dissolve-1.0.3-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07101f98b3ae53b3f767d1a2bd074b99472b1b4e1e1d9d727c61395907e038fb |
|
MD5 | a002e7365eb5691fe3a8dfd58b888429 |
|
BLAKE2b-256 | ec541e8d02ea18a233694ed8dd1f8158f67cd2c41d1dfd48b355bb5f1db9d1b1 |
Hashes for itk_dissolve-1.0.3-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 376f983776f006ef47cef73f43293e4b68698baa3c8d9a69561b69d24f02b733 |
|
MD5 | 090fa9b14ff5eb36fab6c0d339b6cdd5 |
|
BLAKE2b-256 | da8c872272123422199f583735f15b08ce53db65bc262a5c46c7a3b424da2e29 |