Putri Ranati
Putri Ranati

Reputation: 47

How to extract image metadata using MATLAB?

How can I extract image metadata like exposure, width, height, or bitdepth using MATLAB?

Until recently I was using exifread, but this function no longer exists in the newest MATLAB version.

The other function is imfinfo, but it cannot read the 'EXPOSURE DATA' image.

How can I read the 'exposure' image?

Upvotes: 2

Views: 2674

Answers (2)

Piglet
Piglet

Reputation: 28940

exifread() deprecated 9 years ago. It has been replaced by imfinfo

info = imfinfo(filename) will return all information you want.

From the Matlab reference

Additional fields returned by some file formats:

JPEG and TIFF only — If filename contains Exchangeable Image File Format (EXIF) tags, then info might also contain 'DigitalCamera' or 'GPSInfo' (global positioning system information) fields.

info.Width, info.Height, info.BitDepth. The exposuretime as well as all other camera parameters are stored in the 1x1 struct info.DigitalCamera

Here's an example from

https://de.mathworks.com/matlabcentral/answers/146651-missing-functionality-when-using-imfinfo-instead-of-exifread

>> info = imfinfo('img_1771.jpg')
info = 
            Filename: 'C:\Users\fhempel\Desktop\tmp\img_1771.jpg'
         FileModDate: '07-Aug-2014 12:09:45'
            FileSize: 32764
              Format: 'jpg'
       FormatVersion: ''
               Width: 480
              Height: 360
            BitDepth: 24
           ColorType: 'truecolor'
     FormatSignature: ''
     NumberOfSamples: 3
        CodingMethod: 'Huffman'
       CodingProcess: 'Sequential'
             Comment: {}
                Make: 'Canon'
               Model: 'Canon PowerShot S40'
         Orientation: 1
         XResolution: 180
         YResolution: 180
      ResolutionUnit: 'Inch'
            DateTime: '2003:12:14 12:01:44'
    YCbCrPositioning: 'Centered'
       DigitalCamera: [1x1 struct]
       ExifThumbnail: [1x1 struct]


>> info.DigitalCamera
ans = 
                ExposureTime: 0.0020
                     FNumber: 4.9000
                 ExifVersion: [48 50 50 48]
            DateTimeOriginal: '2003:12:14 12:01:44'
           DateTimeDigitized: '2003:12:14 12:01:44'
     ComponentsConfiguration: 'YCbCr'
      CompressedBitsPerPixel: 5
           ShutterSpeedValue: 8.9688
               ApertureValue: 4.6563
           ExposureBiasValue: 0
            MaxApertureValue: 2.9709
                MeteringMode: 'CenterWeightedAverage'
                       Flash: 'Flash did not fire, no strobe return detection function, auto flash mode, f...'
                 FocalLength: 21.3125
                   MakerNote: [1x450 double]
                 UserComment: [1x264 double]
             FlashpixVersion: [48 49 48 48]
                  ColorSpace: 'sRGB'
            CPixelXDimension: 2272
            CPixelYDimension: 1704
         InteroperabilityIFD: [1x1 struct]
       FocalPlaneXResolution: 8.1143e+03
       FocalPlaneYResolution: 8.1143e+03
    FocalPlaneResolutionUnit: 2
               SensingMethod: 'One-chip color area sensor'
                  FileSource: 'DSC'
              CustomRendered: 'Normal process'
                ExposureMode: 'Auto exposure'
                WhiteBalance: 'Auto white balance'
            DigitalZoomRatio: 1
            SceneCaptureType: 'Standard'

Upvotes: 1

Ander Biguri
Ander Biguri

Reputation: 35525

All the information you think you are missing is stored in iminfo, just differently. Most of the parameters you want (including exposure data) are in

info=iminfo(fname);
info.DigitalCamera

Upvotes: 0

Related Questions