You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Random cropping with scaling option for super-resolution data augmentation #4624
Is your feature request related to a problem? Please describe.
In super-resolution networks, a low resolution input is upsampled using a neural networks often with an integer factor (e.g. x2, x3, x4 etc). When performing data augmentation, a good approach is to use random cropping with fixed size, especially if input images are bigger than what can fit in memory for network activations.
Describe the solution you'd like
To address the data augmentation issue of random cropping, a possible solution could be to get a random crop window in low resolution image and apply the same (but scaled up) window to target ground truth image.
For example, in a x4 upsampling network cropping a 56 x 56 window in low res input will correspond to 224 x 224 window cropping in target ground truth
Describe alternatives you've considered
Writing my own MONAI transforms, or manually cropping data
Additional context
This may be useful for super-resolution, upsampling or demosaicing networks that typically take low res input and up resolve it
Apologies if this is addressed by an existing transform, in which case can someone guide me on how I can achieve the above with an existing transform...
thanks for the request, if I understand this correctly, it is similar to: #4491, which mainly requires defining cropping locations and sizes using the actual physical unit instead of number of pixels (essentially 56x56 pixels window at resolution 4mmx4mm is equivalent of 224x224 window at 1mmx1mm). please help clarify @masadcv and we can prioritise it.
not at the moment @masadcv. but as we have the MetaTensor implementation on dev, I hope it could be a universal solution of specifying roi_sizes in terms of physical units instead of number of voxels (for example the hires_scale should be computed from MetaTensor's pixdim property). would you still be interested/have the bandwidth to contribute?
Hi @wyli, I'm Wajid Ali (@wajidcodes), a CS student and Python contributor working on medical imaging with PyTorch. I currently contribute to MONAI and Ultralytics, including the YOLO segmentation instance-ID support in ultralytics/ultralytics#27231.
I read through this thread: @masadcv offered to contribute this transform back in July 2022, but there has been no follow-up since your reply asking whether he still had the bandwidth, and there is still no linked PR. If this is still free, I would like to take it on.
I plan to implement the scaled random crop as a MONAI transform (array and dict variants, with tests and docs), following your suggestion to compute hires_scale from MetaTensor's pixdim property where possible, and checking how it relates to #4491 first.
Could you please confirm whether this is still wanted and whether that MetaTensor-based approach is still the preferred direction? Thanks!
Activity
wyli commentedon Jul 4, 2022
thanks for the request, if I understand this correctly, it is similar to: #4491, which mainly requires defining cropping locations and sizes using the actual physical unit instead of number of pixels (essentially 56x56 pixels window at resolution 4mmx4mm is equivalent of 224x224 window at 1mmx1mm). please help clarify @masadcv and we can prioritise it.
masadcv commentedon Jul 4, 2022
Hi @wyli ,
Yes, in my case it is a special case of that issue - where I am interested in cropping different sized data only.
My not so polished solution looks like this at the moment:
wyli commentedon Jul 5, 2022
thank you @masadcv, the prototype is helpful.
masadcv commentedon Jul 17, 2022
Hi @wyli ,
Just wanted to check if anyone is working on this? If not I will like to contribute with this transform...
wyli commentedon Jul 17, 2022
not at the moment @masadcv. but as we have the MetaTensor implementation on dev, I hope it could be a universal solution of specifying roi_sizes in terms of physical units instead of number of voxels (for example the
hires_scaleshould be computed from MetaTensor'spixdimproperty). would you still be interested/have the bandwidth to contribute?wajidcodes commentedon Nov 27, 2026
Hi @wyli, I'm Wajid Ali (@wajidcodes), a CS student and Python contributor working on medical imaging with PyTorch. I currently contribute to MONAI and Ultralytics, including the YOLO segmentation instance-ID support in ultralytics/ultralytics#27231.
I read through this thread: @masadcv offered to contribute this transform back in July 2022, but there has been no follow-up since your reply asking whether he still had the bandwidth, and there is still no linked PR. If this is still free, I would like to take it on.
I plan to implement the scaled random crop as a MONAI transform (array and dict variants, with tests and docs), following your suggestion to compute hires_scale from MetaTensor's pixdim property where possible, and checking how it relates to #4491 first.
Could you please confirm whether this is still wanted and whether that MetaTensor-based approach is still the preferred direction? Thanks!