Following the wonderful methodologies provided in this post, I have learned how to process microscopic images of the types shown below in order to analyze them. When it comes to analysing the size distribution of the particles, the images always have a scale indicator, which give the actual scale of the image. By default, when we measure the size distribution e.g. using ComponentMeasurements
, everything is measured in pixels. My question is:
- Is there a way to incorporate/detect in Mathematica the actual given length-scale of the image? (in example below $500 nm$ for the shown spacing), that is, to convert pixels to $nm$ (or $nm^2$ for area). Example given below (source):
To detect the particles, I've adopted the following approach learned from Niki Estner's previous answer:
img = Import["https://i.stack.imgur.com/ryzmV.jpg"]
ridges = RidgeFilter[-img, 1];
distRidges =
DistanceTransform@ColorNegate@MorphologicalBinarize[ridges];
distMax = MaxDetect[distRidges, 1];
morph = WatershedComponents[ridges, distMax, Method -> "Basins"];
comp = ComponentMeasurements[{img, morph}, {"Centroid", "Neighbors"}];
edges = Dilation[EdgeDetect[Image[morph], 1, .001], 0.5];
edgeOverlay =
Show[img, SetAlphaChannel[ColorReplace[edges, White -> Red], edges]]
yielding the following detection result:
and to extract the particle sizes in order to estimate the size distribution histogram, I've used the "Area" property in ComponentMeasurements
as follows:
sizesls = {};
areaInPixels = ComponentMeasurements[morph, {"Area"}];
For[i = 1, i <= Length[areaInPixels], i++,
eltmp = areaInPixels[[i]][[2]];
AppendTo[sizesls, eltmp[[1]]];
];
Histogram[sizels]
but the size distribution is obtained in pixels, as opposed to using the actual scale of the image in $nm$ as indicated in the original image. From the source of the image, the indicated expected mean particle size is $60 nm.$