Jump to content

Chill

Newbies
  • Posts

    8
  • Joined

  • Last visited

About Chill

  • Birthday 01/01/1970

Chill's Achievements

Rookie

Rookie (2/14)

  • First Post
  • Week One Done
  • One Month Later
  • One Year In

Recent Badges

0

Reputation

  1. Ed That's a nice implementation. I've been further experimenting with the code for the effect, and I've noticed some problems that maybe your implementation could help with. Firstly, using the image in the earlier post (the model, with the black and white card in the image), I found that the white section of the card has a slightly speckly quality, so that if I use the dropper to select the white point I get a different result depending on precisely which pixel I select. Secondly, I tried an implementation that attempts to 'stretch' the contrast, by using the dropper to select a black point as the secondary colour. It worked well, but again I found that different pixels within the black part of the card have slightly different colours, so the results were not consistent. Also, probably for the same reason, the black part of the card usually seemed to have a different colour cast to the white part. I achieved quite a good result by averaging the colour cast from the black and white sections. I also experimented with applying a variable colour cast, based on the brightness of the each pixel (so a dark pixel used a cast weighted to the black cast, and a light pixel used the cast weighted towards the white point). Where I think your implementation might allow an improvement is in the selection of the white (and black) point. The dropper seems to be limited to a single pixel, but a selection point that averaged the colour cast over several pixels (ie a kind of 'dropper width' setting) would probably make for a more consistent result. Chris
  2. 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.
  3. BoltBait Following your subtle hint regarding your updated CodeLab plugin , 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); } } } }
  4. 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!
  5. 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.
  6. 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); } } } }
  7. 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
  8. 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
×
×
  • Create New...