In the previous sections we aligned three SDSS images of M51 group Color channels in same pixel grid, and created a linearly-scaled color image (only using astconvertt
program) in Color image using linear transformation.
But we saw that showing the brighter and fainter parts of the galaxy in a single image is impossible in the linear scale!
In this section, we will use Gnuastro’s astscript-color-faint-gray
installed script to address this problem and create images which visualize a major fraction of the contents of our astronomical data.
This script aims to solve the problems mentioned in the previous section. See Infante-Sainz et al. 2024, which first introduced this script, for examples of the final images we will be producing in this tutorial. This script uses a non-linear transformation to modify the bright input values before combining them to produce the color image. Furthermore, for the faint regions of the image, it will use grayscale and avoid color over all (as we saw, colored noised is not too nice to look at!). The faint regions are also inverted: so the brightest pixel in the faint (black-and-white or grayscale) region is black and the faintest pixels will be white. Black therefore creates a smooth transition from the colored bright pixels: the faintest colored pixel is also black. Since the background is white and the diffuse parts are black, the final product will also show nice in print or show on a projector (the background is not black, but white!).
The SDSS image we used in the previous sections doesn’t show the full glory of the M51 group! Therefore, in this section, we will use the wider images from the J-PLUS survey. Fortunately J-PLUS includes the SDSS filters, so we can use the same iSDSS, rSDSSS, and gSDSS filters of J-PLUS. As a consequence, similar to the previous section, the R, G, and B channels are respectively mapped to the iSDSS, rSDSS and gSDSS filters of J-PLUS.
The J-PLUS identification numbers for the images containing the M51 galaxy group are in these three filters are respectively: 92797, 92801, 92803.
The J-PLUS images are already sky subtracted and aligned into the same pixel grid (so we will not need the astwarp
and astnoisechisel
steps before).
However, zero point magnitudes of the J-PLUS images are different: 23.43, 23.74, 23.74.
Also, the field of view of the J-PLUS Camera is very large and we only need a small region to see the M51 galaxy group.
Therefore, we will crop the regions around the M51 group with a width of 0.35 degree wide (or 21 arcmin) and put the crops in the same aligned/ directory we made before (which contains the inputs to the colored images).
With all the above information, let’s download, crop, and have a look at the images to check that everything is fine.
Finally, let’s run astscript-color-faint-gray
on the three cropped images.
## Download $ url=https://archive.cefca.es/catalogues/vo/siap/jplus-dr3/get_fits?id= $ wget "$url"92797 -Oin/i-jplus.fits.fz $ wget "$url"92801 -Oin/r-jplus.fits.fz $ wget "$url"92803 -Oin/g-jplus.fits.fz ## Crop $ widthdeg=0.35 $ ra=202.4741207 $ dec=47.2171879 $ for f in i r g; do \ astcrop in/$f-jplus.fits.fz --center=$ra,$dec \ --width=$widthdeg --output=aligned/$f-jplus.fits; \ done ## Visual inspection of the images used for the color image $ astscript-fits-view aligned/*-jplus.fits ## Create colored image. $ R=aligned/i-jplus.fits $ G=aligned/r-jplus.fits $ B=aligned/g-jplus.fits $ astscript-color-faint-gray $R $G $B -g1 --output=m51.pdf
After opening the PDF, you will notice that it is a color image with a gray background, making the M51 group and background galaxies visible together. However, the images does not look nice and there is significant room for improvement! You will notice that at the end of its operation, the script printed some numerical values for four options in a table, to show automatically estimated parameter values. To enhance the output, let’s go through and explain these step by step.
The first important point to take into account is the photometric calibration. If the images are photometrically calibrated, then it is necessary to use the calibration to put the images in the same physical units and create “real” colors. The script is able to do it through the zero point magnitudes with the option --zeropoint (or -z). With this option, the images are internally transformed to have the same pixel units and then create the color image. Since the magnitude zero points are 23.43, 23.74, 23.74 for the i, r, and g images, let’s use them in the definition
$ astscript-color-faint-gray $R $G $B -g1 --output=m51.pdf \ -z23.43 -z23.74 -z23.74
Open the image and have a look. This image does not differ too much from the one generated by default (not using the zero point magnitudes). This is because the zero point values used here are similar for the three images. But in other datasets the calibration could make a big difference!
Let’s consider another vital parameter: the minimum value to be displayed (--minimum or -m). Pixel values below this number will not be shown on the color image. In general, if the sky background has been subtracted (see Color image using linear transformation), you can use the same value (0) for all three. However, it is possible to consider different minimum values for the inputs (in this case use as many -m as input images). In this particular case, a minimum value of zero for all images is suitable. To keep the command simple, we’ll add the zero point, minimum and HDU of each image in the variable that also had its filename.
$ R="aligned/i-jplus.fits -h1 --zeropoint=23.43 --minimum=0.0" $ G="aligned/r-jplus.fits -h1 --zeropoint=23.74 --minimum=0.0" $ B="aligned/g-jplus.fits -h1 --zeropoint=23.74 --minimum=0.0" $ astscript-color-faint-gray $R $G $B --output=m51.pdf
In contrast to the previous image, the new PDF (with a minimum value of zero) exhibits a better background visualization because it is avoiding negative pixels to be included in the scaling (they are white).
Now let’s review briefly how the script modifies the pixel value distribution in order to show the entire dynamical range in an appropriate way. The script combines the three images into a single one by using a the mean operator, as a consequence, the combined image is the average of the three R, G, and B images. This averaged image is used for performing the asinh transformation of Lupton et al. 2004 that is controlled by two parameters: --qbright (\(q\)) and --stretch (\(s\)).
The asinh transformation consists in transforming the combined image (\(I\)) according to the expression: \(f(I) = asinh(q\times{}s\times{}I)/q\). When \(q\rightarrow0\), the expression becomes linear with a slope of the “stretch” (\(s\)) parameter: \(f(I) = s\times{}I\). In practice, we can use this characteristic to first set a low value for --qbright and see the brighter parts in color, while changing the parameter --stretch to show linearly the fainter regions (outskirts of the galaxies for example. The image obtained previously was computed by the default parameters (--qthresh=1.0 and --stretch=1.0). So, let’s set a lower value for --qbright and check the result.
$ astscript-color-faint-gray $R $G $B --output=m51-qlow.pdf \ --qbright=0.01
Comparing m51.pdf and m51-qlow.pdf, you will see that a large area of the previously colored colored pixels have become black. Only the very brightest pixels (core of the galaxies and stars) are shown in color. Now, let’s bring out the fainter regions around the brightest pixels linearly by increasing --stretch. This allows you to reveal fainter regions, such as outer parts of galaxies, spiral arms, stellar streams, and similar structures. Please, try different values to see the effect of changing this parameter. Here, we will use the value of --stretch=100.
$ astscript-color-faint-gray $R $G $B --output=m51-qlow-shigh.pdf \ --qbright=0.01 --stretch=100
Do you see how the spiral arms and the outskirts of the galaxies have become visible as --stretch is increased? After some trials, you will have the necessary feeling to see how it works. Please, play with these two parameters until you obtain the desired results. Depending on the absolute pixel values of the input images and the photometric calibration, these two parameters will be different. So, when using this script on your own data, take your time to study and analyze which parameters are good for showing the entire dynamical range. For this tutorial, we will keep it simple and use the previous parameters. Let’s define a new variable to keep the parameters already discussed so we have short command-line examples.
$ params="--qbright=0.01 --stretch=100" $ astscript-color-faint-gray $R $G $B $params --output=m51.pdf $ rm m51-qlow.pdf m51-qlow-shigh.pdf
Having a separate color-map for the fainter parts is generally a good thing, but for some reason you may not want it! To disable this feature, you can use the --coloronly option:
$ astscript-color-faint-gray $R $G $B $params --coloronly \ --output=m51-coloronly.pdf
Open the image and note that now the coloring has gone all the way into the noise (producing a black background). In contrast with the gray background images before, the fainter/smaller stars/galaxies and the low surface brightness features are not visible anymore! These regions show the interaction of two galaxies; as well as all the other background galaxies and foreground stars. These structures were entirely hidden in the “only-color” images. Consequently, the gray background color scheme is particularly useful for visualizing the most features of your data and you will rarely need to use the --coloronly option. We will therefore not use this option anymore in this tutorial; and let’s clean the temporary file made before:
$ rm m51-coloronly.pdf
Now that we have the basic parameters are set, let’s consider other parameters that allow to fine tune the three ranges of values: color for the brightest pixel values, black for intermediate pixel values, and gray for the faintest pixel values:
Looking at the last lines that the script prints, we see that the default value estimated for --colorval and --grayval are roughly 1.4. What do they mean? To answer this question it is necessary to have a look at the image that is used to separate those different regions. By default, this image is computed internally by the script and removed at the end. To have a look at it, you need to use the option --keeptmp to keep the temporary files. Let’s put the temporary files into the tmp directory with the option --tmpdir=tmp --keeptmp. The first will use the name tmp for the temporary directory and with the second, we ask the script to not delete (keep) it after all operations are done.
$ astscript-color-faint-gray $R $G $B $params --output=m51.pdf \ --tmpdir=tmp --keeptmp
The image that defines the thresholds is ./tmp/colorgray_threshold.fits. By default, this image is the asinh-transformed image with the pixel values between 0 (faint) and 100 (bright). If you obtain the statistics of this image, you will see that the median value is exactly the value that the script is giving as the --colorval.
$ aststatistics ./tmp/colorgray_threshold.fits
In other words, all pixels between 100 and this value (1.4) on the threshold image will be shown in color. To see its effect, let’s increase this parameter to --colorval=25. By doing this, we expect that only bright pixels (those between 100 and 25 in the threshold image) will be in color.
$ astscript-color-faint-gray $R $G $B $params --colorval=25 \ --output=m51-colorval.pdf
Open m51-colorval.pdf and check that it is true! Only the central part of the objects (very bright pixels, those between 100 and 25 on the threshold image) are shown in color. Fainter pixels (below 25 on the threshold image) are shown in black and gray. However, in many situations it is good to be able to show the outskirts of galaxies and low surface brightness features in pure black, while showing the background in gray. To do that, we can use another threshold that separates the black and gray pixels: --grayval.
Similar to --colorval, the --grayval option defines the separation between the pure black and the gray pixels from the threshold image. For example, by setting --grayval=5, those pixels below 5 in the threshold image will be shown in gray, brighter pixels will be shown in black until the value 25. Pixels brighter than 25 are shown in color.
$ astscript-color-faint-gray $R $G $B $params --output=m51-check.pdf \ --colorval=25 --grayval=5
Open the image and check that the regions shown in color are smaller (as before), and that now there is a region around those color pixels that are in pure black. After the black pixels toward the fainter ones, they are shown in gray. As explained above, in the gray region, the brightest are black and the faintest are white. It is recommended to experiment with different values around the estimated one to have a feeling on how it changes the image. To have even better idea of those regions, please run the following example to keep temporary files and check the labeled image it has produced:
$ astscript-color-faint-gray $R $G $B $params --output=m51-check.pdf \ --colorval=25 --grayval=5 \ --tmpdir=tmp --keeptmp $ astscript-fits-view tmp/total_mask-2color-1black-0gray.fits
In this segmentation image, pixels equal to 2 will be shown in color, pixels equal to 1 will be shown as pure black, and pixels equal to zero are shown in gray. By default, the script sets the same value for both thresholds. That means that there is not many pure black pixels. By adjusting the --colorval and --grayval parameters, you can obtain an optimal result to show the bright and faint parts of your data within one printable image. The values used here are somewhat extreme to illustrate the logic of the procedure, but we encourage you to experiment with values close to the estimated by default in order to have a smooth transition between the three regions (color, black, and gray). The script can provide additional information about the pixel value distributions used to estimate the parameters by using the --checkparams option.
To conclude this section of the tutorial, let’s clean up the temporary test files:
$ rm m51-check.pdf m51-colorval.pdf
JavaScript license information
GNU Astronomy Utilities 0.23 manual, July 2024.