otuncelli Posted May 1, 2022 Share Posted May 1, 2022 Hi everyone, I rewrote the @DataDink's "Color Cut" plugin to make it compatible with Paint.net v4.3.10 and (hopefully) later. License: MIT Description: On 12/21/2015 at 8:34 AM, DataDink said: This is similar to other "green screen" plugins, but it uses the secondary color and allows you to configure tolerances. Mainly what I was after in this plugin was the ability to control the "softness" of the effect which you can configure using the "Alpha Falloff" setting. How To Use: On 12/21/2015 at 5:53 PM, DataDink said: The TLDR is: This is another green-screen plugin. Here's the long version: First you'll want to set the secondary color to what you want removed. This can be done by right-clicking with the Color Picker tool: Next you can adjust the color and shade sensitivities to grab the range of colors around your selected colors you wish to remove. The Color Threshold will set the variance in color that will be removed The Shade Threshold will set the variance in shade that will be removed And (the reason I made this plugin) the Alpha Falloff will control the "hardness" of the effect. So hopefully when you are done you have a nice cut-out with blending, non-jagged edges: Green-screen is the simplest usage of this plugin. I created this to to cut objects out of detailed backgrounds that were not intended for cut-out. Current version: 1.0.5 Changes: * Improved performance * CodeLab script available Download Link:ColorCut.zip CodeLab Script: Spoiler // Name: ColorCut // Submenu: Color // Author: DataDink & otuncelli // Title: ColorCut // Version: 1.0.5.0 // Desc: // Keywords: // URL: // Help: #region UICode IntSliderControl colorThreshold = 40; // [0,256] Color Threshold DoubleSliderControl shadeThreshold = 1; // [0,1] Shade Threshold DoubleSliderControl alphaFalloff = .5; // [0,1] Alpha Falloff #endregion private ColorBgra bgColor; private float bgShade; private ColorBgra bgNormal; private void PreRender(Surface dst, Surface src) { bgColor = EnvironmentParameters.SecondaryColor; bgShade = bgColor.ToColor().GetBrightness(); bgNormal = Normalize(bgColor); } private unsafe void Render(Surface dst, Surface src, Rectangle rect) { for (int y = rect.Top, bottom = rect.Bottom; y < bottom && !IsCancelRequested; y++) { ColorBgra* srcRow = src.GetRowPointer(y); ColorBgra* dstRow = dst.GetRowPointer(y); for (int x = rect.Left, right = rect.Right; x < right; x++) { ColorBgra initial = srcRow[x]; float shade = initial.ToColor().GetBrightness(); if (MathF.Abs(shade - bgShade) > shadeThreshold) { dstRow[x] = initial; continue; } ColorBgra norm = Normalize(initial); ColorBgra diff = Diff(bgNormal, norm); if (diff.R > colorThreshold || diff.G > colorThreshold || diff.B > colorThreshold) { dstRow[x] = initial; continue; } diff = Diff(bgColor, initial); byte alpha = Math.Clamp((byte)(Max(diff) * (1d - alphaFalloff)), byte.MinValue, byte.MaxValue); dstRow[x] = initial.NewAlpha(alpha); } } } private static byte Max(ColorBgra c) => Math.Max(Math.Max(c.R,c.G), c.B); private static byte Min(ColorBgra c) => Math.Min(Math.Min(c.R,c.G), c.B); private static ColorBgra Diff(ColorBgra lhs, ColorBgra rhs) { byte b = (byte)Math.Abs(lhs.B - rhs.B); byte g = (byte)Math.Abs(lhs.G - rhs.G); byte r = (byte)Math.Abs(lhs.R - rhs.R); return ColorBgra.FromBgr(b,g,r); } private static ColorBgra Normalize(ColorBgra color) { byte nbase = Min(color); byte b = (byte)(color.B - nbase); byte g = (byte)(color.G - nbase); byte r = (byte)(color.R - nbase); return ColorBgra.FromBgr(b, g, r); } The original plugin page (which is now obsolete and incompatible): 4 1 2 1 Quote Link to comment Share on other sites More sharing options...
Pixey Posted May 1, 2022 Share Posted May 1, 2022 Thank you very much @otuncelli and I have added this to the original post 1 1 Quote How I made Jennifer & Halle in Paint.net My Gallery | My Deviant Art "Rescuing one animal may not change the world, but for that animal their world is changed forever!" anon. Link to comment Share on other sites More sharing options...
homebrew Posted May 3, 2022 Share Posted May 3, 2022 and what about: color clearer and color cut. those two plug-ins are working and are doing pretty the same thing: why should i install your's? Quote Link to comment Share on other sites More sharing options...
otuncelli Posted May 3, 2022 Author Share Posted May 3, 2022 39 minutes ago, homebrew said: and what about: color clearer and color cut. those two plug-ins are working and are doing pretty the same thing: why should i install your's? This plugin uses the same algorithm as @DataDink's Color Cut plugin. But it was not working with the recent versions of Paint.net and it became abandonware at some point. So I decided to rewrite it ( Luckily, it was published under MIT license which gives me right to do so.) Color Clearer seems to be using a different approach. Use the one you prefer 1 Quote Link to comment Share on other sites More sharing options...
Rle Posted May 3, 2022 Share Posted May 3, 2022 1 hour ago, homebrew said: and what about: color clearer and color cut. those two plug-ins are working and are doing pretty the same thing: why should i install your's? Who said you should install it ? Same thing here 🧐 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.