tonyyxliu / CUHKSZ-CSC4005

Project Materials for CUHK(SZ) Course CSC4005: Parallel Programming
MIT License
75 stars 31 forks source link

Incorrect Computation of Intensity Weights of Bilateral Filter #66

Closed tonyyxliu closed 1 month ago

tonyyxliu commented 1 month ago

Thanks to Chen Shi's Email for pointing out the following issue:

In the calculation of the weight w_11 (and likely other similar weights), there appears to be a multiplication where I believe a division should be used. Specifically, in the following line:

float w_11 = w_spatial_corner * expf(powf(center_value - value_11, 2) *
                                     -0.5 * powf(SIGMA_R, 2));

I suspect that the correct formula should use division instead of multiplication:

float w_11 = w_spatial_corner * expf(powf(center_value - value_11, 2) /
                                     (-2 * powf(SIGMA_R, 2)));

This change would align with the standard bilateral filter formula, where the exponential term typically involves division by 2σ². I'm also considering the possibility that SIGMA_R might be defined as a reciprocal value in our implementation.

tonyyxliu commented 1 month ago

The baseline performance will be updated soon.

chenshi3 commented 1 month ago

https://github.com/tonyyxliu/CUHKSZ-CSC4005/blob/892929c9be4664702f97ef80a01ec2ea810477ad/project1/src/utils.cpp#L414

Hi, May we consider using w_spatial_corner here instead of w_spatial_border?

tonyyxliu commented 1 month ago

You are right. I have fixed this bug. Thank you so much for pointing this out!