Determining pixel size based on an image of a scale/ruler.

24 visualizzazioni (ultimi 30 giorni)
I have an image with a scale on it, and I would like to know the size of each pixel. So that way, I can say that an area of x by x pixels, is equal to y mm^2. What's the best way to go about doing this? Here is the image sample:
My initial idea was to use IM profile along the lines, and determine the pixel distance between the intensity drops. However, if I don't draw my profile perfectly perpendicular, then this approach will not work.
Because I have a large data set of images that all have different scales, I would like to automated this process if possible. Something along the lines of detecting these dark lines, and then determining the minimum distance between neighboring lines.
Thanks in advance.

Risposte (2)

Image Analyst
Image Analyst il 29 Gen 2015
See my spatial calibration demo, attached.
Of course you can do it automatically if you can automatically find the lines and know their true separation.
  4 Commenti
Image Analyst
Image Analyst il 30 Gen 2015
Alright, attached is code that does it for you. If you agree, can you mark the Answer as "Accepted". Be sure to change the filename and folder in the attached test.m file.
Faiz Yusoff
Faiz Yusoff il 16 Ott 2020
Hello image analyst,
Would you help me solving my problem to identify the location of red colour in coordinat mm?

Accedi per commentare.


DEEPAK DAIYA
DEEPAK DAIYA il 27 Apr 2018
Get your scale image in your current figure axis and call function imdistline. it will create a distance measuring tool in your figure. Drag the point of the line created by the function to your known positions of the scale image, for example two major ticks of the image which are 5 mm apart.Then read this distance in the pixel values, say 'x'. Then your pixel size calibration will be equal to 5/x in mm/pixel.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by