# Re: [Gimp-developer] healing the healing tool

```On 20 Feb, Hal V. Engel wrote:
> On Tuesday 20 February 2007 16:28, peter sikking wrote:
>> now that we got the brush part nailed, we need to find something for
>> the user to set the source area. To me as an interaction architect
>> the healing brush looks like a smart clone tool on steroids.
>>
>> that means we can use exactly the same interaction as the clone tool.
>
> This is exactly the way this works in photoshop and I can't think of any
> reason to do it differently.  In fact this is exactly what I would expect as
> a user.```
```
Let me explain the difference between the clone tool and the healing
tool in more detail.

Given an I(mage) which contains (usually) small regions S(ource) and
D(estination/defective) of identical shape.

Step 1 (exactly like the clone tool)  Copy S to D, call this S'

Step 2 Usually this copy doesn't fit perfectly to the neighbourhood
of D in I. One reason could be a different 'lightening'.
To improve this - like a chameleon - S' should adapt itself to
its neighbourhood. Georgiev's algorithm tries to find a (distributed)
factor F which should be multiplied to each pixel value (each color)
within S'.
Of course, this distributed factor should be as smoothly varying as
possible since otherwise you get a random picture.
To do so, this factor is computed by dividing (the color values)
of each boundary pixel in D by the corresponding one in S. Now, these
values, which are only given at the boundary of S', are extended smoothly
into the interior of S by solving a so-called Poisson equation.

For this to work as expected the boundary of D must not contain
'defective' pixels since otherwise this defect would be extended into
the interior and the healing tool probably produces worse results than
the clone tool itself.

Therefore one does need an area D which includes the defective
parts but whose boundary must not contain any defective pixels.
Please have a look at the example given on page 3 of
http://www.tgeorgiev.net/Invariant.pdf

If the healing tool were to applied on the fly while the brush is over a
defective part, its boundary will most probably contain defective
pixels. Think of long thin scratch, say several hundreds of pixels long,
and you're using a brush of say 20 pixels in diameter.

So, if the 'brush style' of the healing tool is a must, I'd suggest to
do away with the healing tool altogether - as a separate tool. Instead
one could add a post-processing option to the clone tool which tries to
call for the chameleon described above.

For that to implement, one would need to gather the (set-)union of all
the regions having been touched by the brush in the source as well as in
the destination area. Furthermore this union should be filled afterwards
not to contain many tiny holes.

Again, since I don't know the internal API of Gimp, I would need a lot
of help for implementing that. Once, both regions are given, I could
implement a (fast) method to apply Georgiev's algorithm.

Helmut.

--
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
_______________________________________________
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer
```