How to set up smartphones and PCs. Informational portal
  • home
  • news
  • Analog and discrete coding method. Fourier processing of digital images

Analog and discrete coding method. Fourier processing of digital images

Images consisting of discrete elements, each of which can take only a finite number of distinguishable values ​​that change in a finite time, are called discrete. It should be emphasized that the elements of a discrete image, generally speaking, may have an unequal area and each of them may have an unequal number of distinguishable gradations.

As was shown in the first chapter, the retina transmits discrete images to the higher parts of the visual analyzer.

Their apparent continuity is only one of the illusions of the eye. This "quantization" of originally continuous images is not determined by the limitations that are associated with resolution optical system eyes and not even morphological building blocks visual system and functional organization nerve networks.

The image is divided into discrete elements by receptive fields that combine one or another number of photoreceptors. Receptive fields produce the primary selection of useful light signal by spatial and temporal summation.

The central part of the retina (fovea) is occupied only by cones, on the periphery outside the fovea there are both cones and rods. Under conditions of night vision, the cone fields in the central part of the retina have approximately the same size (about 5 "in angular measure). The number of such fields in the fovea, the angular dimensions of which are about 90", is about 200. The main role in the conditions of night vision is played by rod fields, which occupy the rest of the retinal surface. They have an angular size of about 1° over the entire surface of the retina. The number of such fields in the retina is about 3,000. Not only the detection, but also the examination of dimly lit objects under these conditions is carried out by the peripheral regions of the retina.

With an increase in illumination, another system of storage cells, the cone receptive fields, begins to play the main role. In the fovea, an increase in illumination causes a gradual decrease in the effective field strength until, at a brightness of about 100 asb, it is reduced to one cone. At the periphery, with an increase in illumination, rod fields are gradually turned off (slowed down) and cone fields come into action. Cone fields at the periphery, like foveal ones, have the ability to decrease depending on the light energy incident on them. The largest number of cones, which cone receptive fields can have with increasing illumination, grows from the center to the edges of the retina and at an angular distance of 50-60 ° from the center reaches approximately 90.

It can be calculated that under conditions of good daylight the number of receptive fields reaches about 800 thousand. This value approximately corresponds to the number of fibers in the human optic nerve. Distinguishing (resolution) of objects in daytime vision is carried out mainly in the fovea, where the receptive field can be reduced to one cone, and the cones themselves are located most densely.

While the number of storage cells in the retina can be determined to a satisfactory approximation, there are still insufficient data to determine the number of possible states of the receptive fields. Only some estimates can be made based on the study of the differential thresholds of the receptive fields. Threshold contrast in foveal receptive fields in a certain operating range of illumination is of the order of 1. In this case, the number of distinguishable gradations is small. In the entire range of rearrangement of the cone foveal receptive field, 8-9 gradations differ.

The accumulation period in the receptive field - the so-called critical duration - is determined on average by a value of the order of 0.1 sec., but at high levels lighting can, apparently, be significantly reduced.

In fact, the model describing the discrete structure transmitted images, should be even more difficult. It would be necessary to take into account the relationship between the dimensions of the receptive field, thresholds and critical duration, as well as the statistical nature of visual thresholds. But for now, this is not necessary. It suffices to imagine as an image model a set of elements of the same area, the angular dimensions of which are less than the angular dimensions of the smallest detail resolvable by the eye, the number of distinguishable states of which is greater than maximum number distinguishable gradations of brightness, and the time of discrete change of which is less than the flicker period at the critical flicker fusion frequency.

If we replace the images of real continuous objects of the external world with such discrete images, the eye will not notice the substitution.* Therefore, discrete images of this kind contain at least no less information than the visual system perceives. **

* Color and volumetric images can also be replaced by a discrete model.
** The problem of replacing continuous images with discrete ones is of great importance for film and television technology. Time quantization is at the heart of this technique. In pulse-code television systems, the image is also divided into discrete elements and quantized by brightness.

Tell and show Pascal as an example: 1) What is absolute and what is it for? 2) What is asm and what is it for? 3) What is

constructor and destructor and what is it for?

4) What is implementation and what is it for?

5) Name the Pascal modules (in the Uses line, for example crt) and what features does this module provide?

6) What is the type of variable: pointer (Pointer)

7) And finally: what does the symbol @ , #, $ , ^ mean?

1. What is an object?2. What is a system?3. What is the common name of an object? Give an example.4. What is a single object name? Give an example.5.

Give an example of a natural system.6. Give an example of a technical system.7. Give an example of a mixed system.8. Give an example of a non-material system.9. What is a classification?10. What is an object class?

1. Question 23 - list the modes of operation of the access subd:

Creating a table in design mode;
- create a table using the wizard;
- create a table by entering data.

2. what is vector format?

3. Can the following be attributed to service programs:
a) disk maintenance programs (copying, curing, formatting, etc.)
b) compression of files on disks (archivers)
c) fight against computer viruses and much more.
I myself think that here the answer is B - right or not?

4. What refers to the properties of the algorithm (a. discreteness, b. effectiveness, c. mass character, d. certainty, d. feasibility and understandability) - here I think that all options are correct. Right or not?

test 7 easy multiple choice questions

13. Processor clock speed is:

A. the number of binary operations performed by the processor per unit of time

B. the number of pulses generated per second that synchronize the operation of computer nodes

C. the number of possible processor calls to random access memory per unit of time

D. speed of information exchange between the processor and input / output devices

14. Specify the minimum necessary set devices designed for computer operation:

A. Printer, system unit, keyboard

B. processor, RAM, monitor, keyboard

C. processor, streamer, hard drive

D. monitor, system unit, keyboard

15. What is a microprocessor?

A. integrated circuit, which executes the commands coming to its input and controls

Computer work

B. a device for storing those data that are often used at work

C. device for displaying text or graphic information

D. alphanumeric output device

16.User interaction with software environment carried out using:

A. operating system

B. file system

C. Applications

d. file manager

17.Direct control software tools the user can carry out

Help:

A. operating system

B. GUI

C. UI

d. file manager

18. Ways to store data on physical media defines:

A. operating system

B. application software

C. file system

d. file manager

19. Graphical environment that displays objects and controls Windows systems,

Designed for user convenience:

A. hardware interface

b. user interface

C. desktop

d. software interface

20. Computer speed depends on:

A. clock frequency processor

B. Whether or not a printer is connected

C. operating system interface organization

D. external storage space

Analog and discrete image. Graphic Information can be represented in analog or discrete form. An example analog image can serve as a painting canvas, the color of which changes continuously, and an example of a discrete image, printed using inkjet printer drawing consisting of individual points different color. Analog (oil painting). Discrete.

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

Informatics Grade 9

summary other presentations

"Branching structure algorithms" - IF condition, THEN action. What do we know. Lesson structure. Branching algorithm. Run the algorithm and fill in the table. A student who scores from 85 to 100 points inclusive passes to the second round of the competition. Enter the number of points and determine if he passed 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 the condition, either one or another sequence of actions is performed.

"Creating Artificial Intelligence" - Simulation Approach. Approaches to the construction of artificial intelligence systems. evolutionary approach. Artificial Intelligence. Can cohabit with many people, helping to cope with personal problems. Structural approach. logical approach. Problems during development. Prospects for development and scope.

"Cyclic programs" - Digit. Loop with precondition. Find the amount. Loop with postcondition. Cycle with a parameter. Euclid's algorithm. Cyclic programs. Find the amount natural numbers. The concept of a cycle. An initial fee. Function tabulation. Calculate. Example. Dividers. Informatics. Find the number of numbers. Find. Find the number of three-digit natural numbers. Three digit numbers. Find the set of function values. Dollar conversion table.

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

"Working with e-mail" - E-mail address. Mailbox. Email protocol. file sharing network. Separation of addresses. Benefits of email. Email clients. Email Inventor. The address. Email. Email software. How email works. Teleconference. Mail server. File sharing.

"Processing in Photoshop" - Cool guys. How to distinguish a fake. Raster and vector images. Introduction. Top places. Adobe program Photoshop. Retouching. Photoshop Contests. Brightness adjustment. My friends. Practical part. Similar programs. Main part. Design. Unusual animals. Multiple image montage.

In the previous chapter, we studied linear spatially invariant systems in a continuous two-dimensional domain. In practice, we are dealing with images that have limited dimensions and at the same time are counted in a discrete set of points. Therefore, the methods developed so far need to be adapted, extended and modified so that they can be applied in this area. There are also several new points that require careful consideration.

The sampling theorem says under what conditions, from a discrete set of values, it is possible to accurately restore continuous image. We will also learn what happens when the conditions for its applicability are not met. All this is directly related to the development of visual systems.

Methods requiring transition to frequency domain, have become popular in part due to fast calculation algorithms discrete transformation Fourier. However, care must be taken as these methods involve periodic signal. We will discuss how this requirement can be satisfied and the consequences of violating it.

7.1. Image Size Limit

In practice, images always have finite dimensions. Consider a rectangular image with width and height R. Now there is no need to take integrals in the Fourier transform in infinite limits:

Curiously, in order to restore the function, we do not need to know at all frequencies. Knowing what at is a hard constraint. In other words, a function that is nonzero only in a limited region of the image plane contains much less information than a function that does not have this property.

To verify this, imagine that the screen plane is covered with copies given image. In other words, we expand our image to a function that is periodic in both directions

Here, is the largest integer less than x. The Fourier transform of such a multiplied image has the form

Via appropriately selected convergence factors in ex. 7.1 it is proved that

Hence,

whence we see that it is equal to zero everywhere except for a discrete set of frequencies. Thus, to find it is enough for us to know at these points. However, the function is obtained from a simple clipping of the section for which . Therefore, in order to restore it is enough for us to know only for everyone. This is a countable set of numbers.

Note that the transformation of the periodic function turns out to be discrete. Reverse transformation can be represented as a series, since

Digital photography or otherwise bitmap is an array of numbers captured by brightness level sensors in a two-dimensional plane. Knowing that from a mathematical point of view, a thin lens performs the Fourier transform of images placed in focal planes, it is possible to create image processing algorithms that are analogous to image processing in a classical optical system.

The formula of such algorithms will look like this:

  1. Z=FFT(X) – direct two-dimensional Fourier transform
  2. Z′=T(Z) – application of a function or transparency to the Fourier image of the image
  3. Y=BFT(Z′) – inverse two-dimensional Fourier transform
Fourier transforms are calculated using fast discrete Fourier transform algorithms. Although the optical system of lenses performs the Fourier transform on the continuous range of the argument and for the continuous spectrum, but when passing to digital processing data, the Fourier transform formulas can be replaced by discrete Fourier transform formulas.

Implementation examples

  • Image Blur Algorithm
The implemented algorithms are part of an open source library. source code FFTTools. Internet address: github.com/dprotopopov/FFTTools

Image Blur Algorithm

In optical systems, the aperture located in the focal plane is a simple hole in the screen. As a result of passing luminous flux through the diaphragm, high frequency waves (with shorter wavelengths) pass through the obstruction, and low frequency waves (with longer wavelengths) are cut off by the screen. This improves the sharpness of the resulting image. If we replace the hole in the screen with an obstacle in the screen, then the result will be blurred image, since it will be formed from the frequencies of waves of large lengths.

Algorithm:

  1. Calculate the array Z′=T(Z), where T is the zeroing of the rows and columns located in the given inner areas of the matrix-argument corresponding to high frequencies 5. (that is, the zeroing of the Fourier expansion coefficients corresponding to high frequencies)

Image sharpening algorithm

In optical systems, the aperture located in the focal plane is a simple hole in the screen. As a result of the passage of the light flux through the diaphragm, high frequency waves (with shorter wavelengths) pass through the obstacle, and low frequency waves (with longer wavelengths) are cut off by the screen. This improves the sharpness of the resulting image.

Algorithm:

  1. Let X(N1,N2) be an array of image pixel brightnesses.
  2. Calculate Px = mean (rms) brightness of pixels in array X
  3. Calculate array Z=FT(X) - direct two-dimensional discrete Fourier transform
  4. Save the value L=Z(0,0) - corresponding to the average brightness of the pixels in the original image
  5. Calculate the array Z′=T(Z), where T is the zeroing of the rows and columns located in the given outer regions of the argument matrix corresponding to low 6. frequencies (that is, the zeroing of the Fourier expansion coefficients corresponding to low frequencies)
  6. Restore the value Z'(0,0)=L - corresponding to the average brightness of the original image pixels
  7. Calculate array Y=RFT(Z′) – inverse 2D discrete Fourier transform
  8. Calculate Py = mean (rms) brightness of pixels in array Y
  9. Normalize the array Y(N1,N2) by the average brightness level Px/Py

Image scaling algorithm

In optical systems, the light flux in the focal plane of the system is the Fourier transform of the original image. The size of the image obtained at the output of the optical system is determined by the ratio of the focal lengths of the objective and the eyepiece.

Algorithm:

  1. Let X(N1,N2) be an array of image pixel brightnesses.
  2. Calculate Px = mean (rms) brightness of pixels in array X
  3. Calculate array Z=FT(X) - direct two-dimensional discrete Fourier transform
  4. Calculate the array Z′=T(Z), where T is either adding zero rows and columns of the matrix corresponding to high frequencies, or deleting the rows and columns of the matrix corresponding to high frequencies to obtain the required size of the final image
  5. Calculate array Y=RFT(Z′) – inverse 2D discrete Fourier transform
  6. Calculate Py = mean (rms) brightness of pixels in array Y
  7. Normalize the array Y(M1,M2) by the average brightness level Px/Py
Software used
  • Microsoft visual studio 2013 C# - environment and programming language
  • EmguCV/OpenCV - C++ library of structures and algorithms for image processing
  • FFTWSharp/FFTW – C++ library implementing fast discrete Fourier transform algorithms

Image Blur Algorithm

Algorithm code

///

/// Clear internal region of array /// /// Array of values /// Internal blind region size private static void Blind(Complex[,] data, size) ( int n0 = data.GetLength(0); int n1 = data.GetLength(1); int n2 = data.GetLength(2); int s0 = Math.Max(0, (n0 - size.Height)/2 ); int s1 = Math.Max(0, (n1 - size.Width)/2); int e0 = Math.Min((n0 + size.Height)/2, n0); int e1 = Math.Min(( n1 + size.Width)/2, n1); for (int i = s0; i< e0; i++) { Array.Clear(data, i*n1*n2, n1*n2); } for (int i = 0; i < s0; i++) { Array.Clear(data, i*n1*n2 + s1*n2, (e1 - s1)*n2); } for (int i = e0; i < n0; i++) { Array.Clear(data, i*n1*n2 + s1*n2, (e1 - s1)*n2); } } /// /// Blur bitmap with the Fastest Fourier Transform /// /// Blured bitmap public Bitmap Blur(Bitmap bitmap) ( using (var image = new Image (bitmap)) ( int length = image.Data.Length; int n0 = image.Data.GetLength(0); int n1 = image.Data.GetLength(1); int n2 = image.Data.GetLength(2); var doubles = new double;Buffer.BlockCopy(image.Data, 0, doubles, 0, length*sizeof (double));double power = Math.Sqrt(doubles.Average(x => x*x));var input = new fftw_complexarray(doubles.Select(x => new Complex(x, 0)).ToArray()); var output = new fftw_complexarray(length); fftw_plan.dft_3d(n0, n1, n2, input, output, fftw_direction. Forward, fftw_flags.Estimate).Execute(); Complex complex = output.GetData_Complex(); var data = new Complex; var buffer = new double; GCHandle complexHandle = GCHandle.Alloc(complex, GCHandleType.Pinned); GCHandle dataHandle = GCHandle .Alloc(data, GCHandleType.Pinned); IntPtr complexPtr = complexHandle.AddrOfPinnedObject(); IntPtr dataPtr = dataHandle.AddrOfPinnedObject(); Marshal.Copy(complexPtr, buffer, 0, buffer.Length); Marshal.Copy(buffer, 0 , dataPtr, buffer.Length); Blind(data, _blind erSize); Marshal.Copy(dataPtr, buffer, 0, buffer.Length); Marshal.Copy(buffer, 0, complexPtr, buffer.Length); complexHandle.Free(); dataHandle.Free(); input.SetData(complex); fftw_plan.dft_3d(n0, n1, n2, input, output, fftw_direction.Backward, fftw_flags.Estimate).Execute(); double array2 = output.GetData_Complex().Select(x => x.Magnitude).ToArray(); double power2 = Math.Sqrt(array2.Average(x => x*x)); doubles = array2.Select(x =>

Image sharpening algorithm

Algorithm code

///

/// Clear external region of array /// /// Array of values /// External blind region size private static void Blind(Complex[,] data, Size size) ( int n0 = data.GetLength(0); int n1 = data.GetLength(1); int n2 = data.GetLength(2); int s0 = Math. Max(0, (n0 - size.Height)/2); int s1 = Math.Max(0, (n1 - size.Width)/2); int e0 = Math.Min((n0 + size.Height)/ 2, n0); int e1 = Math.Min((n1 + size.Width)/2, n1); for (int i = 0; i< s0; i++) { Array.Clear(data, i*n1*n2, s1*n2); Array.Clear(data, i*n1*n2 + e1*n2, (n1 - e1)*n2); } for (int i = e0; i < n0; i++) { Array.Clear(data, i*n1*n2, s1*n2); Array.Clear(data, i*n1*n2 + e1*n2, (n1 - e1)*n2); } } /// /// Sharp bitmap with the Fastest Fourier Transform /// /// sharpened bitmap public Bitmap Sharp(Bitmap bitmap) ( using (var image = new Image (bitmap)) ( int length = image.Data.Length; int n0 = image.Data.GetLength(0); int n1 = image.Data.GetLength(1); int n2 = image.Data.GetLength(2); var doubles = new double;Buffer.BlockCopy(image.Data, 0, doubles, 0, length*sizeof (double));double power = Math.Sqrt(doubles.Average(x => x*x));var input = new fftw_complexarray(doubles.Select(x => new Complex(x, 0)).ToArray()); var output = new fftw_complexarray(length); fftw_plan.dft_3d(n0, n1, n2, input, output, fftw_direction. Forward, fftw_flags.Estimate).Execute(); Complex complex = output.GetData_Complex(); Complex level = complex; var data = new Complex; var buffer = new double; GCHandle complexHandle = GCHandle.Alloc(complex, GCHandleType.Pinned) ; GCHandle dataHandle = GCHandle.Alloc(data, GCHandleType.Pinned); IntPtr complexPtr = complexHandle.AddrOfPinnedObject(); IntPtr dataPtr = dataHandle.AddrOfPinnedObject(); Marshal.Copy(complexPtr, buffer, 0, buffer.Length); Marshal. Copy(buffer, 0, dataPtr, buffer.Le ngth); Blind(data, _blinderSize); Marshal.Copy(dataPtr, buffer, 0, buffer.Length); Marshal.Copy(buffer, 0, complexPtr, buffer.Length); complexHandle.Free(); dataHandle.Free(); complex = level; input.SetData(complex); fftw_plan.dft_3d(n0, n1, n2, input, output, fftw_direction.Backward, fftw_flags.Estimate).Execute(); double array2 = output.GetData_Complex().Select(x => x.Magnitude).ToArray(); double power2 = Math.Sqrt(array2.Average(x => x*x)); doubles = array2.Select(x => x*power/power2).ToArray(); Buffer.BlockCopy(doubles, 0, image.Data, 0, length*sizeof (double)); return image.Bitmap; ) )

Image scaling algorithm

Algorithm code

///

/// Copy arrays /// /// input array /// output array private static void Copy(Complex[,] input, Complex[,] output) ( int n0 = input.GetLength(0); int n1 = input.GetLength(1); int n2 = input.GetLength(2); int m0 = output.GetLength(0);int m1 = output.GetLength(1);int m2 = output.GetLength(2);int ex0 = Math.Min(n0, m0)/2;int ex1 = Math.Min(n1 , m1)/2;int ex2 = Math.Min(n2, m2);Debug.Assert(n2 == m2);for (int k = 0;k< ex2; k++) { for (int i = 0; i <= ex0; i++) { for (int j = 0; j <= ex1; j++) { int ni = n0 - i - 1; int nj = n1 - j - 1; int mi = m0 - i - 1; int mj = m1 - j - 1; output = input; output = input; output = input; output = input; } } } } /// /// Resize bitmap with the Fastest Fourier Transform /// /// Resized bitmap public Bitmap Stretch(Bitmap bitmap) ( using (var image = new Image (bitmap)) ( int length = image.Data.Length; int n0 = image.Data.GetLength(0); int n1 = image.Data.GetLength(1); int n2 = image.Data.GetLength(2); var doubles = new double;Buffer.BlockCopy(image.Data, 0, doubles, 0, length*sizeof (double));double power = Math.Sqrt(doubles.Average(x => x*x));var input = new fftw_complexarray(doubles.Select(x => new Complex(x, 0)).ToArray()); var output = new fftw_complexarray(length); fftw_plan.dft_3d(n0, n1, n2, input, output, fftw_direction. Forward, fftw_flags.Estimate).Execute(); Complex complex = output.GetData_Complex(); using (var image2 = new Image (_newSize)) ( int length2 = image2.Data.Length; int m0 ​​= image2.Data.GetLength(0); int m1 = image2.Data.GetLength(1); int m2 = image2.Data.GetLength(2); var complex2 = new Complex; var data = new Complex; var data2 = new Complex; var buffer = new double; GCHandle complexHandle = GCHandle.Alloc(complex, GCHandleType.Pinned); GCHandle dataHandle = GCHandle.Alloc(data, GCHandleType.Pinned ); IntPtr complexPtr = complexHandle.AddrOfPinnedObject(); IntPtr dataPtr = dataHandle.AddrOfPinnedObject(); Marshal.Copy(complexPtr, buffer, 0, buffer.Length); Marshal.Copy(buffer, 0, dataPtr, buffer.Length); complexHandle.Free(); dataHandle.Free(); Copy(data, data2); buffer = new double; complexHandle = GCHandle.Alloc(complex2, GCHandleType.Pinned); dataHandle = GCHandle.Alloc(data2, GCHandleType.Pinned); complexPtr = complexHandle.AddrOfPinnedObject(); dataPtr = dataHandle.AddrOfPinnedObject(); Marshal.Copy(dataPtr, buffer, 0, buffer.Length); Marshal.Copy(buffer, 0, complexPtr, buffer.Length); complexHandle.Free(); dataHandle.Free(); var input2 = new fftw_complexarray(complex2); var output2 = new fftw_complexarray(length2); fftw_plan.dft_3d(m0, m1, m2, input2, output2, fftw_direction.Backward, fftw_flags.Estimate).Execute(); double array2 = output2.GetData_Complex().Select(x => x.Magnitude).ToArray(); double power2 = Math.Sqrt(array2.Average(x => x*x)); double doubles2 = array2.Select(x => x*power/power2).ToArray(); Buffer.BlockCopy(doubles2, 0, image2.Data, 0, length2*sizeof (double)); return image2.Bitmap; ) ) )

Top Related Articles