Jump to content

white,grey and black point plugin


Recommended Posts

Newbie here so please be kind, I plan to use Paint.net for my Nikon Nef files and wondered if there are any plans to develope a plugin for white,grey and blackpoint ref. If not, any one that is compatible? Thanks, Lee from Milwaukee

Leroy Allen Skalstad

Link to comment
Share on other sites

http://www.pictureflow.com/forum/showthread.php?t=7780 Thanks for the reply Boltbait. Often, In my work, Especially with existing light portraiture I will insert a white, gray and black reference card in the bottom of the image and use the above plugin in PS for exposure and color balance. As I mentioned, a newbie who is intrigued by the 64 bit architecture in Paint.net and wondered if this was also possible.

Leroy Allen Skalstad

Link to comment
Share on other sites

could you not just use brightness/contrast adjustment until the black and white swatches appear correct, or is there more going on in the plugin than that?

Thanks User24, will try, I did calibrate my monitor with Huey from Pantone so I should be close to seeing what the Fuji Frontier outputs, Still on a learning curve so thanks for your patience, Lee

Leroy Allen Skalstad

Link to comment
Share on other sites

I tried it with your sample image (in the post linked above) and I must say, it turned out pretty nice.

I just adjusted the Brightness / Contrast up pretty high (82/61) until the general look was achieved. Then I adjusted the color balance by sliding the Yellow/Blue slider to the blue side by +10 (0/0/10).

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

  • 3 weeks later...

Hi

Another newbie here. This 'white balance' tool is something that I too missed when I discovered Paint.NET the other day. I've been playing with the CodeLab plugin in an attempt to make a suitable plugin, and I think I have the code for the effect worked out. However, I can't find a way to get at the current cursor/mouse coordinates, so my testing is a bit long-winded (note cursor coordinates, edit the plugin text).

What I'd like to finish up with is a plugin that uses a new tool, with it's own cursor, and for a click with that cursor to pass the cursor coordinates to the white balance code. Can anyone point me to a similar existing plugin, or perhaps get me started with the code for cursor coordinates and mouse actions?

Thanks

Link to comment
Share on other sites

Chill, there is currently now way to access the mouse location inside of an effect.

One way to get around this is to instruct the user to use the Color Picker tool to select (from the image) White as the primary color and Black as the secondary color before running your effect. Getting the primary/secondary colors is trivial in an effect.

Another way to handle this is to display a thumbnail in the effect's UI and capture mouse clicks from there.

In a way, the levels adjustment takes care of the balance.

True, but I find the levels adjustment much more difficult to use.

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

BoltBait

Thanks for your quick reply. The colour picker seems like a great idea - the user would use it to select a grey point, and my plugin would use the RGB values of the primary colour to make the adjustment. I could even allow the adjustment to be based on an average of the corrections for the primary and secondary colours, thus allowing the user to use two sample points, although I'm not sure there's a need for this.

Any chance you could show me some code to access the primary and secondary colours?

Thanks

Link to comment
Share on other sites

BoltBait

Thanks for your quick reply. The colour picker seems like a great idea - the user would use it to select a grey point, and my plugin would use the RGB values of the primary colour to make the adjustment. I could even allow the adjustment to be based on an average of the corrections for the primary and secondary colours, thus allowing the user to use two sample points, although I'm not sure there's a need for this.

Any chance you could show me some code to access the primary and secondary colours?

Thanks

Had you upgraded to my updated CodeLab, you wouldn't be asking me that question...

http://boltbait.googlepages.com/codelab

Oh, and the reason I suggested using both primary and secondary colors, is that with the user sampling White for primary and Black for secondary, you can calculate if increasing the contrast of the image is necessary.

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

BoltBait

Yes, sorry - too quick to ask for help! I found what I needed, and have implemented a very simple 'White Balance' plugin, which uses, as per your suggestion, the current Primary colour as the grey point.

For what it's worth, the code is shown below (can't see how to attach the DLL at the moment).

I have tested this on a few images that only needed a small white balance correction, and it seems to work OK. It could well need some work for images that have a significant colour cast, but I'm not yet familiar with how the core code copes with illegal, or out of bounds, values for the RGB values.

Thanks for your help.

void Render(Surface dst, Surface src, Rectangle rect) 

// White Balance plugin
// Uses Primary colour as user-selected grey point

{ 
   int r, g, b; 
   int RShift, GShift, BShift;

//local variable for primary colour
   ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor;

// RGB values of primary colour
   r = PrimaryColor.R;
   g = PrimaryColor.G;
   b = PrimaryColor.B;

//RGB correction for primary colour - reduces this colour to grey
   RShift = (r+g+b)/3-r;
   GShift = (r+g+b)/3-g;
   BShift = (r+g+b)/3-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)) 
           { 
//apply RGB shifts to current pixel
               r = (int)src[x,y].R+RShift;
               g = (int)src[x,y].G+GShift;
               b = (int)src[x,y].B+BShift;

               dst[x, y] = ColorBgra.FromBgra( 
                   Utility.ClampToByte(, 
                   Utility.ClampToByte(g), 
                   Utility.ClampToByte(r), 
                   src[x,y].A); 
           } 
       } 
   } 
}

Link to comment
Share on other sites

Nice, but you don't actually lighten up the picture at all.

How about like this:

void Render(Surface dst, Surface src, Rectangle rect) 

// White Balance plugin 
// Uses Primary colour as user-selected grey point 

{ 
   int r, g, b; 
   int RShift, GShift, BShift; 

//local variable for primary colour 
   ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor; 

// RGB values of primary colour 
   r = PrimaryColor.R; 
   g = PrimaryColor.G; 
   b = PrimaryColor.B; 

   int brighter;

   brighter = (r>g)?r:g;
   brighter = (brighter>?brighter:b;

   brighter = 255-brighter;

//RGB correction for primary colour - reduces this colour to grey 
   RShift = (r+g+b)/3-r; 
   GShift = (r+g+b)/3-g; 
   BShift = (r+g+b)/3-b; 

   PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds); 
   Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); 
   for(int y = rect.Top; y     { 
       for (int x = rect.Left; x         { 
           if (selectionRegion.IsVisible(x, y)) 
           { 
//apply RGB shifts to current pixel 
               r = (int)src[x,y].R+RShift+brighter; 
               g = (int)src[x,y].G+GShift+brighter; 
               b = (int)src[x,y].B+BShift+brighter; 

               dst[x, y] = ColorBgra.FromBgra( 
                   Utility.ClampToByte(, 
                   Utility.ClampToByte(g), 
                   Utility.ClampToByte(r), 
                   src[x,y].A); 
           } 
       } 
   } 
} 

This is far from perfect, but I think you get my idea.

Using this on the sample image from the first page, you can see that the contrast of the image needs to be increased.

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

BoltBait

I get the idea, and it would make a nice basis for an integrated 'image improvement' tool. Your suggestion of using the primary and secondary colours to identify the whitest and blackest parts of the image is certainly interesting in that respect.

However, my aim with the the white balance correction was simply to remove any colour cast introduced by, say, an inappropriate colour temperature setting in a digital camera. I'm not sure that such a situation would warrant an automatic change in brightness or contrast (I could be wrong though - it depends what else the wrong colour temperature setting does to the captured image). Personally I would prefer to see the brightness and contrast corrections left to separate tools.

As originally coded, my white balance tool preserves the overall brightness (I think!), and simply applies the same shifts in red, green and blue as are necessary to make the primary colour a shade of 'pure' grey. It means that the user simply has to select a point that should have no colour - it doesn't have to be the whitest or blackest part of the image, any grey point will do. The original poster's grey card in the captured scene would be ideal in this case.

Thanks again.

Link to comment
Share on other sites

No, my mistake! I've just re-read the OP's post, and indeed the use of a white and black point would be useful in that case. Such a tool would have limited use, in my opinion, for the majority of casual photos that don't have absolute white and black references though. There's usually something in the image that one can confidently treat as a grey point though (T-shirt, painted structure, car tyres, clouds etc). Each to his own!

Link to comment
Share on other sites

BoltBait

Following your subtle hint regarding your updated CodeLab plugin :D, I've modified my White Balance plugin using your new template (Alpha 4) as the starting point. Functionally it's no different, but for the benefit of future newbies like myself, I think it's useful to draw attention to your version.

void Render(Surface dst, Surface src, Rectangle rect)
{
   PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds);
   Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();

   ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor;

   ColorBgra CurrentPixel;

   int r, g, b; 
   int RShift, GShift, BShift;

//RGB values of primary colour
   r = PrimaryColor.R;
   g = PrimaryColor.G;
   b = PrimaryColor.B;

//RGB correction for primary colour - reduces this colour to grey
   RShift = (r+g+b)/3-r;
   GShift = (r+g+b)/3-g;
   BShift = (r+g+b)/3-b;

   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];

//apply RGB corrections to current pixel
               r = CurrentPixel.R + RShift;
               g = CurrentPixel.G + GShift;
               b = CurrentPixel.B + BShift;

               dst[x, y] = ColorBgra.FromBgra( 
                   Utility.ClampToByte(, 
                   Utility.ClampToByte(g), 
                   Utility.ClampToByte(r), 
                   src[x,y].A); 
           }
       }
   }
}

Link to comment
Share on other sites

usedHONDA

Well I have - the code above will do for now, until I see that it's doing something wrong :? . I'd post the DLL, but it seems there's no way to include attachments, and I've got nowhere to host it myself. Seems like an oversight to me - shouldn't the 'Plugins' forum at least allow plugins to be attached to posts?

Anyway, if you need the plugin, I suggest you paste the above code into the CodeLab plugin and use the 'Make DLL' button.

EDIT: Yes I know this isn't the Plugins forum, but I checked there and I can't attach plugins in that forum either.

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