This code was written by Lukas Kunc . Some of the code was borrowed from the Gimp Refocus plugin by Ernst Lippe.