Jump to content

Legorol

Newbies
  • Posts

    2
  • Joined

  • Last visited

Legorol's Achievements

Newbie

Newbie (1/14)

  • First Post
  • Conversation Starter
  • Week One Done
  • One Month Later
  • One Year In

Recent Badges

4

Reputation

  1. Thanks for the welcome. I have just recently discovered Paint.NET, and I really like it. I wanted to be able to make the background of images transparent, or be able to change one color to another, but I ran into problems with anti-aliasing. Some Googling made it clear that this is a common problem. I tried out various plugins, but none of them did exactly what I wanted, so I wrote my own. Based on how common this problem is, I'm hoping that my plugin will be able to help a lot of people.
  2. Unblend v1.0 Unblend v1.0.zip This plugin removes a chosen color from the image and replaces it with transparency. In other words, it performs the reverse of a normal blend operation with the chosen color. The more of the chosen color is present in a pixel, the more of it is removed and more transparency is added. In technical terms, this plugin performs inverse alpha compositing. Unlike similar plugins, the result of this plugin is guaranteed to be such that when blended back on a uniform background of the chosen color, the original image is completely recovered in a pixel perfect manner. This plugin can be used for example to change the background of an image to be transparent, and gives the expected result even in the presence of anti-aliasing. If there is an object in the image whose edges blend smoothly into the background, then after using this plugin, the image can be placed on a different background, and the object will smoothly blend into the new background. The download contains the source code, which includes a description of the algorithm and the Maths behind it. How to use 1. Set the color to be removed as the Primary Color (transparency value is ignored). 2. Select Effects->Unblend. That's it! The plugin respects the active selection, so to apply Unblend only to part of the image, select that part first. Comparison with similar plugins There are many plugins that perform Color to Alpha conversion (ColorToAlpha, AlphaMask etc.). However, typically these plugins only add alpha values (transparency) to the image, and do not alter the colors of the pixels in the image. The result is that when placed back on a uniform background of the chosen color, the original image is not recovered. This Unblend plugin does correct the colors of the pixels too, and so does not have this problem. GrimColorReaper is one plugin that does alter the colors of the pixels in addition to adding transparency. However, GrimColorReaper uses an inadequate calculation of the alpha values (Eucledian distance in RGB space). This Unblend plugin uses a mathematically correct calculation. GrimColorReaper's alpha calculation can under some circumstances result in a tint and doesn't always give the expected result. Technical comment Inverse alpha compositing is an underdefined problem, because the alpha value of the result is not unique. A pixel could be made more intense with a lower alpha, or less intense with a higher alpha, and still give the correct result when blended back on the background color. The Unblend plugin uses a greedy algorithm, whereby it always uses the minimum permitted value of alpha for each pixel, so that as much of the background color is removed as possible. Examples Starting with an image of an anti-aliased letter A, the white background is removed with Unblend. The result is then placed on a blue background: => => Magnified: => => Start with a red circle, anti-aliased on a blue background. A selection is made with the Magic Wand at 80% tolerance outside the circle, so that the selection covers the outside of the circle including anti-aliased pixels. The blue background is removed with Unblend. The result is placed on a green background: => => Magnified: => => Notice how outside the circle, red is anti-aliased with green, but inside the circle, red is anti-aliased with blue. For comparison, here is what you would get if you simply tried to use the Paint Bucket tool to replace the blue with green at various levels of tolerance: Tolerance 0% Tolerance 50% Tolerance 80% Notice how at 0% and 50% you are left with some blue-ish pixels outside the circle. At 80%, they are all gone, but so is the anti-aliasing. The Paint Bucket is not the right tool for this kind of color replacement. Download Unblend v1.0.zip
×
×
  • Create New...