[Gimp-user] Turn black background into white -- with fuzzy edges

2007-11-26 Thread Lea Wiemann

Hi,

I'd like to turn a black background into white, or transparency (in 
which case it should look cut if displayed on a white background).  My 
practical use case is photos of objects with black backgrounds that I'd 
like to improve for Wikipedia.  The problem is that the boundary between 
background and object is usually fuzzy.


I've created a pair of example images (attached): Say I start off with 
the image fuzzy-circle.png (a gray-patterned circle on a black 
background); what I would like to get is something like 
fuzzy-circle-goal.png (the gray-patterned circle on a white background) 
-- but that seems pretty hard to achieve:  If I select by color: black 
and then cut the selection, the corners look either aliased/too sharp 
(for high thresholds in the select-by-color tool), or they have dark 
pixels in them (for low thresholds).  Selecting the black background, 
growing the selection (2px), feathering it (2px), and then cutting the 
selection *kinda* works, but it cuts off the blurry part of the object 
boundary.


Any ideas on this one?

Best wishes,

Lea
inline: fuzzy-circle.pnginline: fuzzy-circle-goal.pnginline: fuzzy-circle-too-sharp.pnginline: fuzzy-circle-darks-pixels.png___
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user


Re: [Gimp-user] Turn black background into white -- with fuzzy edges

2007-11-26 Thread Owen
On Mon, 26 Nov 2007 03:59:23 -0500
Lea Wiemann [EMAIL PROTECTED] wrote:

 Hi,
 
 I'd like to turn a black background into white, or transparency (in 
 which case it should look cut if displayed on a white background).  My 
 practical use case is photos of objects with black backgrounds that I'd 
 like to improve for Wikipedia.  The problem is that the boundary between 
 background and object is usually fuzzy.
 
 I've created a pair of example images (attached): Say I start off with 
 the image fuzzy-circle.png (a gray-patterned circle on a black 
 background); what I would like to get is something like 
 fuzzy-circle-goal.png (the gray-patterned circle on a white background) 
 -- but that seems pretty hard to achieve:  If I select by color: black 
 and then cut the selection, the corners look either aliased/too sharp 
 (for high thresholds in the select-by-color tool), or they have dark 
 pixels in them (for low thresholds).  Selecting the black background, 
 growing the selection (2px), feathering it (2px), and then cutting the 
 selection *kinda* works, but it cuts off the blurry part of the object 
 boundary.
 
 Any ideas on this one?


If you are using 2.4, Colours-Colour to alpha
or in 2.2 Filters-Colours-Colour to alpha

After that, make a new layer and fill with whatever colour you want



Owen
___
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user


Re: [Gimp-user] Turn black background into white -- with fuzzy edges

2007-11-26 Thread David Gowers
Hi Lea,

On Nov 26, 2007 7:29 PM, Lea Wiemann [EMAIL PROTECTED] wrote:
 Hi,

 I'd like to turn a black background into white, or transparency (in
 which case it should look cut if displayed on a white background).  My
 practical use case is photos of objects with black backgrounds that I'd
 like to improve for Wikipedia.  The problem is that the boundary between
 background and object is usually fuzzy.

There is no real good way to do this for arbitrary photos; For this
particular photo, the best result I could achieve was by:
1. Use magic wand to select background
2. Convert the selection to a path, and convert the path back into a
selection (this has the effect of smoothing the edges of the
selection.. PoTrace produces better results than the GIMP sel2path
plugin, I assume you have to work with standard GIMP plugins only
though.)
3. Fill with white.

The result of applying this is attached.

Notably this shows a smooth black outline around the object. The
method I tried to convert white to black without causing an outline
effected the overall color of the object too much instead.  (this
method was: 1. layers-transparency-color to alpha (select black); 2.
flatten with bgcolor = white.)
attachment: fuzzy-circle-done.png___
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user


Re: [Gimp-user] Turn black background into white -- with fuzzy edges

2007-11-26 Thread Dave 77459
On Nov 26, 2007 3:57 AM, Owen [EMAIL PROTECTED] wrote:

 On Mon, 26 Nov 2007 03:59:23 -0500
 Lea Wiemann [EMAIL PROTECTED] wrote:

  Any ideas on this one?


 If you are using 2.4, Colours-Colour to alpha
 or in 2.2 Filters-Colours-Colour to alpha

 After that, make a new layer and fill with whatever colour you want



 Owen



I don't know if that satisfies her need, but it is a useful technique I did
not know about but will use extensively.  Thank you.

Dave
___
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user


Re: [Gimp-user] Turn black background into white -- with fuzzy edges

2007-11-26 Thread Pere Pujal i Carabantes

El dl 26 de 11 del 2007 a les 03:59 -0500, en/na Lea Wiemann va
escriure:
 Hi,
 
 I'd like to turn a black background into white, or transparency (in 
 which case it should look cut if displayed on a white background).  My 
 practical use case is photos of objects with black backgrounds that I'd 
 like to improve for Wikipedia.  The problem is that the boundary between 
 background and object is usually fuzzy.
 
 I've created a pair of example images (attached): Say I start off with 
 the image fuzzy-circle.png (a gray-patterned circle on a black 
 background); what I would like to get is something like 
 fuzzy-circle-goal.png (the gray-patterned circle on a white background) 
 -- but that seems pretty hard to achieve:  If I select by color: black 
 and then cut the selection, the corners look either aliased/too sharp 
 (for high thresholds in the select-by-color tool), or they have dark 
 pixels in them (for low thresholds).  Selecting the black background, 
 growing the selection (2px), feathering it (2px), and then cutting the 
 selection *kinda* works, but it cuts off the blurry part of the object 
 boundary.
 
 Any ideas on this one?
 
I am doing a script that might help you. It is not specyfic to your
purpose but hope it helps.

Install mktpstamp.scm from here to your gimp-version/scripts directory
http://fornol.no-ip.org/linux/tuxpaint/scripts
Then open Gimp

Select by fuzzy select or by color black with threshold 50
Show the layers dialog.
add a layer mask  inverted from selection
You get something like fuzzy-circle-darks-pixels.png you posted
Active the image, not the mask, add an alpha channel to it.
Select by fuzzy select or by color black with threshold 50
grow the selection by the number of pixels needed to cover the dark
ones.(1 or 2)
CTRL X to delete all the selection.
You get a image that lacks the edge pixels, they will be regenerated
from the current edges when running the script.

Run mktpstamp (It appears in filters artistic in gimp 2.4.x or in
script-fu alquemy on 2.2.xx)
Uncheck Scale Create .txt file and Create .dat file
If you are confident, select a proper filename and keep Save and close.
This will make a transparent .png file
Else
Change Save and close to Don't save and keep for editing.
This will make a new image with 4 layers
A backup layer two contrast layers and the working layer.
You can then make the contrast layers visible/invisible by turn to check
if there is any weird effect.

When happy fill the green contrast layer with wite or any color you
want, flat the image and save.

If you want transparency, do a new image from the top layer(just drag
the layer to the toolbox) and save it.


More instructions to run it you can find at
http://sourceforge.net/mailarchive/forum.php?thread_name=1185622883.26911.151.camel%40hola.fou.netforum_name=tuxpaint-devel

BTW any comments on how to improve it are welcome.


 Best wishes,
 
  Lea

Yours
Pere
attachment: mystamp.png___
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user


Re: [Gimp-user] Turn black background into white -- with fuzzy edges

2007-11-26 Thread Lea Wiemann

David Gowers wrote:

On Nov 26, 2007 7:29 PM, Lea Wiemann [EMAIL PROTECTED] wrote:

I'd like to turn a black background into white [...]
The problem is that the boundary between
background and object is usually fuzzy.


1. Use magic wand to select background
2. Convert the selection to a path, and convert the path back into a
selection
3. Fill with white.

Notably this shows a smooth black outline around the object.


Cool, thanks a lot!  If I grow the resulting selection by 1px before 
filling with white, I get a very smooth edge without any dark outline 
(attached).  It makes me lose the very outermost pixels of the edge of 
the object, but I think I can live with that.  (In more complex images I 
found that that the paths needed manual fine-tuning, but it's still fast 
enough.)


Best wishes,

Lea
inline: fuzzy-circle-done2.png___
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user