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.
Original image: Results after colorising components An example of what I hope to get:
data = Import["https://i.sstatic.net/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"][[1]][[2]]) & /@Range[1, Length[masks]];
coords = (ComponentMeasurements[masks[[#, 2]],"Centroid"][[1]][[2]]) & /@ Range[1, Length[masks]];
ImagePyramid
) $\endgroup$MedianFilter[i, {0, 50}]
, (across 0 vertical, 50 horizontal pixels) which you could then try to subtract from the image. $\endgroup$