In a lot of image analysis, we want binary data; clear distinction between subject matter and background. The data we collect rarely obliges.
Phillip Green's image angle problem is working with two tone microscopy of sintered metals. The images clearly feature two tone source matter, but regional imbalance makes the distinction difficult for a computer. Binarisation filters use global thresholds, and thus can fail locally.
Pictured: A small segment of a simple binarisation fails to outline objects despite fairly high contrast.
In an image depicting a high range of contrast, this would be hard to avoid. One might patchwork a global binarisation from a variety of local thresholds, but this means choosing a segmentation, and would exacerbate anomalies in sparse areas.
In an image with a small range of source colour (here just two), we should be able to combat regional imbalance more elegantly.
Assuming the image depicts just two colours, and that deviation from these source colours is normal, we can objectively measure what these two colours are.
Pictured: The pixel intensities of the sample image fitted to the sum of two normal curves.
These normals allow us to statistically justify which of the two colours each pixel deviates from, and so calculate the error at each pixel. This gives regional imbalance irrespective of background.
These deviations are fitted to a two variable polynomial to create a cheap correction filter. This is a low cost solution that has been effective in this instance, but other smoothing fits or blurs could be applied. Subtracting this polynomial fit from the deviation set displays the work done, yielding much more consistent local contrast.
Pictured: The deviation matrix and its adjustment.
Subtracting our fit from the source image removes the lighting variance. Using the calculated normal peaks, the contrast is expanded to only the pixels in between our two target colours. The resulting image only contains data from in between the peaks. The unambiguous data is the perfect binary we want to work with. Whilst the ambiguous data occupies the maximum possible range for thresholding.
Pictured: The high contrast output, with the perimeter binarisation that had failed in the first image.
The attached notebook is commented with more implementation details. All thoughts welcome!