Chapter 2
Chapter 2
• Compression
▪ Most image file formats employ some type of compression.
▪ Compression methods can be:
• Lossy: a tolerable degree of deterioration in the visual quality of the
resulting image is acceptable.
• Lossless: the image is encoded in its full quality.
▪ As a general guideline:
• lossy compression should be used for general-purpose photographic images.
• lossless compression should be preferred when dealing with line art, drawings,
facsimiles, or images in which no loss of detail may be tolerable (most notably,
space images and medical images).
IMAGE FILE FORMATS
• Most of the image file formats used to represent bitmap images
consist of a file header followed by (often compressed) pixel data.
• The image file header stores information about the image, such as
image height and width, number of bands, number of bits per
pixel, and some signature bytes indicating the file type.
• Most common file types:
▪ BIN, PPM, PBM, PGM, PNM, BMP, JPEG, GIF, TIFF, PNG.
BASIC TERMINOLOGY
• Image Topology: It involves the investigation of fundamental image
properties (usually done on binary images and with the help of
morphological operators), such as number of occurrences of a particular
object, number of separate (not connected) regions, and number of holes.
• Neighborhood:
▪ The pixels surrounding a given pixel constitute its neighborhood, which
can be interpreted as a smaller matrix containing (and usually centered
around) the reference pixel, most neighborhoods used in image
processing algorithms are small square arrays with an odd number of
pixels.
▪ In the context of image topology, neighborhood takes a slightly different
meaning:
• The 4-neighborhood of a pixel as the set of pixels situated above, below, to the
right, and to the left of the reference pixel (p).
• The 8-neighborhood of a pixel as the set of all of p’s immediate neighbors.
• The pixels that belong to the 8-neighborhood, but not to the 4-neighborhood,
make up the diagonal neighborhood of p.
• Adjacency:
▪ In the context of image topology, two pixels p and q are 4-adjacent if
they are 4-neighbors of each other and 8-adjacent if they are 8-
neighbors of one another.
▪ A third type of adjacency (known as mixed adjacency (or simply m-
adjacency)) is sometimes used to eliminate ambiguities (i.e., redundant
paths) that may arise when 8-adjacency is used.
• Paths
▪ In the context of image topology, a 4-path between two pixels p and q is
a sequence of pixels starting with p and ending with q such that each
pixel in the sequence is 4-adjacent to its predecessor in the sequence.
▪ In the context of image topology, a 4-path between two pixels p and q is
a sequence of pixels starting with p and ending with q such that each
pixel in the sequence is 4-adjacent to its predecessor in the sequence.
• Connectivity
▪ If there is a 4-path between pixels p and q, they are said to be 4-
connected.
▪ Similarly, the existence of an 8-path between them means that they are
8-connected.
• Components
▪ A set of pixels that are connected to each other is called a component.
▪ If the pixels are 4-connected, the expression 4-component is used; if the
pixels are 8-connected, the set is called an 8-component.
▪ Components are often labeled (and optionally pseudocolored) in a
unique way, resulting in a labeled image, L(x, y), whose pixel values are
symbols of a chosen alphabet.
• The symbol value of a pixel typically denotes the outcome of a decision made for that
pixel in this case, the unique number of the component to which it belongs.
▪ Components in MATLAB:
• function bwlabel for labeling connected components in binary images.
• function, label2rgb, helps visualize the results by painting each region with a
different color.
I = imread('test_bw_label.png');
J = logical(I);
L1 = bwlabel(J,4);
L2 = bwlabel(J,8);
• Following Figure shows an example of using bwlabel and label2rgb and highlights
the fact that the number of connected components will vary from 2 (when 8-
connectivity is used, following Figure b) to 3 (when 4-connectivity is used,
following Figure c).
• Example: s = r/2
➢ Neighborhood-Oriented Operations:
▪ Neighborhood-oriented (also known as local or area) operations consist
of determining the resulting pixel value at coordinates (x, y) as a function
of its original value and the value of (some of) its neighbors, typically
using a convolution operation.
▪ The convolution of a source image with a small 2D array (known as
window, template, mask, or kernel) produces a destination image in
which each pixel value depends on its original value and the value of
(some of) its neighbors.
▪ The convolution mask determines which neighbors are used as well as
the relative weight of their original values.
▪ Masks are normally 3 × 3.