Gimp-Forum.net

Full Version: problem with set color to alpha
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
New to all of this, Perhaps I am trying to go about this the wrong way.....not sure.
But, for instance,  suppose I wanted to cut an image of somebody  out of picture "A", and insert it into an already existing image "B"

SO, I painstakingly draw a white area  all around the perimeter of the desired target image, then extend that white area sufficiently large that I can select and crop to a rectangular  image for use.
Then I review the image and find a color not in use in the  target image, say  HTML color h1cf905 for  example ....no sign of that color anywhere in the target image , and then change the white area surrounding the target to that color, and then set that color to alpha.


Hoping to paste that image, complete with the transparent surround, into the "B" image.
Except when I set the surround color to alpha, it's causing the colors in the target image to get all whacked out.  For instance  with the  color mentioned  set to alpha, everything is shifting into violet colors.

Almost seems like the "color to alpha" function isn't discriminating properly, and is perhaps shifting all greens to alpha?
Thanks in advance for pointing me in the right direction
(02-02-2019, 01:35 AM)rickk Wrote: [ -> ]SO, I painstakingly draw a white area  all around the perimeter of the desired target image
It would be better to use the Eraser tool. Select a suitable brush (eg round, hardness 100) and erase the unwanted area.

There are also Gimp's selection tools. Use one of these to select an area, then do Edit > Clear. And when you get to know Gimp a bit better there are Layer Masks.

Quote:Almost seems like the "color to alpha" function isn't discriminating properly, and is perhaps shifting all greens to alpha?
Yes, that is the way "color to alpha" works. Use one of the selection tools to select an area, then use "color to alpha" on that area. The parts of the image outside of the selected area are not affected.
Quote:...Then I review the image and find a color not in use in the target image, say  HTML color h1cf905..

All depends on the image but generally with Gimp 2.8 that will be a difficult find. There will be elements of #1cf905 in the colours. This a comparison before/after 2.8 c2a leaving a semi-transparent image.

[attachment=2583]

If you ever upgrade to Gimp 2.10 the GEGL c2a has some extra controls that might make an improvement.

[attachment=2584]

However as Blighty points out there are other ways and depending what you are doing (one-off / many similar layers) a layer mask is non-destructive and give plenty of control by painting transparency in/out or there are plugins to help. Ofnuts has one ofn-erase-background.py about 5 down here:  http://sourceforge.net/projects/gimp-too...s/scripts/
Thanks to all



(02-02-2019, 05:00 AM)Blighty Wrote: [ -> ]Yes, that is the way "color to alpha" works. Use one of the selection tools to select an area, then use "color to alpha" on that area. The parts of the image outside of the selected area are not affected.

Interesting...I would have thought that with  a bitmap composed of pixels, each pixel would  have a specific color assigned to it, and the "color to alpha" function would affect pixels  having only the exact color specified (in this case h1cf905) .

As an  aside, while I was playing around with this I converted a black and white image to a RGB format and then went through the proceedure as outlined in my original post, and the "color to alpha" function caused a violet shift in that image as well. Making me wonder where the  spurious  h1cf905 could have possibly come from in an image that was originally black and white.

Anyway, thanks for the pointers, the suggestion to work within selected areas sounds like good advice, although it will be challenging to employ on targets  having an irregular outline.

For whatever reason I seem to find it easier (albeit time consuming) to paint a border around a target image than to try and draw a selection boundry around it. And the "auto" gizmos are not discreet enough

Boy this "auto append" function at this board where subsequent replys are just squeezed into your proceeding replies.... sure is annoying
Quote:Interesting...I would have thought that with  a bitmap composed of pixels, each pixel would  have a specific color assigned to it, and the "color to alpha" function would affect pixels  having only the exact color specified (in this case h1cf905) .

That would not give very good results and would have a jagged outline as pixels will transition in color as they get close to another color. You can achieve what you are asking by using the fuzzy select tool. Set the threshold to 1 and select a color on an image and look at the outline of the selection. You can play with the various options, but I don't think you'll achieve exactly what you are thinking.

[attachment=2592]

This color to alpha plugin does more of what you are imagining but only works well with 2 well defined colors and takes a dog's age to process. Still a handy addition to the toolbox for certain situations.
Interesting plugin, one for the collection, however. 

Another option is the G'mic Gimp Plugin. One of the filters is an Interactive Foreground Extraction. Almost fool-proof with a painted in background colour but no need for that, it works (mostly) with a regular background.

Dot around the inside of the foreground, then the background and most of the time makes a good extraction. I often use it to make a binary mask for use with a layer mask. Good starting point for tidying up the edges and uncovering any tiny details.

example: https://i.imgur.com/9EmnkCd.jpg

Again, all depends on purpose, type of image or a one-off or a multitude of images.
(02-03-2019, 05:10 PM)rich2005 Wrote: [ -> ]Again, all depends on purpose, type of image or a one-off or a multitude of images.

Too bad there is not a "paint with transparency" function where existing picture data would be replaced with transparency via one brush stroke.  For example, assume that "transparent" was a selectable "color" in much the same way other colors on the pallet work. Seems like that would be a useful tool.
There is a color erase but the same problem as before, in an RGB image you can remove elements of the 'erase' color but liable to leave remnants of the rest behind.

[Image: 7lP5BiV.jpg]
(02-03-2019, 07:51 PM)rickk Wrote: [ -> ]Too bad there is not a "paint with transparency" function where existing picture data would be replaced with transparency via one brush stroke.

You seem to be describing the Eraser tool. Make sure that the layer has an alpha channel.

In 2.10 you can also use the Paintbrush with Mode set to Erase.
(02-03-2019, 08:37 PM)Blighty Wrote: [ -> ]You seem to be describing the Eraser tool. Make sure that the layer has an alpha channel.

In 2.10 you can also use the Paintbrush with Mode set to Erase.

I'll have to look into that. Seems like the one time that I tried to use the eraser  tool to do a  "cut out", the white surround was a problem when I pasted into the second image. But I wasn't using alpha on the layer being cut from. SO perhaps that's my solution.   Smile

So, if I did do an upgrade to version 2.10, currently I have a  lot of extras like GAP, Resynthesizer, Paint Studio, as well as  custom brushes,  Textures, Gradients, and themes installed in version 2.8
Would I have to go back through and  add-in all of those extras to a 2.10 upgrade installed?
Pages: 1 2