After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 109801 - Implement a healing brush and patch tool like in Photoshop
Implement a healing brush and patch tool like in Photoshop
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Tools
git master
Other All
: Normal enhancement
: 2.4
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks: 127786
 
 
Reported: 2003-04-02 18:04 UTC by Raphaël Quinet
Modified: 2006-09-02 18:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
current status of the healing brush (63.55 KB, patch)
2006-08-04 15:51 UTC, Kevin Sookocheff
none Details | Review
Healing Brush (75.14 KB, patch)
2006-08-10 13:48 UTC, Kevin Sookocheff
none Details | Review

Description Raphaël Quinet 2003-04-02 18:04:57 UTC
I have seen this request a couple of times, but without a description of
what the healing brush is supposed to do.  Now I have just read a message
from Olivier Ripoll in comp.graphics.apps.gimp in which he gives the
following link that contains a PDF file demonstrating the effect:
  http://www.digitalretouch.org/Photoshop7.html
Thanks to Olivier for providing that link as well as the link to the
quicktime video on the Adobe site:
  http://www.adobe.com/products/photoshop/newfeatures.html

The explanations in the PDF file are nice and easy to understand.  In
summary, the healing brush is similar to the clone tool, except that it
merges the "texture" from the sample area into the color and luminosity of
the destination area.  Also, it looks at an area that is a bit larger than
the brush in order to create a seamless merge.

A related tool is the patch tool.  Instead of operating with the active
brush, it works on a whole selection that can be dragged to another part
of the image.  As illustrated on the tutorial included in the other PDF
file on the page above, this technique is really powerful when combined
with transformations of the selection (see the example with the sweater).

These seem to be some very nice tools for photo retouching, so here is a
Bugzilla entry for them...
Comment 1 Alan Horkan 2003-07-23 18:37:46 UTC
Changes at the request of Dave Neary on the developer mailing list.  
I am changing many of the bugzilla reports that have not specified a target
milestone to Future milestone.  Hope that is acceptable.  
Comment 2 gsr.bugs 2003-08-19 19:07:53 UTC
I found some ways that could be those tools (IMO they are the
same thing, just brush or selection based, but same algorithm).
Check mails in gimp-devel or gimp-user archives with subject
"Interesting trick using new modes", by Guillermo S. Romero.

The last step I have to guess is a method to fill areas
when the content is really different from the surroundings.
But the idea is easy: fuzzy the destination so it keeps
the global lighting, and copy the "grain" from a good area.

BTW, since when (date preferably to version) does PS have
those tools?
Comment 3 Frédéric Mantegazza 2006-03-28 13:10:08 UTC
Any news, about this tool ? I saw someone using it on Photoshop some years ago (maybe 4 or 5), and this is one of the tool I'm waiting to see in the Gimp.
Comment 4 Michael Natterer 2006-03-28 15:35:14 UTC
And waiting for it won't make it happen :) A patch would be appreciated.
Comment 5 gsr.bugs 2006-05-02 22:36:34 UTC
Looked for the post
http://lists.xcf.berkeley.edu/lists/gimp-user/2003-August/006469.html

Also, a note about the fill part, there was some kind intelligum filter but
I have not checked how it works internally (or if any good for this use,
demo image looked ok, but I have not texted other cases, like multiple
separate holes).
http://www.geocities.com/lode_leroy/gimp/

There are other methods like in CImg or restorePainting (look for the images
about fixing holes/text, called inpainting). Some ways are fast and others
are slow, worth checking I guess.
http://cimg.sourceforge.net/
http://restoreinpaint.sourceforge.net/

The "make web" in the post, after some toughts, could be like make a vertical
interpolation of the area to be replaced, and another horizontal (travel
along the hole(s) and linear interpolate from last good pixel in one side
to first good pixel in the other side of each hole, a gradient per
column or row, maybe multiple if there multiple holes are crossed), then
use a checker pattern to select pixels from each direction and do a small
blur to mix the checkers.
Comment 6 Michael Schumacher 2006-07-27 07:50:16 UTC
A healing brush is one of the SoC 2006 projects.
Comment 7 Michael Schumacher 2006-08-03 15:01:21 UTC
Disregard the comment above, this SoC project was cancelled.
Comment 8 Kevin Sookocheff 2006-08-04 15:51:53 UTC
Created attachment 70204 [details] [review]
current status of the healing brush
Comment 9 Kevin Sookocheff 2006-08-04 15:55:28 UTC
Comment on attachment 70204 [details] [review]
current status of the healing brush

Although the project has been cancelled.  Here is the progress I have made so far.  I did not have time to clean some of it up, but I have double and triple checked the math and everything is being calculated correctly, there is just a problem when I go to display the calculations that I have made.

At the root of the problem is that I don't know how to correctly extract the PixelRegion directly under the cursor.  Line XXX to XXX of gimpheal.c is where the problem seems to lie.  If I check the contents of fPR, usually the reflect the current value underneath the cursor, but at times pixels in this region are erroneous and after performing the calculations erroneous data is painted to the screen.

Other than that, the code works as advertised, and does not break anything in GIMP, so patch it in and give it a try!  To get the best results (ignoring the erroneous data!) use a big brush.  Perhaps someone with more knowledge of how to extract PixelRegions would be able to fix it.  If you can put the proper data into fPR the rest follows.  I tried a LOT of different things but just couldn't get it to work.

One area of work left is to implement the options that can be used for the  clone tool.  I took out these options so that I could just concentrate on the healing brush itself, but they can be added back in by looking at the Clone tool code.

Lastly, I got the tool to display in the tool box, and created a cursor, but the cursor doesn't display properly.

Attached is a patch with all work done so far.  I hope this helps someone!
Comment 10 Kevin Sookocheff 2006-08-04 15:55:28 UTC
Comment on attachment 70204 [details] [review]
current status of the healing brush

Although the project has been cancelled.  Here is the progress I have made so far.  I did not have time to clean some of it up, but I have double and triple checked the math and everything is being calculated correctly, there is just a problem when I go to display the calculations that I have made.

At the root of the problem is that I don't know how to correctly extract the PixelRegion directly under the cursor.  Line XXX to XXX of gimpheal.c is where the problem seems to lie.  If I check the contents of fPR, usually the reflect the current value underneath the cursor, but at times pixels in this region are erroneous and after performing the calculations erroneous data is painted to the screen.

Other than that, the code works as advertised, and does not break anything in GIMP, so patch it in and give it a try!  To get the best results (ignoring the erroneous data!) use a big brush.  Perhaps someone with more knowledge of how to extract PixelRegions would be able to fix it.  If you can put the proper data into fPR the rest follows.  I tried a LOT of different things but just couldn't get it to work.

One area of work left is to implement the options that can be used for the  clone tool.  I took out these options so that I could just concentrate on the healing brush itself, but they can be added back in by looking at the Clone tool code.

Lastly, I got the tool to display in the tool box, and created a cursor, but the cursor doesn't display properly.

Attached is a patch with all work done so far.  I hope this helps someone!
Comment 11 Kevin Sookocheff 2006-08-10 13:48:51 UTC
Created attachment 70643 [details] [review]
Healing Brush

This patch implements the healing brush.  It adds the new tool to the toolbox, and displays its own cursor.  I know that the code needs to be further integrated into GIMP so that it works like the rest of the tools, but I don't know how to do that right now so if someone is up for it please patch it in for everyone to try.

TODO:

At this point I've identified two error cases:

1.  I have not implemented the funtionality to choose the source healing point from a separate image.  Currently, you must choose the source region from the same image that is being healed.  This could be implemented using the clone tool is a reference point.

2.  The brush does not work for indexed images.  I haven't thought too much about this yet, but it doesn't seem easy to implement the brush for indexed images.
Comment 12 Ville Pätsi 2006-08-19 08:54:21 UTC
Healing tool in cvs as of 2006-08-18. The alignment "none" doesn't work, subsequent cursor strokes start from an aligned position relative to the current cursor position, not from the point selected from source. Actually I can't see any difference between the alignment modes.
Comment 13 Michael Natterer 2006-09-02 18:43:40 UTC
Merged the branch to HEAD and closing as FIXED. If somebody cares about
the "patch tool" mentioned in the summary, or if bugs in the heal tool
are found, please open separate bugs for this.

2006-09-02  Michael Natterer  <mitch@gimp.org>

	Merged the "soc-2006-healing-brush" branch. That branch is now
	officially closed and all further fixes and changes have to be
	applied to HEAD.

	Did some minor adjustments, mostly small indentation and spacing
	fixes. Derive the tool from the newly introduced GimpBrushTool
	which did not exist when the branch was created.

	Thanks a lot to Kevin Sookocheff for this nice contribution!

	* app/paint/paint-enums.[ch]: new enum GimpHealAlignMode.

	* app/paint/Makefile.am
	* app/paint/makefile.msc
	* app/paint/gimpheal.[ch]
	* app/paint/gimphealoptions.[ch]: the heal core and its options.

	* app/paint/gimp-paint.c: register the heal core.

	* app/tools/Makefile.am
	* app/tools/makefile.msc
	* app/tools/gimphealtool.[ch]: the heal tool.

	* app/tools/gimp-tools.c: register the heal tool.

	* app/tools/gimppaintoptions-gui.c: show the widgets that are used
	by heal.

	* app/widgets/gimphelp-ids.h: the heal help ID.

	* tools/pdbgen/stddefs.pdb
	* tools/pdbgen/pdb/paint_tools.pdb: the heal PDB wrappers.

	* app/widgets/widgets-enums.h
	* app/widgets/gimpcursor.c
	* cursors/Makefile.am
	* cursors/makefile.msc
	* cursors/tool-heal.png
	* cursors/xbm/tool-heal.xbm
	* cursors/xbm/tool-heal-mask.xbm: a new cursor for the heal tool.

	* libgimpwidgets/gimpstock.[ch]
	* themes/Default/images/Makefile.am
	* themes/Default/images/makefile.msc
	* themes/Default/images/tools/stock-tool-heal-16.png
	* themes/Default/images/tools/stock-tool-heal-22.png: new stock
	icons for the heal tool.

	* app/pdb/internal_procs.c
	* app/pdb/paint_tools_cmds.c
	* libgimp/gimppainttools_pdb.[ch]: regenerated.