clEsperanto / pyclesperanto_prototype

GPU-accelerated bio-image analysis focusing on 3D+t microscopy image data
http://clesperanto.net
BSD 3-Clause "New" or "Revised" License
208 stars 44 forks source link

implement the sato filter in pyclesperanto (equivalent of fiji tubeness) #320

Open thawn opened 1 year ago

thawn commented 1 year ago

It would be great to implement the skimage.filters.sato filter in pyclesperanto.

the filter takes an image and a range of sigmas (by default range(1,10,2)) It then calculates the hessian matrix eigenvalues for each sigma in descending order. For each sigma, it computes normalized tubeness (eqs. (9) and (22), ref. [1]_) as the geometric mean of eigvals other than the lowest one, clipped to 0, multiplied by sigma^2. Then it returns the maximum tubeness from all the different sigmas for each pixel (->source.

Could we try to implement this using cle.hessian_eigenvalues()? cle.hessian_eigenvalues() does not support a sigma parameter. Can we circumvent this by scaling the image according to the sigma before calculating the eigenvalues?

roughly like this:

tubeness = cle.zeros_like(image)
for sigma in sigmas:
    blurred = cle.gaussian_blur(image, sigma_z=sigma/2, sigma_y=sigma/2, sigma_x=sigma/2)
    cle.scale(blurred, scale_z=1/sigma,scale_y=1/sigma,scale_x=1/sigma)
    # calculate geometric mean of middle and large eigenvalues returned by cle.hessian_eigenvalues(), 
    # clip to 0 and multiply by sigma ** 2
    mean_eigenvalues = ...
    mean_eigenvalues = cle.scale(mean_eigenvalues, scale=sigma)
    tubeness = cle.max_images(mean_eigenvalues, tubeness)
return tubeness

do we do the gaussian blur with sigma/2 or do we scale by 1/(sigma * 2)?