sanghviyashiitb / structured-kernel-cvpr23

Official Code for "Structured Kernel Estimation for Photon-Limited Deconvolution" (CVPR 2023)
https://sanghviyashiitb.github.io/structured-kernel-webpage/
MIT License
32 stars 8 forks source link

Issue with circular blur #1

Closed williamstern closed 1 year ago

williamstern commented 1 year ago

The code will not run when circular blur is turned on tested with demo_greyscale.py

Traceback (most recent call last): File "/home/wstern/deblur/structured-kernel-cvpr23/demo_grayscale.py", line 61, in <module> x_list, k_list = iterative_scheme(y, np.mean(y)/0.33, networks, opts) File "/home/wstern/deblur/structured-kernel-cvpr23/utils/iterative_scheme.py", line 96, in iterative_scheme yn_pad = p4ip_denoiser(y_pad, M, denoiser) UnboundLocalError: local variable 'y_pad' referenced before assignment

sanghviyashiitb commented 1 year ago

Hi williamstern, I assume you changed opts['MODE'] to 'circular' from 'symmetric'

I wrote the initial code with circular mode for testing purposes but changed the code to symmetric mode because latter is a much better assumption for real-world blur. I'll get back to this thread in a couple of days to fix the bug - should be relatively straightforward.

sanghviyashiitb commented 1 year ago

Hi,

Here are some updates. 1) Instead of changing the code in 'utils/iterative_scheme.py', I have created a new file 'iterative_scheme_circular_mode.py' with almost similar code but it runs the function iterative scheme in 'circular' mode as requested. To use this function, all you need to do is change the file where you import 'iterative_scheme' from i.e., Use from utils.iterative_scheme_circular_mode import iterative_scheme instead of from utils.iterative_scheme import iterative_scheme And the code should run just fine!

2) After running demo_grayscale on Levin data with circular mode (using the instructions in [1] ), we get the following result: demo_grayscale_output_circular

This is not that different from 'symmetric' mode but I would still caution against using it. In a couple of years of working with blur, my experience is that symmetric boundary conditions are almost always better. Not using symmetric mode, while computationally less expensive, may lead to wierd artifacts.

sanghviyashiitb commented 1 year ago

Hi, @williamstern , please let me know if the issue is resolved for you or not. If yes, then I can close this thread.

williamstern commented 1 year ago

Thanks for your help! This works great! Thanks for putting so much time into this.