Jump to content


Photo

Change to Transparent Tool


1 reply to this topic

#1 Ilovemath224

Ilovemath224
  • Newbies
  • 3 posts
  • Reputation:0

Posted 17 June 2011 - 01:53 PM

I'm pretty sure you've all seen images with white backgrounds right? Well, what if you want to change the white background to a transparent one? Sure, you could delete most of the white part of the image, but that leaves annoying white edges. Or you could delete every little bit of white that's visible, but that leaves the image undetailed.

OR you could use two long gradients in another image, one directly over the other, with the same length, with the top one being the main color of the image at it's outline fading into an non seeable color, and the bottom one being the main color of the image at it's outline fading into the color of the image's background, with the gradients being parrellel and with the same endpoints to make the process easier, as a key to make the edges of the image the appropriate transparent color, along with getting rid of the unneeded background, by following these easy steps:
1: Make the key, as described above. It should look something like the key attached to this image.
2: Use a selection tool to pick a specific color in the image, preferably the magic wand with a low flood percentage and global select to save time by indicating all parts of the image that are that particular color.
3: Use the color select tool to pick the color that's been selected.
4: Go to the key image with the gradients, and briefly memorize the values for the color (HSV works a bit better for this, instead of RGB) before finding the closest color to that in the bottom gradient. Make sure to set the color select tool to "Do not switch tools", or make sure to not release the left/right mouse button before you pick the transparent color.
5: Once you've found the closest color to the color you originally picked, carefully go to the top gradient to the color directly above the color that's closest to the original, and don't select a new color. This color should be a transparent one. If you can't find a color close to the one you picked, then find the area with the closest color to the S value and the closest color to the V value on the bottom gradient, then pick the color in the middle of those two in the top gradient.
6: Go back to the original image, and make sure you still have the color you picked out selected. Then get rid of every instance of that color and fill the spots where it was at with the original color.
With large areas, adding another layer on top, filling that layer with the transparent color in the selected spots, then going to the first layer and deleting the color you selected helps quite a bit. You can merge the two layers down later when you've done that for every color on the edge of the image.
7: Repeat as nessicary until the entire border is replaced entirely with a transparent outline.

For a visual aid: Check out the attached picture of a circle. It has been divided into 4 sections to illustrate 4 different techniques. The top left technique is simply put, doing nothing. The top left technique is getting rid of only the parts that are pure white. The bottom left techinque is getting rid of everything with even a hint of white. The bottom right technique works as detailed above. Now, as you can see, my technique, as shown in the attached picture, obviously works the best. (And I didn't just draw another circle for that part.)

But there's only 3 needed colors for the key, and one always stays the same, a color with a transparency of 0. So... since there's only two colors needed to use the technique, and the procedure is the same every time, couldn't a tool be made for this procedure? The tool should be named: Change to Transparent, since that's what it does. Here's how I think said tool should work:
On left clicking, the procedure is run for the pixels that are under the cursor as it moves around, in real time, with the primary color as the main color, and the secondary color as the background color.
On right clicking, the procedure is run similarly to how it is done with left clicking, only the secondary color is the main color and the primary color is the background color.
In addition, the tool will not change any already partially transparent colors to a different transparent color. Also, if it cannot find a way to average the three values, it wont change the color as well. Just repick the right colors in that case.

Also, before you ask, if you're wondering how to undo this manually, just create a new layer, move it underneath the original one, then paint the area under the image the background color.
So what do you think of this idea? I think it would be immensely powerful tool that would not be too hard to script, as pretty much all the required components are already in Paint.net.

Sorry, I'm new to this forum, so I don't have images of the pictures where they should be. Also, in case you're wondering why there's two of the same image, one of each of them has a green background underneath it, to illustrate the transparency better. The green background is in fact not a part of the original image.

Attached Thumbnails

  • key.png
  • Circle.png
  • key.png
  • Circle.png

Edited by Ilovemath224, 17 June 2011 - 02:18 PM.

  • 0

#2 Ego Eram Reputo

Ego Eram Reputo

    2013 Proton Award Winner

  • Moderators
  • 7,715 posts
  • LocationNorth Canterbury, New Zealand
  • Reputation:592

Posted 18 June 2011 - 05:44 AM

Generally the two plugins used for this sort of background removal are AlphaSpace and Grim Color Reaper.

I generally go for AlphaSpace. It does a very neat job of removing backgrounds.

  • 0