Image Processing with Python: Glossary

Key Points

Introduction
  • Simple Python and skimage (scikit-image) techniques can be used to solve genuine morphometric and colorimetric problems.

  • Morphometric problems involve the number, shape, and / or size of the objects in an image.

  • Colorimetric problems involve analyzing the color of the objects in an image.

Image Basics
  • Digital images are represented as rectangular arrays of square pixels.

  • Digital images use a left-hand coordinate system, with the origin in the upper left corner, the x-axis running to the right, and the y-axis running down.

  • Most frequently, digital images use an additive RGB model, with eight bits for the red, green, and blue channels.

  • Lossless compression retains all the details in an image, but lossy compression results in loss of some of the original image detail.

  • BMP images are uncompressed, meaning they have high quality but also that their file sizes are large.

  • JPEG images use lossy compression, meaning that their file sizes are smaller, but image quality may suffer.

  • TIFF images can be uncompressed or compressed with lossy or lossless compression.

  • Depending on the camera or sensor, various useful pieces of information may be stored in an image file, in the image metadata.

Image representation in skimage
  • skimage images are stored as three-dimensional NumPy arrays.

  • In skimage images, the red channel is specified first, then the green, then the blue, i.e. RGB.

  • Images are read from disk with the skimage.io.imread() function.

  • We create a window that automatically scales the displayed image with skimage.viewer.ImageViewer() and calling view() on the viewer object.

  • Color images can be transformed to grayscale using skimage.color.rgb2gray() or be read as grayscale directly by passing the argument as_gray=True to skimage.io.imread().

  • We can resize images with the skimage.transform.resize() function.

  • NumPy array commands, like img[img < 128] = 0, and be used to manipulate the pixels of an image.

  • Command-line arguments are accessed via the sys.argv list; sys.argv[1] is the first parameter passed to the program, sys.argv[2] is the second, and so on.

  • Array slicing can be used to extract sub-images or modify areas of images, e.g., clip = img[60:150, 135:480, :].

  • Metadata is not retained when images are loaded as skimage images.

Drawing and Bitwise Operations
  • We can use the NumPy zeros() function to create a blank, black image.

  • We can draw on skimage images with functions such as skimage.draw.rectangle(), skimage.draw.circle(), skimage.draw.line(), and more.

  • The drawing functions return indices to pixels that can be set directly.

Creating Histograms
  • We can load images in grayscale by passing the as_gray=True parameter to the skimage.io.imread() function.

  • We can create histograms of images with the np.histogram function.

  • We can separate the RGB channels of an image using slicing operations.

  • We can display histograms using the matplotlib pyplot figure(), title(), xlabel(), ylabel(), xlim(), plot(), and show() functions.

Blurring images
  • Applying a low-pass blurring filter smooths edges and removes noise from an image.

  • Blurring is often used as a first step before we perform Thresholding, Edge Detection, or before we find the Contours of an image.

  • The Gaussian blur can be applied to an image with the skimage.filters.gaussian() function.

  • Larger sigma values may remove more noise, but they will also remove detail from an image.

  • The float() function can be used to parse a string into an float.

Thresholding
  • Thresholding produces a binary image, where all pixels with intensities above (or below) a threshold value are turned on, while all other pixels are turned off.

  • The binary images produced by thresholding are held in two-dimensional NumPy arrays, since they have only one color value channel. They are boolean, hence they contain the values 0 (off) and 1 (on).

  • Thresholding can be used to create masks that select only the interesting parts of an image, or as the first step before Edge Detection or finding Contours.

Edge Detection
  • The skimage.viewer.ImageViewer is extended using a skimage.viewer.plugins.Plugin.

  • We supply a filter function callback when creating a Plugin.

  • Parameters of the callback function are manipulated interactively by creating sliders with the skimage.viewer.widgets.slider() function and adding them to the plugin.

Connected Component Analysis
  • skimage.measure.label is used to generate objects.

  • We use skimage.measure.regionprops to measure properties of labelled objects.

  • Color objects according to feature values.

Challenges
  • What are the key points?

Glossary

adaptive thresholding
additive color model
a color model that predicts the appearance of colors by summing the numeric representations of the component colors
bacterial colony
a visible cluster of bacteria growing on the surface of or within a solid medium, presumably cultured from a single cell
binary image
a digital image that has only two possible values for each pixel. Typically, the two colors used for a binary image are black and white.
Gaussian blur
a widely used effect in graphics software, typically to reduce image noise and reduce detail
BMP (bitmap image file)
a raster graphics image file format used to store bitmap digital images, independently of the display device
bounding box
the smallest enclosing box for a set of points
colorimetrics
the science of describing human color perception
channel
the grayscale representation of a primary color in a digital image
contour
child (in contours)
crop
the removal of unwanted outer areas from an image
color histogram
a representation of the number of pixels that have colors in each of a fixed list of color ranges
edge detection
a variety of mathematical methods that aim at identifying points in a digital image at which the image brightness changes sharply
fixed-level thresholding
picking a constant cut-off value to distinguish between pixels considered “on” and “off”
grayscale
an image in which the value of each pixel is a single value representing only the amount of light (or intensity) of that pixel
image segmentation
the process of partitioning a digital image into multiple segments to make the image more meaningful and easier to analyze
intensity
value corresponding to amount of light in a pixel
JPEG
a commonly used method of lossy compression for digital images, particularly for those images produced by digital photography
kernel
a small matrix. It is used for blurring, sharpening, embossing, edge detection, and more
left-hand coordinate system
lossy compression
a class of data encoding methods that uses inexact approximations and partial data discarding to represent the content
lossless compression
a class of data compression algorithms that allows the original data to be perfectly reconstructed from the compressed data
maize
also known as corn
mask
applied to digital images to “cut-out” the background or other unwanted features
morphometrics
the quantitative analysis of form, a concept that encompasses size and shape
noise
random variation of brightness or color information in images. An undesirable by-product of image capture that obscures the desired information.
parent (in contours)
raster graphics
a dot matrix data structure that represents a generally rectangular grid of pixels
RGB color model
an additive color model in which red, green and blue light are added together in various ways to reproduce a broad array of colors. The name of the model comes from the initials of the three additive primary colors, red, green, and blue.
root (in contours)
thresholding
the simplest method of image segmentation. From a grayscale image, thresholding can be used to create binary images
TIFF (Tagged Image File Format)
a computer file format for storing raster graphics images; also abbreviated TIF
titration
a common laboratory method of quantitative chemical analysis to determine the concentration of an identified analyte (a substance to be analyzed)