MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / ImageFilter

Class ImageFilter

monai/transforms/utility/array.py:1534–1786  ·  view source on GitHub ↗

Applies a convolution filter to the input image. Args: filter: A string specifying the filter, a custom filter as ``torch.Tenor`` or ``np.ndarray`` or a ``nn.Module``. Available options for string are: ``mean``, ``laplace``, ``elliptical``, ``sobel``, ``shar

Source from the content-addressed store, hash-verified

1532
1533
1534class ImageFilter(Transform):
1535 """
1536 Applies a convolution filter to the input image.
1537
1538 Args:
1539 filter:
1540 A string specifying the filter, a custom filter as ``torch.Tenor`` or ``np.ndarray`` or a ``nn.Module``.
1541 Available options for string are: ``mean``, ``laplace``, ``elliptical``, ``sobel``, ``sharpen``, ``median``, ``gauss``
1542 See below for short explanations on every filter.
1543 filter_size:
1544 A single integer value specifying the size of the quadratic or cubic filter.
1545 Computational complexity scales to the power of 2 (2D filter) or 3 (3D filter), which
1546 should be considered when choosing filter size.
1547 kwargs:
1548 Additional arguments passed to filter function, required by ``sobel`` and ``gauss``.
1549 See below for details.
1550
1551 Raises:
1552 ValueError: When ``filter_size`` is not an uneven integer
1553 ValueError: When ``filter`` is an array and ``ndim`` is not in [1,2,3]
1554 ValueError: When ``filter`` is an array and any dimension has an even shape
1555 NotImplementedError: When ``filter`` is a string and not in ``self.supported_filters``
1556 KeyError: When necessary ``kwargs`` are not passed to a filter that requires additional arguments.
1557
1558
1559 **Mean Filtering:** ``filter='mean'``
1560
1561 Mean filtering can smooth edges and remove aliasing artifacts in an segmentation image.
1562 See also py:func:`monai.networks.layers.simplelayers.MeanFilter`
1563 Example 2D filter (5 x 5)::
1564
1565 [[1, 1, 1, 1, 1],
1566 [1, 1, 1, 1, 1],
1567 [1, 1, 1, 1, 1],
1568 [1, 1, 1, 1, 1],
1569 [1, 1, 1, 1, 1]]
1570
1571 If smoothing labels with this filter, ensure they are in one-hot format.
1572
1573 **Outline Detection:** ``filter='laplace'``
1574
1575 Laplacian filtering for outline detection in images. Can be used to transform labels to contours.
1576 See also py:func:`monai.networks.layers.simplelayers.LaplaceFilter`
1577
1578 Example 2D filter (5x5)::
1579
1580 [[-1., -1., -1., -1., -1.],
1581 [-1., -1., -1., -1., -1.],
1582 [-1., -1., 24., -1., -1.],
1583 [-1., -1., -1., -1., -1.],
1584 [-1., -1., -1., -1., -1.]]
1585
1586
1587 **Dilation:** ``filter='elliptical'``
1588
1589 An elliptical filter can be used to dilate labels or label-contours.
1590 Example 2D filter (5x5)::
1591

Callers 15

__init__Method · 0.90
__init__Method · 0.90
test_init_from_stringMethod · 0.90
test_init_raisesMethod · 0.90
test_init_from_arrayMethod · 0.90
test_init_from_moduleMethod · 0.90
test_call_2dMethod · 0.90
test_call_3dMethod · 0.90

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…