  Phase retrieval, a long-established challenge for recovering a complex-valued
signal from its Fourier intensity measurements, has attracted significant
interest because of its far-flung applications in optical imaging. To enhance
accuracy, researchers introduce extra constraints to the measuring procedure by
including a random aperture mask in the optical path that randomly modulates
the light projected on the target object and gives the coded diffraction
patterns (CDP). It is known that random masks are non-bandlimited and can lead
to considerable high-frequency components in the Fourier intensity
measurements. These high-frequency components can be beyond the Nyquist
frequency of the optical system and are thus ignored by the phase retrieval
optimization algorithms, resulting in degraded reconstruction performances.
Recently, our team developed a binary green noise masking scheme that can
significantly reduce the high-frequency components in the measurement. However,
the scheme cannot be extended to generate multiple-level aperture masks. This
paper proposes a two-stage optimization algorithm to generate multi-level
random masks named $\textit{OptMask}$ that can also significantly reduce
high-frequency components in the measurements but achieve higher accuracy than
the binary masking scheme. Extensive experiments on a practical optical
platform were conducted. The results demonstrate the superiority and
practicality of the proposed $\textit{OptMask}$ over the existing masking
schemes for CDP phase retrieval.
