How to convert pixel size to inches
24 views (last 30 days)
Show older comments
I have an image of my experimental specimen. I know the dimensions of my specimen. I have taken a picture of my specimen. Now, how can I convert pixel information from the image to get the dimensions of my specimen? Basically, I can measure pixel distance and want to correlate to real life dimensions.
0 Comments
Accepted Answer
Image Analyst
on 11 Aug 2011
You need to have an object of known length, such as a ruler or some other calibration standard, in your image. Then measure its length to get a calibration factor with units of centimeters (or whatever) per pixel. Then when you have some other length, just simply multiply by that calibration factor to get a length in units of centimeters. If you have an area, multiply by the square of that factor to get the area in cm^2.
4 Comments
Image Analyst
on 8 Jun 2023
@Ella you need to check the units of what stats is. Not all of the measurements are linear distance measurements. Some are unitless ratios (like Solidity) and don't need any spatial calibration factor, and some are area measurements and need the square of the factor.
mmPerPixel = 0.013;
stats = regionprops(vivi, 'Area', 'MinFeretProperties' , 'MaxFeretProperties', 'Circularity', 'Perimeter', 'Solidity');
allAreas = [stats.Area] * mmPerPixel ^ 2; % Areas need square of spatial calibration factor.
allPerims = [stats.Perimeter] * mmPerPixel; % Linear distances need spatial calibration factor.
allSolidities = [stats.Solidity]; % Unitless measurements don't need any spatial calibration factor.
allCircularities = [stats.Circularity]; % Unitless measurements don't need any spatial calibration factor.
Ella
on 9 Jun 2023
Thanks for your help! Once I have these portions, can I put them back into stats? I'm not very familiar with structures.
More Answers (2)
Ash.P
on 15 Jan 2017
@Image Analyst - The 'calibration factor' that you talk about here would be different for objects at different distance from the camera right? How do you account for this fact?
6 Comments
Image Analyst
on 15 Jan 2017
Like I said, I have used the camera calibration software provided with the Computer Visions System Toolbox. I'd have to figure it out just like you'll have to. Contact the Mathworks for help. Good luck.
John BG
on 16 Jan 2017
Edited: John BG
on 16 Jan 2017
Ashwini
You correct distance by correcting 2 angles, vertical and horizontal.
Try Michael Chan's perspective correction pack available from the File Exchange
it prompts you to key in a few points to reference elements in the picture and the a perspective transform is applied.
If you find this link useful, would please be so kind to mark my answer as accepted answer?
Thanks for time and attention,
John BG
0 Comments
See Also
Categories
Find more on Geometric Transformation and Image Registration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!