question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Motion blur ValueError when blur_limit is even

See original GitHub issue

🐛 Bug

I’m not sure that this line https://github.com/albumentations-team/albumentations/blob/master/albumentations/augmentations/blur/transforms.py#L77 works as expected. It doesn’t take into account allow_shifted parameter at all, since there is or operator.

To Reproduce

Steps to reproduce the behavior:

  1. A.Compose([A.MotionBlur(blur_limit=20)])

ValueError: Blur limit must be odd when centered=True. Got: (3, 20)

Expected behavior

I think that check for motion_limit should take the expression like this

if not allow_shifted and (self.blur_limit[0] % 2 != 1 or self.blur_limit[1] % 2 != 1):

Environment

  • Albumentations version (e.g., 0.1.8): 1.3.0
  • Python version (e.g., 3.7): 3.10.8
  • OS (e.g., Linux): MacOs
  • How you installed albumentations (conda, pip, source): pip
  • Any other relevant information:

Issue Analytics

  • State:open
  • Created 9 months ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Andredancecommented, Dec 9, 2022

@Dipet Error says that blur_limit should be odd when centered=True. I mean that this expression:

if not allow_shifted and self.blur_limit[0] % 2 != 1 or self.blur_limit[1] % 2 != 1:

doesn’t take into account allow_shifted parameter at all (If self.blur_limir[1] is even it will always raise an error if allow_shifted is True or False). If Motion blur works only with odd blur_limit we should specify it somewhere and make this expression without allow_shifted variable. What do you think?

0reactions
Dipetcommented, Dec 9, 2022

No, otherwise, It works with odd sizes only when allow_shifted=False. In that case we need odd value to make centered kernel. Yes. it will work correctly with even kenel sizes, but it maybe a little bit confusing whe you set limit to odd value, but it newer will be reached. At least we need warning that kernel is even and real limit is lower to by 1.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix Motion Blur in PC Games - PCMag
If blurry motion is ruining your PC gaming experiences, tweak these settings in Windows, on your monitor, or in your game to reduce...
Read more >
Freya Holmér on Twitter: "Motion blur - Twitter
In this case, motion blur is a bit of a misnomer though - makes it sound as if it's a simple blur effect,...
Read more >
Motion Blur — Blender Manual
Motion Blur ... Blender's animations are by default rendered as a sequence of perfectly still images. While great for stop-motion and time-lapses, this...
Read more >
Blur transforms (augmentations.blur.transforms)
maximum Gaussian kernel size for blurring the input image. Must be zero or odd and in range [0, inf). If set to 0...
Read more >
Intro to Blur filters in Motion - Apple Support
Gaussian Blur creates a soft blur effect. Gradient Blur creates a graduated blur between two points. Prism blurs and refracts the image as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found