Optimization of DMD-based independent amplitude and phase modulation: a spatial resolution and quantization

This paper presents the results of a comprehensive study on the optimization of the optical system for independent amplitude and phase wavefront manipulation, which is based on a digital micromirror device implementation. The parameters of generated binary fringe patterns to reach the optimal quality of target complex-valued wavefront have been found for several examples, and a general algorithm for DMD pattern optimization is described. It was shown that a trade-off between spatial resolution and quantization of the target amplitude and phase distribution should be achieved. The increase of carrier frequency results in higher spatial resolution of the modulated complex wave but decreases its quantization. The dependence of the best DMD-pattern generation parameters on the type of target complex wavefront is discussed in terms of spatial resolution and quantization degree.


Introduction
The synthesis of wavefronts with known characteristics has gained the interest of many researchers in the field of photonics. Some of the tasks of wavefront shaping are high-resolution microscopy 1 , laser beam shaping 2, 3 , scattering media characterization [4][5][6] , holographic displays 7 , quantum cryptography 8 , metrology 9 , compressed sensing 10 , 3D bioprinting and lithography 11 . To date, there exists a range of static and dynamic wavefront modulators, such as diffraction optical elements 12 , metasurfaces 13 , adaptive optical elements 14 , which provide the possibility to operate with the amplitude, phase, or polarization of the beam profile in a wide range of wavelengths 15,16 . Adaptive spatial light modulators with programmable precise control of the wavefront have become a valuable tool for various applications, e.g., in imaging systems 17 . Two types of such devices can be outlined: liquid crystal-based spatial light modulators and micro-electromechanical systems (MEMS). The former includes such subtypes as transmissive liquid crystal, reflective liquid crystal on silicon, and ferroelectric liquid crystal. MEMS-based spatial light modulators are presented by digital micromirror device (DMD), active micromirror matrix, and grating light valve 18 .
Each of the devices characterized by the type of modulation, among which they are distinguished: purely amplitude, pure-phase, and simultaneous amplitude-phase modulation, and each of modulators has its benefits and disadvantages [18][19][20] . The choice of the required device is determined by the peculiarities of the problem to be solved in a particular case. Several important characteristics of wavefront modulators can be highlighted: the speed of operation, dynamic range, number and size of pixels, modulation efficiency. In applications where high speed is required and spatial resolution can be sacrificed to achieve high light modulation rates 21 , the use of DMD, constructively assuming only binary modulation, is preferable due to its high refresh rate (22 kHz). Over the past few years, such devices have been actively used in various studies 11,21 , and commercial devices (e.g., holotomographic microscope, developed by Tomocube™). Compared to other modulators, DMD has high switching speed, high light efficiency, high fill-factor (90%), and relatively low cost [22][23][24] . It provides a high enhancement factor in the task of focusing through the scattering medium or improving contrast in optical imaging and high beam-shaping fidelity 19,20 . This is particularly relevant in biomedical applications where rapid processes are involved, modulation of ultrashort radiation, or the possibility of real-time measurement should be provided 11,21,25 . DMD consists of a CMOS-placed micromirrors array, each of which can have only two stable states: "On" (+12 • ) and "Off" (−12 • ) 21 . Each micromirror represents a single pixel of the projected image. In addition, the use of binary (1-bit) holograms is convenient in terms of data capacity, for example, for implementation in holographic displays 26 . Another advantage of binary holograms over grayscale holograms is also that they can be easily printed 27 .
Various approaches have previously been proposed for generating binary DMD-patterns or converting grayscale holograms into binary holograms, for instance, global and local thresholding methods 28 , iterative techniques 29,30 , error diffusion method 31 , the superpixel-based method 32 , off-axis computer-generated Lee holography technique 33 . The latter is an efficient and fast method, especially eligible for ultrafast radiation modulation 34 . In this method, the 1 st diffraction order Fourier filtering is utilized, commonly with an aperture in experimental settings, which affects spatial resolution. The number of available amplitude levels (or image quantization) depends on the number of pixels in the fringe period in DMD-generated pattern 35 . These parameters significantly affect the image quality. Various methods of quantization and resolution improvement were proposed. The study by Reimers et.al. 36 has elucidated the optimal resolution obtaining for different object detection in terms of hyperspectral imaging. The results reported by Zhang et. al. 37 suggest that in single-pixel imaging, the quantization error caused by binarization can be eliminated by error diffusion dithering and a high ratio of upsampling. In their recent study, Chipala and Kozacki 7 demonstrated the correlation between the dispersion of the DMD and the resolution of holographic images, and proposed the method of image quality improvement. However, the area of achieving maximum quantization and resolution values by optimizing the experimental setup and binarization parameters has not been explored in depth.
Thus, in a given work, we developed an approach for the optimization of the technique of independent amplitude and phase modulation based on DMD and binarization parameters to obtain the optimal spatial resolution and quantization depending on the target complex wave. Binary DMD patterns, generated by the Lee method 33 , and the experimental setup of off-axis holography were used to investigate the spatial resolution and image quantization depending on the number of pixels per fringe period and aperture size for the 1 st diffraction order filtration. To obtain the optimal parameters, the root mean square error (RMSE) for each case was calculated. In addition, experimental validation of the proposed optimization method was performed. It was established that for applications requiring high spatial resolution, it was necessary to sacrifice the number of amplitude gradations to increase the filtration aperture in Fourier domain. The work also clearly demonstrates that for applications where it is important to preserve the gradation, it is possible to increase the binary fringe period of DMD-pattern.
The paper is organized as follows: In Section 2, an experimental setup and principles of independent amplitude and phase wavefront modulation using binary DMD are described. In Section 3, the results of a detailed study of the dependence of the modulated wavefront quality on the parameters of wavefront modulation are presented. The spatial resolution and image quantization is considered depending on the filtration aperture size and carrier frequency in Subsection 3.1. In Subsection 3.2, the calculation of the optimal aperture and binary fringe period is demonstrated, and Subsection 3.3 shows experimental results of wavefront manipulation using random and optimized DMD pattern.

Experimental setup
The experimental setup is represented by the Mach-Zender interferometer with DMD in the object beam ( Fig. 1).
This setup provides an opportunity to modulate the wavefront using DMD, as well as to evaluate its modulation quality by image reconstruction with off-axis digital holograms. DMD was operated using controller DLPC900 (modulation frequency 9 kHz (1-bit image), 1 kHz (8-bit image)). The laser beam with the wavelength of 532 nm was increased in diameter by the beam expander BE, then it was divided into object and reference waves by the beam splitter BS 1 . The object beam was incident on the DMD (Texas Instrument Light Crafter DLP6500FYE in our case with 1920×1080 micromirrors with a size of 7.56 µm), where the corresponding pattern was displayed on the matrix. Then it was focused with the lens L 1 to the Fourier plane, where the 1 st diffraction order was separated by the spatial filter SF with aperture size scaleable along the x coordinate. Afterward, the lens L 2 , which together with L 1 forms telecentric 4 f -system, collimated the radiation. The desired field distribution was formed in the target plane TP after the second beamsplitter BS 2 . The presence of BS 2 ensured the location of this plane simultaneously both at the end of the diagnostic arm, namely, in the sensor plane (CMOS) and in the application arm. The beamsplitter BS 2 enabled performing both the simultaneous monitoring of the wave, independently modulated in amplitude and phase by off-axis digital holography using CMOS sensor in the monitoring arm (indicated with green dotted frame in Fig. 1) and utilized the modulated wave for any research purposes in the application arm (indicated with blue dash-dotted frame in Fig. 1. Plane reference wave (when the shutter S is opened) passes through the mirrors M 4 and M 5 and enabled detection of formed amplitude and phase distributions in the application arm. In our study, we used the local least square estimation algorithm 38,39 for wavefront reconstruction.
It should be noted that some tasks may require to have the wavefront of a specific structure beyond the target plane. This wavefront may be engineered very precisely by means of an analysis of the resulting field at TP in the diagnostic arm and solving the diffractive equations, which describe the wavefront propagation beyond the TP 40 (case 1 in Fig. 1). Then, this information should be taken into account in the iterative feedback loop. The alternative is not to propagate wavefront numerically, but to image TP further by an additional telecentric system with custom magnification 41 (case 2 in Fig. 1). It is also necessary to mention that independent values in amplitude and phase distributions may be obtained in the TP (or in the corresponding image plane, as a result of the projection of the 4-f telecentric system) only, since the diffraction leads to the projection of phase structure on the amplitude.

Principles of binary complex wavefront modulation
In this subsection, the basic principles of independent amplitude and phase modulation of the wavefront using DMD generated binary off-axis digital hologram are considered and discussed. One of the possible approaches for independent amplitude and phase modulation was proposed by Lee et al. 33 is to generate a binary pattern and "reconstruction" of the synthetic off-axis digital hologram.
It is known that fringes in an analog hologram can be used to change the phase and amplitude of the incident light wave, thus producing an image of the recorded object. Similar to analog holography, the variation of binary fringe parameters such as width and periodicity in the formed binary DMD pattern, enables manipulation of amplitude and phase distributions. The approach to obtaining independent amplitude-phase modulation from binary amplitude modulation is based on the spatial filtering of the wave in one of the diffraction orders arising from the reflection of an incident wave from DMD. It can be conducted, for example, by spatial filtration of this diffraction order if the binary pattern is an off-axis hologram with high enough carrier frequency.
Experimentally, it is usually implemented by Fourier transform performed using a concave lens (L1), as demonstrated in Fig. 1. Filtration of the first diffraction order using adjustable iris aperture (SF), while inverse Fourier transform by another concave lens L2 enables the reconstruction of the target wave modulated by DMD.
The spatial frequency of the binary hologram is calculated using the carrier frequency and phase change as follows 33 : where k x and k x are carrier frequencies in the x and y directions, which are inversely proportional to the specified fringe period due to the wavefront tilt. The second summand refers to the spatial frequency of the wave with target phase distribution. DMD-pattern h(x, y) was formed using the limiter to obtain amplitude hologram binarization 33 : where A(x, y) is the target amplitude, φ (x, y) is the target phase, k x and k y are the carrier frequencies in DMD pixels of the binary off-axis hologram in the x and y direction. The left part of the inequality (2) is responsible for the encoding of the phase distribution, while the amplitude distribution is encoded by the right part. To show this segregation of amplitude and phase parts, we consider DMD-pattern simulated for amplitude-only, phase-only, and complex-valued (simultaneous independent amplitude and phase) modulations (Fig. 2). The first example of varying amplitude (2D Gaussian distribution) and constant phase distributions is presented in Fig. 2 (ac). The target amplitude image ( Fig. 2 (a) and the simulated binary pattern ( Fig. 2 (b)) demonstrate how the complex wave amplitude can be modulated by the variation of the relative amount of DMD pixels at On-state (the On-pixels). The plot of phase part of inequality, indicated by the red line, clearly shows how the inequality (2) provides an opportunity to readily synthesize a binary pattern for a given amplitude distribution. The right (amplitude) and left (phase) parts of the inequality are presented by red and blue lines, respectively. While in this case, the phase distribution is constant, the left part of the inequality representing the phase distribution, is a simple periodical function due to the linear increase of φ (x,y) 2π + (k x · x + k y · y) term and 'mod1' operation. However, the target amplitude image is changed with x coordinate (red line), thus varying the relative amount of the On and Off pixels. If the amplitude part is larger than the phase part, the pixel is On, otherwise it remains Off. In this case, the ratio between the On pixels and the total number of pixels per one period (the On pixel occupancy coefficient η) is changed from 0.3 to 0.5 while the target amplitude increases from ≈0.13 to ≈0.25.
Due to the constant phase distribution, the carrier frequency, as well as the value of spatial frequency of binary hologram here is constant and equals 2π 12 . Subsequently, the fringe period is 12 DMD pixels (indicated with black arrows in Fig. 2 (c)). The phase-only variation is demonstrated with the target spherical phase distribution and constant amplitude. Fig. 2 (d-f) show the target phase distribution (Fig. 2 (d)), the simulated DMD pattern (Fig. 2 (e)) and the plotted functions of DMD pattern pixels, amplitude part and phase part ( Fig. 2 (f)) of inequality (2) in the case of phase-only modulation. In this example, the right part of the inequality (2) is constant due to the absence of amplitude modulation. However, variation of the target phase along x axis results in the change of φ (x,y) 2π + (k x · x + k y · y) slope and alteration of the phase part periodicity and spatial frequency of binary hologram. The black arrows in Fig. 2 (f) demonstrate how the phase variation results in the change of the fringe period from 29 to 20 pixels. At the same time, η is constant among the binary hologram and equal to 0.5. Therefore, phase modulation is achieved by the variation of the binary fringe period, while amplitude modulation is obtained due to the variation of the On pixel occupancy coefficient. Since it is possible to separately vary these two parameters in each local area of the image, the independent manipulation of the phase and amplitude distributions can be achieved.
An example of independent modulation of both amplitude and phase parts of the complex wavefront is presented in Fig. 2 (g-i). It can be noted that both fringe periodicity and the On pixel occupancy coefficient are changed due to amplitude and phase variation.

Experimental settings impact on the quality of the resulting wavefront
It was previously described how a binary pattern is generated for independent modulation of amplitude and phase distributions. However, for practical applications, the quality of the resulting wavefront, which is influenced by the experimental setup parameters, is crucial. One of the most important steps of modulation is the spatial filtration of one diffraction order. A concave lens is usually utilized for this purpose, in the focal plane of which the filtering is performed. This is the most common approach, which was used, e.g., in 21,42 .
In this section, the modulated wavefront quality is discussed and analyzed as a function of the 1 st order filtration aperture size and carrier frequency of binary hologram. To demonstrate the impact of experimental parameters on quality of the reconstructed wavefront, the "mountain" and "sky" images were taken as target amplitude and phase distributions. These two images were chosen since the impact of both gray levels quantization and spatial resolution can be visible on them as they have both smoothly and sharply varying gray levels objects.
If the target amplitude and phase distributions have a large number of small details, the 1 st order filtration can be a challenging problem due to the presence of high spatial frequencies overlapping with other diffraction orders. In this case, target wavefront blurring will be observed due to the inevitable loss of high spatial frequencies and corresponding data of small details. However, even under these conditions, it is possible to find the optimal aperture size, which enables obtaining a wavefront with minimal error. Fig. 3 demonstrates the impact of filtration aperture size and carrier frequency or fringe period variation on the generated complex wave and reveals the relationship between these parameters and image quality.
The first column of Fig. 3 represents the case with an optimal aperture size and fringe period. Very small filtration area (Fig. 3(d)) eliminates high spatial frequencies, which results in image blurring, as it can be seen in the fourth column ( Fig. 3 (i, n)). On the other hand, excessively large aperture size (Fig. 3 (e)) leads to the adjacent diffraction orders penetration through the filtration aperture and the image quality reduction by defect appearance (Fig. 3 (j, o)).
To simplify the filtration and increase the aperture size, the distance between diffraction orders can be increased by the increment of the carrier frequency. The dependence between binary fringe periodicity and image quality was analyzed during carrier frequency variation. The second and third columns of Fig. 3 demonstrate filtration of the 1 st diffraction order in Fourier plane and obtained amplitude and phase distributions at various values of carrier frequency. These results show a significant improvement in spatial resolution due to the carrier frequency increase. However, the increase of carrier frequency is associated with the decrease of the average fringe period as well. As was demonstrated above and shown in Fig. 2, modulation of the wavefront amplitude and phase is possible due to the local variation of (1) the On pixel occupancy coefficient and (2) fringe period. The latter is related with the image quantization and its alteration results in the inevitable variation of the number of amplitude levels of the obtained distribution, as it can be seen in Fig. 3 (g, l, h, m). The explicit demonstration of the correlation between the fringe period and the image quantization is shown in insets for intensity distributions. Since the amplitude modulation is based on the variation of the On pixel occupancy coefficient, only six combinations of amplitude values can be encoded for fringe period of 7, while for the fringe period of 21 enables the encoding of 20 various values of the target amplitude (see insets for Fig. 3 (f, g, h)). Similarly, the phase value in the local area can be changed by variation of the fringe period. However, if the typical fringe period is small, it cannot be neither significantly decreased nor increased, which results in limited capability for phase value variation and low quantization of phase shift. Therefore, in the case of lower carrier frequency (larger fringe period), the image quantization level is high. This effect is also demonstrated in insets for the obtained phase distributions. For example, in insets for Fig. 3 (l) only one phase value is encoded (one color), while for insets for Fig. 3 (k), it is clear that there are at least two phase values. Furthermore, the fringe period in inset for Fig. 3 (m) changes by 1-2 pixels, allowing the smaller phase variations to be encoded. Therefore, increasing the fringe period (reducing carrier frequency) enables encoding smaller variations in the amplitude and phase of the wavefront, while complicating the first diffraction order filtering.
Thus, it was shown that the increase of carrier frequency results in higher spatial resolution but lower amplitude and phase quantization. Therefore, in the general case of DMD-based wavefront manipulation, the trade-off between two image quality compounds, namely, spatial resolution and quantization, should be sustained. If high spatial resolution is required for the Figure 3. Dependence of reconstructed image quality on aperture size and fringe period (carrier frequency). Fourier spectra with indicated 1 st order filtration apertures of different sizes (black circles) (a -e). The spectra are shifted so that the 1 st diffraction order is located in the center; obtained intensity distributions (f -j). Obtained phase distributions (k -o). Insets: enlarged fragments of corresponding DMD patterns and fragments of phase or intensity distributions. modulated wavefront, a large enough carrier frequency of the binary pattern should be chosen to increase the distance between diffraction orders. However, if the target complex wave suggests smoothly varying amplitude and phase distributions, the carrier frequency should be limited to increase amplitude and phase quantization. In the next subsection, several examples of various amplitude and phase images encoded in a binary pattern will be presented. Moreover, such a trade-off between these two image properties can be easily understood as the binary diffraction pattern may contain a limited amount of initial information about the target wavefront. More information can be provided either about spatial resolution (by the increase of carrier frequency) or quantization (by the decrease of carrier frequency), although both of these complex wave characteristics cannot be improved at the same time.

Optimization of aperture size and carrier frequency for modulation error reduction
The results presented above demonstrate a strong correlation between image quality and aperture size and carrier frequency or fringe period. In dependence on the target wavefront parameters, various binary patterns with different carrier frequencies should be generated. In this section, we consider the optimization of wavefront modulation quality for several representative examples of target complex waves. To perform such optimization, we numerically simulated DMD-based target wavefront modulation with various carrier frequencies and filtration aperture sizes and calculated the wavefront modulation error as root mean square error (RMSE) from the target amplitude or phase distributions. Minimization of the calculated error enables obtaining the optimal parameters of DMD-generated binary pattern for a particular target complex wave.
As it will be shown later, the encoding of sharp image elements such as resolution test charts requires high spatial resolution, which can be achieved by using a large spatial aperture size. In this case, a small number of amplitude or phase levels is usually required for successive modulation of the target complex wave. On the other hand, in the case of relatively smooth objects, amplitude or phase quantization is a more important parameter than spatial resolution. Thus, the carrier frequency as well as aperture size can be decreased in this case.
Let us consider the encoding of several target objects containing different range of spatial frequencies: "cat", "circles", 2D Gaussian distribution, USAF 1951 test chart, phase object characterized by high and low spatial frequencies content (mixed-frequency phase object), which was utilized in 43 . The difference between objects was analyzed using radial-averaged structure of angular spectrum, which is presented in the forms of diagrams of Fourier spectrum magnitude in logarithmic scale along spatial frequency in Fig. 4-7. Object "circles" (high-frequency object) and 2D Gaussian distribution (low-frequency object) were used as the target intensity or phase distribution, while the corresponding phase or intensity distributions were two-dimensional arrays with a constant value at each point (amplitude-only and phase-only modulation). Object "cat" was used for amplitude-only modulation, USAF 1951 test chart, and mixed-frequency phase object were used for phase-only modulation. In addition, complex modulation was performed for "sky" image as amplitude and "mountain" image as phase target distributions.
To investigate the dependence of the modulation quality on major DMD modulation parameters, each of these images was encoded with the aperture size ranging from 1 to 720 pixels and the fringe period varying from 1 to 170 pixels. For each of the obtained images, its RMSE from the target wave was calculated and represented as a 2D pseudocolored surface (see Fig. 4-7). In the case of "cat" amplitude encoding, both spatial resolution and quantization levels are crucial, as various parts of this image may have high requirements for each of these characteristics. A smooth subsidence of the angular spectrum with the spatial frequency increment is observed. Moreover, the angular spectrum structure is characterized by both high and low spatial frequencies in the Fourier spectrum. Therefore, the best amplitude modulation (inset 2 in Fig. 4) is achieved at intermediate values of both carrier frequency and aperture size. Fig. 4 shows the image defects that appear in the non-optimal selection of aperture size and fringe period. Inset 1 shows insufficient amplitude levels at high spatial resolution, inset 2 shows minimal modulation error, inset 3 has low spatial resolution at a large number of grayscale levels, and inset 4 shows defects due to the passing of several adjacent diffraction orders.
The curve separating the maximum error area (orange and red colors) is hyperbola-shaped because of the inverse proportionality of the assigned fringe period and the distance between the diffraction orders. Therefore, all images obtained with parameters above this curve will be distorted by defects such as those in inset 4 due to the passing of several adjacent diffraction orders. Since various objects pose a different amount of high spatial frequencies, the hyperbola-shaped curve location varies slightly depending on the object. Thus, for further objects, only the area under this curve was considered.
The object "circles" is used as a demonstration of the small elements content influence on optimal aperture size and fringe period selection. The object 2D Gaussian distribution is used to demonstrate the example of high image quantization and low requirements to spatial resolution. Fig. 5 shows the maps of amplitude and phase RMSE in the case of amplitude-only and phase-only field variations, respectively, for these two objects. The insets show the examples of the obtained intensity and phase distributions at the indicated parameters, corresponding to the minimum RMSE.
In the first example, it is important to achieve the maximum possible aperture size to provide sufficient spatial resolution. The target image includes repetitive circles of several fixed sizes. Therefore, the structure of the angular spectrum contains 7/14 Figure 5. Amplitude (a, c) and phase (b, d) RMSE map dependent on aperture size and fringe period for the "circles" (a, b) and 2D Gaussian distribution (c, d) objects. Insets: enlarged fragments, obtained intensity (a, c) and phase (b, d) distributions at the points indicated by the markers. Target distributions with corresponding angular spectrum structure diagrams are shown on the left in black rectangles. smooth oscillations around several values of certain spatial frequencies. Simultaneously, for the second example, a decrease in the distance between diffraction orders and the aperture size does not significantly deteriorate the image quality due to the absence of small details in this image. Its angular spectrum diagram is characterized by prevailing number of low spatial frequencies with almost total absence of high ones. As shown in Fig. 5 (a, b), the minimal error area is local and global minimum corresponds to large apertures and small fringe periods. In the case of 2D Gaussian distribution, the high error of amplitude and phase modulation corresponds only to small fringe periods (high carrier frequencies) (Fig. 5 (c, d)). The minimum error of wavefront modulation can be achieved in case of small aperture size and large fringe period. Fig. 6 demonstrates results of phase-only modulation of an object which contain a different range of spatial frequencies, i.e., combine scattering structures with different sizes of inhomogeneities 43,44 .
The angular spectrum structure differs from synthesized 2D Gaussian distribution or "cat" object and partly resembles the structure of "circles" object. This can be due to the presence of small details on target distribution. Furthermore, on the graph the prevalence of low spatial frequencies is observed. Following this, there is a decline and monotonic reduction of the graph. The reason for this may be that the main part of the distribution is occupied by the band corresponding to the low frequencies elements with corresponding phase values π and −π. Thus, these details make a significant contribution to the spectrum structure.
The fragments containing low (red rectangle) and high (blue rectangle) spatial frequencies are demonstrated for each set of parameters. From Fig. 6 (d), it can be noted that objects with similar requirements to spatial resolution and quantization are reconstructed with minimal error in case of balanced fringe period and aperture size. Increased aperture size results in low spatial frequencies loss (Fig. 6 (c)), while increased fringe period tends to loss of high ones (Fig. 6 (e)).
Objects in both amplitude and phase were selected to investigate complex field modulation. The amplitude error, phase error, and modulation error together with the resulting intensity and phase distributions are shown in Fig. 7. The modulation error was calculated as δ = 1 − F, where F = |E * target E obtained | 2 , E target is a target field, E obtained is the field obtained after DMD modulation 32 .
The graphs of angular spectrum structure show that these images are characterized by the content of both high and low spatial frequencies. Therefore, in this example, it is impossible to neglect spatial resolution as well as image quantization. The area of small errors is in the middle of the graph (insets in Fig. 7), i.e., in the case of small apertures and small fringe periods. Figure 6. Phase RMSE map dependent on aperture size and fringe period for the phase object modulation (a). The RMSE map is shown on a larger scale. (b) Target phase distribution and enlarged fragments (red and blue rectangles) with corresponding angular spectrum structure diagram are shown in a black rectangle. Obtained phase distributions enlarged fragments obtained using the following parameters: (c) fringe period=4 pixels, aperture size=300 pixels, (d) fringe period=11 pixels, aperture size=139 pixels, (e) fringe period=51 pixels, aperture size=30 pixels. Increasing one or another parameter leads to an increase in modulation error.
Due to similar types of target intensity and phase images in Fig. 7 (a, b) global minimum of RMSE for these images corresponds to similar parameters. Meanwhile, optimal parameters of experimental setup for independent simultaneous modulation of both amplitude and phase distributions [15;93] (Fig. 7(c)) lies in between of the values calculated for amplitude [15,66] and phase [13;107] images only.
It should be noted that the angular spectrum structure of the objects "sky" and "mountains" is similar to the structure of the object "cat". The latter was modulated as an intensity distribution, and the optimum was in the same area as for the "sky" object. In addition, regarding phase and amplitude modulation in Fig. 7, it is shown that the complex modulation optimum is in the middle between the two coordinates for amplitude and phase modulation. Therefore, knowing the optimum parameters for amplitude and phase modulation separately is possible to predict the optimum parameters for complex modulation.

Experimental results
In the presented above sections, the factors affecting the quality of amplitude or phase images are discussed. On this basis, for the experimental validation of numerical simulation, optimization of the parameters of the binary pattern and the experimental setup was conducted.
The experimental setup is described in Subsection 2.1. Experimental confirmation of the image reconstruction quality dependence on aperture size was performed on the example of phase-only modulation of the USAF 1951 test chart. This object is usually applied for the determination of optical systems spatial resolution and can be successfully used for the demonstration of aperture size impact on the spatial resolution of the modulated wave. Since this object should be reconstructed with the highest possible spatial resolution, the setup parameters and the binary pattern were selected according to the optimization results (Section 3.2): the aperture size diameter was 301 DMD pixels and the fringe period was 5 DMD pixels. Considering the parameters of the experimental setup, the aperture diameter should be equal to approximately 2.27 mm.
To confirm the accuracy of the selected parameters, the aperture size for filtration was changed in the x axis. The micrometeradjusted monochromator slit was set in the Fourier plane to filter the first diffraction order. It allowed us to precisely vary the size of the filtration area along the x coordinate. The variation of only a single coordinate spatial aperture enables the demonstration of the impact of the aperture size. It can be clearly seen on the Fourier spectrum that this distribution contains the large amount of high spatial frequencies.
Consequently, it is confirmed that the maximum possible aperture size should be used. The results of phase distributions 10/14 reconstruction at different filtering aperture sizes are shown in Fig. 8. Whereas the size was changed along the x axis, image blurring using the insufficient aperture size is observed only in the horizontal direction ( Fig. 8 (a)). Fig. 8 (e) shows the image deterioration due to adjacent diffraction orders passing through the filtration aperture. As can be seen in Fig. 8 (c), the optimal aperture size allowed us to reconstruct the phase distribution with minimal error and high image quality. The spatial resolution was calculated using the following equation: Resolution = 2 GroupNumber+ ElementNumber−1 6 As it can be seen from Fig. 8 (d), Group Number was -1, and Element Number was 3. Real size USAF 1951 test chart to DMD pattern size conversion ratio was 13.8. Therefore, the estimated spatial resolution was 8.72 lp/mm.
The cross-sections comparing the target and reconstructed distributions are provided (Fig. 8 (c, e, g)). In the case of the optimal aperture, an almost complete phase coincidence is observed (Fig. 8 (d)). For a small aperture, there are no sharp edges between the objects, which is demonstrated in Fig. 8 (b). For large apertures, the image corrupting fringes resulting from the adjacent diffraction orders passage can also be seen in the cross-section in Fig. 8 (f)).
The experimental results have demonstrated that the parameters of the binary pattern and aperture size, selected by the described above method allowed to reconstruct the phase with high image quality. The correlation between the aperture size and image quality was also confirmed.

Discussion and conclusion
Over the past few decades, wavefront manipulation by DMD has been widely used in light processing technology, despite the fact that DMD itself can be used for binary modulation of amplitude distribution only. The modulation of both amplitude and phase distribution is performed in two steps. Firstly, it is necessary to generate a binary pattern and project it on DMD. The pattern must be encoded in such a way that the wave reflected from DMD is divided into several diffraction orders, and the target distribution is contained in one of them. Secondly, this diffraction order is filtered by aperture, while others are blocked. Although there are various techniques for binarization of necessary patterns [28][29][30][31][32] , computer-generated Lee holography 33 is one of the most reliable methods to perform fast and efficient generation of binary patterns.
As it was mentioned above, this method assumes the generation of binary patterns and filtration of the first diffraction order in the Fourier domain. The quality of the wavefront modulation is significantly affected by experimental parameters such as filtration aperture size and binary hologram carrier frequency. The variation of these two parameters enables the optimization of the quality of complex wave modulation and the achievement of either high spatial resolution or high image quantization. If the target complex wave requires high spatial resolution, carrier frequency, and filtration aperture size should be increased. However, target complex wave with gradually changing phase or amplitude values modulation requires a high quantization of target amplitude or phase distribution. Therefore, the considered parameters should be decreased to provide the best quality of wave modulation.
The correlations between quantization and carrier frequency, resolution and aperture size are particularly interesting considering the wide variety of applications utilizing DMD. Some type of application has different requirements for spatial resolution and quantization of intensity and phase. For instance, DMD patterns with lower spatial frequencies are used to correct aberrations by increasing the fringe period and decreasing the filtering aperture. Laser processing or lithography objectives 11,14 require increased accuracy and high spatial resolution, which can be achieved by increasing the filtering aperture and decreasing the fringe period of binary hologram. High spatial resolution is also required in imaging applications such as optoacoustic microscopy 19 or optical coherence tomography 45 . However, as we have demonstrated in Subsection 3.1, reduction in the binary pattern carrier frequency results in an increase of phase and amplitude quantization. In the case when the target wavefront poses a slow variation of amplitude and phase distributions, e.g., cells or intracellular organelles, quantization of modulated complex wave becomes important. Thus, in applications of such type, it is impossible to sacrifice one parameter to improve another. In this case, it is necessary to maximize equally the spatial resolution and quantization of images.
In summary, the results reported here demonstrate that the achievement of the accurate wavefront modulation using digital micromirror device requires optimization of experimental parameters according to the target complex wave and its properties related with spatial resolution of quantization levels. The mathematical and physical principles that enable independent manipulation of phase and amplitude were described and discussed in detail. Moreover, we have discussed restrictions related to the distribution of the original information capacity of the encoding binary pattern and demonstrated that trade-off between the spatial resolution of the encoded complex wave and its quantization should be achieved in dependence on the target complex wave. It is shown that increasing one of these parameters results in an inevitable decrease in the other. In addition, we have proposed an approach for the optimization of the generated DMD binary patterns for each amplitude and phase distribution. The approach is based on a simulation of the modulated complex wave generation and takes into account the requirements of the target distribution to the quantization and spatial resolution. Preliminary estimation of the necessity to increase the aperture for filtering is performed by calculating the Fourier spectrum of the target amplitude or phase distribution, which enables the determination of the content of high and low spatial frequencies. Furthermore, the main applications of DMD for wavefront modulation, in which it is likely to be beneficial to maximize quantization or spatial resolution, are highlighted. Being optimized with the best experimental parameters, wavefront manipulation using DMD enables the accurate independent modulation of amplitude and phase distributions, and provides outstanding opportunities in various biomedical and technological applications. This technique is promising for implementation in various fields and applications, for instance, in the fast generation of shaped beams 46 or in studies of scattering media, in particular, for modulation of ultrashort laser irradiation 47,48 . However, the best results can be achieved only when the DMD pattern generation algorithm is optimized for certain types of amplitude and phase images, specific for a given application.