# Patch-Wise-Based Diffusion Model with Uncertainty Guidance for Low-Light Image Enhancement
## 3 Methods
### Patch-Wise Diffusion Model
#### 3.5.2 Random Patch Global Structures via Hierarchical Clustering  
This section introduces a novel random patch-based global structure modeling approach using hierarchical clustering to enhance the global structure consistency in low-light image enhancement. Instead of traditional patch-based matrix rank modeling, we randomly select six non-overlapping regions of varying sizes from the input image, ensuring multi-scale structural information is captured. This method reduces computational complexity while effectively modeling both local heterogeneity and non-local structural relationships within the image.  
Random patch selection and multi-scale division.The input image \(X_{0}\) is randomly divided into six non-overlapping regions of varying sizes. Each selected patch provides unique local information across multiple scales, which helps capture the diversity and heterogeneity within the image. Each patch is vectorized and represented as \(\{x_{0}^{(i)}\}_{i=1}^{6}\), where \(x_{0}^{(i)}\in\mathbb{R}^{m_{i}}\) is the vectorized form of the selected region.  
Hierarchical clustering of patches. A hierarchical clustering algorithm is applied to group patches with similar textures, colors, or structural patterns, which may be distributed across different locations. These patches are selected at varying scales, ranging from small local regions to larger structural areas, to capture both fine-grained details and global patterns.The resulting clusters capture the relationships between different regions of the image. Each cluster of patches is stacked into a matrix \(M_{0}^{n_{j}}\in\mathbb{R}^{m\times n_{j}}\), where each row corresponds to a patch feature. This hierarchical structure allows the model to handle the multi-scale nature of image structures effectively.  
Multi-Scale matrix feature analysis and regularization. Matrix decomposition techniques, such as Singular Value Decomposition (SVD) or Principal Component Analysis (PCA), are used to extract key structural features from each cluster. At each time step \(t\), the generated sample \(X_{t-1}\) is compared with the original image \(X_{0}\) by evaluating the similarity between their respective patch matrices:  
\[L_{s}(M_{t-1}^{n_{j}},M_{0}^{n_{j}})=\|\text{diag}(S_{t-1}^{j})-\text{diag}(S_ {0}^{j})\|_{1} \tag{9}\]  
Here, \(S_{t}\) denotes the singular value matrix of the patch clusters, and the \(L_{1}\)-norm measures the difference between the diagonal elements of the singular value matrices from the generated and original image samples.  
Adaptive injection of regularization. To prevent premature convergence and ensure structural consistency, we adaptively inject regularization over time. At each time step \(t\), the regularization weight \(\kappa_{t}\) is gradually increased to ensure the stability and performance of the diffusion process:  
\[L_{s}^{t}=\kappa_{t}L_{s}(M_{t-1}^{n_{j}},M_{0}^{n_{j}}) \tag{10}\]  
The weight \(\kappa_{t}\) increases with each time step, ensuring that the structure-aware regularization becomes more prominent in later stages of the diffusion process, preserving both local and global consistency.  
Capturing randomness and structural heterogeneity. The random selection of six non-overlapping patches introduces diversity in the sampled features, allowing the model to handle heterogeneous patterns within the image. This randomness ensures that the learned features are not biased toward specific image regions, improving the model's robustness to various image conditions.