I am using FITS images, and noticed negative values in value matrix. What they mean? For example, for one of the images, the minimum value is -0.34472656 and the maximum = 552.0. The data type(format) is float32. I know float data values should be in a range of [0.0, 1.0]. How can I convert them to [0.0, 1.0]?

  • 2
    $\begingroup$ You need to provide more information on how the image was obtained, what it is of and what processing has been applied. Floating point numbers can be negative. Raw CCD data are integers. $\endgroup$
    – ProfRob
    Mar 6, 2023 at 7:15
  • $\begingroup$ I just opened fits file with Python Astropy lib. Image is in grayscale. I got the primary hdu's data... I noticed that more dark pixels is close to *minimum value*=-0.34472656and and more bright(white) piels` to the maximum=552.0. But why the -0.3 can be 'black'? $\endgroup$
    – TatevAram
    Mar 6, 2023 at 15:26

1 Answer 1


Raw data from detectors is usually some sort of integer type, giving the number of "counts" detected during an integration period. So the values could be [0,65535] for 16-bit data, or [0,4294967295] for 32-bit data. But you are probably working with processed data rather than raw data.

Processed astronomical data can have all sorts of corrections applied, but the most basic are dark subtraction (for read noise), sky subtraction (for sky/observatory background), and flat-fielding (for detector spatial variation).

Negative values in FITS images often happen due to the subtraction steps. For example, correction for sky background and readout noise should produce data evenly distributed about zero. This means that an image of a completely dark scene will have an average value of zero, even though most of the values are not equal to zero.

The flat-fielding step involved division by a number close to 1, so the processed data are going to have to be float type, not integer type.

Also note that while image display programs such as matplotlib often only display floats in the range [0, 1), the values in a FITS image usually depend on the units of the image (DN, photons, radiance, etc).

  • 1
    $\begingroup$ So if I want to wind most darker(black) pixels in grayscale fits, I need to search within the values which have values close to 0 and negative??? $\endgroup$
    – TatevAram
    Mar 6, 2023 at 15:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .