Custom PSF for RL deconvolution

Issue #218 closed
Former user created an issue

Would be great if it was possible to load a custom PSF image for RL deconvolution, including an RGB one. For example, here is a D65 Airy disk, which could be used to correct diffraction:

https://commons.wikimedia.org/wiki/File:Airy_disk_D65.png

Optional:

  • convert the PSF image to linear light before applying
  • apply the PSF image in linear light
  • ability to apply an RGB PSF image, like the one above
  • add presets (gaussian blur, airy disk, etc.)
  • add iterations slider

Comments (13)

  1. agriggio repo owner

    Having a custom PSF sounds like a nice idea, I can look into it. However, note that at the moment RL deconvolution is applied only to the Y channel, not in RGB.

    Patches are welcome though

  2. agriggio repo owner

    This is now on master. You can upload your psf function as an image or as a matrix in json format. Example of the latter showing an identity 3x3 kernel:

    [[0, 0, 0],
     [0, 1, 0],
     [0, 0, 0]]
    

    In the case of images, no color space conversion is performed. The kernel values are read straight from the image data. So no gamma/linear/sRGB etc., just make sure that the actual pixel values encode your kernel. Also, the image must be RGB but is assumed to be monochrome (i.e. with all 3 channels identical)

  3. Former user Account Deleted reporter

    I see, works for me, and thanks for implementing the iterations slider. Is it possible to also add a scale/radius slider, like with normal gaussian kernel (probably using area-average downscaling)? This is useful when you know what the kernel looks like but not sure what size it should be - for example, synthetic airy disk on a real f/22 image

  4. agriggio repo owner

    I did have a scale slider in the first version, but later I decided to remove it. Since specifying a custom PSF is an “expert user” tool, I think it’s better to leave the downscaling to the user (except of course when computing the preview, for that a simple bilinear resampling is used). So if you are unsure about the size of your airy disk, just create a few different variants in GIMP with different sizes…

  5. Former user Account Deleted reporter

    I would ask you to consider bringing it back, at least as an option in settings. Sometimes you have a lot of diffraction limited photos all of which were taken at different apertures. While you can calculate the needed kernel size for each image and downscale the kernel image and save and …, it would be much simpler to use this feature with a slider. Even bilinear downscaling would be better than nothing, and advanced users could still downscale the psf as they want.

    Also, I noticed it doesn’t work as expected on very big kernels (~100 pixels), does it do some normalization and is it possible to turn it off?

  6. agriggio repo owner

    I’ll think about adding the slider back.

    I noticed it doesn’t work as expected on very big kernels (~100 pixels),

    what does that mean exactly? Please provide a precise description of the issue and (if possible) the data to reproduce it, thanks!

    does it do some normalization and is it possible to turn it off

    the kernel is normalized so that the sum of all the entries is 1. This is necessary to preserve the brightness of the picture.

  7. Former user Account Deleted reporter

    Thank you!

    I was talking about size normalization - for example, you can use one of the bokeh balls on this photo as a PSF (yes, I know, you shouldn’t do that, but I tried anyway):

    https://www.dpreview.com/sample-galleries/1958121696/rokinon-samyang-af-35mm-f1-8-fe-sample-gallery/7328722736

    The expected result is that those balls become smaller and the BAR sign now has two separate lines as the letter borders. What happens instead is a slight sharpening, like if the radius is too low

  8. Log in to comment