Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How guided filter is working where? #119

Open
deepakdhull80 opened this issue Jun 14, 2024 · 0 comments
Open

How guided filter is working where? #119

deepakdhull80 opened this issue Jun 14, 2024 · 0 comments

Comments

@deepakdhull80
Copy link

I started understanding the problem statement, it look very cool to me. So i started to implement this in Pytorch and learn some stuff in CV.

def guided_filter(x, y, r, eps=1e-2):
    
    x_shape = tf.shape(x)
    #y_shape = tf.shape(y)

    N = tf_box_filter(tf.ones((1, x_shape[1], x_shape[2], 1), dtype=x.dtype), r)

    mean_x = tf_box_filter(x, r) / N
    mean_y = tf_box_filter(y, r) / N
    cov_xy = tf_box_filter(x * y, r) / N - mean_x * mean_y
    var_x  = tf_box_filter(x * x, r) / N - mean_x * mean_x

    A = cov_xy / (var_x + eps)
    b = mean_y - A * mean_x

    mean_A = tf_box_filter(A, r) / N
    mean_b = tf_box_filter(b, r) / N

    output = mean_A * x + mean_b

    return output

I find out in guided_filter.py, mean_a is a matrix having sum(mean_a) == reduce((lambda x, y: x * y), mean_a.shape) and sum(mean_b) == 0.
from guided_filter(x, x) getting again x.
Please help me to understand this. I refered the same paper as you for guided_filter
https://kaiminghe.github.io/publications/pami12guidedfilter.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant