RTUEE / EC / EEEYr 2021 · Sem 72021

Q9Digital Image Processing

Question

16 marks

Q.5. (a) Discuss watershed transform along with its suitable application. [8]

(b) Discuss any one lossless compression technique and state advantages of lossless compression. [8]

Answer

The watershed transform treats the (gradient) image as a topographic surface and floods it from local minima to build dams (watershed lines) that segment touching objects, mitigating over-segmentation via marker-controlled watershed; Huffman coding is a lossless compression technique that assigns shorter codes to more frequent symbols, guaranteeing exact, reversible reconstruction of the original data.

(a) Watershed Transform

The watershed transform is a region-based image segmentation technique inspired by the geographical concept of drainage basins and watershed lines on a topographic terrain. In this analogy, the image (usually its gradient magnitude image, since regions of high gradient correspond to object boundaries/edges) is treated as a three-dimensional topographic surface, where the (x,y) position represents geographic location and the pixel intensity value at that position represents elevation. Bright, high-gradient regions (edges) correspond to high mountain ridges, while dark, low-gradient regions (smooth interiors of objects) correspond to low-lying valleys or basins.

The watershed algorithm conceptually simulates a flooding process: water is imagined to rise up from each of the local minima of the topographic surface (i.e., from each of the darkest, flattest low points, which typically lie inside object regions). As the water level steadily rises, it fills up the catchment basin surrounding each local minimum. Whenever the rising water from two distinct catchment basins (belonging to two different local minima) is about to merge into a single body of water, a dam, called a watershed line, is constructed at that exact boundary to prevent the merger. This flooding and dam-building process continues until the entire topographic surface is submerged, at which point the set of all constructed dams forms a complete network of watershed lines that partitions the image into distinct, non-overlapping catchment-basin regions, each corresponding to one segmented object or region.

A well-known practical problem with the direct application of the watershed transform is over-segmentation: because real images typically contain many small local minima due to noise and minor intensity variations (rather than just one clean minimum per meaningful object), the naive watershed algorithm tends to produce a very large number of small, spurious catchment basins, far more than the number of visually and semantically meaningful objects actually present in the image, making the raw result generally unusable without further processing. The standard mitigation for this problem is marker-controlled watershed segmentation: instead of flooding from every local minimum in the gradient image, the flooding process is restricted to begin only from a pre-selected, much smaller set of marker points, which are chosen (either manually or via some automated pre-processing step such as identifying regional minima after suitable smoothing, or foreground/background markers derived from morphological processing) to correspond specifically to the interiors of the actual objects of interest and the background. Since flooding starts from a controlled, limited set of markers, the number of resulting catchment basins in the marker-controlled approach matches the number of markers rather than the number of noisy local minima, effectively eliminating the over-segmentation problem while retaining the watershed algorithm's core strength of naturally producing continuous, connected boundary lines even between touching objects.

A major practical application of the watershed transform, particularly the marker-controlled variant, is segmenting touching or overlapping objects that are difficult to separate using simple thresholding, such as separating individual touching or clustered cells in microscopy images, where a simple intensity threshold would merge adjacent touching cells into a single connected blob, but the watershed transform's dam-building mechanism naturally inserts a dividing boundary line exactly at the point of contact between the touching cells, correctly separating them into individual segmented regions.

Watershed Segmentation Conceptbasin 1basin 2basin 3watershed line (dam)

(b) Lossless Compression: Huffman Coding

Huffman coding is a widely used lossless data compression technique that assigns variable-length binary codewords to the distinct symbols (e.g., gray-level values) present in an image, based on their probability of occurrence, such that symbols that occur more frequently are assigned shorter codewords and symbols that occur rarely are assigned longer codewords. This is achieved by building a binary tree (the Huffman tree) through a bottom-up construction algorithm: initially, every distinct symbol is treated as a separate leaf node, labeled with its probability of occurrence. The algorithm repeatedly selects the two nodes (or partially built subtrees) with the currently lowest combined probabilities, merges them into a new parent node whose probability is the sum of the two children's probabilities, and continues this merging process until only a single root node remains, representing the complete binary tree. The final binary codeword for each original symbol is then obtained by tracing the path from the root of the tree down to that symbol's leaf node, assigning a '0' for each left branch taken and a '1' for each right branch taken (or vice versa, by convention).

As a small worked example, suppose an image has just four gray-level symbols with probabilities: A = 0.4, B = 0.3, C = 0.2, D = 0.1. The two lowest-probability nodes, C (0.2) and D (0.1), are merged first into a combined node CD with probability 0.3. Next, the two lowest-probability nodes among {A=0.4, B=0.3, CD=0.3} are B and CD (both 0.3, tie broken arbitrarily), merged into node BCD with probability 0.6. Finally, A (0.4) and BCD (0.6) are merged into the root (probability 1.0). Tracing paths from the root gives, for example, codeword '0' for A (1 bit), '10' for B (2 bits), '110' for C (3 bits), and '111' for D (3 bits). Note that the most probable symbol A received the shortest codeword, while the least probable symbols C and D received the longest codewords, exactly matching the desired inverse relationship between probability and codeword length. Huffman coding is proven to produce the minimum possible average codeword length among all uniquely decodable prefix codes for a given set of symbol probabilities, making it an optimal prefix code.

The key advantage of lossless compression techniques generally, of which Huffman coding is one example (others include run-length encoding and arithmetic coding), is that they guarantee exact, bit-for-bit reconstruction of the original uncompressed data upon decompression, with absolutely no information loss whatsoever. This exact reversibility is critical in application domains such as medical imaging (where any loss of diagnostic detail could be clinically dangerous), legal and archival document imaging (where authenticity and completeness of the original record must be preserved), and any other scenario where the integrity of the exact original data must be guaranteed rather than merely visually approximated.

Watershed segmentation and lossless compression address two entirely different, complementary stages of a typical image-processing pipeline - watershed transform extracts meaningful object boundaries from an image for subsequent analysis or recognition tasks, while lossless compression instead reduces the storage or transmission bandwidth required for an image without altering its pixel content in any way, which is precisely why lossless compression is mandatory for applications such as medical imaging and legal or forensic image archiving, where even the smallest pixel-level alteration introduced by lossy compression could be unacceptable, whereas watershed segmentation is instead a preprocessing or analysis step used to extract structure from the image content itself.

Back to Paper