Skip to content

ImageFilter's filter_size arg #8127

@oseymour

Description

@oseymour

Describe the bug
The docs say that NotImplementedError will be raised "when filter is a string and not in self.supported_filters". When I try to initialize a Gaussian filter with no filter_size arg, I get "ValueError: filter_size must be specified when specifying filters by string.". When I print out the support filters for ImageFilter, I get ['elliptical', 'gauss', 'laplace', 'mean', 'median', 'savitzky_golay', 'sharpen', 'sobel'].

To Reproduce
Steps to reproduce the behavior:

from monai.transforms import ImageFilter
import torch

x = torch.rand((1,10,10))
trans = ImageFilter(filter="gauss", sigma=2)
y = trans(x)

Expected behavior
When initializing a Gaussian filter, I shouldn't need to pass the filter_size arg.

Screenshots
n/a

Environment
Python 3.12.3

Ensuring you use the relevant python executable, please paste the output of:

================================
Printing MONAI config...
================================
MONAI version: 1.3.2
Numpy version: 1.25.2
Pytorch version: 2.4.0+cpu
MONAI flags: HAS_EXT = False, USE_COMPILED = False, USE_META_DICT = False
MONAI rev id: 59a7211070538586369afd4a01eca0a7fe2e742e
MONAI __file__: C:\Apps\Anaconda3\v3_9_7_x64\Local\lib\site-packages\monai\__init__.py

Optional dependencies:
Pytorch Ignite version: NOT INSTALLED or UNKNOWN VERSION.
ITK version: NOT INSTALLED or UNKNOWN VERSION.
Nibabel version: 5.2.1
scikit-image version: 0.19.2
scipy version: 1.9.3
Pillow version: 9.2.0
Tensorboard version: 2.8.0
gdown version: NOT INSTALLED or UNKNOWN VERSION.
TorchVision version: 0.19.0+cpu
tqdm version: 4.64.1
lmdb version: NOT INSTALLED or UNKNOWN VERSION.
psutil version: 5.9.0
pandas version: 1.5.1
einops version: NOT INSTALLED or UNKNOWN VERSION.
transformers version: NOT INSTALLED or UNKNOWN VERSION.
mlflow version: 2.12.1
pynrrd version: NOT INSTALLED or UNKNOWN VERSION.
clearml version: NOT INSTALLED or UNKNOWN VERSION.

For details about installing the optional dependencies, please visit:
    https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies


================================
Printing system config...
================================
System: Windows
Win32 version: ('10', '10.0.19045', 'SP0', 'Multiprocessor Free')
Win32 edition: Enterprise
Platform: Windows-10-10.0.19045-SP0
Processor: Intel64 Family 6 Model 186 Stepping 3, GenuineIntel
Machine: AMD64
Python version: 3.9.7
Process name: python.exe
Command: ['C:\\Apps\\Anaconda3\\v3_9_7_x64\\Local\\python.exe', '-c', 'import monai; monai.config.print_debug_info()']
Open files: [popenfile(path='C:\\Windows\\System32\\en-US\\KernelBase.dll.mui', fd=-1), popenfile(path='C:\\Windows\\System32\\en-US\\tzres.dll.mui', fd=-1), popenfile(path='C:\\Windows\\System32\\en-US\\kernel32.dll.mui', fd=-1)]
Num physical CPUs: 10
Num logical CPUs: 12
Num usable CPUs: 12
CPU usage (%): [37.8, 14.6, 45.1, 4.7, 7.3, 7.5, 4.4, 8.1, 14.5, 12.4, 8.0, 4.0]
CPU freq. (MHz): 1800
Load avg. in last 1, 5, 15 mins (%): [0.0, 0.0, 0.0]
Disk usage (%): 67.7
Avg. sensor temp. (Celsius): UNKNOWN for given OS
Total physical memory (GB): 31.4
Available memory (GB): 18.7
Used memory (GB): 12.6

================================
Printing GPU config...
================================
Num GPUs: 0
Has CUDA: False
cuDNN enabled: False
NVIDIA_TF32_OVERRIDE: None
TORCH_ALLOW_TF32_CUBLAS_OVERRIDE: None

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions