What is True Color Mode. Graphic encoding

3 Bitmap coding pixel sampling! The drawing is distorted! A pixel is the smallest element in a picture for which you can set your own color. A bitmap is an image that is encoded as many pixels.

4 Raster coding 0 0 0 1 1 0 0 1 0 1 1 1 0 0 0 1 1 A 26 42 FF 0 0 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 42 5 A 5 A 7 E 1 A 2642 FF 425 A 5 A 7 E 16

6 Resolution is the number of pixels per inch of image size. ppi \u003d pixels per inch, pixels per inch 1 inch \u003d 2, 54 cm 300 ppi 96 ppi print screen 48 ppi 24 ppi

7 Resolution Problem 1. What size in pixels should an encoded image with a resolution of 300 ppi have in order to make a 10 × 15 cm print from it? height 10 cm × 300 pixels 1181 pixels 2, 54 cm 15 cm × 300 pixels 1771 pixels width 2, 54 cm

8 Resolution Task 2. The encoded image has dimensions of 5760 × 3840 pixels and a resolution of 600 ppi. What size will the printed image be? width 5760 pixels × 2, 54 cm 24.4 cm 600 pixels height 3840 pixels × 2, 54 cm 16.3 cm 600 pixels

9 Young-Helmholtz color theory sensitivity three types of "cones" 0 400 500 600 700, nm! Light of any wavelength can be replaced with red, green and blue rays!

10 RGB color model D. Maxwell, 1860 color \u003d (R, G, B) green red blue red green blue 0.. 255 (0, 0, 0) (255, 255) (255, 0, 0) (255, 150) (0, 255, 0) (0, 255) (0, 0, 255) (100, 0, 0 )? How many different colors can you code? 256 · 256 \u003d 16,777,216 (True Color)! RGB is a color model for devices that emit light (monitors)!

11 RGB color model (255, 0) #FFFF 00 RGB Web page (0, 0, 0) # 000000 (255, 255) #FFFFFF (255, 0, 0) #FF 0000 (0, 255, 0) # 00 FF 00 (0, 0, 255) # 0000 FF (255, 0) #FFFF 00 (204, 204) #CCCCCC

12 Problems Plot hex codes: RGB (100, 200) RGB (30, 50, 200) RGB (60, 180, 20) RGB (220, 150, 30)

13 Color depth is the number of bits used to encode the color of a pixel. ? How much memory do you need to store 1 pixel in True Color? R (0.. 255) 256 \u003d 28 options 8 bits \u003d 1 byte R G B: 24 bits \u003d 3 bytes True Color Problem. Determine the size of the file that encodes a 20x30 pixel bitmap in True Color? 20 3 bytes \u003d 1800 bytes

14 Encoding with a palette? How to reduce file size? decrease resolution decrease color depth decreases quality A color palette is a table in which a numerical code is assigned to each color specified as components in the RGB model.

15 Coding with palette 00 11 11 11 11 00 01 01 01 01 00 10 10 10 10 Palette: 0 0 0 color 002 0 0 255 0 0 color 012 color 102? What is the color depth? ? How long does a palette take? 255 255 color 112 2 bits per pixel 3 4 \u003d 12 bytes

16 Encoding with a palette Step 1. Select the number of colors: 2, 4,… 256. Step 2. Select 256 colors from the palette: 248 0 88 0 221 21 181 192 0 21 0 97 Step 3. Make a palette (each color has a number 0 .. 255) the palette is stored at the beginning of the file 0 248 0 88 1 0 221 21 254 181 192 0… 255 21 0 97 Step 4. Pixel code \u003d number of its color in the palette 2 45 65 14… 12 23

17 Palette encoding Palette file: palette pixel codes Number of colors Palette size (bytes) Color depth (bits per pixel) 2 4 16 256 6 12 48 768 1 2 4 8

18 Tasks Task 1. In the process of converting a raster graphic file, the number of colors decreased from 512 to 8. How many times has the information volume of the file decreased? Task 2. The screen resolution of the monitor is 1024 x 768 pixels, the color depth is 16 bit. How much video memory is required for this graphics mode? Problem 3. How many bytes will the code for a 40 × 50 pixel image take in true color mode? when encoding with a 256 color palette? Task 4. 4 kilobytes of memory were allocated to store a bitmap image with a size of 128 x 128 pixels. What is the maximum possible number of colors in the image palette?

19 Bitmaps: File Formats BMP Format JPG True Color GIF Palette PNG Transparency Animation

20 Printing color coding (CMYK) RRGBGB White - red \u003d cyan C \u003d Cyan White - green \u003d magenta M \u003d Magenta White - blue \u003d yellow Y \u003d Yellow CMY 0 0 0 255 255 255 CMYK model: + Key color § less ink consumption and the best quality for black and gray

21 RGB and CMYK human sees RGB CMYK not all colors displayed by the monitor (RGB), you can print (CMYK) when converting the color code from RGB to CMYK, the color is distorted RGB (0, 255, 0) CMYK (65, 0, 100, 0) RGB (104, 175, 35)

22 Color model HSB (HSV) HSB \u003d Hue Saturation Brightness or Value 0/360 270 0 Hue (H) Saturation 100 Brightness (B) 90 100 Brightness (S) 0 180 saturation - add white brightness - add black

23 Lab Color Model International Standard for Device Independent Color Coding (1976) Based on the human color model. Lab \u003d Lightness a, b (sets the color tone) for translation between color models: RGB Lab CMYK Lightness 25% Lightness 75% for color correction of photos

24 Device Profiles? What color will we see? RGB (255, 0, 0) as 680 nm RGB (255, 0, 0) 680 nm monitor profile RGB (225, 10, 20) scanner profile CMYK (0, 100, 0) printer profile

25 Raster coding: results a universal method (you can encode any image) the only method for encoding and processing blurry images that do not have clear boundaries (photographs) is the loss of information (why?) When resizing, the color and shape of objects in the figure is distorted file size does not depend on the complexity of the drawing (and what does it depend on?)

26 Vector coding Drawings from geometric shapes: lines, polylines, rectangles, circles, ellipses, arcs, smooth lines (Bezier curves) For each shape, the following are stored in memory: dimensions and coordinates in the drawing; color and style of the border; color and fill style (for closed shapes)

27 Vector coding Bézier curves: A C B corner knot smooth knot E D The coordinates of the nodes and ends of the "arms" are stored (3 points for each node, curves of the 3rd order).

28 Vector coding (summary) the best way to store drawings, diagrams, maps during coding there is no loss of information when resizing there is no distortion bitmap drawing vector drawing is smaller file size, depends on the complexity of the drawing ineffectively used for photos and blurry images

29 Vector Encoding: WMF File Formats (Windows Metafile) EMF (Windows Metafile) CDR (Corel. Draw Program) AI (Adobe Illustrator Program) for Web Pages SVG (Scalable Vector Graphics)

Width: \u003d "" auto \u003d ""\u003e

31 Practical task Slide 12 to complete in a notebook In the Paint program will follow the pattern. work:

33 Digitizing audio analog signal Digitizing is the conversion of an analog signal into a digital code (sampling). - sampling interval (s) - sampling frequency (Hz, kHz) T A person hears 16 Hz ... 20 kHz t 8 kHz - the minimum frequency for speech recognition 11 kHz Hz, 22 kHz Hz, 44, 1 Hz - CD quality 48 kHz - DVD movies 96 kHz, 192 kHz

34 Digitizing Sound: Quantizing? How many bits does it take to write the number 0, 6? Quantization (level sampling) is the representation of a number as a finite-length digital code. ADC \u003d Analog-to-Digital Converter 3-bit coding: 8 bits \u003d 256 levels 16 bits \u003d 65536 levels 24 bits \u003d 224 levels 7 6 5 4 3 2 1 0 The coding width is the number of bits used to store one sample. T t

35 Digitizing sound Problem. Determine the informational volume of data obtained by digitizing sound of 1 minute duration at 44 kHz using a 16-bit sound card. The recording was done in stereo. For 1 second, each channel records 44000 values, each takes 16 bits \u003d 2 bytes in total 44000 2 bytes \u003d 88000 bytes Taking into account "stereo", total 88000 2 \u003d 176000 bytes For 1 minute 176000 60 \u003d 1056000 bytes 10313 KB 10 MB

36 Digitizing sound How to recover a signal? DAC \u003d Digital-to-Analogue Converter after without was before smoothing digitizing smoothing T analog devices! t? Which one to improve the quality? ? What will get worse? reduce T file size

37 Digitization - as a result, you can encode any sound (including voice, whistle, rustle, ...) there is a loss of information a large amount of files? What properties of the digitized sound determine the sound quality? File formats: WAV (Waveform audio format), often uncompressed (size!) MP 3 (MPEG-1 Audio Layer 3, human compressed) AAC (Advanced Audio Coding, 48 channels, compression) WMA (Windows Media Audio, streaming audio, compression) OGG (Ogg Vorbis, open format, compression)

38 Instrument encoding MIDI (Musical Instrument Digital Interface). in file. mid: 128 melodic notes (pitch, duration) and 47 percussion musical instrument sound parameters (volume, timbre) program for up to 1024 sound card channels! in the sound card memory: sound samples (wave tables) MIDI keyboard: § no loss of information when encoding instrumental music § small file size impossible to encode non-standard sound, voice

39 Tracker music In a file (module): sound samples (samples) musical notation, track (track) - track musical instrument up to 32 channels File formats: MOD developed for computers Amiga S 3 M digitized channels + synthesized sound, 99 instruments XM, STM , ... Usage: demoscene (file size is important)

40 Video encoding! Video \u003d images + sound Synchronization! image: ≥ 25 frames per second PAL: 768 × 576, 24 bits per second: 768 × 576 × 3 bytes ≈ 32 MB in 1 minute: 60 × 32 MB ≈ 1.85 GB HDTV: 1280 × 720, 1920 × 1080 . original frame + changes (10 -15 s) compression (codecs - compression algorithms) Div. X, Xvid, H. 264, WMV, Ogg Theora ... sound: 48 kHz, 16 bit compression (codecs - compression algorithms) MP 3, AAC, WMA, ...

41 Video file formats AVI - Audio Video Interleave - interleaved audio and video; container - different codecs can be used MPEG - Motion Picture Expert Group WMV - Windows Media Video, Microsoft MP 4 - MPEG-4, compressed video and sound MOV - Quick Time Movie, Apple Web format. M - open format, supported by browsers

42 Sources of illustrations 1. 2. 3. 4. 5. 6. 7. 8. http: // ru. wikipedia. org / http: // www. cyberphysics. co. uk http: // epson. su http: // www 8.hp. com http: // head-fi. org http: // ru. wikipedia. org / http: // ru. wikipedia. org copyrighted materials

Rasters, pixels, sampling, resolution

Like all types of information, images in a computer are encoded as binary sequences. They use two fundamentally different coding methods, each of which has its own advantages and disadvantages.

Both the line and the area are made up of an infinite number of points. We need to encode the color of each of these points. If there are infinitely many of them, we immediately come to the conclusion that this requires an infinite amount of memory. Therefore, the image cannot be encoded using the "pointwise" method. However, this idea can still be used.

Let's start with a black and white drawing. Let's imagine that a grid is superimposed on the image of a rhombus, which breaks it into squares. This mesh is called a raster. Now for each square we define a color (black or white). For those squares in which a part turned out to be painted over with black and a part with white, we will choose a color depending on which part (black or white) is larger.

Picture 1.

We have got a so-called raster image, consisting of squares-pixels.

Definition 1

Pixel (English pixel \u003d picture element, picture element) is the smallest picture element for which you can set your own color. Having broken the "usual" drawing into squares, we performed its discretization - we split a single object into separate elements. Indeed, we had a single and indivisible drawing - the image of a rhombus. As a result, we got a discrete object - a set of pixels.

The binary code for a black-and-white image obtained as a result of sampling can be constructed as follows:

  • replace white pixels with zeros and black ones with ones;
  • we write out the lines of the resulting table one by one.

Example 1

Let's show this with a simple example:

Figure 2.

The width of this figure is $ 8 $ pixels, so each row of the table consists of $ 8 $ binary digits - bits. In order not to write a very long string of zeros and ones, it is convenient to use the hexadecimal number system, encoding $ 4 $ of the adjacent bits (tetrad) with one hexadecimal digit.

Figure 3.

For example, for the first line we get the code $ 1A_ (16) $:

and for the whole picture: $ 1A2642FF425A5A7E_ (16) $.

Remark 1

It is very important to understand what we gained and what we lost as a result of sampling. Most importantly, we were able to encode the drawing in binary. However, this distorted the drawing - instead of a rhombus, we got a set of squares. The reason for the distortion is that in some squares, parts of the original image were filled with different colors, and in the encoded image, each pixel necessarily has the same color. Thus, some of the original information was lost during encoding. This will manifest itself, for example, when the picture is enlarged - the squares increase, and the picture is distorted even more. To reduce the loss of information, you need to reduce the pixel size, that is, increase the resolution.

Definition 2

Resolution Is the number of pixels per inch of image size.

Resolution is usually measured in pixels per inch (using the English notation $ ppi $ \u003d pixels per inch). For example, a $ 254 $ ppi $ resolution means there are $ 254 $ pixels per inch ($ 25.4 mm), so each pixel “contains” a $ 0.1 x $ 0.1 mm square of the original image. The higher the resolution, the more accurately the picture is encoded (less information is lost), but the file size also grows at the same time.

Color coding

What if the drawing is colored? In this case, one bit is no longer enough to encode the pixel color. For example, in the image of the Russian $ 4 $ flag shown in the picture, the colors are black, blue, red and white. It takes $ 2 $ bits to encode one of the four options, so each color code (and each pixel code) will be two bits. Let $ 00 $ denote black, $ 01 $ red, $ 10 $ blue, and $ 11 $ white. Then we get the following table:

Figure 4.

The only problem is that when displaying on the screen, you need to somehow determine which color corresponds to one or another code. That is, color information needs to be expressed as a number (or a set of numbers).

A person perceives light as a multitude of electromagnetic waves. A certain wavelength corresponds to a certain color. For example, $ 500-565 nm wavelength is green. The so-called "white" light is actually a mixture of wavelengths that cover the entire visible range.

According to the modern concept of color vision (Jung-Helmholtz theory), the human eye contains three types of sensitive elements. Each of them perceives the entire flow of light, but the former are most sensitive in the red region, the second in the green region, and the third in the blue region. Color is the result of the excitation of all three types of receptors. Therefore, it is believed that any color (that is, the sensations of a person who perceives waves of a certain length) can be imitated using only three light beams (red, green and blue) of different brightness. Consequently, any color is approximately decomposed into three components - red, green and blue. By changing the strength of these components, you can create any colors. This color model is named RGB after the initial letters of the English words red, green and blue.

In the RBG model, the brightness of each component (or, as they say, each channel) is most often encoded with an integer from $ 0 $ to $ 255 $. In this case, the color code is a triple of numbers (R, G, B), the brightness of individual channels. The color ($ 0.0.0) is black and ($ 255,255,255) is white. If all components are of equal brightness, the result is shades of gray, from black to white.

Figure 5.

To make a light red (pink) color, you need to equally increase the brightness of the green and blue channels in red ($ 255.0.0), for example, the color ($ 255, $ 150, $ 150) is pink. Decreasing the brightness of all channels evenly makes a dark color, for example, a color with a code ($ 100.0.0) - a dark red.

There are a total of $ 256 in brightness options for each of the three colors. This allows you to encode $ 256 ^ 3 \u003d 16,777,216 $ shades, which is more than enough for a human. Since $ 256 \u003d 2 ^ 8 $, each of the three components occupies $ 8 $ bits or $ 1 $ bytes in memory, and all information about a color is $ 24 $ bits (or $ 3 $ bytes). This value is called the color depth.

Definition 3

Color depth Is the number of bits used to encode the color of a pixel.

$ 24 $ -bit color coding is often referred to as True Color. To calculate the size of the picture in bytes with this encoding, you need to determine the total number of pixels (multiply the width and height) and multiply the result by $ 3 $, since the color of each pixel is encoded in three bytes. For example, a drawing of $ 20x30 $ pixels encoded in true color would take up $ 20x30x3 \u003d $ 1800 bytes.

In addition to the true color mode, $ 16 $ -bit coding is also used (English High Color - "high" color), when $ 5 $ bits are allocated to the red and blue components, and $ 6 $ bits to the green, to which the human eye is more sensitive. In High Color mode, you can encode $ 2 ^ (16) \u003d 65,536 $ different colors. On mobile phones, $ 12-bit color coding ($ 4 $ bits per channel, $ 4096 colors).

Palette encoding

Generally, the fewer colors are used, the more the color image will be distorted. Thus, when coding color, there is also an inevitable loss of information, which is "added" to the loss caused by sampling. Very often (for example, in diagrams, diagrams and drawings) the number of colors in an image is small (no more than $ 256). In this case, palette coding is used.

Definition 4

Color palette Is a table in which a numerical code is assigned to each color specified as components in the RGB model.

Palette encoding is done as follows:

  • choose the number of colors $ N $ (as a rule, no more than $ 256 $);
  • from the true color palette ($ 16,777,216 $ colors) select any $ N $ colors and for each of them find the components in the RGB model;
  • each color is assigned a number (code) from $ 0 $ to $ N – 1 $;
  • compose a palette, first writing down the RGB components of the color code $ 0 $, then the components of the color code $ 1 $, etc.

The color of each pixel is encoded not as RGB values, but as a color number in the palette. For example, when encoding the image of the Russian flag (see above), $ 4 $ colors were chosen:

  • black: RGB code ($ 0.0.0); binary code $ 002 $;
  • red: RGB code ($ 255.0.0); binary code $ 012 $;
  • blue: RGB code ($ 0.0,255); binary code $ 102 $;
  • white: RGB code ($ 255,255,255); binary code $ 112 $.

Therefore, the palette, which is usually written into a special service area at the beginning of the file (called the file header), consists of four three-byte blocks:

Figure 6.

Each pixel takes only two bits.

Palettes with colors over $ 256 are not used in practice.

Advantages and Disadvantages of Raster Coding

Bitmap encoding has dignity:

  • universal method (you can encode any image);
  • the only method for encoding and processing blurry images that have no clear boundaries, such as photographs.

AND limitations:

  • there is always a loss of information during sampling;
  • when resizing the image, the color and shape of objects in the picture is distorted, since when increasing the size, it is necessary to somehow restore the missing pixels, and when decreasing, to replace several pixels with one;
  • file size does not depend on the complexity of the image, but is determined only by the resolution and color depth.

As a rule, bitmap images are large.

What difficulties have you encountered? How can they be overcome?

2. Construct an 8 px wide black and white image, encoded with the sequence 2466FF6624 16.

3. Construct a 5 px wide black and white picture, encoded in hex sequence 3A53F88 16.

4. A 10 × 15 cm drawing is encoded at 300 ppi. Estimate the number of pixels in this drawing. (Answer: about 2 megapixels)

5. Plot the hexadecimal code for colors that have RGB codes (100,200,200), (30,50,200), (60,180, 20), (220, 150, 30). (Reply: # 64C8C8, # 1E32C8, # 3CB414, # DC961E)

6. How would you name the color given on the web page as a code: #CCCCCC, #FFCCCC, #CCCCFF, # 000066, # FF66FF, #CCFFFF, # 992299, # 999900, # 99FF99? Find the decimal values \u200b\u200bof the RGB code components. (Answer: (204,204,204), (255,204,204), (204,204,255), (0,0,102), (255.255,102), (104,255,255), (153,34,153), (153,153,0), (153,255,153))

7. What is color depth? How are color depth and file size related?

8. What is the color depth if the drawing uses 65,536 colors? 256 colors? 16 colors? (Answer: 16 bits; 8 bits; 4 bits)

9. For yellow, find the red, green, and blue components in 12-bit encoding. (Answer: R \u003d G \u003d 15, B \u003d 0)

10. How much space does the palette take up in a file that uses 64 colors? 128 colors?

11. How many bytes will the code for a 40 × 50 pixel image take in true color mode? when encoding with a 256 color palette? when encoding with a palette of 16 colors? in black and white (two colors)? (Answer: 6000, 2000, 1000, 250)

12. How many bytes will the code of an 80 × 100 pixel image take when encoded with a color depth of 12 bits per pixel? (Answer: 12000)

13. 512 bytes of memory were allocated to store a 32 × 32 pixel raster image. What is the maximum possible number of colors in the image palette? (Answer: 16)

14. For storing a bitmap with a size of 128 x 128 pixels, 4 kilobytes of memory were allocated. What is the maximum possible number of colors in the image palette? (Answer: 4)

15. In the process of converting a raster graphic file, the number of colors decreased from 1024 to 32. How many times has the information volume of the file decreased? (Answer: 2 times)

16. In the process of converting a raster graphic file, the number of colors decreased from 512 to 8. How many times has the information volume of the file decreased? (Answer: 3 times)

17. The screen resolution of the monitor is 1024 x 768 pixels, the color depth is 16 bit. How much video memory is required for this graphics mode? (Answer: 1.5 MB)

18. After converting a raster 256-color graphic file into black-and-white format (2 colors), its size has decreased by 70 bytes. What was the size of the original file? (Answer: 80 bytes)

19. How much memory do you need to store a 64-color 32-by-128-dot bitmap graphic? (Answer: 3 Kbytes)

20. What is the width (in pixels) of a rectangular 64-color unpacked bitmap that takes up 1.5 MB of disk space if its height is half the width? (Answer: 2048)

21. What is the width (in pixels) of a rectangular 16-color unpacked bitmap that occupies 1 MB of disk space if it is twice its height and wide? (Answer: 1024)

An important stage in coding a graphic image is its division into discrete elements (discretization).

The main ways of presenting graphics for storage and processing with a computer are raster and vector images.

A vector image is a graphic object consisting of elementary geometric shapes (most often lines and arcs). The position of these elementary segments is determined by the coordinates of the points and the value of the radius. For each line, binary codes of line type (solid, dotted, dash-dotted), thickness and color are indicated.

A raster image is a collection of dots (pixels) obtained as a result of image sampling in accordance with the matrix principle.

The matrix principle of coding graphic images is that the image is divided into a given number of rows and columns. Then each element of the resulting grid is encoded according to the selected rule.

Pixel (picture element) is the minimum unit of an image, the color and brightness of which can be set independently of the rest of the image.

In accordance with the matrix principle, images output to the printer, displayed on the display screen, obtained using a scanner are built.

The image quality will be the higher, the "denser" the pixels are located, that is, the higher the resolution of the device, and the more accurately the color of each of them is encoded.

For a black and white image, the color code of each pixel is specified by one bit.

If the picture is colored, then a binary code of its color is set for each point.

Since colors are also encoded in binary code, then if, for example, you want to use a 16-color picture, then you need 4 bits (16 \u003d 24) to encode each pixel, and if it is possible to use 16 bits (2 bytes) for color encoding one pixel, then you can then transfer 216 \u003d 65536 different colors. Using three bytes (24 bits) to encode the color of a single dot allows for 16,777,216 (or about 17 million) different shades of color to be reflected — so-called True Color. Note that these are currently used, but far from the limiting capabilities of modern computers.

Graphic information, like information of any other type, is stored in the computer memory in the form of binary codes. An image consisting of individual points, each of which has its own color, is called bitmap... The minimum element of such an image in printing is called raster, and when displaying graphics on a monitor, the minimum image element is called pixel (pix).

Fig. 4.1. Minimum image unit: pixel and raster.

If a pixel of an image can only be colored in one of 2 colors, say, either black (0) or white (1), then 1 bit of memory is enough to store information about the color of the pixel (log 2 (2) \u003d 1 bit) ... Accordingly, the volume occupied by the entire image in the computer's memory will be equal to the number of pixels in this image (Fig. 20a).

If 2 bits are allocated for storing information about the color of a pixel, then the number of colors allowed for coloring each pixel will increase to 4x (N \u003d 2 2 \u003d 4), and the size of the image file in bits will be twice as large as the number of pixels that make it up (Fig. . 20b).

When printing on a non-color printer, it usually allows 256 shades of gray (from black (0) to white (255)) for coloring each point of the image. In this case, 1 byte is allocated for storing information about the color of a point, i.e. 8 bits (log 2 (256) \u003d 8 bits).

Color perception

Color is a sensation that arises in a person's consciousness when the visual apparatus is exposed to electromagnetic radiation with a wavelength in the range from 380 to 760 nm. These sensations can be caused by other reasons: illness, shock, mental association, hallucinations, etc.

The ability to sense color arose in the process of evolution as a reaction of adaptation, as a way to obtain information about the surrounding world and a way to orientate in it. Each person perceives colors individually, differently from other people. However, for most people, color sensations are very similar.

The physical basis of color perception is the presence of specific light-sensitive cells in the central part of the retina, the so-called rods and cones.

There are three types of cones, based on their sensitivity to different wavelengths of light (colors). S-type cones are sensitive in violet-blue, M-type in green-yellow, and L-type in yellow-red parts of the spectrum.

The presence of these three types of cones (and rods that are sensitive in the emerald green part of the spectrum) give a person color vision.

At night, only sticks provide vision, so at night a person cannot distinguish colors.

Each animal sees the world in its own way. Sitting in ambush, the frog sees only moving objects: the insects it hunts, or its enemies. To see everything else, she has to start moving herself.

Twilight and nocturnal animals (for example, wolves and other predatory animals), as a rule, hardly distinguish colors.

The dragonfly distinguishes colors well only with the lower half of the eyes, the upper half looks at the sky, against which the prey is already clearly visible.

We can judge about the good eyesight of insects at least by the beauty of the flowers of plants - after all, this beauty is intended by nature precisely for insects - pollinators. But the world as they see it is very different from the one we are used to. The flowers pollinated by bees are usually not colored red: the bee perceives this color as we are black. But, probably, many nondescript flowers in our opinion acquire unexpected splendor in the ultraviolet spectrum, in which insects see. On the wings of some butterflies (for example, lemongrass, hawthorn) there are patterns hidden from the human eye and visible only in ultraviolet rays. When in the course of the experiment the ants were irradiated with strong ultraviolet rays, they ran to hide "in the shade" not under the protection of a dark plate that passed through ultraviolet light, but under transparent, in our opinion, glass that held these rays.

Color models

All objects of the surrounding world can be divided into: emitting (glowing: sun, lamp, monitor), reflecting radiation (paper) and transmitting (glass).

Fig. 4.4. Radiant, reflective and transmissive objects.

Depending on whether an object is emitting or reflective, two inverse color models are used to represent the description of its color in the form of a numeric code: RGB or CMYK.

RGB.Model RGB used in TVs, monitors, projectors, scanners, digital cameras ... This model is additive (total), which means that colors in this model are added to black (blacK) color.

The main colors in this model: red (Red), green (Green), blue (Blue)... Their paired combination in equal proportions gives additional colors: yellow (Yellow), blue (Cyan) and magenta (Magenta).

R + G \u003d Y; G + B \u003d C; B + R \u003d M.

The sum of all three primary colors in equal parts gives white color: R + G + B \u003d W.

CMYK. Color model CMYK used in the printing industry to form images intended for printing on paper. The main colors in it are those that are complementary in the RGB model, because they turn out subtraction RGB colors from whitecolors. Therefore, the CMYK model is called subtractive.

C \u003d W-R; M \u003d W-G; Y \u003d W-B.

In turn, a pairwise combination in equal proportions of CMY colors gives RGB colors. Everyone knows that if you mix yellow and blue paint on paper, you get green. In the language of color models, this is described by the expression: Y + C \u003d G, Besides, C + M \u003d B and M + Y \u003d R.

In theory, the amount C + M + Y \u003d K, i.e. gives black (blacK) color, but since real printing inks have impurities, the color does not exactly match the theoretically calculated cyan, yellow, and magenta. It is especially difficult to obtain black from these paints. Therefore, in the CMYK model, black K is added to the CMY triad. From the word blacK, the last letter is taken to denote black, and since the letter B is already used in RGB to denote blue.

If we encode the color of one point in the image with three bits, each of which will be a sign of the presence (1) or absence (0) of the corresponding component of the RGB system, then we get all eight different colors of the models described above.

Table 4.2. Color coding

In practice, in order to store information about the color of each point of a color image in the RGB model, 3 bytes (i.e. 24 bits) are usually allocated - 1 byte (i.e. 8 bits) for the color value of each component. Thus, each RGB component can take on a value in the range from 0 to 255 (total 2 8 \u003d 256 values), and each point of the image, with such a coding system, can be colored in one of 2 3 * 8 \u003d 2 24 \u003d 16 777 216 colors. This set of colors is commonly called True Color, because the human eye is still unable to distinguish more variety.

Fig. 4.6. Color cube.

RGB coordinates ranging from 0 to 255 form a color cube. Any color is located inside this cube and is described by its own set of coordinates, showing in what proportions the red, green and blue components are mixed in it.

Table 4.3. Reference table

HSB.The two models described above are more convenient for computers than for us. It is much easier for a person not to synthesize a color from individual components, but to choose it, focusing on more natural parameters: tone, saturation, brightness. It is these three parameters that became the basis for the HSB (Hue, Saturation, Brightness) model, aka HSL (Hue, Saturation, Lightness).

The hue parameter Hue (read "hue") is a pure color in itself - one of the colors of the spectrum (rainbow). In the HSB model, it is represented as a vicious circle, the position of a particular shade on which is indicated in degrees from 0 to 359.

The Saturation parameter is saturation. The lower the saturation, the closer the color is to gray, and vice versa: with increasing saturation, the color becomes richer. Lightness, respectively, determines the proportion of white in the final color.

Lab.In an attempt to match the gamut of RGB and CMYK models, a Lab model was created that is not tied to the output environment. The L model parameter shows the overall brightness of pixels, the a parameter shows colors from dark green to bright pink with different variations in saturation and brightness, and the b parameter - from light blue to bright yellow. The Lab model provides the greatest compatibility, color gamut and speed. Because of its versatility, Lab is widely used by skilled professionals who can understand it.

Graphic information can be understood as a drawing, drawing, photograph, picture in a book, images on a TV screen or in a cinema, etc. Let's consider the principles of encoding graphic information using the example of an image on a TV screen. This image consists of horizontal lines - lines, each of which in turn consists of the smallest elementary units of the image - points, which are usually called pixels (picsel - PICture "S ELement - picture element). The whole array of elementary image units is called raster .

The degree of sharpness of the image depends on the number of lines on the whole screen and the number of dots per line, which represent resolution screen, or just resolution ... The more lines and dots, the clearer and better the image.

If we look at the resolution rates of modern plasma and LCD TVs, we find that the most common resolutions are 640x480 (LCD TVs with an aspect ratio of 4: 3); 852 × 480 (plasma panels with an aspect ratio of 16: 9), 1024 × 768 (LCD and "plasma" both 4: 3 and 16: 9); 1366 × 768 (HD Ready); 1920 × 1080 (Full HD) pixels. There are, but rarely, some other resolution values, for example, 800 × 600 or 1024 × 1024 pixels.

A resolution designation such as 640x480 means that 480 horizontal lines of 640 pixels are used. Thus, the image on the screen is a sequence of 640 * 480 \u003d 307200 pixels.

Images can be monochrome or color.

Monochrome image consists of any two contrasting colors - black and white, green and white, brown and white, and so on. For ease of discussion, we will assume that one of the colors is black and the other is white. Then each pixel of the image can be either black or white. By assigning the binary code "0" to the black color and the code "1" to the white color (or vice versa), we can encode the state of 1 pixel of a monochrome image in 1 bit. However, the resulting image will be overly contrasting.

It is generally accepted today, which gives fairly realistic monochrome images, to encode the state of 1 pixel with 1 byte, which allows to transfer 256 different shades of gray from completely white to completely black. In this case, 307200 bytes are required to transfer the entire raster of 640x480 pixels.

Color image can be formed on the basis of various models. The most common color models:

· RGB is most often used in computer science;


· CMYK - the main color model in printing;

· In television for the PAL standard, the YUV color model is used, for SÉCAM - the YDbDr model, and for NTSC - the YIQ model;

· The XYZ reference model is based on measurements of the characteristics of the human eye.

RGB model (from the words Red, Green, Blue - red, green, blue) most closely matches the principles of displaying an image on a monitor screen - three numbers set the brightness of the red, green and blue phosphor grains at a given point on the screen. Therefore, this model has become the most widespread in the field of computer graphics, focused on viewing images on a monitor screen.

The RGB model is based on the fact that the human eye perceives all colors as the sum of three primary colors - red , green and blue (Figure 4.1). Since the color is formed by adding three colors, this pattern is often called additive (summing).

For example, to set the white color, you must specify the maximum brightness values \u200b\u200bfor all three components, and to set the black color, you must completely extinguish all sources (for example, phosphor dots) that set the color at the desired point in the image - specify zero brightness for them.

If each of the colors is encoded using 1 byte (the brightness of each component is set by numbers from 0 to 255), as is customary for a realistic monochrome image, it will be possible to transmit 256 shades of each of the primary colors. And in total, in this case, the transmission of 256 256 256 \u003d 16 777 216 different colors is provided, which is quite close to the real sensitivity of the human eye. Thus, with this color coding scheme, 1 pixel image requires 3 bytes or 24 bits of memory. This way of representing color graphics is commonly called the mode True Color (true color - true color) or full color mode .

There are professional devices (for example, scanners) that allow you to obtain images in which each pixel is described not by three, but by six (16 bits for each color component) or even eight bytes. Such modes are used for the best reproduction of shades and, most importantly, the brightness of image points. This allows the most reliable reproduction of images of such technically complex subjects as, for example, evening or sunrise landscapes.

Fig. 4.1. RGB color model represented as a cube

Example 4.7. In Win32, the standard type for representing colors is COLORREF. To determine the color in RGB, 4 bytes are used in the form:

BB, GG, RR - intensity value of blue, green and red color components, respectively. Their maximum value is 0xFF.

Then you can define a variable of type COLORREF as follows:

COLORREF C \u003d(b, g, r);

b, g and r - intensity (in the range from 0 to 255), respectively, of blue, green and red components of the determined color C. That is, bright red can be defined as (255,0,0), bright purple - (255,0,255), black - (0,0,0) and white - (255,255,255).

Full color mode is memory intensive. Therefore, various modes and graphic formats are being developed that reproduce color a little worse, but require much less memory. In particular, we can mention the High Color mode (high color - rich color), in which 16 bits are used to transmit the color of 1 pixel, and therefore 65,535 color shades can be transmitted, as well as the index mode, which is based on a previously created for this the table of the colors used in it. Then the desired pixel color is selected from this table using a number - an index that takes only 1 byte of memory. When recording an image into the computer's memory, in addition to the color of individual dots, it is necessary to record a lot of additional information - the size of the pattern, the resolution, the brightness of the dots, etc. The specific way of encoding all the information required when recording the image into the computer's memory is a graphic format. Graphic information encoding formats based on the transmission of the color of each individual pixel that makes up an image are referred to the group of raster, or BMP (Bit MaP - bitmap) formats.

CMYK Model(Cyan, Magenta, Yellow, blacK) A subtractive color shaping scheme used primarily in the printing industry for standard process printing. CMYK schemes (Figure 4.2) tend to have a relatively small color gamut.

Fig. 4.2.Subtractive synthesis scheme in CMYK

In Russian, these colors are often referred to as: cyan, magenta, yellow ... The color in such a scheme depends not only on the spectral characteristics of the dyes and on the method of their application, but also on their quantity, paper characteristics, and other factors. For example, there are American, European, and Japanese standards for coated and uncoated papers.

While in theory black can be obtained by mixing equal proportions of magenta, cyan, and yellow, in practice, mixing real magenta, cyan, and yellow produces a rather dirty brown or muddy gray. Since the purity and saturation of black is extremely important in the printing process, another color was introduced into the model - the black .

The explanation of the first three letters in the abbreviation CMYK is given above, and regarding the fourth one of the versions claims that K - short for English. blac K (if we took B, there would be confusion with the RGB model, where B is blue). According to this version, when printing films, the color to which they belong was indicated with one letter. Alternatively, the letter K appeared from the abbreviation of English. the words Key : in English-speaking countries, the term key plate indicates the printing plate for black ink.

CMYK is called the subtractive model, because this model is used mainly in printing for color printing, and paper and other printed materials serve as surfaces that reflect light: it is more convenient to calculate how much light (and color) is reflected from a particular surface, rather than how much absorbed. So, if we subtract the three primary colors, RGB, from white, we get three additional CMY colors. “Subtractive” means “subtracted” - we subtract the primary colors from the white.

Each of the numbers that define a CMYK color represents a percentage of that color's ink that makes up a color combination.For example, 30% cyan, 45 magenta, 80 yellow, and 5% black would be mixed to produce a dark orange. This can be denoted as follows: (30,45,80,5). Sometimes they use this designation: C30M45Y80K5.

Control questions and tasks

1. What is called a data format?

2. How are numerical information encoded in computers?

3. How the range of representation of an integer is related to its storage format.

4. Are there any differences in the display of positive numbers in forward, backward and complement codes?

5. Represent the number -78 in forward, backward, and two's complement in single-byte format.

6. How are the precision and range of representation of a real number related to the digit capacity of the mantissa?

7. Why is the order in the representation of a real number called shifted?

8. Why isn't the first digit of the mantissa stored when representing a normalized real number?

9. Represent the number 34.256 as a single real number.

10. How are text information encoded in computers?

11. What are the code tables used for? What code tables do you know?

12. What is the difference between the basic ASCII table and the extended one?

13. What are the benefits of presenting text information in Unicode format?

14. Define concepts pixel, raster, resolution .

15. How many bytes of memory are needed to encode an image on a computer monitor screen with a resolution of 800 × 600 with 256 colors?

16. What color imaging models do you know?

17. What colors are considered primary in RGB and CMYK models?


5. Basic concepts of algebra of logic