Jump to content

Is it possible to... delete a color?


Recommended Posts

I was wondering if it were possible to make a plugin for the following effect:

Getting from this:

cropex1.png

To this:

cropex3.png

By using a magicwand to select all of the blue (including that "under" the red) and deleting. All on the same layer.

Better example would be: You're cropping a picture, the outline of the picture (black) has several semi grayish pixels, semi blue (same blue as background). Using the magic wand with this effect^ would select the blue in the background, including that overlapping the gray, and remove it when you press delete.

Alternatively, perhaps an effect that removes all hues in a certain range (similar to the already made plugin to change colors).

-Used for cropping n stuff

HellRiverSig3_stretch.png
Link to comment
Share on other sites

Sure, easy. Here's a Codelab script to basically do what you want:

void Render(Surface dst, Surface src, Rectangle rect)
{
   PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds);
   Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
   ColorBgra CurrentPixel;
   ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor;
   for(int y = rect.Top; y     {
       for (int x = rect.Left; x         {
           if (selectionRegion.IsVisible(x, y))
           {
               CurrentPixel = src[x,y];
               if (CurrentPixel.R >= PrimaryColor.R) {
                   CurrentPixel.R -= PrimaryColor.R;
                   CurrentPixel.A=(byte)((CurrentPixel.A - PrimaryColor.R                 } else {
                   CurrentPixel.A=(byte)((CurrentPixel.A - CurrentPixel.R                     CurrentPixel.R = 0;
               }
               if (CurrentPixel.G >= PrimaryColor.G) {
                   CurrentPixel.G -= PrimaryColor.G;
                   CurrentPixel.A = (byte)((CurrentPixel.A - PrimaryColor.G                 } else {
                   CurrentPixel.A=(byte)((CurrentPixel.A - CurrentPixel.G                     CurrentPixel.G = 0;
               }
               if (CurrentPixel.B >= PrimaryColor. {
                   CurrentPixel.B -= PrimaryColor.B;
                   CurrentPixel.A=(byte)((CurrentPixel.A - PrimaryColor.B ;
               } else {
                   CurrentPixel.A=(byte)((CurrentPixel.A - CurrentPixel.B ;
                   CurrentPixel.B = 0;
               }
               dst[x,y] = CurrentPixel;
           }
       }
   }
} 

All you need to do is use the color picker to set your primary color to the color you want to eliminate (i.e. blue, in your example).

Then, run the effect in Codelab.

Enjoy. 8)

P.S. I'm sure there's a more efficient way to do this, but what do you want for 10 minutes of work? ;)

Oh, and here's your precompiled DLL: StripPrimaryColor.dll.

Click to play:
j.pngs.pngd.pnga.pngp.png
Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game

Link to comment
Share on other sites

If your trying to crop out a border from an image, in your other example, use the rectangular marquee tool and select the picture.

Then inverse your selection by going to Edit- Invert selection.

Or hit Ctrl+I, delete it.

If you want to use a different color, then make a new layer, select the transparent part on the other layer, then fill it on the new layer, and adjust opacity.

ravennm3.png
Link to comment
Share on other sites

Boltbait is correct, masto.

And Raven, I don't think that's what I was asking for... I don't think...

Thanks for the code. :) I'm gonna try it out now.

Thanks a whole bunch for that, it's great for a few things. Yet, it isn't precise enough for what i had in mind. I was wondering if it were possible to add the same color selection method as the one used in the "Conditional Hue/Saturation" plugin. Because the plugin you posts selects white, so the color selector from that other plugin ^ has an ability to not select white within it's selection thing... and stuff xD

HellRiverSig3_stretch.png
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.

Guest
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.

 Share

×
×
  • Create New...