Jump to content
How to Install Plugins ×

Color Cut 2022

Recommended Posts

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



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


* Improved performance

* CodeLab script available


Download Link:ColorCut.zip


CodeLab Script:

// Name: ColorCut
// Submenu: Color
// Author: DataDink & otuncelli
// Title: ColorCut
// Version:
// 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

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;

            ColorBgra norm = Normalize(initial);
            ColorBgra diff = Diff(bgNormal, norm);
            if (diff.R > colorThreshold || diff.G > colorThreshold || diff.B > colorThreshold)
                dstRow[x] = initial;

            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):


  • Like 4
  • Thanks 1
  • Upvote 2
  • You're a Smart Cookie! 1
Link to comment
Share on other sites

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 :) 

  • Like 1
Link to comment
Share on other sites

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 🧐 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...