How are images saved in different color spaces?

I am learning about color spaces, but I am wondering about how computers save color values of each pixel.

I know that if an image is in the RGB color space, the computer will save the Red, Green, Blue values of each pixel.

But if an image is in the HSL color space, will the computer save the Hue, Saturation, Intensity value of each pixel or will it still save RGB values of each one?

And how does the computer know what color space an image is in?

• The computer saves numbers . It stores whatever you feed it. That's all. Jul 7, 2016 at 11:35

RGB is not a color space, it is a color mode or color model. The same for HSB, HSL CMYK, Lab, Grayscale.

But if an image is in HSL color space, is computer will save Hue, Saturation, Intensity

Yeap

And how computer know what color space an image is?

Because you tell it what you need to tell it.

On the beginning of each photo file, or any file for that matter, there is a set of instructions on what is the content of the file and how to interpret it.

A color space

Is what colors of the perceptible human vision can be stored, and reproduced by a device.

In that respect Lab is a color space, as well as a color mode.

https://en.wikipedia.org/wiki/Color_space

A basic explanation on what is the difference

Between color mode, color model, and color space.

Color mode is the way you store color information. For example RGB stores Red, Green, Blue info.

Color model is the theoretical base of that, is which 3D coordinate system you will use. A RGB model uses rectangular coordinates, like a cube.

A HSB and HSL model uses polar coordinates. Hue is not a range between 0-255 but a 0 to 360 value (a circle), the 3D shape is more like a conical one and two inverted cones for the second (also can be interpreted as a cylinder, but I personally do not like the cylinder shape).

Color space is how to interpret the previous values.

My typical example: grab a water based happy marker, a cyan one.

If you use it on a newspaper the color reproduced will be dark, but on a coated glossy paper will be a light cyan.

The Cyan value is the same: Just full ink on a stroke, but the color space of the combination is totally different. One can only reproduce dark colors, the other one has a wider range of reproducible colors.

And a fourth concept a color profile is a small set of instructions on how to convert-reproduce-display-correct thoose kind of diferences depending on the medium.