Luminous Landscape Forum

Raw & Post Processing, Printing => Digital Image Processing => Topic started by: mjk on July 11, 2011, 12:44:07 pm

Title: app for Mac OS X 10.6 for deconvolution
Post by: mjk on July 11, 2011, 12:44:07 pm
hi,
i'm new to these forums. I posted on photo.net an announcement of two mac apps, one is for decovolution using caron-algorithm and another for upscaling images preserving edges using neural-networks. Apps are free, tested on mac mini 8GB memory and widescreen display and an old macbook, the app window looks like fitting on different screen resolutions. Andrew Rodney pointed me kindly to LL-forums, as here have been discussions about deconvolution. The code is located http://www.mattikoskinenphoto.com/code (http://www.mattikoskinenphoto.com/code) sources will be available later, after commenting them more properly and cleaning the code.

have fun

-matti
Title: Re: app for Mac OS X 10.6 for deconvolution
Post by: Jeremy Roussak on July 11, 2011, 12:53:57 pm
That's very kind of you. I'll certainly try them out and I'm sure there are people here, far more expert than I, who will be able to provide constructive comment.

Jeremy
Title: Re: app for Mac OS X 10.6 for deconvolution
Post by: kirkt on July 11, 2011, 06:53:56 pm
I will give them a shot and report back. Thanks foe the effort!

Kirk
Title: Re: app for Mac OS X 10.6 for deconvolution
Post by: EricWHiss on July 13, 2011, 04:02:40 am
I'll try it too!
Thanks!
Title: Re: app for Mac OS X 10.6 for deconvolution
Post by: Bart_van_der_Wolf on July 13, 2011, 08:35:41 am
I'll try it too!
Thanks!

Since I'm not a Mac person, I won't be able to try it out. Publishing the code would possibly allow to compile a Windows version for a large audience. It would be interesting to see some results that can be compared with other methods (such as tested in this thread (http://www.luminous-landscape.com/forum/index.php?topic=45038.0)).

This image (http://bvdwolf.home.xs4all.nl/main/downloads/0343_Crop+Diffraction.png) would be a nice one to test. With some relatively low contrast, yet very fine, detail which is blurred by a simulated f/32 diffraction effect it will tell something about the deconvolution capabilities. We've already seen that a very good recovery is possible, so it's interesting to see what the James Caron method can do.

Another image sample (http://www.xs4all.nl/~bvdwolf/main/downloads/7640_Crop+Diffraction.png) was introduced (reply 208) in that thread, which has some more high contrast features as well. It wil be easier to detect ringing artifacts with that image, and noise in the sky.

Looking forward to the results.

Cheers,
Bart
Title: Re: app for Mac OS X 10.6 for deconvolution
Post by: EricWHiss on July 13, 2011, 03:23:32 pm
It's working pretty well actually!  Some rough edges around the GUI but still the results are quite good and its working fairly fast - about 10 seconds for a 30mb jpeg file on my Mac Pro.
I tried to donate money using the paypal link on your page but was given an error. Fix it and I'll send some money as I can already see some benefit from your program.

Thanks,
Eric

Title: Re: app for Mac OS X 10.6 for deconvolution
Post by: EricWHiss on July 13, 2011, 03:38:11 pm
Bart,
Here's your image done with Caron with the following parameters - 1e-7 Sigma, 0.45 Alpha, 3 Smooth, and Use psf tiles checked.
Eric

Edit - sorry could not upload as a png so resaved as jpeg - now compressed but you can see the deconvolution effect.
Title: Re: app for Mac OS X 10.6 for deconvolution
Post by: EricWHiss on July 13, 2011, 03:44:12 pm
Bart,
The windmill image looked great in the preview but threw an error on trying to save it - something about an incompatible file for Open CL.  Don't have more time to play with this right now but will come back later and post some crops of one of my own images that I thought was a really great result.
Eric
Title: Re: app for Mac OS X 10.6 for deconvolution
Post by: Bart_van_der_Wolf on July 13, 2011, 05:35:53 pm
Bart,
Here's your image done with Caron with the following parameters - 1e-7 Sigma, 0.45 Alpha, 3 Smooth, and Use psf tiles checked.
Eric

Hi Eric,

Thanks for the test. It looks a bit coarse and noisy, compared to the earlier attempts with other methods as shown in the thread I mentioned. Also, the overall brightness increased but I understand that that issue is being looked into.

Quote
Edit - sorry could not upload as a png so resaved as jpeg - now compressed but you can see the deconvolution effect.

JPEG output is not an issue, it's supposed to be the end result after all other postprocessing. I just supplied a 16-bit PNG as input to avoid losses to the input data as much as possible, so that the deconvolution algorithms have relatively uncorrupted data to crunch.

Cheers,
Bart
Title: Re: app for Mac OS X 10.6 for deconvolution
Post by: francois on July 14, 2011, 03:18:43 am
Bart,
The windmill image looked great in the preview but threw an error on trying to save it - something about an incompatible file for Open CL.
…
Got the same result  :(
Title: Re: app for Mac OS X 10.6 for deconvolution
Post by: EricWHiss on July 14, 2011, 04:24:58 am
Bart,
I think this worked a lot better with higher resolution files with fine detail.  I haven't seen many programs for the Mac that are this easy.  There was one program for astronomers that could not handle large files, and another raw therapee?  that was a comprehensive image edit program but it was not stable.  Matti's program is very fast and easy to use. 

One issue is that it needs to save out the files as jpeg and not png and it would be helpful if it could save the files with the profiles.

Eric
Title: Re: app for Mac OS X 10.6 for deconvolution
Post by: EricWHiss on July 14, 2011, 05:03:57 am
Here's an image I just worked....  It's from a test I was doing with the Aptus 12 (80mega pix) to see how much detail would be lost as I stopped the lens down. Shot was taken at f/23 - well beyond diffraction limits.   First full frame to show what part of the image was taken, and then the 100% crops - unsharpened, and deconvoluted using sigma value of 1e-4, Alpha of .38   psf of 20 tiles
Title: Re: app for Mac OS X 10.6 for deconvolution
Post by: EricWHiss on July 14, 2011, 05:06:54 am
btw - the deconvoluted image is a much better result than can be achieved using C1 sharpening.  I think Leaf Capture is better for fine detail as is LR3  - but I haven't made that comparison yet.   Still as the cameras push the pixel size down, this kind of processing will become valuable.
Title: Re: app for Mac OS X 10.6 for deconvolution
Post by: Bart_van_der_Wolf on July 14, 2011, 07:32:28 am
btw - the deconvoluted image is a much better result than can be achieved using C1 sharpening.  I think Leaf Capture is better for fine detail as is LR3  - but I haven't made that comparison yet.   Still as the cameras push the pixel size down, this kind of processing will become valuable.

Hi Eric,

Yes, I've been advocating the use of deconvolution sharpening for a long time. It's the only way to really increase (or actually restore) resolution at the pixel level. As sensel density increases, actual system resolution will increase. However, with increased sensel density, the per pixel resolution will go down and the effects of diffraction will not help either. Deconvolution can do a lot to restore a lot of that per pixel resolution, so crops and larger output will also benefit more.

Cheers,
Bart
Title: Re: app for Mac OS X 10.6 for deconvolution
Post by: EricWHiss on July 14, 2011, 01:36:35 pm
Probably, hopefully the big software makers are also well aware of this and are working on building this in.  I think LR3 already has partial implementation maybe others do as well.
Title: Re: app for Mac OS X 10.6 for deconvolution
Post by: ErikKaffehr on July 15, 2011, 12:46:39 am
Hi,

Yes, according to Eric Chan moving the detail slider fully to the right employs deconvolution. It works quite well in my view. Problem is that for deconvolution you really need a PSF (Point Spread Function).

I also use Topaz In Focus, sometimes, it can guess PDSF but I don't know how well.

Best regards
Erik




Probably, hopefully the big software makers are also well aware of this and are working on building this in.  I think LR3 already has partial implementation maybe others do as well.
Title: Re: app for Mac OS X 10.6 for deconvolution
Post by: Bart_van_der_Wolf on July 15, 2011, 03:39:44 am
Hi,

Yes, according to Eric Chan moving the detail slider fully to the right employs deconvolution. It works quite well in my view. Problem is that for deconvolution you really need a PSF (Point Spread Function).

Hi Erik,

I asume Photoshop ACR and Smart Sharpen (advanced mode) use the Radius slider to simulate a PSF shape, perhaps something like a Gaussian. Anyway, Smart Sharpening does not seem as effective as a dedicated deconvolver.

Quote
I also use Topaz In Focus, sometimes, it can guess PDSF but I don't know how well.

Actually, the estimate function of InFocus seems to function quite well. However, it needs some reasonable contrasty edges in various directions in order to find enough clues. It cannot save this PSF (it only saves the slider settings), so it has to be able and find it in the image itself. It's not possible to use a similar setup (distance/aperture) and build a reference to save and use in another image. A workaround would be to enlarge the canvas of an image and add some detail from another image for InFocus to work with. InFocus currently has issues with structures that have a slightly different PSF, such as at a different distance fom the focus plane in the DOF zone. It doesn't take much to create artifacts, forcing one to reduce the amount and thus effectiveness. They'll probably improve it in an upcoming release they say they are working on.

RawTherapee will work reasonably well, when you can find a stable V3 alpha release. The previous stable V2 version also allowed to use the Richardson Lucy deconvolution on e.g. TIFFs, so that would be an alternative.

Cheers,
Bart
Title: Re: app for Mac OS X 10.6 for deconvolution
Post by: Guillermo Luijk on July 18, 2011, 11:06:39 am
Yes, I've been advocating the use of deconvolution sharpening for a long time. It's the only way to really increase (or actually restore) resolution at the pixel level.

Bart, do you think using deconvolution over undemosaiced data (i.e. deconvolute the RAW R, G1/G2 and B channels separately) prior to demosaicing could mean some advantage?. Since diffraction is wavelength dependent, a different PSF for each RAW channel could provide more accurate deconvolution of the information. Also the deconvolution process (PSF estimation + deconvolution) wouldn't be fooled by any undesired characteristic of the demosaicing algorithm.

Care should be taken that each RAW channel is individually sampled at half the spatial frequency as the final image.

This is a series of images representing the B channel (pure RAW undemosaiced data) for several lenses (Hexanon AR 40mm f/1.8, S-M-C Takumar 50mm f/1.4 and Canon 24-70 f/2.8 ) and appertures:

(http://www.guillermoluijk.com/misc/escena.jpg)

(http://www.guillermoluijk.com/misc/nitidez.gif)


This is exactly what the sensor saw, intuitively this should be the domain where deconvolution would work best.

Regards
Title: Re: app for Mac OS X 10.6 for deconvolution
Post by: EricWHiss on July 19, 2011, 11:57:22 pm
I've tested now Topaz In Focus, LR3 detail slider, Raw Therapee (couldn't get it to be stable and work), and Caron.   I really think Caron is working best.  LR3 is different but also showing some nice results. Topaz well worked but not as good as the others.   I tried to post crops from all last night but for some reason the uploading wasn't working - all the crops were about 3mb. 

Long story short, I'm pretty impressed with Caron so far, but at different settings than what the newer version is auto calculating.   

I'll try to upload my results again later. 
Title: Re: app for Mac OS X 10.6 for deconvolution
Post by: Bart_van_der_Wolf on July 20, 2011, 06:23:45 am
Bart, do you think using deconvolution over undemosaiced data (i.e. deconvolute the RAW R, G1/G2 and B channels separately) prior to demosaicing could mean some advantage?. Since diffraction is wavelength dependent, a different PSF for each RAW channel could provide more accurate deconvolution of the information. Also the deconvolution process (PSF estimation + deconvolution) wouldn't be fooled by any undesired characteristic of the demosaicing algorithm.

Hi Guillermo,

Theoretically, and assuming it doesn't screw up subsequent demosaicing, I think it would be a benefit. The 3 color band PSFs could be optimzed for the CFA filter characteristics. However, the practical question will be how much will the benefit be compared to the current practice of deconvolving the RGB channels with the same PSF.

It's interesting to notice that the R/G/B resolution of a gray tone test target is virtually identical to the weighted luminance resolution. They have practically identical MTFs after demosaicing (as determined with Imatest). So the potential gain is in improving the chroma resolution, which isn't the most critical for human vision. How much that would improve the luminance resolution after demosaicing, remains to be seen. 

Quote
Care should be taken that each RAW channel is individually sampled at half the spatial frequency as the final image.

Possibly the easiest (from a programming point of view) approach would be to create 4 intermediate Raw images, just using the relevant R/G1/B/G2 channel sensel data, that would each be 1/4th of the full sensor size (which will also speed up the processing of each). These can then be deconvolved with the appropriate PSF for the spectral band. After that the full Raw data can be repopulated with resolution improved data, and normal demosaicing can take place. That could be an interesting thing for Emil Martinec to try, since he also has worked on the basis of the AMaZE demosaicing algorithm for RawTherapee.

Cheers,
Bart
Title: Re: app for Mac OS X 10.6 for deconvolution
Post by: jguentert on January 09, 2012, 04:34:23 pm
 See: http://www.luminous-landscape.com/forum/index.php?topic=45038.new#new

For all those who are interested in deconvolution like me this may be interesting: I'm still searching for a perfect solution for the Mac (bought but not satisfied with Topaz InFocus – I would pay a lot to get the not perfect but easy to use Focus Magic updated for CS 4 or 5 without the need of Rosetta) but meanwhile I found sth. relatively new in this special field: Back In Focus (http://www.metakine.com/products/backinfocus/) Currently implemented algorithms: Unsharp masking (fast and full) Wiener finite and infinite impulse response Richardson-Lucy (with a thresholding variant) Linear algebra deconvolution

"Back In Focus" is absolutely not for beginners. It took me some days to learn how to use it – and here's room for improvement. But once you got how to use it – you'll get better pictures.

http://www.metakine.com/products/backinfocus/
Title: Re: app for Mac OS X 10.6 for deconvolution
Post by: PierreVandevenne on January 11, 2012, 08:34:37 am
Theoretically, and assuming it doesn't screw up subsequent demosaicing, I think it would be a benefit. The 3 color band PSFs could be optimzed for the CFA filter characteristics. However, the practical question will be how much will the benefit be compared to the current practice of deconvolving the RGB channels with the same PSF.

I did try a similar approach with my astro sensors (working on full frame L R G and B images) with LR and VC deconvolution algorithms. The issue I had was that while the individual images "improved" in resolution, at least in my perception they were harder to combine regardless of whether I used the same PSF (calculated from an unsaturated star in the L frame) or a specific PSF calculated on each frame. I was unable to decide whether the issue was caused by the mysteries of iterations, noise around the star I used for the PSF (which had a very different look in the R and B channel for example) or the fact that even with a good apchromatic triplet R G and B do not focus exactly at the same point or even the fact that somes stars saturated the sensor in one color and not in another....

And indeed, if there is a benefit, will it be worth the trouble? Sharpening is a bit subjective anyway.