High-precision phase unwrapping method and system
By introducing multi-head self-attention and cross-attention modules into the Transformer U-Net network, the problem of high-precision phase unwrapping in high-noise and large-phase-change scenarios is solved, achieving lightweight and real-time phase reconstruction results.
Patent Information
- Application Number
- CN202511272496.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-08
- Publication Date
- 2026-01-16
AI Technical Summary
Existing deep learning methods struggle to achieve high-precision, low-latency absolute phase reconstruction in scenarios with high noise and large phase transitions. Traditional methods are prone to propagation errors and artifacts, and pure Transformer applications result in excessive computational costs.
We employ the Transformer U-Net network, combining multi-head self-attention and cross-attention modules, along with lightweight convolution and mixed-precision inference, to design a lightweight model that achieves local noise reduction and global context-synchronous modeling.
While maintaining model compactness, it achieves high-precision phase unwrapping, reduces computational load and power consumption, and is suitable for real-time operation.
Smart Images

Figure CN121346698A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of optical measurement and digital image processing, and particularly to a method and system for high-precision, low-artifact unwrapping of speckle interferometric phase maps using a Transformer U-Net network. This method combines the local feature extraction capabilities of convolutional neural networks with the global modeling advantages of the Transformer attention mechanism, enabling real-time, low-latency absolute phase reconstruction in high-noise, strong phase-jump, and large-scale discontinuous scenes. It is suitable for digital speckle interferometry, optical coherence tomography, synthetic aperture radar interferometry (InSAR), and other applications requiring continuous phase information. Background Technology
[0002] Speckle interferometry records the speckle fringes on the surface of an object and then inverts its morphology or displacement field. In actual measurements, phase information is wrapped in the form of [-π, π); to obtain a physically meaningful continuous phase, phase unwrapping must be performed. Traditional branching, quality map-guided, and least squares methods are effective in low-noise, smooth-phase conditions, but are prone to propagation errors and artifacts in high-noise or large-amplitude phase jumps. In recent years, deep learning methods have shown potential in phase unwrapping. Typical U-Nets fuse shallow spatial details with deep semantics through skip connections, but are limited by kernel locality, making it difficult to fully capture cross-regional phase correlations. In high-noise speckle interferometric images, with dense fringes and frequent phase abrupt changes, simple convolutional networks are still prone to connectivity errors and texture blurring. Transformer self-attention mechanisms can establish pixel-to-pixel dependencies globally, but directly applying pure Transformers to high-resolution phase maps leads to a sharp increase in memory usage and computational cost. Maintaining model compactness while simultaneously suppressing local noise and ensuring global phase consistency is the core challenge of current deep learning unwrapping algorithms. Summary of the Invention
[0003] This invention discloses an optical speckle interferometry phase unwrapping method and system based on Transfommer U-Net, addressing the problem of insufficient unwrapping accuracy in digital speckle interferometry under high noise, large phase transition, and real-time computing scenarios. The method introduces multi-head self-attention and cross-attention modules into the U-Net encoding / decoding framework to achieve local noise reduction and global context-synchronous modeling; simultaneously, it incorporates lightweight convolution, mixed-precision inference, and online fine-tuning mechanisms, achieving a balance between high accuracy, low power consumption, and ease of deployment.
[0004] According to one aspect of this disclosure, a high-precision phase unwrapping method is provided, comprising the following steps:
[0005] Step a: Constructing an unwrapping neural network model
[0006] An unwrapping model based on TransformerU-Net is constructed. The model sequentially includes an encoder subnetwork, a bottleneck attention layer, a decoder subnetwork, and an output layer, which is used to capture global context and local details while maintaining lightweight design.
[0007] Optionally, the encoder employs a three-level hierarchical compression (resolution 256→128→64→32px), with a bottleneck layer inserting multi-head self-attention (MHSA) to obtain the long-range dependencies of the entire image; the decoder performs feature filtering and fine restoration by using cross-layer skip connections and embedding multi-head cross-attention (MHCA); the output layer uses 1×1 convolution combined with bilinear interpolation, and the output size is consistent with the input.
[0008] Step b: Encoder subnetwork design
[0009] Several downsampling modules (DownsamplerBlock) and depthwise separable convolution-non-bottleneck one-dimensional convolution modules (SepConv+NB1D) are set in the encoder subnetwork to achieve efficient feature compression and multi-scale abstraction.
[0010] Optionally, the downsampling module consists of parallel 3×3 depthwise separable convolution (stride 2) and 2×2 max pooling. The output is compressed by channel concatenation and 1×1 convolution, reducing the resolution to 1 / 8 and the computational cost by about 55%.
[0011] Optionally, the NB1D module employs two sets of alternating k×1 and 1×k asymmetric convolutions (k=3), and introduces an increasing dilation rate d=1 / 2 / 4 / 8 in each layer, which expands the receptive field by 8 times and reduces the number of parameters by about 65% compared to the standard 3×3 convolution.
[0012] Step c: Bottleneck and Decoder Subnetwork Design
[0013] The decoder subnetwork integrates a deconvolutional upsampling layer, an MHCA module, and a dual convolutional fusion layer, and aligns encoder features through residuals and skip connections to achieve multi-scale detail reconstruction.
[0014] Optionally, MHCA uses the high semantic features of the decoder as keys / values and the high-resolution features of skip connections as queries, and generates a weight matrix through Sigmoid gating to suppress noisy regions.
[0015] Optionally, to capture cross-scale context, three 3×3 dilated convolutions (dilation rates of 6, 12, and 18) and a global average pooling branch are inserted into the lowest-level decoder, concatenated and then fused by a 1×1 convolution, which improves the utilization of multi-scale information by approximately 30%.
[0016] Step d: Phase unwrapping execution
[0017] The phase image of the package to be processed is input into the neural network to obtain the corresponding continuous phase output, which can be directly used for deformation analysis or subsequent imaging reconstruction.
[0018] Optionally, the input image undergoes guided filtering preprocessing (radius r = 5, regularization) before inference, reducing the noise standard deviation from 30 to ≤9 and controlling the edge gradient error to within 0.05 rad / pixel;
[0019] Optionally, for images with resolutions of 4K and above, a 512×512 sliding window (step size 256) is used and weighted overlap averaging is employed for seamless stitching to achieve real-time unpacking of large field of view.
[0020] Step e: Model training and optimization
[0021] Using L total =λ1L var +λ2L tv A composite loss function is used to supervise the training of the neural network model, minimizing the difference between the unwrapped phase image and the true phase image.
[0022] Optionally, an additional 5 epochs of L1 refinement (learning rate reduced to 1×10⁻⁶) can be added during the later stages of training to enhance texture fidelity;
[0023] Optionally, during the training phase, Gaussian noise (σ ~ U(0, 30)), salt-and-pepper noise (density p ~ U(0, 0.1)), and phase jumps (the area of the jump region accounts for 5%-20%) are randomly added to the input phase map to enhance the generalization robustness of the model in high-noise scenarios.
[0024] 2. A phase unwrapping system, comprising:
[0025] Input module: Receives package phase image data output by the digital image acquisition device, and supports real-time data stream input;
[0026] Processing unit: Embedded Transformer U-Net, FP16 inference; 256×256 image latency ≤15ms, power consumption ≤20W; Optional, Jetson Orin / Xavier NX / FPGA+DDR5; When using FPGA, MHSA / MHCA can be mapped to sparse matrix multiplication to reduce logic utilization;
[0027] Evaluation module: Normalized root mean square error (NRMSE), peak signal-to-noise ratio (PSNR), and structural similarity index (SSIM) are used to quantitatively evaluate the unwrapping results;
[0028] Storage module: Storage model weight parameters and evaluation results, supporting long-term archiving of terabyte-level data. Optionally, NVMeRAID0 improves write bandwidth for high-speed production line data traceability;
[0029] Optionally, the processing unit is configured with an online fine-tuning module based on the Adam optimization algorithm. When the evaluation module detects that NRMSE>2.0, it extracts the most recent 100 frames of data from the cache and fine-tunes them 10 times with a learning rate of 1e-5. The model switching time is <1ms, which can adapt to different noise scenarios. Attached Figure Description
[0030] Figure 1 The algorithm model diagram of this invention is shown below.
[0031] Figure 2(a) shows the phase wrapping diagram of moderate noise in the test set;
[0032] Figure 2(b) shows the Ground Truth corresponding to the phase wrapping map with moderate noise in the test set;
[0033] Figure 2(c) shows the unwrapping phase diagram based on Goldstein;
[0034] Figure 2(d) shows the unwrapping phase diagram of the CPULSI-based unwrapping method;
[0035] Figure 2(e) is an unwrapping phase diagram of the unwrapping method of the present invention;
[0036] Figure 2(f) shows the unwrapping phase diagram of the DLPU unwrapping method;
[0037] Figure 2(g) shows the unwrapping phase diagram of the VUR-Net unwrapping method;
[0038] Figure 3(a) shows the phase wrapping diagram with severe noise in the speckle interferometry experiment;
[0039] Figure 3(b) shows the unwrapping phase diagram based on Goldstein;
[0040] Figure 3(c) shows the unwrapping phase diagram of the CPULSI-based unwrapping method;
[0041] Figure 3(d) is an unwrapping phase diagram of the unwrapping method of the present invention;
[0042] Figure 3(e) shows the unwrapping phase diagram of the DLPU unwrapping method;
[0043] Figure 3(f) shows the unwrapping phase diagram of the VUR-Net unwrapping method. Detailed Implementation
[0044] The following detailed description of the specific implementation steps of "a high-precision phase unwrapping method and system" is provided in conjunction with the practical process of this invention. It should be understood that the order and details of each step can be modified and expanded according to actual needs. All substitutions or modifications made within the scope of the concept and core technical solution of this invention are within the protection scope of this invention.
[0045] Step 1: Design and construction of the network model.
[0046] Figure 1 This diagram illustrates the Transformer U-Net network structure according to an embodiment of the present disclosure. The network consists of an encoder sub-network, a Transformer bottleneck layer, and a decoder sub-network connected in series to form an end-to-end phase unwrapping system. The input is a wrapped phase map. (B is the batch size, H×W is the image size), the output is absolute phase. The encoder subnetwork adopts a three-level pyramid structure, with each level containing convolutional blocks and max pooling operations. The input to the first-level encoder is the original wrapped phase map φ. w (Size B×1×256×256), firstly, feature extraction is performed using convolutional blocks: The convolutional kernel size is 3×3, with p=1 padding and s=1 stride; batch normalization is then performed. And ReLU activation Output dimensions B×64×256×256. Next, perform max pooling: X p ooll (m,n)=max i,j∈[0,1] X1(2m+i,2n+j), kernel size 2×2, stride 2, output size B×64×128×128. The second-stage encoder expands the number of channels to [missing information] through convolutional blocks. Then it is pooled again, outputting B×128×64×64. The third-stage encoder further expands the channels to 256, and the final output feature map size is B×256×32×32.
[0047] At the end of the encoder, the Transformer bottleneck layer implements global context modeling. First, it expands the channel dimension using 1×1 convolutions. in Output dimensions. Then inject two-dimensional sine-cosine position encoding:
[0048]
[0049] Where i∈[0, 31], j∈[0, 31] are spatial coordinates, and c∈[0, 255] is the channel index, the position-aware feature X is obtained. pos =X proj+Г. The Multi-Head Self-Attention (MHSA) module reshapes features into N = 32 × 32 = 1024, calculation for parallel head processing (number of heads h = 2):
[0050]
[0051] Multi-head output fusion is Y = concat(Attention1, ..., Attention) h W O ,in The output size is B×512×32×32, enabling global phase continuity modeling.
[0052] The decoder subnetwork gradually restores spatial resolution through upsampling and feature fusion. The input to the first-stage decoder is the bottleneck layer output B×512×32×32, and it first processes skip connection features through multi-head cross-attention (MHCA):
[0053] Q S =Linear(S) (6)
[0054] K Y =Linear(Y) (7)
[0055] V Y =Linear(Y) (8)
[0056]
[0057] S′=S ⊙ Z (11)
[0058] in For encoder 3 output, use the Sigmoid activation function to filter the output features. Next, transpose convolution upsampling is performed: Kernel size 2×2, stride 2, output B×256×64×64. Final feature fusion: X c oncat =concat(X) up1 The first encoder (S′) is processed by ConvBlock, outputting B×256×64×64. The second decoder processes encoder 2 features (B×128×64×64), reducing the number of channels to 128 through transpose convolution, outputting B×128×128×128. The third decoder processes encoder 1 features (B×64×128×128), outputting B×64×256×256.
[0059] The output layer generates an absolute phase map through 1×1 convolution: in Output dimensions are B×1×256×256. To address the 2π periodic transition issue, a dual-channel output mode is provided: the output layer is modified to... Simultaneously output φ u And the periodic counting diagram K, through φ f i n a l (x, y) = φ u The complete phase is reconstructed using (x, y) + 2π·round(K(x, y)). An alternative approach uses a path tracing algorithm.
[0060]
[0061] The path pass Optimize selection.
[0062] Key parameter configurations include: 3×3 convolutional kernels for convolutional blocks, padding p=1 to preserve spatial dimensions; MHSA head number h=2, embedding dimension 512, d k =256 ensures stable training; transposed convolution kernel size 2×2, stride 2; positional encoding frequency base 10000. Implementation variants support dynamic resolution adaptation: network depth L = log2(min(H, W)) - 3 automatically adjusts with input size; real-time optimized versions can reduce the number of MHCA heads to 1 and halve the number of channels; noise robustness enhancement can be achieved by adding spectral normalization before MHCA. Adding a regularization term to the loss function Multimodal extension supports combined input of amplitude map and phase map, and outputs phase and confidence maps.
[0063] Step 2: Construction of the Phase Dataset
[0064] True phase The generation mainly consists of two parts: first, a linear or nonlinear slope background; and second, a distribution of several Gaussian spots with different positions, widths, and amplitudes. To generate an initial phase distribution for an image of a specified size, this process first constructs random slopes in the x and y directions using randomly generated gradients m1 and m2, and then superimposes a constant bias C, thereby forming large-scale phase fluctuations. Next, at a randomly selected center (μ... x μ y At point ), based on the specified standard deviation σ x and σ yMultiple Gaussian spots are added to a linearly superimposed Gaussian function to introduce subtle local variations in the phase map. Finally, these Gaussian spots are blended into the main slope with small coefficients to obtain the final true phase distribution I(x, y). To further enhance the diversity of the generated images, the gradient and bias of the slope, as well as the number, position, size, and amplitude of the Gaussian spots, are randomly sampled to generate phase images with distinct styles from different samples.
[0065] For the already generated absolute phase I(x, y), using the following equation
[0066] φ(x,y)=wrap(I(x,y)) (13)
[0067] The corresponding package phase can then be obtained, the core of which is
[0068] φ(x, y) = ∠(e jI(x,y) (14)
[0069] It is worth noting that in practice, it is often necessary to modify the generated... Rescaling (e.g., mapping it to the range [-4π, 4π]) ensures that the input range is reasonable during subsequent network training.
[0070] Real-world speckle interferometry is inevitably affected by noise. To simulate this process, noise is typically added to the complex form of the interferogram before its phase is extracted. The specific method is as follows:
[0071] (1) Spell
[0072] z(x, y) = e jI(x,y) (15)
[0073] Here, I(x, y) represents the true phase;
[0074] (2) Add independent and identically distributed Gaussian noise n to the real and imaginary parts of z respectively. real and n image Synthetic noise
[0075] n = n real +j·n image (16)
[0076] Obtain a noisy complex image.
[0077] Z noisy (x, y) = z(x, y) + n (17)
[0078] (3) Final calculation of the package phase
[0079] φ noisy (x, y) = ∠(z) noisy(x, y)) (18)
[0080] A noise interferogram is simulated by adding Gaussian noise to the phase image and controlling the signal-to-noise ratio (SNR).
[0081] Step 3: Loss function design and network training.
[0082] This invention employs a composite loss function oriented towards the phase expansion problem to balance local gradient consistency and overall phase accuracy. It can synthesize the following components: L var Loss: Minimize the deviation between the wrapped phase and the predicted phase at the gradient level to facilitate accurate recovery of local phase transitions.
[0083]
[0084] L tv Cross Entropy Loss: Select L tv The loss is used to encourage the predicted unpacked phase image to be as close as possible to the true phase image.
[0085]
[0086] Set an initial learning rate (e.g., 0.001), optimizer (e.g., Adam), and batch size (e.g., 4), and iterate according to the total number of training epochs (e.g., 500 epochs) or an early stopping strategy. In the later stages of training, a learning rate decay strategy can be used to make the network converge more robustly. When the validation set error or overall loss reaches its optimum or tends to plateau, save the network weight parameters for subsequent inference and application.
[0087] Step 4: Model prediction and experimental results analysis.
[0088] Input the unknown package phase map into the trained model; combine the spatial awareness capability of position encoding and the adaptive noise suppression characteristics of the MHCA module to achieve high-precision phase unwrapping in complex noise environments and output the absolute phase; as needed, simple post-processing (such as boundary difference correction) can be performed to reduce the micro-errors caused by local large jumps and obtain the final unwrapping result.
[0089] Example
[0090] The first embodiment of this invention uses a phase wrapping image with moderate noise in the test set, as shown in Figure 2(a). Figure 2(b) shows the Ground Truth of the corresponding unwrapped phase. Figures 2(c), 2(d), 2(e), 2(f), and 2(g) show the unwrapping methods based on Goldstein, CPULSI, the present invention, DLPU, and VUR-Net, respectively. It can be seen that our method has the smallest NRMSE, indicating that our algorithm performs best. The first embodiment of this invention uses a phase wrapping image with severe noise in a speckle interferometry experiment, as shown in Figure 3(a).
[0091] Figures 3(b), 3(c), 3(d), 3(e), and 3(f) show the results of the Goldstein-based unwrapping method, the CPULSI-based unwrapping method, the unwrapping method of this invention, the DLPU unwrapping method, and the VUR-Net unwrapping method, respectively. It can be seen from these figures that our method has the best unwrapping effect.
Claims
1. A high-precision phase unwrapping method, which is suitable for unwrapping wrapped phase images in the process of digital speckle shearing interferometry, characterized in that, The method comprises the following steps: a) constructing an unwrapping neural network model, which adopts an encoder-decoder (U-Net) backbone structure, embeds a multi-head self-attention (MHSA) module at the bottleneck layer of the encoder, and embeds a multi-head cross-attention (MHCA) module between each decoder stage and the corresponding skip connection; b) setting a 2x2 max-pooling layer after each convolutional block of the encoder to achieve 2 times down-sampling, and introducing absolute and relative position encoding at the bottleneck layer to maintain spatial position information; c) inputting the to-be-processed wrapped phase image into the model, outputting an unwrapped phase image after jointly modeling the global context by the MHSA and the MHCA; d) using a composite loss function L = λ1L var with total variation loss L tv total = λ1L var + λ2L tv The model is supervised to minimize the difference between predicted and true phase and to be compatible with the phase periodicity multi-solution; e) performing data augmentation on the wrapped phase image in the training stage, wherein the data augmentation comprises randomly generating continuous phase, phase wrapping, adding Gaussian noise and phase jump based on the speckle interference physical model, so as to enhance the generalization robustness of the model in a high-noise environment.
2. The method of claim 1, wherein, The multi-head self-attention module (MHSA) includes h parallel attention heads, each of which respectively calculates scaled dot-product correlation between queries Q, keys K, and values V, satisfying embedding dimension D = h x d k and gradient stability is ensured by residual connection and layer normalization.
3. The method of claim 1, wherein, The multi-head self-attention module (MHSA) weights and aggregates the input features by calculating the attention weights between the elements in the feature map, generating a new feature representation containing global context information, and the calculation process is represented as: wherein Q, K, V are query matrix, key matrix and value matrix obtained by different linear transformations of the bottleneck layer feature map, respectively, d k is the dimension of the key vector.
4. The method of claim 1, wherein, The multi-head cross-attention module (MHCA) is used to filter the skip connection features from the encoder path, specifically including: a) taking the high-level features of the current decoder path as the query (Q), and taking the skip connection features of the corresponding level as the key (K) and the value (V); b) calculating the attention weight matrix between Q and K; c) applying the attention weight matrix to the value (V) to generate an attention-weighted feature map; d) mapping the attention-weighted feature map to the [0, 1] interval through a Sigmoid activation function to generate a spatial attention mask; e) performing element-wise multiplication (Hadamard product) between the spatial attention mask and the original skip connection features to obtain filtered skip connection features; f) concatenating the filtered skip connection features with the current decoder high-level features as the input of the next decoding stage.
5. The method of claim 1, wherein, The composite loss function is defined as: L total = λ1L var + λ2L tv where L var represents the error variance loss term, which is used to reduce the variance of the prediction error, allowing different solutions that comply with the phase periodicity at convergence, and is calculated as the variance of the difference between the predicted and the real phase maps: L var denotes the total variation loss term, which constrains the gradient smoothness of the unwrapped phase in horizontal and vertical directions, and is calculated as the difference between the sum of the absolute values of the first-order difference of the predicted phase and the real phase in x and y directions: wherein, is the unwrapped phase map predicted by the network, φ x is the real unwrapped phase map, λ1and λ2are the weight coefficients balancing the two loss terms.
6. The method of claim 1, wherein, In the training stage, data augmentation is performed on the input wrapped phase image, which includes randomly adding Gaussian noise of different intensities, simulating phase jump, and random cropping, so as to enhance the robustness of the Transformer U-Net unwrapping network model in complex noise environment and non-continuous phase area.
7. A high-precision phase unwrapping system characterized by, It comprises: a) an image input interface for receiving wrapped phase image data generated by an optical interference measurement device; b) a processing core connected with the image input interface, which internally integrates the Transformer U-Net unwrapping model trained according to the method of any one of claims 1-6, and is used for performing phase unwrapping operation on the input wrapped phase image and outputting an unwrapped phase image; c) a quality evaluation unit connected with the processing core, which is used for quantitatively evaluating the unwrapped phase image; d) a storage unit configured to store the weight parameters of the Transformer U-Net unwrapping model, the input wrapped phase image, the output unwrapped phase image and the quality evaluation results.
8. The system of claim 7, wherein, The processing core is implemented by a graphics processing unit (GPU) or a field programmable gate array (FPGA), and adopts a mixed precision calculation strategy or a specific hardware accelerator to optimize the matrix multiplication and attention mechanism operation in the Transformer, so as to improve the processing speed and reduce the power consumption.
9. The system of claim 7, wherein, The quality evaluation unit is configured to calculate the normalized root mean square error (NRMSE), the peak signal-to-noise ratio (PSNR) and the structural similarity index (SSIM) between the unwrapping result and the reference phase image, or to evaluate the phase continuity and the noise suppression effect by using a no-reference index.
10. The system of claim 9, wherein, The processing core is further configured with an online adaptive module, which can fine-tune part of the layer parameters of the Transformer U-Net unwrapping model by using a gradient descent algorithm according to the evaluation index fed back by the quality evaluation unit or a small amount of correction samples input by a user, so as to optimize the unwrapping performance of the model in a specific measurement environment or noise mode in real time.
Citation Information
Cited By
Multi-scale anisotropic dynamic elastic-plastic grid phase unpacking method and device
CN122287256A
