I've been trying to analyse some SEM images to determine grain areas and sizes. Some of my images (I've attached an example below) appear to have horizontal bands that manifest as regions with different brightness, which leads to discontinuities when detecting via MorphologicalComponents (code snippet below).
I've tried applying a number of filters (Meanfilter, Medianfilter, Gaussianfilter etc.) but haven't been able to come up with a solution for this. Could anyone please help? Thanks.
data = Import["https://i.stack.imgur.com/uVv8l.jpg"] snip = ImageTake[data, 880]; ImageHistogram[snip] regions = ColorNegate[Binarize[snip, .283]]; inverse = ColorNegate[%]; medianF = MedianFilter[inverse, 1]; ImageHistogram[medianF] components = MorphologicalComponents[medianF, 0.5, CornerNeighbors -> False]; Colorize[components] masks = ComponentMeasurements[components, "Mask"]; areas = (ComponentMeasurements[masks[[#, 2]], "Area"][][]) & /@Range[1, Length[masks]]; coords = (ComponentMeasurements[masks[[#, 2]],"Centroid"][][]) & /@ Range[1, Length[masks]];