Monday, 17 November 2014

Colour Sampling - Sample Homogenity and a Defocus Analysis Technique

Colour Sampling Technique
Colour reproduction and analysis is complex.  I have gone into it is reasonable detail in a number of postings.  If you are coming at this for the first time you might like to start at the page I have devoted to colour, HERE.

Lets assume that we have properly calibrated everything and gotten our colour management right.  Now we want to sample and analyse the colours in an image.  In the posting HERE I outlined a simple and effective technique for sampling colours consistently from digital photographs.  

Challenges of Lighting and Defocus
What happens if an area which we wish to sample is defocused or hidden in shadow?  Should we even sample it?

We know that light and shade affect every object in an environment.  Lighting is complex and hard to analyse at times.  Colour sampling must take account of the lighting conditions and suitability of patches being sampled.  For more on some of the complexities see HERE.

In this posting HERE I explained the mechanism by which defocus works.  I also elaborated on the analysis of defocus HERE.  We know that defocus (out of focus areas of the image) affects every pixel in defocused areas, reducing contrast as well as spreading out and influencing other pixels around it.  Defocus can even potentially influence neighbouring pixels within apparently sharply focused areas (if there is for instance a defocused object between the infocus subject and the camera).  If defocus blends and merges colours how can we be sure that the areas we are interested in sampling have not been tainted by the colours around them?  Or worse, could there be defocused objects between the subject and camera that we can't even see as they are defocused to the point they are for all intents and purposes, 'fully dissolved'?  And if so, could these, hidden objects taint the colours we are sampling?

A Simple Solution
I am going to use the Gaussian Blur tool to create a blurred copy of an image and then, in turn compare this copy with the original, looking for differences in homogeneity between the two.  The Gaussian Blur tool is a simple transformation which reduces the luminosity and saturation values of each pixel.  If the patches being sampled are already homogeneous then a slight Gaussian Blur wont affect the patch too much (perhaps a slight reduction in luminosity and saturation, hue hopefully unchanged).  If however there is a big change it might indicate that there is much more going on within the sample patch than initially meets the eye - perhaps it is not an ideal sample patch afterall.

The theory is that defocus blending radiates out from the defocused parts of the image and the extent to which it radiates out is dependent on the level of defocus applied.  Further defocusing the entire image might enhance some of this blending.  It might also reveal if a sample patch is dangerously close to the edge of other colour patches or markings that could taint the purity of the colour being sampled.

Step 1  Create a blurred layer
I am using Adobe Elements for this analysis.  Other packages may have similar tools.  First step is to open the image and duplicate the image as a separate new layer (renamed 'Blurred Layer' above).  To the new layer I have added a Gaussian Blur of radius 3.0 pixels.

Step 2  Sample and postarize the same points on both layers
I am using the MS postarizing tool 'Cutout' for sample postarizing.  Basically this homogenises the colour patch to make it easier to sample correctly.  It is quick and effective and accessible in any of the MS office suite, though I tend to use MS Powerpoint, 2010.  As demonstrated HERE I select an area to be analysed then copy and paste that area into, say MS  Powerpoint.  I process the patch using the Cutout tool then I cut and paste the patch into MS Paint where I read its Hue, Saturation and Luminosity values.

The additional step here is that I do the same for both the original and blurred image layers.  By keeping the patch selection open in Adobe Elements and merely toggling between the original and blurred layers I can retain exactly the sample selection area.  This in turn allows for a direct comparison of the colour of the original image patch versus the blurred copy that I have made.

Step 3 Comparing the results
Taking this Great Shearwater Puffinus gravis image as an example.  I have selected a patch of colour on the bird's crown.  The patch is on a brightly-lit, uniform part of the bird, well clear of the edges with nothing in the foreground to influence the image.  The hue, saturation and luminosity values remain very similar after defocusing the image, so this should be a good, reliable location to sample colour from, even though the bird is slightly out of focus in the original image.

The next point which I have sampled is on the breast.  Obviously the breast should be white but this patch is in shadow, lit by blue sky light.  What is interesting here is there is a notable difference between the values in the original versus the blurred image.  This I believe is due to the amount of variation in the selected sample area - i.e. the sample area is not homogeneous  This variation in turn increases the difference between the original and blurred images.  Though the original feather was white, there is a complex tonal gradient laid down by the shadow pattern.  So I am getting some useful feedback here, telling me that this may not be an ideal sample location.

The third patch (located on the rear secondaries) was the smallest of the three sampled patches in size yet it has produced the biggest variance between the original and blurred images.  There are a couple of separate things going on here I think.
- Firstly, the patch is very close to an edge between two very different colours.  Defocus has slightly blended these colours.  The fact that the original image was also defocused should raise alarm bells.  The original image probably suffers from some colour blending in this area.
- The patch is also in shade, so as with the earlier breast patch, the tonal gradient possibly adds further variation across the sample patch.  So, clearly this is not a good patch to sample for colour.

In summary, the technique has a few facets to it.  It helps us locate a good, homogeneous sample point.  It also flags up potential sample impurities such as the potential for defocus and variable luminance to blend colours.  It might even help to detect hidden objects between the subject and the camera which may have gone unnoticed when the photograph was taken and are now 'fully dissolved' by defocus.  Even though hidden, their ghost impressions may register as slight tonal gradients or similar anomalies, thus registering as an impurity or drop in homogeneity across the sample patch.

Quality Control when sampling colours from digital images
The original sampling method presented HERE didn't consider the quality of the colour patches chosen for sampling.  As it turns out, one of the novel advantages of this method is that it introduces a measure of quality control to the sampling process.  When sampling colour, we are trying to minimise variation throughout the patch being sampled.  Postarising the patch later removes any remaining variation but, in doing so may inadvertently mask impurities in the colour being sampled.
This simple Defocus Analysis introduces a QC check to the colour sampling process, which can only be a good thing.

No comments:

Post a Comment