usedHONDA Posted March 9, 2007 Share Posted March 9, 2007 I think the title is painful enough for any coder. Chroma key Masking. I don't need it, as I already have Recomposite. But just imagine how many people would download this plugin*! It would be the only freeware Chroma key masking tool ever made! An example of masking (I did myself in 2 minutes): Before After It could be the biggest thing since Paint.NET! *also note that this plugin will only work on Paint.NET Quote "The greatest thing about the Internet is that you can write anything you want and give it a false source." ~Ezra Pound twtr | dA | tmblr | yt | fb Link to comment Share on other sites More sharing options...
barkbark00 Posted March 9, 2007 Share Posted March 9, 2007 does it just remove the white? In PDN, 20 seconds... Second try: Quote Take responsibility for your own intelligence. -Rick Brewster Link to comment Share on other sites More sharing options...
Crazy Man Dan Posted March 9, 2007 Share Posted March 9, 2007 usedHONDA: Actually, for those who must do this, The GIMP does have a Color to Alpha function that does this: Non PDN image warning! And Barkbark, how did you accomplish your results? Quote I am not a mechanism, I am part of the resistance; I am an organism, an animal, a creature, I am a beast. ~ Becoming the Archetype Link to comment Share on other sites More sharing options...
barkbark00 Posted March 9, 2007 Share Posted March 9, 2007 alpha import plugin, invert selected(I think?), no image selected... Quote Take responsibility for your own intelligence. -Rick Brewster Link to comment Share on other sites More sharing options...
usedHONDA Posted March 9, 2007 Author Share Posted March 9, 2007 A competition it is! This isn't great, but I did this: Parts of this: I did this a week ago: This is one of the exploded planets: EDIT: Just when you think you have all the plugins.... Quote "The greatest thing about the Internet is that you can write anything you want and give it a false source." ~Ezra Pound twtr | dA | tmblr | yt | fb Link to comment Share on other sites More sharing options...
Crazy Man Dan Posted March 9, 2007 Share Posted March 9, 2007 I was able to get this with the Alpha Mask Import plugin. I inverted the wine glass, used Brightness / Contrast ... to cover most of what was there, and lo and behold: It's still not perfect, and what I love about color to Alpha is that, if the pixels are a light red, the white is removed and the red hue remains and blends into the layers behind it. I agree that this is a feature I'd love, and I know I tried to explain it to Rick before. If anyone could replicate a plugin for PDN that does this, I would have to bow in humble adoration. Quote I am not a mechanism, I am part of the resistance; I am an organism, an animal, a creature, I am a beast. ~ Becoming the Archetype Link to comment Share on other sites More sharing options...
The_Lionhearted Posted March 9, 2007 Share Posted March 9, 2007 I would worship them as if they were a god! Well...kinda... Quote My Gallery Link to comment Share on other sites More sharing options...
barkbark00 Posted March 9, 2007 Share Posted March 9, 2007 A competition it is!This isn't great, but I did this: Parts of this: I did this a week ago: This is one of the exploded planets: EDIT: Just when you think you have all the plugins.... What competition? Quote Take responsibility for your own intelligence. -Rick Brewster Link to comment Share on other sites More sharing options...
usedHONDA Posted March 9, 2007 Author Share Posted March 9, 2007 Has anyone noticed that things look better with the checkerboard background as opposed to a solid color? Quote "The greatest thing about the Internet is that you can write anything you want and give it a false source." ~Ezra Pound twtr | dA | tmblr | yt | fb Link to comment Share on other sites More sharing options...
Bob Posted March 9, 2007 Share Posted March 9, 2007 If anyone could replicate a plugin for PDN that does this, I would have to bow in humble adoration. Guess what: Shipping expected within the next decade. Yeah I said decade. Quote No. Way. I've just seen Bob. And... *poof!*—just like that—he disappears into the mist again. ~Helio Link to comment Share on other sites More sharing options...
BoltBait Posted March 9, 2007 Share Posted March 9, 2007 Dude! You're cracking me up! Stripprimarycolor is the worst.plugin.evar! Quote Click to play: Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game Link to comment Share on other sites More sharing options...
usedHONDA Posted March 10, 2007 Author Share Posted March 10, 2007 What competition? Inside joke. You wouldn't understand. Quote "The greatest thing about the Internet is that you can write anything you want and give it a false source." ~Ezra Pound twtr | dA | tmblr | yt | fb Link to comment Share on other sites More sharing options...
Rick Brewster Posted March 10, 2007 Share Posted March 10, 2007 ... I agree that this is a feature I'd love, and I know I tried to explain it to Rick before. And I think I've articulated several times that what I'm really driving towards are the more general concept and implementation of layer masks Then once you have that it becomes trivial to do about 500 new scenarios. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Bob Posted March 10, 2007 Share Posted March 10, 2007 Please wait a bit, I'm still having a lot of fun! Quote No. Way. I've just seen Bob. And... *poof!*—just like that—he disappears into the mist again. ~Helio Link to comment Share on other sites More sharing options...
Illnab1024 Posted March 10, 2007 Share Posted March 10, 2007 1. Get HSV value of a pixel. 2. Given a set Hue, Hue tolerance, and Saturation tolerance. 3. Set A=255 if pixel.H > H+hT+1 OR pixel.H < H-hT-1 4. Set A=0 if pixel.H < H+hT-1 OR pixel.H > H-hT+1 5. If else, set A = (Math.abs(pixel.H-H+hT)*128) ^My concept Quote ~~ Link to comment Share on other sites More sharing options...
Crazy Man Dan Posted March 10, 2007 Share Posted March 10, 2007 And I think I've articulated several times that what I'm really driving towards are the more general concept and implementation of layer masks I apologize. I wasn't trying to insult your ability to understand, I was insulting my ability to explain exactly what it does. :wink: I know layer masks are important, and I'm really looking forward to them, but layer masks really don't do the same thing, not without some editing and trickery. Quote I am not a mechanism, I am part of the resistance; I am an organism, an animal, a creature, I am a beast. ~ Becoming the Archetype Link to comment Share on other sites More sharing options...
Illnab1024 Posted March 10, 2007 Share Posted March 10, 2007 Hmm.... A prototype for codelab, right here (Really, dirty and hacky) int Amount1=120; //Base Hue green=120, blue=240, reds aren't supported very well int Amount2=50; //Hue Tolerance int Amount3=16; //Value tolerance const double HSV_UNDEFINED = -999.0; void Render(Surface dst, Surface src, Rectangle rect) { float BaseHue = Amount1; float HueTol = Amount2; float VTol = (float)Amount3; double H = 0, S = 0, V = 0; VTol /= 100f; for(int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { ColorBgra col = src[x, y]; EvanRGBtoHSV(col.R, col.G, col.B, ref H, ref S, ref V); if (V > VTol) { if (H > (BaseHue-HueTol+3)&&H > (BaseHue+HueTol-3)||H < (BaseHue-HueTol+3)&&H < (BaseHue-HueTol-3)) col.A=255; else col.A = 0; } dst[x, y] = col; } } } public void EvanRGBtoHSV(int R, int G, int B, ref double outH, ref double outS, ref double outV) { // R, G, and B must range from 0 to 255 // Ouput value ranges: // outH - 0.0 to 360.0 // outS - 0.0 to 1.0 // outV - 0.0 to 1.0 double dR = (double)R/255.0; double dG = (double)G/255.0; double dB = (double)B/255.0; double dmaxRGB = EvanMax3(dR, dG, dB); double dminRGB = EvanMin3(dR, dG, dB); double delta = dmaxRGB - dminRGB; // Set value outV = dmaxRGB; // Handle special case if (dmaxRGB == 0) { outH = HSV_UNDEFINED; outS = 0.0; return; } outS = delta/dmaxRGB; if (dmaxRGB == dminRGB) { outH = HSV_UNDEFINED; return; } // Finally, compute hue if (dR == dmaxRGB) { outH = (dG-dB)/delta*60.0; } else if (dG == dmaxRGB) { outH = (2.0+(dB-dR)/delta)*60.0; } else //if (dB == dmaxRGB) { outH = (4.0+(dR-dG)/delta)*60.0; } if (outH < 0) { outH += 360.0; } } public double EvanMax3(double x, double y, double z) { return (x>y)?((x>z)?x:z)(y>z)?y:z); } public double EvanMin3(double x, double y, double z) { return (x(y} Last 3 functions were made by EvanOlds, best to attribute him. Okay, here's an example for the wine glass. I took the white background to blue because white is the most difficult color to mask out. Now, Amount1 = 240, for blue. Amount2 = 40, for good hue range. Amount3 = 56, to catch some of the edges. After: The blue is still visible, but it's a prototype. Quote ~~ Link to comment Share on other sites More sharing options...
Bob Posted March 10, 2007 Share Posted March 10, 2007 How did you made the background blue? There is still some white artefacts (on the blued pic). Quote No. Way. I've just seen Bob. And... *poof!*—just like that—he disappears into the mist again. ~Helio Link to comment Share on other sites More sharing options...
barkbark00 Posted March 10, 2007 Share Posted March 10, 2007 How did you made the background blue? Best I could do... Quote Take responsibility for your own intelligence. -Rick Brewster Link to comment Share on other sites More sharing options...
MadJik Posted March 10, 2007 Share Posted March 10, 2007 The Best I have seen IMO... Still the wine surface shouldn't be blue, I think. Quote My DeviantArt | My Pictorium | My Plugins | Donate via Paypal Link to comment Share on other sites More sharing options...
barkbark00 Posted March 10, 2007 Share Posted March 10, 2007 The Best I have seen IMO...Still the wine surface shouldn't be blue, I think. That part becomes clear once you remove the blue. Then it looks like the wine surface is reflecting the background... Quote Take responsibility for your own intelligence. -Rick Brewster Link to comment Share on other sites More sharing options...
Bob Posted March 10, 2007 Share Posted March 10, 2007 The Best I have seen IMO... Hu. Quote No. Way. I've just seen Bob. And... *poof!*—just like that—he disappears into the mist again. ~Helio Link to comment Share on other sites More sharing options...
Bob Posted March 13, 2007 Share Posted March 13, 2007 Once more teasing: Still some rounding errors *bangs his head against the wall*. I restarted from (gimp) scratch this morning ECT, the main work begin now ... Quote No. Way. I've just seen Bob. And... *poof!*—just like that—he disappears into the mist again. ~Helio Link to comment Share on other sites More sharing options...
usedHONDA Posted March 17, 2007 Author Share Posted March 17, 2007 So what's the status report on the plugin? Quote "The greatest thing about the Internet is that you can write anything you want and give it a false source." ~Ezra Pound twtr | dA | tmblr | yt | fb Link to comment Share on other sites More sharing options...
Bob Posted March 18, 2007 Share Posted March 18, 2007 Here is the current code, if some coding fairies want to look at it. I don't know if I can go further. /* * /!\ Warning, this is GPL code! * Color2Alpha Paint.NET plugin by Bibinou based on : * Color To Alpha plug-in v1.0 by Seth Burgess & others, 1999/05/14 * The GIMP -- an image manipulation program * Copyright (C) 1995 Spencer Kimball and Peter Mattis * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ void Render(Surface dst, Surface src, Rectangle rect) { PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds); Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); long CenterX = (long)(((selection.Right - selection.Left) / 2)+selection.Left); long CenterY = (long)(((selection.Bottom - selection.Top) / 2)+selection.Top); ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor; ColorBgra CurrentPixel = new ColorBgra(); double red, key_red, green, key_green, blue, key_blue, alpha, maxalpha; int rnew, gnew, bnew; for(int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { if (selectionRegion.IsVisible(x, y)) { CurrentPixel = src[x,y]; red = CurrentPixel.R ; green = CurrentPixel.G ; blue = CurrentPixel.B ; key_red = PrimaryColor.R ; key_green = PrimaryColor.G ; key_blue = PrimaryColor.B ; /* Store red alpha component */ if (red >= key_red ) alpha = (key_red == 255 ? 0 : (red - key_red ) / (255 - key_red) ); else alpha = (key_red == 0 ? red / 255 : 1.0 - red / key_red ); maxalpha = alpha; /* Store green alpha component, if greater */ if (green >= key_green) alpha = (key_green == 255 ? 0 : (green - key_green) / (255 - key_green)); else alpha = (key_green == 0 ? green/ 255 : 1.0 - green / key_green ); if (alpha > maxalpha) maxalpha = alpha; /* Store blue alpha component, if greater */ if (blue >= key_blue ) alpha = (key_blue == 255 ? 0 : (blue - key_blue ) / (255 - key_blue )); else alpha = (key_blue == 0 ? blue / 255 : 1.0 - blue / key_blue ); if (alpha > maxalpha) maxalpha = alpha; /* Threshold the alpha */ //alpha = (maxalpha * 255) / pvals.threshold ; /* Using int to Math.Round the values */ if (alpha > 1) alpha = 1 ; else if (alpha < 0) alpha = 0 ; if (alpha > 0) { rnew = (int) ( Math.Round( (red - key_red ) / alpha + key_red ) ) ; gnew = (int) ( Math.Round( (green - key_green) / alpha + key_green ) ) ; bnew = (int) ( Math.Round( (blue - key_blue ) / alpha + key_blue ) ) ; } else { rnew = (int) red; gnew = (int) green; bnew = (int) blue; }; if ( rnew <=255 && gnew <=255 && bnew <=255 && rnew >=0 && gnew >=0 && bnew >= 0) { CurrentPixel.R = (byte)rnew ; CurrentPixel.G = (byte)gnew ; CurrentPixel.B = (byte)bnew ; CurrentPixel.A = (byte)(alpha * 255) ; dst[x,y] = CurrentPixel; } else { dst[x,y] = src[x,y]; } } } } } /* EOF */ Quote No. Way. I've just seen Bob. And... *poof!*—just like that—he disappears into the mist again. ~Helio 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.