error using RandomNoise and RandomBlur on 2D images
See original GitHub issue🐛Bug 2d transform of my images is not working resulting in crash
To reproduce
I try to use torchio transforms on 2d sattelite images, I have only 1 input channel:
# << INTENSITY augmentations >>
tio_intensity_prob = 0.2
_tio_noise_tfs = Compose([
RandomBlur(p=tio_intensity_prob, keys=["images"]),
RandomNoise(p=tio_intensity_prob, keys=["images"]),
])
Expected behavior transformed images
Actual behavior crash, I added dimensions and shape of the tensor to the error msg
Original Traceback (most recent call last):
File "/home/florian/miniconda3/envs/sat/lib/python3.8/site-packages/monai/transforms/utils.py", line 361, in apply_transform
return transform(data)
File "/home/florian/miniconda3/envs/sat/lib/python3.8/site-packages/torchio/transforms/transform.py", line 68, in __call__
subject = data_parser.get_subject()
File "/home/florian/miniconda3/envs/sat/lib/python3.8/site-packages/torchio/transforms/data_parser.py", line 66, in get_subject
subject = self._get_subject_from_dict(self.data, self.keys)
File "/home/florian/miniconda3/envs/sat/lib/python3.8/site-packages/torchio/transforms/data_parser.py", line 134, in _get_subject_$rom_dict
value = ScalarImage(tensor=value)
File "/home/florian/miniconda3/envs/sat/lib/python3.8/site-packages/torchio/data/image.py", line 516, in __init__
super().__init__(*args, **kwargs)
File "/home/florian/miniconda3/envs/sat/lib/python3.8/site-packages/torchio/data/image.py", line 124, in __init__
tensor = self._parse_tensor(tensor)
File "/home/florian/miniconda3/envs/sat/lib/python3.8/site-packages/torchio/data/image.py", line 364, in _parse_tensor
raise ValueError(
ValueError: ('Input tensor must be 4D, but has these dimensions:', 3, torch.Size([1, 512, 512]))
System info
Output of python <(curl -s https://raw.githubusercontent.com/fepegar/torchio/master/print_system.py)
:
(sat) florian@ibbm_giga:~/satellite_one$ python <(curl -s https://raw.githubusercontent.com/fepegar/torchio/master/print_system.py)
If you use TorchIO for your research, please cite the following paper:
Pérez-García et al., TorchIO: a Python library for efficient loading,
preprocessing, augmentation and patch-based sampling of medical images
in deep learning. Credits instructions: https://torchio.readthedocs.io/#credits
Platform: Linux-4.15.0-144-generic-x86_64-with-glibc2.10
TorchIO: 0.18.1
PyTorch: 1.7.0+cu110
NumPy: 1.18.1
Python: 3.8.5 (default, Sep 4 2020, 07:30:14)
[GCC 7.3.0]
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Blurring Images – Image Processing with Python
The Gaussian blur is a way to apply a low-pass filter in skimage. It is often used to remove Gaussian (i. e., random)...
Read more >Add noise to image - MATLAB imnoise - MathWorks
This MATLAB function adds zero-mean, Gaussian white noise with variance of 0.01 to grayscale image I.
Read more >Removing blur from images – deconvolution and using ...
In this post, we'll have a look at the idea of removing blur from images, videos, or games through a process called “deconvolution”....
Read more >2022 Adding and Filtering Random Noise (Median ... - YouTube
How to add Random Noise to an image in MATLAB ! ... 2022 How to Blur an Image with an Average Mask in...
Read more >Python code to add random Gaussian noise on images · GitHub
Python code to add random Gaussian noise on images - add_gaussian_noise.py. ... gaussian noise multiplied then added over image: noise increases with image...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry, for the late response and thanks for clarifying 😃
Yes, thank you. In the meantime I solved it like this with some MONAI transforms:
I still believe “native” 2D support would be good enhancement 😃