Closed andmccall closed 9 months ago
Hi @andmccall
Thanks for taking a look at this. This is a really important example meant to show the importance of edge handling and deconvolution acceleration and it sucks that it didn't work for a while.
The original version was definitely broke, but I couldn't get your version to work for me either (on a fresh install of Fiji). Below is what finally worked. (I also took out the small_kernel, as that didn't really contribute to the example)
#@ OpService ops
#@ UIService ui
#@ ConvertService convert
#@ DatasetService data
import net.imglib2.type.numeric.real.FloatType;
import net.imagej.ops.Op
import net.imglib2.outofbounds.OutOfBoundsConstantValueFactory
import net.imagej.ops.deconvolve.RichardsonLucyC
import net.imglib2.util.Util
// create the sample image
base = ops.run("create.img", [150, 100], new FloatType())
formula = "p[0]^2 * p[1]"
ops.image().equation(base, formula)
ui.show("input image", base);
// create kernel
kernel_big = ops.run("create.img", [20,20], new FloatType())
ops.image().equation(kernel_big, "p[0]")
// convolve with large kernel
convolved_big = ops.filter().convolve(base, kernel_big)
ui.show("convolved", convolved_big);
// deconvolve with Richardson Lucy
base_deconvolved_big=ops.create().img(convolved_big, new FloatType())
base_deconvolved_big = ops.deconvolve().richardsonLucy(base_deconvolved_big, convolved_big, kernel_big, null, new OutOfBoundsConstantValueFactory<>(Util.getTypeFromInterval(kernel_big).createVariable()), 10)
// deconvolve with non-circulant Richardson Lucy
base_deconvolved_big_noncirc=ops.create().img(convolved_big, new FloatType())
base_deconvolved_big_noncirc = ops.deconvolve().richardsonLucy(base_deconvolved_big_noncirc, convolved_big, kernel_big, null, null, null, null, null, 50, true, false)
// deconvolve with accelerated non-circulalant Richardson LUcy
base_deconvolved_big_acc_noncirc=ops.create().img(convolved_big, new FloatType())
base_deconvolved_big_acc_noncirc = ops.deconvolve().richardsonLucy(base_deconvolved_big_acc_noncirc, convolved_big, kernel_big, null, null, null, null, null, 50, true, true)
ui.show("RL",base_deconvolved_big)
ui.show("RLNon-Circ",base_deconvolved_big_noncirc)
ui.show("RL Acc/Non-Circ",base_deconvolved_big_acc_noncirc)
Below is the result you should get, which shows in this extreme example (with structure right to the edge and a big PSF) you need non-circulant edge handling to get an acceptable result and the acceleration give an even sharper result. Can you replicate this either using my code or you RichardsonLucyC version? If the latter we should discuss further why the RichardsonLucyC version is working for you but not me.
Hi @bnorthan,
I double checked and hadn't even noticed the error that popped up on my version, just saw the original image, convolved image and what looked like a decent deconvolved image and thought that was the whole output.
I tried your version and it works great.
Was looking at the groovy example scripts and noticed this one didn't work. Looks like RichardsonLucyF changed to RicahdrsonLucyC at some point