Gnuastro: visualizing the full dynamic range in color images

Color plays a crucial role in the visualization, interpretation, and analysis of multi-wavelength astronomical images. However, generating color images that accurately represent the full dynamic range of astronomical sources is challenging. In response, Gnuastro v0.22 introduces the program 'astscript-color-faint-gray', which is extensively documented in the Gnuastro manual. It employs a non-linear transformation to assign an 8-bit RGB (Red-Green-Blue) value to brighter pixels, while the fainter ones are shown in an inverse grayscale. This approach enables the simultaneous visualization of low surface brightness features within the same image. This research note is reproducible with Maneage, on the Git commit 48f5408.


INTRODUCTION
In common language, an image is a visual representation of something.More technically, an image is an array of numerical values or pixels (picture elements).High pixel values mean more intensity or flux, while low pixel values imply lower brightness.
Astronomical images have a very wide range of pixel values.On the one hand, there are regions with very high signal-to-noise ratios (S/N>1000) which correspond to the brightest parts in the center of stars or galaxies.On the other hand, there are regions for which there is no significant signal from astronomical sources at all: the noisy background pixels.Intermediate cases are those regions with a per-pixel S/N smaller than three.These include the outer part of galaxies, stellar Corresponding author: Raúl Infante-Sainz infantesainz@gmail.comstreams, diffuse emission like Galactic cirrus, and other faint structures.Typically, the distribution of pixel values in an astronomical image is highly non-uniform.The majority of pixel values tend to be faint, while only a few stand out as exceptionally bright.Combined with the 8-bit (256 layers) nature of standard image formats (like JPEG or PNG; as opposed to 32-bit FITS images), visualization of astronomical images becomes a challenging task.
Astronomical images are usually captured using cameras equipped with filters.These filters allow specific wavelengths of light to pass through while blocking others, creating what is known as a "channel".A single-channel image does not inherently possess color information since the color is defined by multiple channels, typically the RGB channels (for Red, Green, and Blue).
Color images in common formats serve a more profound purpose than just producing beautiful pictures for outreach purposes.They contain valu-able physical information that can distinguish between astronomical sources.Variations in color result from differences in stellar populations, ages, distance, and more.Such color information can be automatically analyzed by specialized software and artificial intelligence algorithms.Consequently, addressing the challenges of creating high-quality color images is vital for extracting this valuable physical information.
Gnuastro's astscript-rgb--faint-gray is a new executable program to address this problem.It is introduced in Gnuastro v0.221 and addresses the complexities commented above by applying the stretching technique described by Lupton et al. (2004) for the brighter pixels, and using inverse-grayscale (where the brightest is black) for the noisy regions.This combination avoids the "saturation" of the extended/diffuse signal in a black background, making it particularly important in the context of very deep imaging and low surface brightness studies (see e.g., Infante-Sainz et al. 2020;Trujillo et al. 2021;Martínez-Delgado et al. 2023;Román et al. 2023).

CREATING COLOR IMAGES
This script takes three input images, typically representing the different RGB channels.Once the transformations are applied, the modified images are combined to construct the color image.The script offers various options to customize the resulting color image.Traditional black background images hide interesting details that are revealed by considering a gray background.Additionally, it is possible to provide a fourth image (commonly referred to as "K") that is used to represent the gray background pixels, resulting in a combination of R, G, B, and K channels.
It is important to note that the specific parameters used in the script may need adjustment based on the characteristics of the input images.There-fore, the generation of a customized color image might involve some trial and error to achieve the desired result.For comprehensive details on how to use astscript-color-faint-gray, we refer to the Gnuastro manual2 .In particular, there is a step-by-step tutorial on how to use this program with real examples directly executable on the command-line that is always up-to-date with the latest version of the software.
In Figure 1, we present color images of the M51 galaxy group using J-PLUS (Cenarro et al. 2019) data.Each image is obtained using different options.Notably, the default gray background reveals intriguing low surface brightness features that are veiled, or saturated, in the traditional color image (that have a black background).The different regions of the bottom-left panel correspond to a different surface brightness in the rS-DSS channel: colored regions are those brighter than 23 mag arcsec −2 , black regions are those regions between 23 and 25 mag arcsec −2 , while gray regions are those fainter than 25 mag arcsec −2 .
The use of the Hα narrow band filter (J0660) in the bottom-right panel allows for the visualization of interesting features such as the star-forming regions.This shows how color images are not only useful for aesthetic/outreach images of astronomical sources but also to visualize quantitative measurements.

Figure 1 .
Figure 1.M51 galaxy group color images from J-PLUS DR3 using the iSDSS, rSDSS, gSDSS (R-G-B), and J0660 (Hα) filters.Top-left: traditional color image, where the background regions become black.Top-right: modified weights of the channels balance to obtain a bluer image.Bottom-left: gray background color image; this is the default mode of astscript-color-faint-gray.The separation between color, black, and gray regions are defined from surface brightness cuts (see text) of the G channel (rSDSS).The use of the gray background colormap reveals diffuse low surface brightness structures that would otherwise remain unveiled.Bottom-right: color image using the Hα narrow band filter (J0660) for the intermediate (G) channel instead of rSDSS.The use of this filter reveals interesting features such as the star-forming regions that are shown in green.