Post Reply 

Colour to Alpha leaves behind white pixels

Jul 19, 2011, 19:51
Post: #1
Colour to Alpha leaves behind white pixels
Whenever I try to use the 'Colour to Alpha' tool, while it works on most of the image, I always get little white dots left behind, and have to spend ages use the eraser tool to get rid of them. Why is this happening and how can I stop this?
Find all posts by this user
Quote this message in a reply
Jul 19, 2011, 20:17
Post: #2
RE: Colour to Alpha leaves behind white pixels
Do you have an example (before & after)?

Now answering your questions on
https://Gimp-Forum.net
Visit this user's website Find all posts by this user
Quote this message in a reply
Jul 20, 2011, 16:02
Post: #3
RE: Colour to Alpha leaves behind white pixels
(Jul 19, 2011 20:17)ofnuts Wrote:  Do you have an example (before & after)?

Here's before-
[Image: ohprgi.png]

And after-
[Image: 16gbzhu.png]

I used a black background on the after so you could see the white dots. This time I tried the fuzzy select tool, then hit delete (colour to alpha was making the whole picture transparent!), but I was still left with white pixels!
Find all posts by this user
Quote this message in a reply
Jul 20, 2011, 20:31
Post: #4
RE: Colour to Alpha leaves behind white pixels
Color-to-alpha leaves white spots because 1) your background isn't perfect white (it's 254,254,254) and 2) it contains grey spots (as low as 226,226,226).

Here is how you can remove them without looking every pixel up:
  • Select everything but the subject:
    • Use the magic wand with a moderate threshold (15).
    • Click to select the background.
    • Shift-click to add any non-contiguous bits (like the space between the legs above).
    • Also shift-click on the 'islands' you see (they should become integrated in the selection and disappear).
    • Shrink the selection by 2 pixels.
    • Use 'quickmask' to check you didn't get anything selected in the subject and paint it to exclude it.
    • Invert and save to channel as 'Subject'
  • Select everything which is not exactly the normal background:
    • Use the color picker to pick the background color (use sample average with a large radius, or make sure you aren't picking a grey spot).
    • Create a layer and fill it with that color.
    • Set the new layer to "difference" mode. You'll see something that look like a negative
      of your picture.
    • use "Layer/New from visible" so this image becomes a layer. You can delete the "white" layer you created.
    • Use the Threshold tool on that new layer and drag the threshold down to "1". Your grey spots should become very visible
    • Using the select by color tool, select the white, and grow it by one pixel
    • Save that selection to channel as "subject+spots"
  • Hide that layer and select the image layer
  • In the Channels dialog, right click on the 'subject+spots' selection saved before, and 'channel to selection". Then right click on the 'subject' and "substract from selection". The selection is now all the grey spots far enough from the subject.
  • Bucket-fill selection with background color. All you gray spots are painted over.

We can now deal with color-to-alpha. It indeed makes part of the subject (partially) transparent. So the good and easy technique is:
  • Start the magic wand with a low threshold (<5). Click to select the background. Shift-click to add any non-contiguous bits (like the space between the legs above).
  • Select/Grow the selection by one or two pixels: the selection should now include the border of the subject
  • Run color-to-alpha, after setting the color to the actual background color. Its effects will be restricted by the selection, and therefore will only change the background and the border of the subject.
In your image the "wings" have a blur/partial transparency which isn't only caused by anti-aliasing, so color-to-alpha isn't perfect (they look added, they miss the black contour line)
[attachment=553]

Now answering your questions on
https://Gimp-Forum.net
Visit this user's website Find all posts by this user
Quote this message in a reply
Jul 21, 2011, 22:46
Post: #5
RE: Colour to Alpha leaves behind white pixels
(Jul 20, 2011 20:31)ofnuts Wrote:  Color-to-alpha leaves white spots because 1) your background isn't perfect white (it's 254,254,254) and 2) it contains grey spots (as low as 226,226,226).

Here is how you can remove them without looking every pixel up:
  • Select everything but the subject:
    • Use the magic wand with a moderate threshold (15).
    • Click to select the background.
    • Shift-click to add any non-contiguous bits (like the space between the legs above).
    • Also shift-click on the 'islands' you see (they should become integrated in the selection and disappear).
    • Shrink the selection by 2 pixels.
    • Use 'quickmask' to check you didn't get anything selected in the subject and paint it to exclude it.
    • Invert and save to channel as 'Subject'
  • Select everything which is not exactly the normal background:
    • Use the color picker to pick the background color (use sample average with a large radius, or make sure you aren't picking a grey spot).
    • Create a layer and fill it with that color.
    • Set the new layer to "difference" mode. You'll see something that look like a negative
      of your picture.
    • use "Layer/New from visible" so this image becomes a layer. You can delete the "white" layer you created.
    • Use the Threshold tool on that new layer and drag the threshold down to "1". Your grey spots should become very visible
    • Using the select by color tool, select the white, and grow it by one pixel
    • Save that selection to channel as "subject+spots"
  • Hide that layer and select the image layer
  • In the Channels dialog, right click on the 'subject+spots' selection saved before, and 'channel to selection". Then right click on the 'subject' and "substract from selection". The selection is now all the grey spots far enough from the subject.
  • Bucket-fill selection with background color. All you gray spots are painted over.

We can now deal with color-to-alpha. It indeed makes part of the subject (partially) transparent. So the good and easy technique is:
  • Start the magic wand with a low threshold (<5). Click to select the background. Shift-click to add any non-contiguous bits (like the space between the legs above).
  • Select/Grow the selection by one or two pixels: the selection should now include the border of the subject
  • Run color-to-alpha, after setting the color to the actual background color. Its effects will be restricted by the selection, and therefore will only change the background and the border of the subject.
In your image the "wings" have a blur/partial transparency which isn't only caused by anti-aliasing, so color-to-alpha isn't perfect (they look added, they miss the black contour line)



Thanks, I really appreciate your help, but I forgot to say, I'm still relatively new to GIMP, so I can't really do anything that technical yet...Blush I'm really sorry, I should have said. But since you obviously do know what you're doing, I don't suppose you'd be able to get rid of the background for me, and upload it on tinypic or something and post the link? It would be great if you could, but I completely understand if you're too busy or something, so you don't have to
Find all posts by this user
Quote this message in a reply
Jul 21, 2011, 23:47 (This post was last modified: Jul 21, 2011 23:48 by ofnuts.)
Post: #6
RE: Colour to Alpha leaves behind white pixels
(Jul 21, 2011 22:46)Animegirl13 Wrote:  Thanks, I really appreciate your help, but I forgot to say, I'm still relatively new to GIMP, so I can't really do anything that technical yet...Blush I'm really sorry, I should have said. But since you obviously do know what you're doing, I don't suppose you'd be able to get rid of the background for me, and upload it on tinypic or something and post the link? It would be great if you could, but I completely understand if you're too busy or something, so you don't have to

The image I posted has no background (the black is GimpForums background).

The first long explanation is really quickly done if you have some small Gimp skills. It is faster than the low-tech pixel-peeping the original background to find the gray spots.

Now answering your questions on
https://Gimp-Forum.net
Visit this user's website Find all posts by this user
Quote this message in a reply
Jul 23, 2011, 13:38
Post: #7
RE: Colour to Alpha leaves behind white pixels
(Jul 21, 2011 23:47)ofnuts Wrote:  
(Jul 21, 2011 22:46)Animegirl13 Wrote:  Thanks, I really appreciate your help, but I forgot to say, I'm still relatively new to GIMP, so I can't really do anything that technical yet...Blush I'm really sorry, I should have said. But since you obviously do know what you're doing, I don't suppose you'd be able to get rid of the background for me, and upload it on tinypic or something and post the link? It would be great if you could, but I completely understand if you're too busy or something, so you don't have to

The image I posted has no background (the black is GimpForums background).

The first long explanation is really quickly done if you have some small Gimp skills. It is faster than the low-tech pixel-peeping the original background to find the gray spots.



Thanks, I've found a way around it now using the Shrink/Grow Selection on the Select tab, and various other ways. Smile
Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Color alpha function and its current errors Fuse809 0 266 Oct 11, 2014 03:53
Last Post: Fuse809
  Two 'halves' colour correction Supermandan1 3 280 Oct 10, 2014 12:05
Last Post: iForStyle007
Question Alpha broken?? Zrahurgh 13 752 Sep 6, 2014 09:38
Last Post: Zrahurgh
  Colour balance is broken in 2.8? snowjoke 1 249 Sep 4, 2014 00:11
Last Post: snowjoke
  Gimp 2.8 freezing on Color to alpha Garverick 8 531 Aug 16, 2014 18:18
Last Post: Garverick

Forum Jump:


GIMP ForumPortalArchiveContactTermsRSS