ofgulban / segmentator

3D MRI data exploration and segmentation tool.
https://github.com/ofgulban/segmentator/wiki
BSD 3-Clause "New" or "Revised" License
73 stars 13 forks source link

Math problem in gradient calculation. Deriche filter. #90

Open TreshUp opened 3 years ago

TreshUp commented 3 years ago

Hello. i'm currently studying 3D implementation of Deriche filter and to my mind, i found a mistake in coefficients calculation. From your code (deriche_3D.pyx): S = alpha*(S_p - S_n) In the articles [1], [2] Deriche didn't use alpha. but -1 * (1 - exp(-alpha)) ^ 2. I checked your code, in order to find some convertions of alpha, but didn't found anything. I hope I'm mistaken. Your answer will help me in understanding theory of this filter. Thanks! P.S. [1] Monga, O., Deriche, R., & Rocchisani, J.-M. (1991). 3D edge detection using recursive filtering: Application to scanner images. CVGIP: Image Understanding, 53(1), 76–87. doi:10.1016/1049-9660(91)90006-b [2] Monga, O., Deriche, R., Malandain, G., & Cocquerez, J. P. (1991). Recursive filtering and edge tracking: two primary tools for 3D edge detection. Image and Vision Computing, 9(4), 203–214. doi:10.1016/0262-8856(91)90025-k

ofgulban commented 3 years ago

Hi @TreshUp , thanks for looking into this carefully and reporting this issue. Appreciated.

I had a quick look at deriche_3D.pyx and Monda, Deriche, Rocchisani 1991. It seems that indeed I did not apply the alpha conversion in their Eq. 10. Do you mind fixing this and contributing or would you rather leave it to me?

TreshUp commented 3 years ago

@ofgulban Sorry for long answer. After creating this issue, i've compared the 2D and 3D Deriche filters and found a typo in [1]. In [3] (Eq. 47, 50) When you apply derivative filter, you sum y_p and y_n, but in 3D they subtract them. As i understand the 3D filter is the extension of 2D filter, so the equations must be similar. So, to my mind the correct calculation in your file is S = -1 (1 - exp(-alpha)) ^ 2 (S_p + S_n). I would leave it to you, if you want, you can add me as a math contributor :D

[3] Deriche, R. (1990). Fast algorithms for low-level vision. IEEE Transactions on Pattern Analysis and Machine Intelligence, 12(1), 78–87. doi:10.1109/34.41386

ofgulban commented 3 years ago

Thanks @TreshUp , I will fix this.

TreshUp commented 3 years ago

Thanks @TreshUp , I will fix this.

Nice, good bye)