Metadata-Version: 2.1
Name: itk-dissolve
Version: 1.0.5
Summary: This is a module for the Insight Toolkit (ITK) that provides filters to replace regions within a masked region with the surrounding labels.
Home-page: https://github.com/dyollb/ITKDissolve
Download-URL: https://github.com/dyollb/ITKDissolve
Author: Bryn Lloyd
Author-email: lloyd@itis.swiss
License: MIT
Keywords: ITK InsightToolkit
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python
Classifier: Programming Language :: C++
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Healthcare Industry
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Classifier: Topic :: Software Development :: Libraries
Classifier: Operating System :: Android
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX
Classifier: Operating System :: Unix
Classifier: Operating System :: MacOS
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: itk-core (>=5.2.1.post1)

# ITKDissolve

[![Build Status](https://github.com/dyollb/ITKDissolve/workflows/Build,%20test,%20package/badge.svg)](https://github.com/dyollb/ITKDissolve/actions)
[![License]( https://img.shields.io/github/license/dyollb/ITKDissolve?color=blue)](https://github.com/dyollb/ITKDissolve/blob/main/LICENSE)
[![PyPI version](https://img.shields.io/pypi/v/itk-dissolve.svg)](https://badge.fury.io/py/itk-dissolve)
<img src="https://img.shields.io/pypi/dm/itk-dissolve.svg?label=pypi%20downloads&logo=python&logoColor=green"/>
<img src="https://img.shields.io/badge/python-%203.7%20|%203.8%20|%203.9%20-3776ab.svg"/>
## 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
```
