Discrete image. Self-study tasks

Consider a continuous image - a function of two spatial variables x 1 and x 2 f(x 1 , x 2) on a limited rectangular area (Figure 3.1).

Figure 3.1 - Transition from continuous image to discrete

Let us introduce the concept of the discretization step Δ 1 in the spatial variable x 1 and Δ 2 in the variable x 2. For example, you can imagine that at points located at a distance of Δ 1 along the axis x 1 there are point video sensors. If such video sensors are installed over the entire rectangular area, then the image will be specified on a two-dimensional lattice

To shorten the notation, we denote

Function f(n 1 , n 2) is a function of two discrete variables and is called a two-dimensional sequence. That is, the discretization of the image in terms of spatial variables translates it into a table of sampled values. The dimension of the table (the number of rows and columns) is determined by the geometric dimensions of the original rectangular area and the choice of the sampling step according to the formula

Where square brackets […] represent the whole part of the number.

If the domain of the continuous image is a square L 1 = L 2 = L, and the sampling step is chosen the same along the axes x 1 and x 2 (Δ 1 = Δ 2 = Δ), then

and the dimension of the table is N 2 .

The element of the table obtained by sampling the image is called " pixel " or " Countdown"... Consider a pixel f(n 1 , n 2). This number takes on continuous values. Computer memory is capable of storing only discrete numbers. Therefore, for recording in memory, the continuous value f must be subjected to analog-to-digital conversion with step D f(see figure 3.2).

Figure 3.2 - Quantization of a continuous quantity

The operation of analog-to-digital conversion (sampling of a continuous value by level) is often called quantization... The number of quantization levels, provided that the values ​​of the luminance function lie in the interval _____ _ ____ ___, is

In practical problems of image processing, the quantity Q varies widely from Q= 2 ("binary" or "black and white" images) up to Q= 210 or more (almost continuous brightness values). Most often chosen Q= 28, while the image pixel is encoded with one byte of digital data. From all of the above, we conclude that the pixels stored in the computer's memory are the result of discretizing the original continuous image by arguments (coordinates?) And by levels. (Where and how much, and everything is discrete) It is clear that the sampling steps Δ 1 , Δ 2 should be chosen small enough so that the sampling error is negligible and the digital representation retains the basic information about the image.

It should be remembered that the smaller the sampling and quantization step, the larger the amount of image data must be recorded in the computer's memory. Let us consider, as an illustration of this statement, an image on a 50 × 50 mm slide, which is entered into memory using a digital optical density meter (microdensitometer). If, upon input, the linear resolution of the microdensitometer (step of discretization in spatial variables) is 100 microns, then a two-dimensional array of pixels of dimension N 2 = 500 × 500 = 25 ∙ 10 4. If the step is reduced to 25 microns, then the size of the array will increase 16 times and amount to N 2 = 2000 × 2000 = 4 ∙ 10 6. Using quantization at 256 levels, that is, encoding the found pixel by a byte, we find that in the first case, 0.25 megabytes of memory is required for recording, and in the second case, 4 megabytes.

Analog and discrete image. Graphic information can be presented in analog or discrete form. An example of an analog image is a painting canvas, the color of which changes continuously, and an example of a discrete image, a drawing printed using an inkjet printer, consisting of separate dots of different colors. Analog (oil painting). Discrete.

Slide 11 from presentation "Coding and processing of information"... The size of the archive with the presentation is 445 KB.

Informatics grade 9

summaries of other presentations

Forking Algorithms - IF condition, THEN action. What do we know. Lesson structure. Forking algorithm. Follow the algorithm and fill in the table. A student who scored from 85 to 100 points, inclusive, passes to the second round of the competition. Enter the number of points and determine if he made it to the second round. Find the largest number between a and b. Write a program in a programming language. A branching algorithm is an algorithm in which, depending on a condition, either one or another sequence of actions is performed.

"Creation of Artificial Intelligence" - Simulation Approach. Approaches to building artificial intelligence systems. An evolutionary approach. Artificial intelligence. Can cohabit with many people, helping to cope with personal problems. Structural approach. Logical approach. Development problems. Development prospects and areas of application.

Cyclic programs - Digit. Loop with precondition. Find the amount. Loop with postcondition. Loop with parameter. Euclid's Algorithm. Cyclic programs. Find the sum of natural numbers. Cycle concept. An initial fee. Tabulation function. Calculate. Example. Dividers. Computer science. Find the number of numbers. Find. Find the number of three-digit natural numbers. Three-digit numbers. Find the set of values ​​of the function. Dollar conversion table.

"What is Email" - Sender. E-mail address. Email history. The issue of the emergence of e-mail. The structure of the letter. Mail routing. Letter. Email. Copy. Date. X-mailer. Email. How email works.

"Working with e-mail" - E-mail address. Mailbox. Email protocol. File-sharing network. Separation of addresses. Benefits of email. Mail clients. The inventor of email. Address. Email. Software for working with e-mail. How email works. Teleconference. Mail server. File exchange.

"Processing in Photoshop" - Cool guys. How to distinguish a fake. Raster and vector images. Introduction. Top places. Adobe Photoshop program. Retouching. Photoshop contests. Brightness correction. My friends. The practical part. Similar programs. Main part. Design. Unusual animals. Montage of several images.

Analog and discrete provision of graphic information A person is able to perceive and store information in the form of images (visual, sound, tactile, gustatory and olfactory). Visual images can be saved in the form of images (drawings, photographs, and so on), and sound images can be recorded on records, magnetic tapes, laser disks, and so on.

Information, including graphic and sound, can be presented in analog or discrete form. With an analog representation, a physical quantity takes on an infinite set of values, and its values ​​change continuously. With a discrete representation, a physical quantity takes on a finite set of values, and its value changes abruptly.

Let's give an example of analog and discrete information representation. The position of the body on an inclined plane and on a staircase is set by the values ​​of the X and Y coordinates.When a body moves along an inclined plane, its coordinates can take on an infinite set of continuously changing values ​​from a certain range, and when moving along a staircase, only a certain set of values, and changing abruptly


An example of an analogue representation of graphic information can be, for example, a painting canvas, the color of which changes continuously, and discrete - an image printed using an inkjet printer and consisting of separate dots of different colors. An example of analog storage of sound information is a vinyl record (the sound track changes its shape continuously), and discrete storage is an audio CD (the sound track of which contains areas with different reflectivity).

Conversion of graphic and audio information from analog to discrete form is carried out by sampling, that is, dividing a continuous graphic image and a continuous (analog) audio signal into separate elements. In the process of sampling, coding is performed, that is, the assignment of each element to a specific value in the form of a code.

Sampling is the transformation of continuous images and sound into a set of discrete values ​​in the form of codes.

Sound in computer memory

Basic concepts: audio adapter, sampling rate, register capacity, sound file.

The physical nature of sound is vibrations in a certain frequency range, transmitted by a sound wave through air (or other elastic medium). The process of converting sound waves into binary code in the computer's memory: sound wave -> microphone -> alternating electric current -> audio adapter -> binary code -> computer memory .

The process of playing sound information stored in the computer memory:
computer memory -> binary code -> audio adapter -> alternating electric current -> speaker -> sound wave.

Audio adapter(sound card) - a special device connected to a computer designed to convert electrical vibrations of an audio frequency into a numerical binary code when inputting sound and for reverse conversion (from a numerical code to electrical vibrations) when playing sound.

While recording sound the audio adapter with a certain period measures the amplitude of the electric current and enters into the reg pp is the binary code of the obtained value. Then the received code from the register is rewritten into the computer's RAM. The quality of computer sound is determined by the characteristics of the audio adapter: sampling frequency and bit depth.

Sampling frequency Is the number of measurements of the input signal per second. Frequency is measured in hertz (Hz). One measurement in one second corresponds to a frequency of 1 Hz. 1000 measurements in one second -1 kilohertz (kHz). Typical frequencies of audio adapters disketation: 11 kHz, 22 kHz, 44.1 kHz, etc.

Register size- the number of bits in the audio adapter register. The bit depth determines the accuracy of the input signal measurement. The larger the digit capacity, the smaller the error of each individual conversion of the magnitude of an electrical signal to a number and vice versa. If the bit width is 8 (16), then when measuring the input signal, 2 8 = 256 (2 16 = 65536) different values ​​can be obtained. Obviously 16-bit an audio adapter encodes and reproduces sound more accurately than an 8-bit one.

Sound file- a file storing audio information in a numerical binary form. Typically, information in audio files is compressed.

Examples of solved problems.

Example # 1.
Determine the size (in bytes) of a digital audio file whose playing time is 10 seconds at a sampling rate of 22.05 kHz and a resolution of 8 bits. The file is not compressed.

Solution.
Formula for calculating the size (in bytes) of a digital audio file (monaural sound): (sampling frequency in Hz) * (recording time in seconds) * (resolution in bits) / 8.

Thus, the file is calculated as follows: 22050 * 10 * 8/8 = 220500 bytes.

Self-study assignments

# 1. Determine the amount of memory for storing a digital audio file, the playing time of which is two minutes at a sampling rate of 44.1 kHz and a resolution of 16 bits.

No. 2. The user has a memory of 2.6 MB at his disposal. You need to record a 1 minute digital audio file. What should be the sampling rate and bit depth?

No. 3. The free disk space is 5.25 MB, the sound depth of the board is 16. What is the duration of the sound of a digital audio file recorded with a sampling frequency of 22.05 kHz?

No. 4. One minute of a digital audio file takes up 1.3 MB on a disk, the bit depth of the sound card is 8. What is the sampling rate of the sound recorded?

No. 5. Two minutes of recording a digital audio file takes up 5.1 MB on a disc. The sampling rate is 22050 Hz. What is the bit depth of the audio adapter? No. 6. The amount of free memory on the disk is 0.01 GB, the bit depth of the sound card is 16. What is the duration of the sound of a digital audio file recorded with a sampling rate of 44100 Hz?

Presentation of graphical information.

Bitmap representation.

Basic concepts: Computer graphics, pixel, raster, screen resolution, video information, video memory, graphic file, bit depth, video memory page, pixel color code, graphic primitive, graphic coordinate system.

Computer graphics- a section of informatics, the subject of which is working on a computer with graphic images (pictures, drawings, photographs, video frames, etc.).

Pixel- the smallest element of the image on the screen (dot on the screen).

Raster- a rectangular grid of pixels on the screen.

Screen resolution Is the size of the raster grid, specified as a product M * N, where M is the number of horizontal dots, N is the number of vertical dots (the number of lines).

Video information- information about the image reproduced on the computer screen, stored in the computer memory.

Video memory- random access memory that stores video information during its playback into an image on the screen.

Graphic file- a file that stores information about a graphic image.

The number of colors reproduced on the display screen (K) and the number of bits allocated in the video memory for each pixel (N) are related by the formula: K = 2 N

The quantity N is called bit depth.

Page- a video memory section containing information about one screen image (one "picture" on the screen). Several pages can be located in the video memory at the same time.

All the variety of colors on the screen is obtained by mixing three basic colors: red, blue and green. Each pixel on the screen is made up of three closely spaced elements that glow with these colors. Color displays using this principle are called RGB (Red-Green-Blue) monitors.

Code pixel colors contains information about the proportion of each base color.
If all three components have the same intensity (brightness), then 8 different colors can be obtained from their combinations (2 3). The following table shows the encoding of an 8-color palette using a 3-bit binary code. In it, the presence of the base color is indicated by one, and the absence by zero.

Binary code


TO Z WITH Colour
0 0
0
Black
0 0
1
Blue
0 1 0 Green
0 1 1 Blue
1 0
0
Red
1 0
1
Pink
1 1
0
Brown
1 1
1
White

A sixteen-color palette is obtained using 4-bit pixel coding: one bit of intensity is added to the three bits of the base colors. This bit controls the brightness of all three colors at the same time. For example, if in an 8-color palette code 100 means red, then in a 16-color palette: 0100 - red, 1100 - bright red; 0110 - brown, 1110 - bright brown (yellow).

A large number of colors are obtained by separately controlling the intensity of the base colors. Moreover, the intensity can have more than two levels, if more than one bit is allocated to encode each of the basic colors.

When using a bit depth of 8 bits / pixel, the number of colors is 2 8 = 256. The bits of this code are distributed as follows: KKKZZSS.

This means that 3 bits are allocated for the red and green components, and 2 bits for the blue. Therefore, the red and green components each have 2 3 = 8 levels of brightness, and the blue - 4 levels.

Vector representation.

In the vector approach, the image is considered as a collection of simple elements: straight lines, arcs, circles, ellipses, rectangles, shades, etc., which are called graphic primitives... Graphic information is data that uniquely identifies all graphic primitives that make up a drawing.

The position and shape of graphic primitives are set in graphics coordinate system related to the screen. Usually the origin is located in the upper left corner of the screen. The pixel grid matches the coordinate grid. The horizontal X axis runs from left to right; the vertical Y-axis is from top to bottom.

A segment of a straight line is uniquely determined by specifying the coordinates of its ends; circle - center coordinates and radius; polyhedron - by the coordinates of its corners, the filled area - by the boundary line and the fill color, etc.

Command

Action

Line to X1, Y1

Draw a line from the current position to position (X1, Y1).

Line X1, Y1, X2, Y2

Draw a line with start coordinates X1, Y1 and end coordinates X2, Y2. The current position is not set.

Circle X, Y, R

Draw a circle: X, Y - center coordinates, R - radius length in raster grid steps.

Ellipse X1, Y1, X2, Y2

Draw an ellipse bounded by a rectangle; (X1, Y1) are the coordinates of the upper left corner, and (X2, Y2) are the coordinates of the lower right corner of this rectangle.

Rectangle X1, Y1, X2, Y2

Draw a rectangle; (X1, Y1) are the coordinates of the upper-left corner, and (X2, Y2) are the coordinates of the lower-right corner of this rectangle.

Paint color COLOR

Set the current drawing color.

Fill color COLOR

Set the current fill color.

Paint over X, Y, BORDER COLOR

Paint over an arbitrary closed shape; X, Y - coordinates of any point inside a closed shape, BORDER COLOR - border line color.

Examples of solved problems.

Example # 1.
To form a color, 256 shades of red, 256 shades of green and 256 shades of blue are used. How many colors can be displayed on the screen in this case?

Solution:
256*256*256=16777216.

Example # 2.
On a screen with a resolution of 640 * 200, only two-color images are displayed. What is the minimum amount of video memory required to store an image?

Solution.
Since the bit depth of a two-color image is 1, and the video memory must at least contain one page of the image, the amount of video memory is: 640 * 200 * 1 = 128000 bits = 16000 bytes.

Example No. 3.
How much video memory is required to store four pages of an image if the bit depth is 24 and the display resolution is 800 * 600 pixels?

Solution.
To store one page, you need

800 * 600 * 24 = 11,520,000 bits = 1,440,000 bytes. For 4, respectively, 1,440,000 * 4 = 5,760,000 bytes.

Example No. 4.
The bit depth is 24. How many different shades of gray can be displayed on the screen?
Note: A shade of gray is obtained with equal values ​​of the brightness levels of all three components. If all three components have the maximum brightness level, then the color is white; the absence of all three constituents represents black.

Solution.
Since the RGB components are the same for grayscale, the depth is 24/3 = 8. We get the number of colors 2 8 = 256.

Example No. 5.
Given a raster grid 10 * 10. Describe the letter "K" with a sequence of vector commands.

Solution:
In vector representation, the letter "K" is three lines. Any line is described by indicating the coordinates of its ends in the form: LINE (X1, Y1, X2, Y2). The image of the letter "K" will be described as follows:

LINE (4,2,4,8)
LINE (5,5,8,2)
LINE (5,5,8,8)

Tasks for independent work.

# 1. How much video memory is required to store two pages of an image, assuming the display resolution is 640 * 350 pixels and the number of colors used is 16?

No. 2. The amount of video memory is 1 MB. Display resolution - 800 * 600. What is the maximum number of colors that can be used if the video memory is split over two pages?

No. 3. The bit depth is 24. Describe several options for the binary representation of light gray and dark gray shades.

No. 4. On the computer screen, you need to get 1024 shades of gray. What should be the bit depth?

No. 5. For the representation of decimal digits in the postal code standard (as they say on envelopes), get a vector and raster representation. Select the size of the raster grid yourself.

No. 6. Reproduce drawings on paper using vector commands. Resolution 64 * 48.

A)
Drawing color Red
Fill Color Yellow
Circumference 16, 10, 2
Paint over 16, 10, Red
Set 16, 12
Line to 16, 23
Line to 19, 29
Line to 21, 29
Line 16, 23, 13, 29
Line 13, 29, 11, 29
Line 16, 16, 11, 12
Line 16, 16, 21, 12

B)
Drawing color Red
Fill color Red
Circumference 20, 10, 5
Circumference 20, 10, 10
Paint over 25, 15, Red
Circumference 20, 30, 5
Circumference 20, 30, 10
Paint over 28, 32, Red

Analog and discrete presentation of images and sound

A person is able to perceive and store information in the form of images (visual, sound, tactile, gustatory and olfactory). Visual images can be saved in the form of images (drawings, photographs, etc.), and sound images can be recorded on records, magnetic tapes, laser disks, and so on.

Information, including graphics and sound, can be presented in analog or discrete form. With an analog representation, a physical quantity takes on an infinite set of values, and its values ​​change continuously. With a discrete representation, a physical quantity takes on a finite set of values, and its value changes abruptly.

Let's give an example of analog and discrete information representation. The position of the body on an inclined plane and on a staircase is set by the values ​​of the X and Y coordinates.When a body moves along an inclined plane, its coordinates can take on an infinite set of continuously changing values ​​from a certain range, and when moving along a staircase, only a certain set of values, and changing abruptly (Fig. . 1.6).

An example of an analogue representation of graphic information can be, for example, a painting canvas, the color of which changes continuously, and discrete - an image printed using an inkjet printer and consisting of separate dots of different colors. An example of analogue storage of sound information is a vinyl record (the soundtrack changes its shape continuously), and discrete storage is an audio CD (the soundtrack of which contains areas with different reflectivity).

Conversion of graphic and sound information from analog to discrete form is performed by sampling, that is, dividing a continuous graphic image and a continuous (analog) audio signal into separate elements. In the process of sampling, coding is performed, that is, the assignment of a specific value to each element in the form of a code.

Sampling is the transformation of continuous images and sound into a set of discrete values ​​in the form of codes.

Questions to Think About

1. Give examples of analog and discrete ways of presenting graphic and sound information.

2. What is the essence of the sampling process?

Signals arrive in the information processing system, as a rule, in a continuous form. For computer processing of continuous signals, it is necessary, first of all, to convert them into digital ones. For this, the operations of sampling and quantization are performed.

Image sampling

Sampling Is the transformation of a continuous signal into a sequence of numbers (samples), that is, the representation of this signal in some finite-dimensional basis. This view consists in projecting a signal to a given basis.

The most convenient from the point of view of the organization of processing and the natural way of sampling is the presentation of signals in the form of a sample of their values ​​(samples) in separate, regularly spaced points. This method is called rasterization, and the sequence of nodes at which samples are taken is raster... The interval through which the values ​​of the continuous signal are taken is called sampling step... The value inverse to the step is called sampling rate,

An essential question that arises in the course of sampling: with what frequency to take samples of the signal in order to be able to restore it from these samples? Obviously, if samples are taken too rarely, then they will not contain information about a rapidly changing signal. The rate of change of a signal is characterized by the upper frequency of its spectrum. Thus, the minimum allowable sampling interval is related to the highest frequency of the signal spectrum (inversely proportional to it).

For the case of uniform sampling, it is true Kotelnikov's theorem published in 1933 in the work “On the bandwidth of ether and wire in telecommunications”. It says: if a continuous signal has a frequency-limited spectrum, then it can be completely and unambiguously reconstructed from its discrete samples taken with a period, i.e. with frequency.

Signal recovery is carried out using the function ... Kotelnikov proved that a continuous signal that satisfies the above criteria can be represented as a series:

.

This theorem is also called the sampling theorem. The function is also called counting function or Kotelnikov, although an interpolation series of this type was studied by Whitaker in 1915. The counting function has an infinite extent in time and reaches its greatest value, equal to one, at the point relative to which it is symmetrical.

Each of these functions can be viewed as a response to an ideal low pass filter(LPF) on the delta pulse arriving at the moment of time. Thus, to restore a continuous signal from its discrete samples, they must be passed through the corresponding low-pass filter. It should be noted that such a filter is non-causal and physically unrealizable.

The given ratio means the possibility of accurate reconstruction of signals with a limited spectrum from the sequence of their samples. Limited spectrum signals- these are signals, the Fourier spectrum of which is nonzero only within a limited portion of the definition domain. Optical signals can be attributed to them, because the Fourier spectrum of images obtained in optical systems is limited due to the limited size of their elements. The frequency is called Nyquist frequency... This is the cutoff frequency above which there should be no spectral components in the input signal.

Quantizing images

In digital image processing, the continuous dynamic range of luminance values ​​is divided into a number of discrete levels. This procedure is called quantization... Its essence lies in the transformation of a continuous variable into a discrete variable that takes on a finite set of values. These values ​​are called quantization levels... In the general case, the transformation is expressed by a step function (Fig. 1). If the intensity of the image sample belongs to the interval (i.e., when ), then the original sample is replaced by the quantization level, where quantization thresholds... It is assumed that the dynamic range of brightness values ​​is limited and equal.

Rice. 1. Function describing quantization

The main task in this case is to determine the values ​​of the thresholds and quantization levels. The simplest way to solve this problem is to divide the dynamic range into equal intervals. However, this is not the best solution. If the intensity values ​​of most of the image samples are grouped, for example, in the "dark" region and the number of levels is limited, then it is advisable to quantize unevenly. In the "dark" region, it is necessary to quantize more often, and less often in the "light" region. This will reduce the quantization error.

In digital image processing systems, they tend to reduce the number of levels and quantization thresholds, since the amount of information required to encode an image depends on their number. However, with a relatively small number of levels in a quantized image, false contours may appear. They arise as a result of an abrupt change in the brightness of the quantized image and are especially noticeable in the shallow areas of its change. False contours significantly degrade the visual quality of the image, since human vision is especially sensitive to contours. With uniform quantization, typical images require at least 64 levels.