Region Labeling

One of the common tasks in image processing (and computer vision) is "region labeling." At a higher level of its application, the outcome looks like this:

At lower levels, the process typically starts by grouping neighboring pixels based on a given heuristic, such as color similarity. For example, the following image (bw.png in the resources/tiny folder) clearly has two regions:

Notice in our definition of "region," the pixels must have the same color and be connected to form a group. For example, you see five colors in the following image but seven regions (two blacks, two greens, one red, one blue and one white).

We will use the Union-Find Data structure to perform region labeling at low-level (i.e., assigning a label to each pixel so that all pixels that belong to the same region have the same label).

Resources

These resources are provided for completeness; you do not need to consult any of these for this take-home exam!