I have looked at the documentation but I didn't find what I was looking for. All the explanations I could find on the web states that this is used to improve contrasts in images.
Look at this code for example(that is made to run on an astronomical FITS Image):
from astropy.visualization import ZScaleInterval
z = ZScaleInterval()
z1,z2 = z.get_limits(image_data)
plt.figure()
plt.imshow(image_data, vmin=z1, vmax=z2)
According to the documentation, get_limits
returns the minimum and maximum value in the interval based on the values provided. I'm guessing it means the maximum and minimum intensities. What do vmax
and vmin
do?
ZScaleInterval()
:
AstroPy's ZScaleInterval()
is actually an implementation of IRAF's ZScale Algorithm. According to the IRAF's documentation, the algorithm was designed to display the image values near the median image value without the time-consuming process of computing a full image histogram. This was very useful in the earlier days when computing power was still an issue for very big .fits
files.
AstroPy implemented the interval to give the ability to compare their plots with plots generated using IRAF. Also, it's just a very brilliant algorithm and gives you the almost right vmin
and vmax
value required for your specific task.
What do vmin
and vmax
does:
Your image_data
is basically a 2D array with each element representing some value, let's say brightness. When you plot image_data
using plt.imshow()
, you basically plot these brightness values stored at a specific point in that 2D array. plt.hist(image_data.ravel())
will give you a histogram of the flattened image array, which will show mainly two peaks (assuming there is a single galaxy in the image), one for the sky background and one for the galaxy itself.
To clearly see faint objects in your image, you improve contrast by setting vmin
and vmax
to the sides of the intensity peak of the galaxy.
Now, generating this histogram for big images can be very computationally expensive, and that's where ZScaleInterval()
interval comes in handy.
You can find more details here: https://js9.si.edu/js9/plugins/help/scalecontrols.html