by256 / imagedataextractor

ImageDataExtractor 2.0 - a Python library for electron microscopy image quantification.
https://imagedataextractor.org
MIT License
12 stars 2 forks source link

manully measure scalebar #5

Closed alissa777 closed 3 years ago

alissa777 commented 3 years ago

Hi, I am Alissa.

I got issue about scalebar detection. As the image shown, the scalebar is 50 nm, but the output particle size are over 400 nm. I think its not right. The particle size should be less than 50 nm. Then I imput the Example image and got same error.

Screenshot 2021-05-08 at 10 41 49 Screenshot 2021-05-08 at 10 28 29

Last time you replied me that if I have to measure scalebar manually to get the result in this case. Could you please instruct me to measure it by myself?

Screenshot 2021-05-08 at 10 32 53 Screenshot 2021-05-08 at 10 26 01

Thank you for reading my writing.

by256 commented 3 years ago

Hi,

The output particle sizes are in {units}^2 — in this case, nm^2. In the example you gave, the particles are spherical, so to calculate for example the radius of a particle, you would divide the area by pi and square root the result. This will give you particle radius in units of nm in your case. In other cases, where the shapes of the particles are different from spheres (i.e. cubic, rods, etc), it may not be possible to characterize a particle with a radius or diameter. This is why sizes are given as areas, so that a user may use them (along with other quantitative measures potentially) to calculate any morphological parameter of their choice.

To calculate the scalebar conversion manually, you need to first measure your scalebar in pixels. Let's say you do this and you get X pixels for the example you showed. Since you know the length of the scalebar in nanometers and the length in pixels, you can calculate the pixel to nanometer conversion as 100 nm / X pixels. Multiplying any length which is in units of pixels by this value will give you the same length in nanometers.

In terms of actually measuring the scalebar in pixels, there are a couple of ways you can do this. It should be possible to do this in any image editing software, but I usually use matplotlib. I plot the image in a Python script (this won't work in a Jupyter Notebook) which opens a window showing the image. Hovering over any point in the image shows the x-y location of the mouse cursor. So I obtain the x coordinate of the right side of the scalebar and the x coordinate of the left side of the scalebar. Taking the difference of these two values gives you the length in pixels.

I hope this helps.

Batuhan

alissa777 commented 3 years ago

Thank you a lot for the reply. It helps a lot. Alissa