Spatial image sampling. Spatial sampling. Processing of graphic information. Time sampling of audio

In those days, when computers were not as powerful as they are now, there was no talk of converting images on paper or film. Now it is generally accepted that such objects correspond to an analogue form. With the advent of new technologies, it has become possible to perform digitization (for example, using scanners). Thanks to this, the so-called discrete form of images appeared. But how is graphics transferred from one form to another? The essence of such methods will be briefly described below in as much detail and simplicity as possible, so that every user understands what we are talking about.

What is spatial sampling in computer science?

First, let's look at general concept, explaining it the most in simple language. A graphic image is converted from one form to another by spatial sampling. To understand what this is, let's look at a simple example.

If you take any picture painted with watercolors, it is easy to notice that all the transitions are smooth (continuous). But in a scanned image that was printed on an inkjet printer, there are no such transitions, since it consists of many small dots, called pixels. It turns out that a pixel is a kind of building brick that has certain properties (for example, it has its own color or shade). These bricks make up the complete image.

What is the essence of the spatial sampling method?

If we talk about the essence of the method of converting graphics using such technologies, we can give another example that will help you understand how it all works.

Digitized images, whether scanned, displayed on a computer monitor, or printed, can also be compared to a kind of mosaic. Only here a pixel acts as one piece of the mosaic. This is one of the main characteristics of all modern devices. As you might have guessed, the more such points, and the more smaller size each of them, the smoother the transitions will be. Ultimately, it is their number for each specific device that determines its resolution. In computer science, for such a characteristic, it is customary to calculate the number of pixels (dots) per inch (dpi - dot per inch), both vertical and horizontal.

Thus, a two-dimensional spatial grid is created, somewhat reminiscent of a conventional coordinate system. For each point in such a system, you can set your own parameters, which will differ from neighboring points.

Factors affecting encoding quality

But not only the above examples fully reflect how spatial sampling works. Coding of graphic information takes into account several more important parameters on which the quality of the digitized image depends. They apply not only to the images themselves, but also to devices that reproduce graphics.

First of all, this includes the following characteristics:

  • sampling frequency;
  • color depth.

Sampling frequency

The sampling rate refers to the size of the fragments that make up the image. This parameter can equally be found in the characteristics of digitized images, scanners, printers, monitors and graphic cards.

However, there is one catch. The fact is that by increasing the total number of points you can get more high frequency. But at the same time, the file size of the saved original object also changes significantly. To avoid this, artificially maintaining the size at one constant level is currently used.

Concept of resolution

This parameter has already been mentioned. However, if you look at image output devices, the picture is somewhat different.

As an example of the parameters that spatial sampling uses, consider scanners. For example, the device characteristics indicate a resolution of 1200 x 1400 dpi. Scanning is performed by moving a strip of photosensitive elements along the scanned image. But the first number indicates the optical resolution of the device itself (the number of scanning elements in one inch of the strip), and the second refers to the hardware resolution and determines the number of “micro-movements” of the strip with scanning elements across the image when passing one inch of the picture.

Color depth

Before us is another important parameter, without taking into account which we can fully understand what spatial discretization is. Color depth (or encoding depth) is usually expressed in bits (the same can be said for audio depth, by the way) and determines the number of colors that were used to construct the image, but ultimately refers to palettes (sets of colors).

For example, if we consider a black and white palette that contains only two colors (without taking into account gradations of shades of gray), the amount of information when encoding each point can be calculated using the given formula, taking into account that N is the total number of colors (in our case N = 2 ), and I is the number of states that each point can take (in our case I=1, since there are only two options: either black or white). Thus, N I =2 1 =1 bit.

Quantization

Spatial sampling can also take into account a parameter called quantization. What it is? In some ways this is reminiscent of the interpolation technique.

The essence of the process is that the signal sample value is replaced by the nearest neighboring value from a fixed set, which is a list of quantization levels.

To better understand how graphical information is converted, look at the image above. It presents graphics in their original (analog) form, an image with quantization applied, and side distortions called noise. In the second photo from above you can see peculiar transitions. They are called the quantization scale. If all transitions are the same, the scale is called uniform.

Digital coding

When converting graphic information, it should be taken into account that, unlike an analog signal, a quantum signal can only take on a very specific fixed number of values. This allows you to convert them into a set of symbols and signs, the sequence of which is called a code. The final sequence is called a code word.

Each codeword corresponds to one quantization interval, and a binary code is used for encoding. In this case, sometimes you should also take into account the data transfer rate, which is the product of the sampling frequency and the length of the codeword and is expressed in bits per second (bps). Roughly speaking, this is nothing more than the maximum possible number of transmitted binary symbols per unit of time.

An example of calculating video memory for displaying a raster image on a monitor

Finally one more important aspect, related to what the spatial discretization represents. Raster images on a monitor screen are reproduced according to certain rules and require memory.

For example, the monitor is set to graphics mode with a resolution of 800 x 600 dpi and a color depth of 24 bits. The total number of points will be equal to 800 x 600 x 24 bits = 11,520,000 bits, which corresponds to either 1,440,000 bytes, or 1406.25 KB, or 1.37 MB.

Video compression methods

Spatial sampling technology, as is already clear, is applicable not only to graphics, but also to video images, which in a sense can also be classified as graphic (visual) information. True, the digitization of such material until some time was carried out with limited capabilities, since the final files turned out to be so huge that keeping them on a computer hard drive was impractical (remember, for example, the original AVI format, once developed by Microsoft specialists).

With the advent of M-JPEG, MPEG-4 and H.64 algorithms, it has become possible to reduce the final files by a factor of 10-400x. Many may argue that the compressed video image will have more low quality compared to the original. In a sense, this is true. However, in such technologies, size reduction can be done with or without loss of quality.

There are two main methods by which compression is performed: intra-frame and inter-frame. Both of these options are based on excluding repeating elements from the image, but do not affect, for example, changes in brightness, color, etc. In both the first and second cases, the difference between scenes in one frame or between two adjacent ones is insignificant, so the difference is not particularly noticeable to the eye. But when you remove the above elements from the file, the difference in size between the original and final image is quite significant.

One of the most interesting, albeit rather complex, methods that spatial sampling uses to compress images is a technology called discrete cosine transform, proposed by W. Chen in 1981. It is based on a matrix in which, unlike the original one, which describes only the values ​​of the counts, the values ​​of the rate of their change are presented.

Thus, it can be considered as a kind of grid of changes in speeds in the vertical and horizontal directions. The size of each block is determined by JPEG technology and has a size of 8 x 8 pixels. But compression is applied to each individual block, and not to the whole image. Thus, the difference between the source and final material becomes even less noticeable. Sometimes in computer terminology this technique is also called subsampling.

Next, for brightness and color, the quantization described above can be used, in which each value of the cosine transformation is divided by the quantization coefficient, which can be found in special tables obtained on the basis of so-called psychophysical tests.

The tables themselves correspond to strictly defined classes of blocks, grouped by activity (uniform image, unstructured image, horizontal or vertical difference, etc.). In other words, each block sets its own values, which are not applicable to neighboring ones or those that differ in class.

Finally, after Huffman-based quantization, redundant coefficients are removed (redundancy reduction), resulting in a codeword with a length of less than one bit per coefficient (VLC) for subsequent encoding. Next, a linear sequence is formed, for which a zigzag reading method is used, which groups the values ​​in the final matrix in the form of significant quantities and sequences of zeros. But they can just be removed. The remaining combinations are compressed in the standard way.

In general, experts especially do not recommend encoding graphic information using JPEG technologies, since they have a number of disadvantages. Firstly, repeatedly resaving files invariably leads to deterioration in quality. Secondly, because objects encoded using JPEG cannot contain transparent areas, such methods can only be applied to graphic images or scanned samples of art if they do not exceed a vertical and horizontal size of 200 pixels. Otherwise, the deterioration in the quality of the final image will be very pronounced.

True, JPEG algorithms became the basis for MPEG compression technologies, as well as for many conferencing standards like H.26X and H32X.

Instead of an afterword

Here is a brief summary of everything that concerns the understanding of issues related to the conversion of analog graphics and video into discrete ones (by analogy, such techniques are also used for sound). The described technologies are quite complex for the average user to understand, but some important components of the basic techniques can still be understood. The issues of setting up monitors to obtain the highest quality picture were not discussed here. However, on the issue that interests us, it can be noted that it is not always worth setting the maximum possible resolution, since inflated parameters can lead to inoperability of the device. The same goes for the screen refresh rate. It is better to use the values ​​recommended by the manufacturer or those that the operating system after installing the appropriate drivers and control software suggests using the default.

As for independently scanning or transcoding information from one format to another, you should use special programs and converters, however, in order to avoid a decrease in quality, it is better not to get carried away with the maximum possible compression in order to reduce the size of the final files. Such methods are applicable only in cases where information needs to be stored on media with limited space (for example, CD/DVD disks). But if you have enough space on your hard drive, or when you need to create a presentation for broadcast on a large screen, or print photos on modern equipment(photo printers don’t count), it’s better not to neglect quality.

or why the file resolution must exceed the raster lineature at least twice

A characteristic feature of modern printing systems for processing halftone originals is that both the spatial sampling of the image and the quantization of its tone by level are carried out at least twice. Spatial sampling is the replacement of an image, the tone of which varies arbitrarily in X and Y coordinates, with an image composed of individual sections - zones within which this parameter is averaged. IN general case, as already indicated, the sampling frequency must be at least twice the frequency of the harmonic component of the original image to be reproduced on the copy. This situation is illustrated schematically in Fig. 1 (a), at position a) of which the original continuous message is a sinusoidal oscillation and(t) with period T. The spectrum of such a signal consists of a constant component and the first harmonic:

u = U 0 +U l sin(27tt/T)

Rice. 1.

The original signal (a), its sample values ​​and modulation depth (%) at zero (b), opposite (c) and intermediate (d) phase of the sampling frequency.

At zero phase of discrete samples U D period T/2 the depth of their modulation by the first harmonic of the original signal is zero and the frequency information is completely lost. Only the average value is transmitted U 0 original signal (see Fig. 1, b). With a change in the phase of the samples by half their period, the modulation depth turns out to be equal to 100% (see Fig. 1, c). Intermediate between the considered phases of readings are accompanied by distortions of the amplitude and phase of the first harmonic, although, as the graph in Fig. 1 (d), information about its frequency is stored. At least one-dimensional (along one of the coordinates) image sampling accompanies the process of electro-optical analysis. In analogue reproduction systems and television, an optical parameter, which is a function of the coordinates of the original or the transmitted scene, is converted into the amplitude of an electrical signal that changes at the output of the photovoltaic cell in time during line-by-line reading (scanning). The spectrum of spatial frequencies of the image in the direction transverse to the line scanning direction is limited by the frequency of decomposition into lines. Due to the finite dimensions of the scanning spot (aperture), this spectrum is also limited along the lines by a frequency reciprocal to the value of this spot. The second reason for limiting the frequency spectrum and image sampling along the line is the modulation by the video signal of the amplitudes, phases or frequencies of an additional electromagnetic oscillation - the carrier frequency necessary for signal transmission, for example, in television or in analogue remote (using electrical communication channels) reproduction. Two-dimensional (in both coordinates) sampling and quantization take place during the so-called analog-to-digital conversion of a video signal, as a result of which a set of spatial samples of the tone value can be represented by a certain array of numbers written, for example, in binary code. This representation allows you to ignore the time of actual scanning and perform functional transformations of tone, color, small details, contours and other image contents as operations on the numbers of this array. For such purposes, PCs are now effectively used.
Spatial sampling also accompanies rasterization - the representation of an image in the form of a set of printed and white-space elements, the relative area of ​​which is determined by the tone or color of the corresponding sections of the original. In this case, as already indicated, the frequency of the first sampling associated with electro-optical analysis and analog-to-digital conversion is usually taken at twice exceeding the lineature of the printing raster, or more precisely, the frequency of the raster function, within the period of which this or that number of raster dots and spaces is formed. If this condition is met, then when reproducing a system of periodic strokes of an arbitrary spatial phase, the sizes of neighboring points will be at least somewhat different from each other in all cases except one: when the strokes themselves are shifted by exactly half the period relative to decomposition element 1 and the raster cell. On the print, instead of strokes, a uniform field of identical raster dots with a relative area of ​​50% is formed (see Fig. 2, d), since the reflection coefficient of the original, averaged over the area of ​​the reading spot I, has the same (intermediate) value for all raster elements. Each time, half a stroke and half a space fall into reference zone 7 (see Fig. 2, c). This case is similar to that shown in Fig. 1(b).

Rice. 2.
Strokes of frequency 0.51 in a raster grating of lineature L with coinciding (a) and opposite (c) phases; their raster copies: b, d - with reading element 1 equal to the line pitch; d - with readings of 2 half-smaller raster steps.

In all other spatial phases, the contrast of strokes on reproductions turn out to be higher, since the values ​​of neighboring readings and the sizes of the raster dots formed in accordance with them differ. The maximum difference occurs in the opposite extreme case, when, as shown in Fig. 2 (a, b), strokes of frequency 0.51 are in phase with the raster grating. There is an analogy here with the case illustrated in Fig. 1 (a, c). They are transmitted with a raster of twice the lineature, equal to L lines/cm, without loss of contrast. A guarantee of transmitting strokes with full contrast, regardless of their spatial phase, is provided by a decomposition frequency that is twice the raster lineature, as illustrated in Fig. 2(d). Since in printing reproduction there are at least two spatial discretizations of the image, it follows from the simplified example given that a two-fold margin in the decomposition frequency must be provided twice. The first time this has to be done is when choosing the raster lineature, if the task is to reproduce certain spatial frequencies of the original on the print. The second double margin, this time in relation to the selected lineature value, is set for the scanning frequency of the original. For example, to reproduce strokes that have a frequency of 4 lines/mm on the original, a print lineature of 80 lines/cm (~200dpi) is required (as well as the corresponding paper smoothness and other printing parameters). When scanning such an original, it is necessary to read it at a frequency of 16 lines/mm (~400ppi). The degree of destruction of contours and small details in the raster process is slightly reduced if the sampling frequency, in accordance with the provisions of sampling theory, is twice the raster lineature (see Fig. 3, e, f).

Rice. 3.
« Funnel" (a) and random (b) distribution of weight values; images of contour 1, separating areas on the original with absorption of 0.94 and 0.04, based on one (c, d), four (e, f) and 64 (g, h) readings per raster period;
2 - analysis reference zone

The section of the original intersected by the contour is represented in this case by four different values ​​of readings. Four fragments of the corresponding section of the copy are formed according to different signs of the “alphabet” of dots. The shape of the area printed within the area is modulated by the geometry of the contour, and the latter is rendered with greater graphic precision and sharpness. This effect is clearly illustrated by the model in Fig. 4 (d) in comparison with those presented in Fig. 4(b,c).

Rice. 4.
Line element(s) of a halftone original and their raster copies using:

  • one (b, c, e) and four (d, f) samples in the period of the raster function;
  • unsharp masking of a numeric array (c);
  • displacement of raster points (e) and their fragments (f) on contours.

The accuracy of the transfer of the full contrast contour further increases as the frequency of reading the original increases and turns out to be at the level of the resolution of the output device, when each synthesis element in the original video array corresponds to an independent multi-level reading (see Fig. 3, g, h). The sampling zones, as a rule, are almost an order of magnitude larger than the size of the synthesis elements and cannot be significantly reduced. Otherwise, the already large volumes of illustration files, amounting to tens and hundreds of megabytes, increase excessively, on average by two orders of magnitude. Accordingly, the capacity of storage devices, the processing time and exchange of video information between various modules and workstations of pre-printing systems, the transmission time or the occupied frequency band during remote reproduction are increasing. In practice, they are limited to only a twofold excess of the sampling frequency over the lineature, which corresponds to the examples in Fig. 3 (e, f) and fig. 4 (d). Such modes and reproduction systems are conventionally classified as systems of the coarse scan/fine print type (rough reading/fine print). The number of samples is equal to the number of synthesis subelements, i.e. fine scan/fine print type modes, are found only in continuous tone output devices or inkjet-drop digital printing with relatively small image formats, low input/output resolutions (about 12-24 lines /mm (300-600dpi)) and, in this regard, low lineatures.




















Spatial sampling of continuous images stored on paper, photographic and film can be achieved by scanning. Currently, digital photo and video cameras that capture images immediately in discrete form are becoming increasingly widespread.











Color depth and number of colors in the palette Color depth, i (bits) Number of colors in the palette, N 42 4 = = = =


Monitor graphic modes The quality of the image on the monitor screen depends on the spatial resolution and color depth. The spatial resolution of a monitor screen is defined as the product of the number of image lines and the number of pixels per line. The monitor can display information with different spatial resolutions (800*600, 1024*768, 1152*864 and higher).


Monitor graphics modes Color depth is measured in bits per pixel and characterizes the number of colors in which image pixels can be painted. The number of colors displayed can also vary widely, from 256 (8-bit color depth) to over 16 million (24-bit color depth).




Graphic monitor modes Periodically, with a certain frequency, dot color codes are displayed on the monitor screen. The frequency of image reading affects the stability of the image on the screen. In modern monitors, image updates occur at a frequency of 75 or more times per second, which ensures comfortable image perception by the user. Example Let's find the amount of video memory for graphics mode


with a spatial resolution of 800x600 pixels and a color depth of 24 bits. I P = i * X * Y = 24 bits x 600 x 800 = bit = byte = 1,406.25 KB = 1.37 MB


Task Screen resolution Color depth x x 768 The monitor can have graphics modes with color depths of 8, 16 and 24, 32 bits. Calculate the amount of video memory in KB required to implement a given color depth at various screen resolutions. Enter the solution into the table. Sources of information: - Ugrinovich N. D. Textbook Computer Science: textbook for grade 9 / N. D. Ugrinovich - 4th ed. – M.: BINOM. Laboratory of knowledge, – 178 p.; - Ugrinovich N.D., Bosova L.L., Mikhailova N.I. Informatics and ICT: workshop / N. D. Ugrinovich, L. L. Bosova, N.I. Mikhailova - M.: BINOM. Knowledge Laboratory, – 394 p. - Ugrinovich N.D. Computer science and ICT classes: Toolkit

/ N. D. Ugrinovich - M.: BINOM. Knowledge Laboratory, p.;.

Spatial sampling During the encoding process, an image is spatially discretized. Spatial sampling of an image can be compared to constructing an image from a mosaic ( large quantity

small multi-colored glasses). The image is divided into separate small fragments (dots, and each fragment is assigned a color value, that is, a color code (red, green, blue, and so on). Sampling - This

conversion of graphic information from analogue to discrete form, that is, splitting a continuous graphic image into individual elements.

1) The quality of image encoding depends on: sampling rate

The choice of sampling frequency is always a compromise between the quality of reproduction of fine details and the degree of information reduction. As a rule, in the process of image sampling, its “format” is determined, i.e. the number of elements forming it. In this case, of course, the size of the image also changes. Therefore, in order to exclude the influence of this additional factor (image size) on the parameter under study, an artificial technique was used in this work: when changing the sampling conditions, the image size is artificially is maintained constant.

2) coding depth, i.e. number of flowers. The greater the number of colors, that is, the greater the number of possible states of an image point, is used, the better the image is encoded (each point carries a greater amount of information). The combination of colors used in a set forms a color palette.

Graphic information on the monitor screen is presented in the form bitmap, which is formed from a certain number of lines, which in turn contain a certain number of points (pixels).

Pixel- the minimum area of ​​the image whose color can be set independently.

Each color can be considered as a possible state of a point, then the number of colors displayed on the monitor screen can be calculated by the formula: N = 2i, where i is the color depth: (if color depth (I) = 8, then 2^8 = 256)

Problem 1. Let's consider the formation of a raster image on the monitor screen, consisting of 600 lines of 800 points in each line (480,000 points in total). In the simplest case (black and white image without grayscale), each point on the screen can have one of two states - “black "or "white", that is, 1 bit is needed to store its state.

TASK 2. Let's calculate the required amount of video memory for one of the graphics modes, for example, with a resolution of 800 x 600 pixels and a color depth of 24 bits per pixel.

Total dots on the screen: 800,600 = 480,000. Required video memory: 24 bits 480,000 = 11,520,000 bits = 1,440,000 bytes = 1406.25 KB = 1.37 MB.




  • Graphic images are converted from analog (continuous) to digital (discrete) form by spatial sampling.
  • Spatial sampling of an image can be compared to constructing an image from a mosaic (a large number of small multi-colored glasses).
  • The image is divided into individual small elements (dots, or pixels), and each element can have its own color (red, green, blue, etc.).



  • The most important characteristic of the quality of a raster image is resolution.
  • The resolution of a raster image is determined by the number of pixels both horizontally and vertically per unit length of the image.
  • The smaller the dot size, the greater the resolution and, accordingly, the higher the image quality.
  • 1 inch = 2.54 cm

  • During the sampling process, various color palettes can be used, i.e., sets of colors in which image points can be colored.
  • Each color can be considered as a possible state of a point.
  • Number of colors N in the palette and amount of information I , necessary to encode the color of each point are interconnected and can be calculated using the formula:

2 = 2 i= 2 1 = 2 i = i=1 bit.



Color depth, (bits)

Number of colors in the palette, N

2 24 =16 777 216


  • The quality of the image on the monitor screen depends on the spatial resolution and color depth.
  • The spatial resolution of a monitor screen is defined as the product of the number of image lines and the number of pixels per line. The monitor can display information with different spatial resolutions (800 x 600, 1024 x 768, 1152 x 864 and higher).

  • The greater the spatial resolution and color depth, the higher the image quality.
  • IN operating systems It is possible to select the desired and technically possible graphic mode for the user.

  • The information volume of the required video memory can be calculated using the formula:
  • Where I- information volume of video memory in bits;
  • X Y- number of image pixels (X - number of horizontal pixels, Y- vertically);
  • I- color depth in bits per dot.

  • Example: the required amount of video memory for graphics mode with a spatial resolution of 800 x 600 pixels and a color depth of 24 bits is:
  • 1 P = I *X*Y = 24 bits x 800 x 600 = 11,520,000 bits = = 1,440,000 bytes = 1,406.25 KB ~ 1.37 MB.

  • The quality of information displayed on a monitor screen depends on the screen size and pixel size. Knowing the screen diagonal size in inches (15", 17", etc.) and the screen pixel size (0.28 mm, 0.24 mm or 0.20 mm), you can estimate the maximum possible spatial resolution of the monitor screen.