Image enhancement techniques aim to provide users maximal control in directing the improvements of the appearance of an image. They are widely used in photography post-processing (i.e., retouching), medical image processing, and object recognition. Many image editing platforms, such as Adobe Photoshop, utilize region selection, similarity, and/or thresholding to determine groups of pixels to edit. Then, editing options (e.g., contrast or brightness) that only consider global image properties are provided, never considering the topological structure of an image. Topological information provides a new perspective on the “shape” of the image and new capabilities for manipulating it .
In this paper, we leverage a tool from Topological Data Analysis (TDA) , specifically the contour tree , to extract a hierarchical representation of key features of an image (i.e., critical points) and the monotonic regions connecting those features (i.e., Morse cells). The contour tree of a scalar function defined on a simply connected domain (i.e., an image) is obtained by encoding the evolution of the connectivity of the level sets induced by the scalar function. The key property of contour tree that makes it a viable tool for image enhancement is its graph-based representation that captures the changes of topology in image data. The contour tree can therefore be searched, modified, and pruned locally, in a quantifiable way, while retaining the global structures in the image. Using the contour tree, topology-aware transfer functions provide new image enhancement functionalities for editing images using local topological properties, instead of using global image properties.
The contributions of this paper are: (1) we provide a mapping of color images to the contour tree for extracting the topological structure of the image; (2) we describe an interface for selecting topological features for image editing; and (3) we provide 4 topology-aware transfer function modalities for image editing: brightness enhancement, contrast enhancement, denoising, and gamma correction.
2 Capturing the Topology of an Image
Let be a continuous function on a simply connected domain . The level set of a single isovalue is, and a contour is a connected component of a level set. The most familiar context of contours are topographic maps (see Fig. 1), where is the elevation, and contours are shown at selected values. The contour tree tracks the creation, merging, splitting, and destruction of contours as a plane is swept across .
Consider the example height map in Fig. 1(c) and contour tree in Fig. 1(d). First, a plane is swept from . As the plane sweeps up, when it reaches local minima, nodes are created in the contour tree, denoted by labels , , and , since these represent the “birth” of a contour. As the plane continues its sweep up, one can observe that at there are 3 independent contours, each represented by an edge in the contour tree.
At , a special event occurs, where the contour of and merge together. The merge, called a join event, represents the “death” of the contour that was born more recently, in this case . The event creates the feature pair . Similarly, at , the contours of and join and “dies”, creating the pair.
The birth/death relationships are important, because they segment the space into a hierarchy of regions of uniform (i.e., monotonic) behavior. Furthermore, the difference between the birth and death, , of a contour is known as the persistence of the feature. Persistence is an important measure in our context, as it captures the amplitude/magnitude of a feature.
Likewise, we also consider a sweep plane that goes from . As the plane sweeps downwards, new contours are born at local maxima, such as and . For downward sweeps, when the contours merge together at , this is called a split event. Similarly to join events, the split represents the “death” of the feature born more recently, in this case . With splits, .
Finally, the global minimum and maximum are paired into a special feature, captured twice as and , representing the range of values.
2.1 Computing the Contour Tree
As the previous section implies, the construction is split into 2 phases: an upward and downward sweep, implemented as join tree (see Fig. 2(c)) and split tree (see Fig. 2(e)) construction, respectively. To find the join and split trees, the construction first finds the augmented join tree and augmented split tree.
Using the scalar field in Fig. 2(a), which is a downsampled version of Fig. 1(a), the augmented join tree construction is shown in Fig. 2(b). First, the pixels are sorted by values, . Pixels are inserted 1 at a time into the augmented join tree. As they are inserted, connected components are tracked by connecting with neighboring pixels already in the augmented join tree. In our implementation we consider the ring of 8 neighbors surrounding a given pixel. In this example, we only consider 4 (i.e., left/right/up/down) neighbors. If a pixel joins 1 or more existing components, it is connected to the top of those components in the augmented join tree. If it joins no component, it starts a new connected component. For example, when is added to the tree, no connected components exist, so it creates one. When is inserted, it joins the component, since they are neighbors in the image. Continuing forward, when is inserted, it links the component to the component.
Augmented split tree construction is performed nearly identically, except it starts at the largest valued pixel first. The augmented contour tree is constructed by pealing leaf nodes off of the join/split trees and adding them to the augmented contour tree, as described in . The join/split/contour trees consist of only critical nodes (i.e., nodes that cause birth and death events). They are calculated by removing “regular” nodes, those having only 1 upward and 1 downward edge, from the augmented tree. Finally, using the contour tree, the critical points are paired into birth/death units using the approach in .
This construction assumes that all pixels have unique values, which is not the case in real images. There are 2 cases of equal valued pixels we consider. When equal valued pixels are non-adjacent, no special handling is required—the pixels can be processed in arbitrary order, but the output is still deterministic. However, adjacent pixels of equal value are problematic, since changing their insertion order can change the contour tree structure. This is resolved by grouping adjacent equal-valued pixels into “super-pixel” units that are processed together.
2.2 Feature Subtree Extraction
Extracting the regions of monotonic behavior requires selecting a subtree from the augmented contour tree for a given feature pair. Given a join/split node and local minimum/maximum pair, starting at the join/split, find the 3 subtrees extending from it. The selected subtree for the feature pair is the one containing the local minimum/maximum node. For example, in Fig. 2(f), the feature pair contains join node and local minimum . Join node has 3 subtrees: up, down-left, and down-right. The down-left subtree contains the local minimum node , making it the feature subtree, containing nodes . The selection can be seen in Fig. 4(a).
2.3 Using the Contour Tree of Color Images
The contour tree requires (i.e., a single color channel). However, considering color images in RGB (Red, Green, Blue) colorspace, 3 channels map to each pixel. We consider each channel, red, green, and blue independently, generating 3 contour trees. We also consider HSB (Hue, Saturation, Brightness) colorspace. Saturation and brightness each map to their own contour trees. However, hue maps to (i.e., circular coordinates), and the contour tree does not work in . Resolving this limitation requires additional theoretical studies. Other colorspaces are possible, when channels map to .
3 Image Processing via Contour Trees
The basic procedure for topology-based enhancement of an image is: (1) first, the user selects a set of feature pairs of interest; (2) next, the feature pairs are used to automatically select pixels for editing; (3) finally, the image is edited by the user, and the contour trees are recalculated so the process can restart.
3.1 Visualizing the Contour Tree
Direct visualization of the contour tree is generally not advisable, as the size and complexity of the tree is unmanageable for even moderately sized data. To select features to edit, each contour tree is displayed using 2 interactive interfaces—the persistence diagram and persistence-volume diagram.
Persistence Diagram. A standard practice in TDA represents the contour tree with birth/death feature pairs in a scatterplot display, called a persistence diagram . In a persistence diagram, the x-axis is tied to the feature birth value, while the death value is tied to the y-axis. Fig. 3(a)(left) shows an example for the contour tree in Fig. 1(d). Join features (i.e., and ) are on the upper left, while split features (i.e., ) are on the lower right. Features are also colored by their type—join features blue and split features red. The persistence diagram provides 2 powerful selection hints. First, features on the lower left are darker pixels, while those on the upper right are brighter pixels, since the birth and death are parameterized by pixel value. Second, the distance of the point from the diagonal is an analog of the persistence of the feature pair. In other words, features with larger magnitude are farther from the diagonal.
Persistence-Volume Diagram. The persistence diagram primarily captures the amplitude of a selected feature. The volume (i.e., the pixel count of a feature) is sometimes important as well. The persistence-volume diagram (see Fig. 3(a)(right)) is an alternative representation that encodes persistence (i.e., ) on the x-axis using a linear scale and volume on the y-axis using a log scale. Volume is calculated by counting the number of nodes/pixels in the feature subtree. For example, the contains 4 nodes/pixels, , , , and .
3.2 Subtree Selection
Once the contour trees are generated and visualized, user interaction can proceed. Many topological features come from an image, so while individual selection is possible, selection of multiple features is desirable. We provide a brushing mechanism on both the persistence diagram and persistence-volume diagram for selecting a set of features of interest. As the mouse is clicked-and-dragged, the features and feature subtrees are gathered for further processing. For example, brushing across the middle of the persistence-volume diagram in Fig. 3(a) would select feature and its subtree, as shown in Fig. 3(b). Features of the contour tree are hierarchical, thus, if more than one feature is selected, those features may be inclusions (i.e., one feature may be a subsets of another). In that case, only the larger/outermost feature is processed.
The selected feature pairs and their associated subtrees are relatively easy to use for segmentation. Starting with a full resolution binary mask, the nodes/pixels of each selected feature is marked in the mask. Fig. 4(f) shows how this would work given the selection of the feature from Fig. 1.
3.3 Subtree Modification as Image Editing
From a segmentation mask, global image editing options (i.e., contrast enhancement, brightness enhancements, etc.) could be easily executed. However, this misses an opportunity for modifications based upon local topology, by using subtree information. For subtree-based modification, we provide 4 transfer function options that utilize the properties of the subtree.
Contrast Enhancement. Contrast enhancement fixes value of the feature pair join/split node and linearly stretches rest of the subtree. For a given node in the subtree and a contrast scale factor , the value . Fig. 4(b) shows an example of the operation, where the local contrast enhancement fixes the death value of a feature, while lowering the birth value.
Denoising. Denoising linearly collapses the subtree, such that all pixels eventually have the same value, . The calculation of denoising is identical to contrast enhancement—for a given node in the subtree and a denoising scale factor , the value . Fig. 4(c) shows an example, where the death value is fixed and the values of other nodes/pixels are increased.
Brightness Enhancement. The brightness of the entire subtree can be modified up or down uniformly. For a given node in the subtree and a brightness scale factor , the value . Fig. 4(d) shows an example.
Gamma Correction. Gamma correction provides a nonlinear modification, which is usually applied to the luminance of an image. For a given node in the subtree and a gamma correction value , where , the value of a pixel is first normalized and gamma corrected
. The final value of the pixel is then linearly interpolated,. Fig. 4(e) shows an example, where .
Interface. The interface for selecting the editing mode and scale is shown in Fig. 3(b). The interface designed represents how a chosen function modifies the persistence of the feature (horizontally) and the birth and death of a feature (vertically). For example, contrast enhancement increases persistence, while denoising decreases it. Brightness enhancement modified both the birth and death of a feature, leaving persistence unchanged. Finally, gamma correction changes nothing about the birth, death, or persistence. To use this interface, the user simply selects the button (i.e., the arrow or the circle) for the edit type they prefer. Finally, the level of the transfer function is selected using a slider.
Topology Preservation. It is important to note that many of these edits will ultimately modify the local topology (i.e., within a subtree) and/or global topology (i.e., entire contour tree) of the image. Contrast enhancement and denoising change the persistence of local topology, and they can change feature pairs in the global context. Brightness enhancement makes no modification of the local topology, but significant changes can occur in the global topology (e.g., creation of new features, changes in persistence, etc.). Finally, gamma correction can modify the persistence of local topology, but it will have no effect on the global topology. To handle these cases, as part of the normal process of image editing, the contour trees are recalculated after an edit is applied to the image.
We have implemented a prototypes of our approach using Java. Images were generated using a 2017 MacBook Pro. All aspects of our approach are interactive, except the construction of the contour trees and extraction of feature pair subtrees, which took between 5 and 30 seconds, depending upon the size and complexity of the image. Before considering the quality of an enhancement, context, such as how the image will be utilized, needs to be taken into account. We do not consider this context in our analysis, and instead only provide examples enhancements.
Synthetic Example. Our synthetic example, based upon the selection of the feature from Fig. 3(b), has the operations outlined in Fig. 4 applied: contrast enhancement (Fig. 4(g)), denoising (Fig. 4(h)), brightness enhancement (Fig. 4(i)), and gamma correction (Fig. 4(j)).
4.1 Grayscale Images
Since contour trees operate on a single channel, grayscale images are a natural way to demonstrate this functionality. For the following datasets, the brightness channel of the HSB colorspace was used for editing.
The Florala dataset, seen in Fig. 5(a), is a photograph of Florala Alabama, retrieved from . The photograph had a series of denoising, contrast enhancement, and gamma correction steps applied to recover the final image in Fig. 5(b). The persistence and persistence-volume diagrams are shown for comparison.
The Brain dataset, seen in Fig. 6(a), is a noisy and low contrast MRI scan of a brain, retrieved from . The figure shows a midpoint (Fig. 6(c)) and the final version (Fig. 6(d)) after a combination of 12 contrast, brightness, gamma correction, and denoising steps. The final image removes noise and highlights important features, such as the skull, white matter, and grey matter. The persistence and persistence-volume diagrams are shown for comparison.
The Lenna Grayscale Dataset, seen in Fig. 7 shows a series of 7 edits to a noisy version of the classic Lenna dataset.
4.2 Color Images
The Notre Dame dataset, retrieved from  and shown in Fig. 8(a), is a photo with an underexposed foreground. For this dataset, we first performed a (virtually invisible) brightness enhancement to the green color channel, to make the foliage a green hue (see Fig. 8(c)). Next, we performed a denoising and contrast enhancement to the saturation channel of the HSB colorspace (see Fig. 8(d)). Finally, denoising, gamma correction, and contrast enhancement were applied to the brightness channel of HSB. Persistence and persistence-volume diagram are not shown due to the number of diagrams involved (10 total—2 red, green, blue, saturation, and brightness). This is compared to a reference image (Fig. 8(b)) generated using a high-dynamic range technique (i.e., using significantly more data than our approach).
The Swan dataset, shown in Fig. 9(a) is a photograph of a swan with a mix of light and shadow, retrieved from . We perform a series of enhancements that include denoising of the brightness channel (see Fig. 9(c)); followed by brightness enhancement in the saturation channel (see Fig. 9(d)); and contrast enhancement and gamma correction of the brightness channel (see Fig. 9(e)). This is compared to a reference image (Fig. 9(b)) generated using a high-dynamic range technique.
The Lenna Color Dataset, seen in Fig. 10 shows a series of 11 edits to a noisy version of the classic color Lenna dataset.
5 Prior Work & Conclusions
We have presented a new approach to image enhancement based upon the topology of an image. Our approach provides a high-level of control to users, while not requiring an extensive number of interactions to achieve desirable results.
Like with most other image enhancement algorithms, artifacts are an important concern. Our approach does not introduce new artifacts, per se, but instead it may emphasize existing image artifacts. For example in Fig. 5, blocking artifacts appear due to lack of detail for generating a smooth result. In Fig. 6, artifacts occur due once again to missing contrast and detail that lead to small differences in intensity ending up emphasized.
Much of the prior work on image enhancement has focused on automated techniques. A number approaches have addressed segmentation. For example, algorithms for edge detection and image segmentation detected “contours” (i.e., edges) in a hierarchical manner for segmentation 
. Supervised learning, such as the hierarchical merge trees model in, are popular in image segmentation. Contrast enhancement has been proposed as an optimization problem that maximizes the average local contrast of an image 
. Recently, deep learning has been leveraged to automatically retouch images. These approaches provide high quality results, but they offer limited opportunity for tuning the output.
TDA has also been used previously in image processing. The first use of the contour tree on a binary image was . Edge detection and Delaunay triangulation were performed to decompose images into regions indexed by radius of a disk and persistence . Finally, persistence-based segmentation of noisy 2D point clouds have been studied . Our approach in this paper is different from these prior works in that it not only captures the structure of images, but it also enables a variety of methods for manipulating the segmented regions of images.
This project was supported in part by the National Science Foundation (IIS-1513616 and IIS-1845204).
-  Arbelaez, P., Maire, M., Fowlkes, C., Malik, J.: Contour detection and hierarchical image segmentation. IEEE Trans. Pattern Anal. Mach. Intell. 33(5), 898–916 (2011)
-  Aydogan, D.B., Hyttinen, J.: Binary image representation by contour trees. In: Medical Imaging 2012: Image Processing. vol. 8314, p. 83142X (2012)
-  Boyell, R.L., Ruston, H.: Hybrid techniques for real-time radar simulation. In: Proc. 1963 Fall Joint Comp. Conf. pp. 445–458 (1963)
-  Carr, H., Snoeyink, J., Axen, U.: Computing contour trees in all dimensions. Computational Geometry 24(2), 75–94 (2003)
-  Cohen-Steiner, D., Edelsbrunner, H., Harer, J.: Stability of persistence diagrams. Discrete and Computational Geometry 37(1), 103–120 (2007)
-  Edelsbrunner, H., Letscher, D., Zomorodian, A.J.: Topological persistence and simplification. Discrete and Computational Geometry 28, 511–533 (2002)
-  Fattal, R., Lischinski, D., Werman, M.: Gradient domain high dynamic range compression. ACM transactions on graphics (TOG) 21(3), 249–256 (2002)
-  Hu, Y., He, H., Xu, C., Wang, B., Lin, S.: Exposure: A white-box photo post-processing framework. ACM Transactions on Graphics (TOG) 37(2), 26 (2018)
-  Kervrann, C., Boulanger, J.: Patch-based image denoising. https://www.irisa.fr/vista/Themes/Demos/Debruitage/ImageDenoising.html (2019)
Kurlin, V.: A fast persistence-based segmentation of noisy 2d clouds with provable guarantees. Pattern Recognition Letters83, 3 – 12 (2016)
-  Letscher, D., Fritts, J.: Image segmentation using topological persistence. In: Kropatsch, W.G., Kampel, M., Hanbury, A. (eds.) Computer Analysis of Images and Patterns. pp. 587–595 (2007)
-  Liu, T., Seyedhosseini, M., Tasdizen, T.: Image segmentation using hierarchical merge tree. IEEE Transactions on Image Processing 25(10), 4596–4607 (2016)
-  Majumder, A., Irani, S.: Contrast enhancement of images using human contrast sensitivity. In: Applied Perception in Graphics and Visualization. pp. 69–76 (2006)
Robles, A., Hajij, M., Rosen, P.: The shape of an image - a study of mapper on images. In: International Conference on Computer Vision, Imaging and Computer Graphics Theory and Applications (VISIGRAPP). pp. 339–347 (2018)
-  Rosen, P., Tu, J., Piegl, L.A.: A hybrid solution to parallel calculation of augmented join trees of scalar fields in any dimension. Computer-Aided Design and Applications 15(4), 610–618 (2018)
-  Tu, J., Hajij, M., Rosen, P.: Propagate and pair: A single-pass approach to critical point pairing in reeb graphs. International Symposium on Visual Computing (2019)