Python Skimage: hessian() filter. Why are filter result values <= 0 set to 1?

I am currently working with ridge detection filters such as frangi(), sato() and hessian() within the python skimage package. In my project, I am using the hessian() filter to detect river-like structures in an image. Since the those filte types make use of the Hessian matrix (which applies 2nd order spatial derivatives), I would expect the result 0 for image regions, where all pixel values are constant.

In the following, I am referring to line 432 in the skimage source code for hessian()

filtered[filtered <= 0] = 1

In my images I have areas, where all pixel values are equal. But instead of 0 (what I would expect, because when all pixels are constant there can not be any vessel-like structures and the hessian() should give back the "vesselness" of the image), the hessian() filter gives me ones. Of course, this results from line 432 in the skimage source code:

So my question is: WHY should this be useful? Why is it not acceptable to have filter results = 0 ? Which potential problems could arise if I create my own custom filter which would not have this line of code applied to my results?


  • Short answer: The code that you are referring to is broken.

    Long answer:

    What you found is a known and, as of today, still open bug in the skimage project. You can find the corresponding bug report here.

    If you want to give it a shot and try and implement the "hybrid Hessian filter" method yourself (which is the method that skimage's hessian() claims but fails to implement), have a look at the corresponding publication:

    Ng, CC., Yap, M.H., Costen, N., Li, B. (2015). Automatic Wrinkle Detection Using Hybrid Hessian Filter. In: Cremers, D., Reid, I., Saito, H., Yang, MH. (eds) Computer Vision -- ACCV 2014. ACCV 2014. Lecture Notes in Computer Science(), vol 9005. Springer, Cham.

    You can find a freely available PDF version of it here.