clij / clij2-fft

21 stars 6 forks source link

Total varation #10

Closed bnorthan closed 3 years ago

bnorthan commented 3 years ago

Hi @haesleinhuepf

This branch adds a total variation regularization to the Richardson Lucy algorithm. See

This regularization can be useful when deconvolving noisy confocal data. I'll probably merge it in a day or two if you have no objections. A couple of things.

  1. I've written a total variation kernel and added some code to read the kernel and compile it. (oooh... just noticed I hard coded a local file name, will fix that before merging). Does clEsperanto have a c-interface?? Last we talked it didn't. Just wanted to check again before getting to far into writing code to compile the kernels.

  2. There is now a new optional parameter for regularization factor. If the regulariation factor is 0 no regularization is applied, otherwise regularization is applied and the level of smoothing is controlled by the regularization factor. Does the code to check for the optional parameter look OK?

haesleinhuepf commented 3 years ago

Hey Brian @bnorthan ,

wow, that's super cool. Thanks for investing time on this.

  1. added some code to read the kernel and compile it

Clij has all the logic and infrastructure you need to compile and call OpenCL kernels. If you want to use it, and enjoy the benefits for image-type-agnostic OpenCL-code, you need to replace things like __global float *estimate with IMAGE_estimate_TYPE estimate. More details on what to replace with what and why here.

  1. Does clEsperanto have a c-interface??

It has a C++ interface under development. The API uses the same OpenCL-dialect as specified above.

2. Does the code to check for the optional parameter look OK?

Unfortunately, I didn't manage to make optional parameters work in ImageJ Macro. Furthermore, you need to specify the new parameter here.

Is it necessary to have that parameter optional? How about assuming that it's not given in case it's zero?

Thanks for your efforts!

Merry Christmas and happy Holidays! 🎄 🙂

Cheers, Robert

bnorthan commented 3 years ago

Thanks for the info @haesleinhuepf . Long term I am very interested in the clEsperanto c++ interface. For this iteration I am going to simply compile the total variation kernel within the c++ code, as I need this to work as a stand alone c++ program with limited dependencies (in addition to the java warpper and clij integration).

I added the regularization factor as a parameter. If it is zero the regularization will be skipped, typical values of the regularization factor are 0.0001 to 0.01 (lower the algorithm doesn't do much, higher artifacts occur).

Where are the default values for the parameters set?? The default value for iterations and regularization factor is set to 2.0 somewhere and I need change it. I'm probably missing something obvious.

bnorthan commented 3 years ago

I'm going to merge this. In addition to the regularization option this pull request adds a couple of other important updates.

2.2.0.14

  1. Total Variation regularization option added. This option is useful when deconvoling noisy images.
  2. Non-ciculant deconvolution option added. This option is useful when deconvolving extended objects and structure near edges.
  3. Update some pointers from 'long' to 'long long' to address issues that could occur addressing 64 bit memory locations.