how to determine image size png

5 views (last 30 days)
Hi all, anyone can help me how to know the pixel size of one pixel??
my image is medtest.png
>> info = imfinfo('medtest.png')
info =
struct with fields:
Filename: 'C:\Users\Akmal\Documents\MATLAB\Add-Ons\Functions\Region Growing\medtest.png'
FileModDate: '25-Dec-2020 23:21:43'
FileSize: 53631
Format: 'png'
FormatVersion: []
Width: 468
Height: 400
BitDepth: 8
ColorType: 'grayscale'
FormatSignature: [137 80 78 71 13 10 26 10]
Colormap: []
Histogram: []
InterlaceType: 'none'
Transparency: 'none'
SimpleTransparencyData: []
BackgroundColor: []
RenderingIntent: []
Chromaticities: [0.31269 0.32899 0.63999 0.33001 0.3 0.6 0.15 0.05999]
Gamma: 0.45454
XResolution: 2835
YResolution: 2835
ResolutionUnit: 'meter'
XOffset: []
YOffset: []
OffsetUnit: []
SignificantBits: []
ImageModTime: []
Title: []
Author: []
Description: []
Copyright: []
CreationTime: []
Software: []
Disclaimer: []
Warning: []
Source: []
Comment: []
OtherText: []

Accepted Answer

Walter Roberson
Walter Roberson on 23 Jan 2021
IF you can trust the headers
XResolution: 2835
YResolution: 2835
ResolutionUnit: 'meter'
then the resolution is 2835 pixels per meter, which happens to correspond to 72 pixels per inch.
However, when you see 72 pixels per inch or 100 pixels per inch, you should pretty much assume that nominal values have been written into the headers, that might have no relationship to reality.
There is probably nothing in those headers that you should trust other than the height and width.
You either need external information (e.g., knowledge that it was taken with a microscope with particular settings), or else you need to know the true size of some object in the field of view in order to calculate scales.

More Answers (0)

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!