BoltBait Posted January 17, 2007 Posted January 17, 2007 Color Balance Whenever I take pictures indoors, the pictures always come out looking yellow. So, I needed a color correcting effect. I wanted to create something that would be MUCH easier than fiddling with the RGB levels adjustment that is already included in Paint.NET. The Idea I wanted to make an effect that would make my pictures less yellow. Well, if they are going to be less yellow they will have to be more... what? Blue? Yup. That's the opposite of yellow. Perfect! I figured a slider between yellow and blue would do the trick. And, while I'm at it, I might as well add a slider between Cyan and Red and a slider between Magenta and Green. (Not that I'll ever need those, but, what the hay!) Opposites Yellow is opposite of blue? Sure. Let's take a look at the color wheel: Basically, the arrows shown in this illustration are the sliders in the Color correction effect. In the RGB color model, Yellow is a combination of Red and Green. So, in the code, when we increase the level of Blue in our image, we decrease the levels of Red and Green (each by half of the Blue adjustment). If you notice, we have each of the primary colors on one end of the sliders and the combination of the remaining primary colors (called secondary colors) on the other end. The Effect DLL If you like it, you can download the precompiled effect here: BoltBait's Plugin Pack How to Use Typically, this effect is used to correct the colors of a photograph. Notice in the illustration of the color wheel above, all 3 arrows cross at white. The best way to adjust a photograph's colors is to look at the white areas of the photograph and try to adjust the sliders until you achieve a true white in those areas. For example, many times when taking photographs indoors, white walls will appear slightly yellow. Simply move the Yellow/Blue slider to the right until the walls appear white. Then adjust the other sliders to fine tune the resulting shade of white. It may take some tinkering with the sliders to get something close to a true white. Then, once you get the colors right, it may be necessary to adjust the brightness and contrast. By the way, this is a great way to "whiten" teeth, too. Waaaay easier than brushing. Tinting Another use of this effect is to tint images. First, change the image to Black and White (desaturate the image). Then run the effect and adjust the sliders for the desired coloring. As an example, you can make an image appear Sepia by making the image Black and White, then running the Color Balance effect and setting the sliders to 100, 85, and 75. Source Code The codelab script is fairly straight forward: void Render(Surface dst, Surface src, Rectangle rect) { int CyanRed = 0; // Slider, Range -100 to 100, default 0 int MagentaGreen = 0; // Slider, Range -100 to 100, default 0 int YellowBlue = 0; // Slider, Range -100 to 100, default 0 int r, g, b; PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds); Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); for(int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { if (selectionRegion.IsVisible(x, y)) { r = (int)src[x,y].R; g = (int)src[x,y].G; b = (int)src[x,y].B; // Cyan-Red adjustment r += CyanRed; g -= (CyanRed / 2); b -= (CyanRed / 2); // Magenta-Green adjustment r -= (MagentaGreen / 2); g += MagentaGreen; b -= (MagentaGreen / 2); // Yellow-Blue adjustment r -= (YellowBlue / 2); g -= (YellowBlue / 2); b += YellowBlue; dst[x, y] = ColorBgra.FromBgra( Utility.ClampToByte(b), Utility.ClampToByte(g), Utility.ClampToByte(r), src[x,y].A); } } } } Enjoy. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game
Picc84 Posted January 17, 2007 Posted January 17, 2007 Doesent Illnab do all your UI's? I had though you two were a good team! Quote
BoltBait Posted January 17, 2007 Author Posted January 17, 2007 Doesent Illnab do all your UI's? I had though you two were a good team! It is true, I like his work... but, where is he? MadJik also does fine work. I may just do this one myself when I find the time. I have upgraded my dev enviroment to VS2005. So, its just a matter of time before I get off my lazy butt and do one for myself. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game
Picc84 Posted January 17, 2007 Posted January 17, 2007 I'm not sure, I tried contacting him on Gmail chat, but he's not currently on, wich is something almost unheard of... Quote
Rick Brewster Posted January 17, 2007 Posted January 17, 2007 BoltBait, I think it is high time that you just buckled down and learned how to do this Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
BoltBait Posted January 17, 2007 Author Posted January 17, 2007 BoltBait, I think it is high time that you just buckled down and learned how to do this After writing 11 effects... ya think? Rick, Its all a matter of TIME, not ability. Besides, everybody knows the UI is the hardest part... Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game
Rick Brewster Posted January 17, 2007 Posted January 17, 2007 You've got Visual Studio 2005, right? Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
BoltBait Posted January 17, 2007 Author Posted January 17, 2007 You've got Visual Studio 2005, right? Yes. Along with 2 full-time jobs and a family... Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game
Picc84 Posted January 17, 2007 Posted January 17, 2007 Man, if i had Visual Studio, i'd learn, and do them for you guys, but I dont... haha, I realise you can get trials, but everyone knows thats not worth the agervation, learning it in the trial period, and not being able to buy it later... Quote
Rick Brewster Posted January 17, 2007 Posted January 17, 2007 You've got Visual Studio 2005, right? Yes. Along with 2 full-time jobs and a family... Very true. Anyway for the UI you want, the "ThreeAmountsConfigDialog" already does exactly what you want. Just look through the code in the Effects project (d/l the PDN 2.72 source) for one of the effects that uses it, like say Hue/Saturation. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
BoltBait Posted January 17, 2007 Author Posted January 17, 2007 Well, I'll take a look at it when I get a chance. Maybe tomorrow. Man, if i had Visual Studio, i'd learn, and do them for you guys, but I dont... haha, I realise you can get trials, but everyone knows thats not worth the agervation, learning it in the trial period, and not being able to buy it later... You know you can download Visual Studio for free... http://msdn.microsoft.com/vstudio/express/visualcsharp/ Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game
Picc84 Posted January 17, 2007 Posted January 17, 2007 Why Look at that! *ithoughiwassosly* I guess i should learn some, it would be realy cool to know... (stopping about this due to getting too offtopic) Quote
MadJik Posted January 17, 2007 Posted January 17, 2007 Well 3 sliders is standard so... That's it! New plugin ColorBalance.dll here is the DLL Source for plugin ColorBalance.dll here is the SRC Tell me if you want another icone... Quote My DeviantArt | My Pictorium | My Plugins | Donate via Paypal
BoltBait Posted January 17, 2007 Author Posted January 17, 2007 Nice! Thanks! It is working well. I will add the links to the first post. By the way, I'm not sure what that icon is, but I like it. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game
MadJik Posted January 17, 2007 Posted January 17, 2007 ...the icon is from nebulous code lab on 16x16... I find it could "illustrate" the color balance! And the source is for whose wants to dig into UI creating... :wink: I use Visual Studio 2005 Express! Quote My DeviantArt | My Pictorium | My Plugins | Donate via Paypal
BoltBait Posted January 28, 2007 Author Posted January 28, 2007 Thanks, MadJik, for the source code. I have modified it so that the Color Balance effect shows up under the Adjustments menu instead of the Effects menu. Download here: ColorBalance.dll (updated) Just drop this file into your C:/Program Files/Paint.NET/Effects directory and you should be all set. Enjoy. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game
BuzzKill Posted January 28, 2007 Posted January 28, 2007 I have modified it so that the Color Balance effect shows up under the Adjustments menu instead of the Effects menu. Excellent idea! Thank you. Quote - DO NOT contact me asking for the .pdn of my avatar or the PDN logo. Thank you. Have a nice day.
MadJik Posted January 28, 2007 Posted January 28, 2007 Thanks, MadJik, for the source code. you're welcome.I have modified it so that the Color Balance effect shows up under the Adjustments menu instead of the Effects menu. I thought we could only add plugins to the effect menu! 1.Why can't then we put some into the tool menu (polygone)? 2.Could you tell me what you did change for that? Enjoy. sure I'll do. Quote My DeviantArt | My Pictorium | My Plugins | Donate via Paypal
BoltBait Posted January 28, 2007 Author Posted January 28, 2007 BuzzKill, You're welcome. Madjik, I only had to add one line of source code to the file in order to move the effect to the Adjustment menu. If you look through the source code to some of the effects that are in the adjustment menu, I'm sure you'll see the difference. Here is your code, edited (this is only the interesting part): namespace ColorBalance { [EffectCategory(EffectCategory.Adjustment)] public class ColorBalance : Effect { You can not put things in any other menus--only Effects and Adjustments. Please be advised, that Rick told me in a PM that in a future version of Paint.NET, this will not be possible. So, use at your own risk. By the way, this should be used sparingly. In fact, I've written 11 effects and this is the only one that I feel should be in the Adjustments menu. OK, now two. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game
Rick Brewster Posted January 28, 2007 Posted January 28, 2007 I said it might not be possible. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
davidtayhs Posted September 7, 2007 Posted September 7, 2007 Wonder if it would be possible to date this plugin on the Title so that users can know when there is another update. The present "Updated" tag will still be valid for all versions without anyone knowing of later improvements. Thanks. Quote
Drazick Posted March 31, 2011 Posted March 31, 2011 Does it replicate Photoshop results 1 to 1? Thanks. Quote
BoltBait Posted April 1, 2011 Author Posted April 1, 2011 Does it replicate Photoshop results 1 to 1? Thanks. Nope. Mine's bloody potato. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game
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.