Specifying a Region of Interest for Illumination Correction


While this is not a biology related problem, I am attempting to do some illumination correction on a set of images and I’m having an issue with the sharp contrast present within the images. I believe the transition zones within the images are throwing off the illumination function deviation. I’m wondering if there is a good way to separate the image into regions (there are well-defined edges) and analyze each region on its own. I haven’t had any luck doing so with the IdentifyPrimaryObjects module. I can, with some consistency, use ApplyThreshold and filter out the brighter areas, and then apply the correction factor to that image, but goal of the project is do a quick and simple analysis of the illumination quality of the image without first altering it to do so. So I suppose the question I’m asking is, is there a method to seperate an image based on well defined edges and then do image math on each individual region?

I’m attaching a sample image and my pipeline.

P.S. Some of the images I’m using have scale bars. Has anyone developed a method by which to remove them automatically without cropping out a whole chunk of the image (or using manual object identification)? I’m guessing the assumption is if you have access to the image with scale bars, then you also have access to the image without scale bars, but I figured I’d ask.

Thresholding.cp (6.36 KB)

Hi Ryan,

You may want to consider splitting the image into R,G,B channels and examining which of the channels gives the best contrast. You could then use ApplyThreshold on the chosen channel to obtain a binary foreground for the lighter region, MaskImage to mask the grayscale image with the binary image, and then perform illumination correction on the result. CorrectIlluminationCalculate is designed to omit masked pixels from consideration, so this approach should work.

Then, use ImageMath to invert the pixel intensities of the binary image to to obtain a binary image of the other region, and then mask and correct with this new binary mask.

Re: scale bars - The only solution I’ve seen (other than pleading with people not to use them) is to invert the image, and use IdentifyPrimary to detect that scalebar rectangle. Usually you can set the size criterion accordingly so it captures only that region.

Hope this helps!