Removing horizontal noise artefacts from a (SEM) image
One thing to look at is to level-adjust each line separately by dividing (or subtracting) the mean of the line's gray value:
img = ImageCrop[ColorConvert[Import["https://i.stack.imgur.com/uVv8l.jpg"],
"Grayscale"], {Full, 850}, {Center, Bottom}];
calib = Rescale[
With[{mean = Mean[#]}, # - mean] & /@ ImageData[img, "Real"]
] // Image
This removes a good portion of the fluctuations
After that, you can try your smoothing and segmentation again
bin = DeleteSmallComponents[
ColorNegate[MedianFilter[calib, 5]] // Binarize,
100
];
HighlightImage[calib, bin]
I like what @halirutan did and had a slight riff on it that appears to yield a better result.
Rescale[With[{meanFiltered = MeanFilter[#, 50]}, # - meanFiltered] & /@
ImageData[img, "Real"]] // Image
The result of this:
If I get time, I might experiment a bit with the "radius" of the MeanFilter to see if that improves the results.
Update: Using Manipulate, it appears that the best results occur between about 50 and 70, after which the banding starts reappearing and is more significant at about 120.
Manipulate[calib = Rescale[With[{meanFiltered = MeanFilter[#, radius]}, # - meanFiltered] & /@ImageData[img, "Real"]] // Image, {{radius, 50}, 10, 250, 5}]
Update2: I decided to let a program find the optimal by doing this:
initialImageData = ImageData[img, "Real"];
allSortedImages =
With[ {choices =
Table[Rescale[
With[ {meanFiltered = MeanFilter[#, radius]},
# -
meanFiltered
] & /@ initialImageData], {radius, 30, 100,
1}]},
SortBy[choices, Total[initialImageData - #] &]
];
That gives this as the best image.
allSortedImages[[1]] // Image
I modified this slightly just to more easily be able to find what was the optimal radius.
initialImageData = ImageData[img, "Real"];
allAdjustedImages =
Table[Rescale[
With[ {meanFiltered = MeanFilter[#, radius]},
# - meanFiltered
] & /@
initialImageData], {radius, 30, 100, 1}];
allSortedImages =
SortBy[allAdjustedImages, Total[initialImageData - #] &];
Position[allAdjustedImages, allSortedImages[[1]]]
The position returned is 38 (and the image is the same as above).