Images Files and File Types 27
MATLAB
>> imfinfo(’backyard.png’)
ans
=
Filename: ’backyard.png’
FileModDate: ’02-Jan-2015
05:45:17’
FileSize: 264103
Format: ’png’
FormatVersion: []
Width: 482
Height: 643
BitDepth: 24
ColorType: ’truecolor’
FormatSignature: [73 73 42 0]
ByteOrder: ’little-endian’
NewSubFileType: 0
BitsPerSample: [8 8 8]
Compression: ’JPEG’
Now we shall test this function on a binary image, in Octave:
Octave
>> imfinfo(’circles.png’)
ans =
scalar structure containing the fields:
Filename = /home/amca/Images/circles.png
FileModDate = 2-Jan-2015 21:37:54
FileSize = 1268
Format = PNG
FormatVersion =
Width = 256
Height = 256
BitDepth = 1
ColorType = grayscale
In MATLAB and Octave, the value of ColorType would be GrayScale.
What is going on here? We have a binary image, and yet the color type is given as either
“indexed” or “grayscale.” The fact is that the
imfinfo command in both MATLAB nor
Octave has no value such as “Binary”, “Logical” or “Boolean” for
ColorType. A binary image
is just considered to be a special case of a grayscale image which has only two intensities.
However, we can see that
circles.png is a binary image since the number of bits per pixel
is only one.
In Chapter 3 we shall see that a binary image matrix, as distinct from a binary image
file, can have the numerical data typ e
Logical.
To obtain image information in Python, we need to invoke one of the libraries that
supports the metadata from an image. For TIFF and JPEG images, such data is known as
EXIF data, and the Python
exifread library may be used: