lightknight Posted December 26, 2020 Share Posted December 26, 2020 Greetings, How can I increase or decrease the RGB or HSV values of a group of pixels in a selected area by the same amount? For instance, I need to increase one region's brightness by 17 on the HSV scale to make it match another region; however, neither the Brightness / Contrast tool, nor the Hue / Saturation tool seem to increase or decrease these values by any calculation that I can thus far figure out (I apologize in advance if the answer is simple; I've been at this for over 16 hours). Much of my work has thus been trial and error to find the right amount to increase or decrease these values using the provided tools. Is there a formula or plugin I can use? Thank You. Quote Link to comment Share on other sites More sharing options...
ardneh Posted December 26, 2020 Share Posted December 26, 2020 There may be a plugin for this. idk For the specific example, raise V by 17, try this: Select the area you want to brighten. Copy and paste into a New Layer. Set new layer Properties to Additive. Adjust Opacity to 85. (5x17) Hope this helps. Quote Link to comment Share on other sites More sharing options...
Reptillian Posted December 26, 2020 Share Posted December 26, 2020 (edited) It's not too hard to make a plugin for this. Once you insert color space conversion functions, and do basic arithmetric, you can make the plugin. There's Mixer filters within G'MIC-QT. Also, @ardneh doesn't seem to address on subtract part. Edited December 26, 2020 by Reptillian Quote G'MIC Filter Developer I am away from this forum for undetermined amount of time: If you really need anything related to my PDN plugin or my G'MIC filter within G'MIC plugin, then you can contact me via Paint.NET discord, and mention me. Link to comment Share on other sites More sharing options...
BoltBait Posted December 26, 2020 Share Posted December 26, 2020 16 hours ago, lightknight said: How can I increase or decrease the RGB or HSV values of a group of pixels in a selected area by the same amount? I recommend using CodeLab for something like this. Here is a list of tutorials to get you started: https://boltbait.com/pdn/CodeLab/help/ Tutorial 2 includes instruction on how to modify the R, G, and B values independently. As for V, take a look at this script: // Force Aliased Selection #region UICode IntSliderControl Amount1 = 0; // [-100,100] Adjustment #endregion void Render(Surface dst, Surface src, Rectangle rect) { // Look at each row of your selection for (int y = rect.Top; y < rect.Bottom; y++) { if (IsCancelRequested) return; // Look at each pixel on that row for (int x = rect.Left; x < rect.Right; x++) { // Look at the current pixel ColorBgra CurrentPixel = src[x,y]; // Split the pixel's color into pieces HsvColor hsv = HsvColor.FromColor(CurrentPixel.ToColor()); int H = hsv.Hue; // 0-360 int S = hsv.Saturation; // 0-100 int V = hsv.Value; // 0-100 byte A = CurrentPixel.A; // 0-255 // TODO: Modify H, S, V, and A according to some formula here V = Math.Max(Math.Min(V+Amount1,100),0); // Put the pieces back together CurrentPixel = ColorBgra.FromColor(new HsvColor(H,S,V).ToColor()); CurrentPixel.A = A; // Save to destination canvas to see the result dst[x,y] = CurrentPixel; } } } Hope this helps! ~BoltBait 1 Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game Link to comment Share on other sites More sharing options...
ardneh Posted December 27, 2020 Share Posted December 27, 2020 (edited) On 12/26/2020 at 1:59 PM, Reptillian said: Also, @ardneh doesn't seem to address on subtract part. Okay. So, based on two randomly chosen colors, H90 S88 V49 and H0 S50 V49, to reduce V by 17: Select the area you want to darken. Copy and paste into a New Layer. Set new layer Properties to Color Burn. Adjust Opacity to 90. Sadly, this is no solution. Pixels with different starting Values will need different Opacity settings. Also, any pixel with V from 84 to 100 could never have the V raised by 17. Neither could a pixel at V of 0 to 16 have its V reduced by 17. Edited December 27, 2020 by ardneh 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.