Chapter 3
Image and Its Properties
3.1 Introduction
We begin this chapter with an introduction to images, image types,
and data structures in Python. Image processing operations can be
imagined as a workflow similar to Figure 3.1. The workflow begins with
reading an image. The image is then processed using either low-level or
high-level operations. Low-level operations operate on individual pixels.
Such operations include filtering, morphology, thresholding, etc. High-
level operations include image understanding, pattern recognition, etc.
Once processed, the image(s) are either written to disk or visualized.
The visualization may be performed during the course of processing as
well. We will discuss this workflow and the functions using Python as
an example.
FIGURE 3.1: Image processing work flow.
37
38 Image Processing and Acquisition using Python
3.2 Image and Its Properties
In the field of medical imaging, the images may span all spatial
dimensions (x-, y- and x-axis) and also the time dimension. Hence it
is common to find images in 3D, and in some cases such as cardiac
CT, images in 4D. In the case of optical microscopy, the images of
the same specimen may be acquired at various emission and excitation
wavelengths. Such images will span multiple channels and may have
more than 4 dimensions. We begin the discussion by clarifying some of
the mathematical terms that are used in this book.
For simplicity, let us assume the images that will be discussed in
this book are 3D volumes. A 3D volume (I) can be represented math-
ematically as
α = I −→ R and I ⊂ R
Thus, every pixel in the image has a real number as its value. How-
ever, in reality as it is easier to store integers than to store floats; most
images have integers for pixel values.
3.2.1 Bit-Depth
The pixel range of a given image format is determined by its bit-
depth. The range is [0, 2bitdepth − 1]. For example, an 8-bit image will
have a range of [0, 28 − 1] = [0, 255]. An image with higher bit-depth
needs more storage in disk and memory. Most of the common photo-
graphic formats such as JPEG, PNG, etc. use 8 bits for storage and
only have positive values.
Medical and microscope images use a higher bit-depth, as scientific
applications demand higher accuracy. A 16-bit medical image will have
values in the range [0, 65535] for a total number 65536 (= 216 ) values.
For a 16-bit image that has both positive and negative pixel values, the
range is [−32768, +32767]. The total number of values in this case is