https://github.com/dyollb/itkdissolve
ITK external module to dissolve masked regions
https://github.com/dyollb/itkdissolve
c-plus-plus image-processing itk itk-module python segmentation
Last synced: 4 months ago
JSON representation
ITK external module to dissolve masked regions
- Host: GitHub
- URL: https://github.com/dyollb/itkdissolve
- Owner: dyollb
- License: mit
- Created: 2022-08-20T20:11:05.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-03-26T07:10:06.000Z (about 2 years ago)
- Last Synced: 2024-04-26T13:46:27.782Z (about 2 years ago)
- Topics: c-plus-plus, image-processing, itk, itk-module, python, segmentation
- Language: C++
- Homepage:
- Size: 43.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ITKDissolve
[](https://github.com/dyollb/ITKDissolve/actions)
[](https://github.com/dyollb/ITKDissolve/blob/main/LICENSE)
[](https://badge.fury.io/py/itk-dissolve)
## Overview
This is a module for the Insight Toolkit ([ITK](https://github.com/InsightSoftwareConsortium/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.
```python
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:
```python
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:
```shell
python -m pip install itk-dissolve
```