Digital PCR image real-time denoising method and system based on gradient information enhancement
By designing a gradient information enhancement loss function and constructing a gradient enhancement denoising network, the problems of noise pollution and loss of structural details in digital PCR images were solved, achieving real-time high-precision image denoising and quantitative analysis, and improving image quality and computational efficiency.
Patent Information
- Application Number
- CN202511476195.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-16
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2045-10-16
AI Technical Summary
Digital PCR images suffer from severe noise contamination and loss of structural details during imaging and analysis. Furthermore, deep learning methods neglect gradients and high-frequency information, resulting in overly smoothed boundaries and fluorescence signal points, making it difficult to meet the requirements of real-time, high-precision quantitative analysis.
We design a gradient information enhancement loss function, combine L1 loss function, L2 loss function and structural similarity loss function, introduce adversarial discriminator and binary classification loss function, and construct a gradient enhancement denoising network architecture. We perform feature extraction and reconstruction through encoder and decoder, enhance image attention by using CBAM attention module, and design skip connection branches to preserve image details.
It effectively removes noise from digital PCR images, preserves important structural information, improves image quality, meets the needs of real-time high-precision quantitative analysis, reduces computational complexity, and enhances denoising effect and robustness.
Smart Images

Figure CN120953116B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of biomedical image processing and analysis technology, specifically to a method and system for real-time denoising of digital PCR images based on gradient information enhancement. Background Technology
[0002] Digital PCR (dPCR) is a highly sensitive and precise nucleic acid detection technology that has been widely used in gene testing, clinical diagnosis, non-invasive prenatal testing, and tumor liquid biopsy in recent years. Its basic principle is to segment the reaction system in a high-throughput manner, so that each microreaction unit contains only a very small amount or even a single DNA template molecule. Single-molecule amplification and detection are achieved through fluorescent probe signals, and absolute quantification of the target DNA is achieved by statistically analyzing positive and negative reaction units.
[0003] However, digital PCR imaging and analysis still face many challenges: First, due to limitations in fluorescence imaging conditions (such as low light, photon noise, detector dark current, etc.), images are often accompanied by severe noise contamination, making it difficult to distinguish positive signals; Second, traditional denoising methods (such as mean filtering, Gaussian filtering, BM3D, etc.) often cause edge blurring and loss of structural details while reducing noise, thus affecting the accuracy of microreaction unit determination; Third, although deep learning methods have shown excellent performance in image denoising in recent years, most methods have failed to fully utilize gradient and high-frequency information, resulting in overly smoothed boundaries and fluorescence signal points in digital PCR images, making it difficult to meet the needs of high-precision quantitative analysis.
[0004] In the prior art, Chinese patent document CN117689610A discloses "a method for eliminating noise and bubbles in PCR detection images based on dynamic deep learning." This method uses a mask deep convolutional neural network model to identify and output a mask of noise and bubble recognition results. Then, it subtracts noise and bubble regions from the original image and uses dynamic region selection to select the largest effective continuous region for brightness analysis. This achieves noise and bubble identification and removal for each thermal cycle image, ensuring that the selected interval for calculating the average brightness value in each cycle is free from noise and bubble interference, thereby improving the accuracy and sensitivity of PCR detection. However, the dynamic programming algorithm used in this technical solution has high computational complexity in image processing, especially for high-resolution images or large-scale data processing, which may lead to insufficient real-time performance. Although the dynamic region selection method is theoretically effective, in practical applications, its computational efficiency may become a bottleneck, and it fails to fully utilize gradient and high-frequency information, resulting in incomplete noise removal and loss of structural information during real-time image denoising.
[0005] In the prior art, Chinese patent document CN114663310A discloses "a method for denoising ultrasound images based on multi-attention fusion". This method acquires the original ultrasound image and inputs it into a constructed residual encoder-decoder network (RED-MAM) using a multi-attention mechanism fusion. The RED-MAM includes an encoder and a multi-attention fusion decoder. The encoder extracts features from the input image. In the multi-attention fusion decoder, in addition to the basic decoding and reconstruction module, a multi-attention mechanism fusion module (MAM) is introduced. Each encoding or decoding block is followed by a ReLU activation function. After the first and third deconvolutions of the decoding block, a multi-attention mechanism fusion attention block is introduced. Subsequently, the multi-attention fusion feature vector output by the multi-attention mechanism fusion attention block is activated using the ReLU activation function. Then, the multi-attention fusion feature is input into the next decoding block, and the decoded ultrasound image is obtained through decoding and reconstruction. However, this technical solution is only designed for speckle noise in ultrasound images, which has high computational complexity. It does not take into account the need for real-time image denoising in experimental testing. Furthermore, it relies too much on channel attention and spatial attention mechanisms for feature enhancement and does not make full use of gradient information and high-frequency features for constraint. This makes it easy to produce edge blurring and loss of structural details during the denoising process, and it is especially difficult to preserve the boundary information of positive signal points in digital PCR images.
[0006] In summary, existing technologies suffer from severe noise pollution and loss of structural details in digital PCR images during imaging and analysis. Furthermore, deep learning methods neglect gradients and high-frequency information, resulting in overly smoothed boundaries and fluorescence signal points in digital PCR images, making it difficult to meet the requirements of real-time, high-precision quantitative analysis. Summary of the Invention
[0007] This invention solves the problems of existing technologies, such as severe noise pollution and loss of structural details in digital PCR images during imaging and analysis, and the fact that deep learning methods ignore gradients and high-frequency information, resulting in overly smoothed boundaries and fluorescence signal points in digital PCR images, making it difficult to meet the requirements of real-time high-precision quantitative analysis.
[0008] The real-time denoising method for digital PCR images based on gradient information enhancement described in this invention includes the following steps:
[0009] Step 1: Design the gradient information enhancement loss function. Specifically, the gradient information enhancement loss function is as follows:
[0010] The L1 loss function, L2 loss function, and structural similarity loss function are weighted and fused, and gradient consistency constraints are superimposed. An adversarial discriminator and a binary classification loss function are introduced. The adversarial discriminator consists of five sequentially constructed convolutional layers, specifically:
[0011] ;
[0012] in, The Sigmoid activation function is defined as follows: , is the ReLU activation function, O is the confidence level that the local patch is "true", and Convn is the nth convolutional layer;
[0013] Step 2: Construct a gradient enhancement denoising network architecture, and train the gradient enhancement denoising network architecture using the gradient information enhancement loss function to obtain the trained gradient enhancement denoising network architecture.
[0014] Step 3: Use the trained gradient boosting denoising network architecture to denoise the input image to obtain the denoised image.
[0015] Furthermore, in one embodiment of the present invention, the gradient enhancement denoising network architecture in step 2 includes an encoder, a CBAM attention module, and a decoder, specifically:
[0016] The input image is feature extracted by an encoder, the CBAM attention module is used to enhance the attention of the feature-extracted image, and the attention-enhanced image is decoded and reconstructed by a decoder to obtain the output image.
[0017] Furthermore, in one embodiment of the present invention, the feature extraction of the input image by the encoder specifically includes:
[0018] The input image is processed by channel mapping and channel expansion through the first and second convolutional layers, respectively, and two levels of downsampling are performed. The third and fourth convolutional layers are used to enhance the channels of the input image after two levels of downsampling to obtain the channel features of the input image. The fifth convolutional layer reduces the number of channels of the attention-enhanced image and outputs it to the decoder.
[0019] Furthermore, in one embodiment of the present invention, the decoding and reconstruction of the attention-enhanced image using a decoder specifically includes:
[0020] The image is upsampled in two stages by using the first transposed convolutional layer and the second transposed convolutional layer, while compressing the number of channels. The image is then output based on the sixth convolutional layer.
[0021] Furthermore, in one embodiment of the present invention, the gradient enhancement denoising network architecture further includes three skip branches, specifically:
[0022] The first hop branch includes multiple convolutions and activation functions, which fuse the shallow features of the input image with the output image;
[0023] The second hop branch uses convolution to map the 32-channel features of the first convolutional layer to the 64-channel features of the first transposed convolutional layer.
[0024] The third hop branch uses convolution to extend the 64-channel features of the second convolutional layer to the 128-channel features of the fifth convolutional layer.
[0025] The real-time digital PCR image denoising system based on gradient information enhancement described in this invention is constructed based on the above method and includes the following modules:
[0026] The design module designs a gradient information enhancement loss function, which is specifically as follows:
[0027] The L1 loss function, L2 loss function, and structural similarity loss function are weighted and fused, and gradient consistency constraints are superimposed. An adversarial discriminator and a binary classification loss function are introduced. The adversarial discriminator consists of five sequentially constructed convolutional layers, specifically:
[0028] ;
[0029] in, The Sigmoid activation function is defined as follows: , is the ReLU activation function, O is the confidence level that the local patch is "true", and Convn is the nth convolutional layer;
[0030] The training module constructs a gradient enhancement denoising network architecture, uses gradient information to enhance the loss function, and trains the gradient enhancement denoising network architecture to obtain the trained gradient enhancement denoising network architecture.
[0031] The denoising module uses the trained gradient boosting denoising network architecture to denoise the input image, resulting in a denoised image.
[0032] The present invention provides a computer program product comprising a computer program or instructions which, when executed by a processor, implement any of the above-described methods for real-time denoising of digital PCR images based on gradient information enhancement.
[0033] The electronic device of the present invention includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus.
[0034] Memory, used to store computer programs;
[0035] When a processor executes a program stored in memory, it implements any of the above-described methods for real-time denoising of digital PCR images based on gradient information enhancement.
[0036] The present invention provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements any of the above-described methods for real-time denoising of digital PCR images based on gradient information enhancement.
[0037] This invention addresses the problems of existing technologies, such as severe noise contamination and loss of structural details in digital PCR images during imaging and analysis, and the over-smoothing of boundaries and fluorescence signal points in digital PCR images due to deep learning methods neglecting gradients and high-frequency information, making it difficult to meet the requirements of real-time, high-precision quantitative analysis. Specific beneficial effects include:
[0038] 1. This invention proposes a real-time denoising method for digital PCR images based on gradient information enhancement. By designing a new gradient information enhancement loss function and combining the advantages of deep learning models, a gradient enhancement denoising network architecture is constructed. This architecture can effectively remove noise from digital PCR images in real time while preserving important structural information in the images, especially the edges and details of fluorescence signals in digital PCR images, thus improving the quality of the denoised images.
[0039] 2. This invention proposes a real-time denoising method for digital PCR images based on gradient information enhancement. By designing a gradient information enhancement loss function and performing dynamic weight adjustment, hierarchical design, and specific directional constraints, it can ensure noise suppression while denoising, and achieve the effect of clear edges of fluorescent signal points and preservation of the overall image structure.
[0040] 3. This invention proposes a real-time denoising method for digital PCR images based on gradient information enhancement. By constructing a gradient enhancement denoising network architecture and training it with a gradient information enhancement loss function, the overall number of parameters is significantly reduced while maintaining high denoising performance. Combined with GPU acceleration optimization, a high frame rate (FPS) can be achieved in actual tests, meeting the real-time interpretation requirements of digital PCR experiments. Attached Figure Description
[0041] The above and / or additional aspects and advantages of the present invention will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein:
[0042] Figure 1 This is a schematic diagram showing the comparison results of the gradient information enhancement loss function described in Implementation Method 1;
[0043] Figure 2 This is a diagram of the gradient enhancement denoising network architecture described in Implementation Method 2.
[0044] Figure 3 This is a schematic diagram of the comparison results of the denoising visualization described in Implementation Method 4;
[0045] Figure 4 This is a visual schematic diagram of the ablation results of the CBAM attention module described in Implementation Method 4. Detailed Implementation
[0046] Various embodiments of the present invention will now be clearly and completely described with reference to the accompanying drawings. The embodiments described with reference to the drawings are exemplary and intended to explain the present invention, and should not be construed as limiting the present invention.
[0047] Implementation Method 1. A real-time denoising method for digital PCR images based on gradient information enhancement, comprising the following steps:
[0048] Step 1: Design the gradient information enhancement loss function. Specifically, the gradient information enhancement loss function is as follows:
[0049] The L1 loss function, L2 loss function, and structural similarity loss function are weighted and fused, and gradient consistency constraints are superimposed. An adversarial discriminator and a binary classification loss function are introduced. The adversarial discriminator consists of five sequentially constructed convolutional layers, specifically:
[0050] ;
[0051] in, The Sigmoid activation function is defined as follows: , is the ReLU activation function, O is the confidence level that the local patch is "true", and Convn is the nth convolutional layer;
[0052] Step 2: Construct a gradient enhancement denoising network architecture, and train the gradient enhancement denoising network architecture using the gradient information enhancement loss function to obtain the trained gradient enhancement denoising network architecture.
[0053] Step 3: Use the trained gradient boosting denoising network architecture to denoise the input image to obtain the denoised image.
[0054] Existing digital PCR image denoising methods typically employ traditional methods such as mean filtering, Gaussian filtering, and BM3D (3D block matching algorithm). However, while these traditional methods reduce noise, they often result in blurred microreaction unit edges, loss of structural details, and decreased accuracy in positive / negative identification. They are unable to effectively handle complex noise patterns in digital PCR images, especially when noise overlaps with the real signal in the frequency domain, significantly reducing denoising effectiveness. Although deep learning methods have shown advantages in image denoising, they still suffer from insufficient information utilization in the digital PCR field. Most methods fail to fully utilize image gradients and high-frequency information, leading to over-smoothing of boundaries and fluorescence signal points, affecting accurate microreaction unit segmentation. Furthermore, they have limited generalization ability, as training data differs from real-world scenarios, exhibiting poor adaptability to different instruments and sample types, and lacking robustness in practical applications. In contrast, gradient-based loss functions can effectively preserve edge details and prevent over-smoothing.
[0055] Therefore, in order to solve the above-mentioned technical problems, this embodiment provides a real-time denoising method for digital PCR images based on gradient information enhancement loss, and designs a gradient information enhancement loss function based on the Sobel operator. By using the gradient information enhancement loss function and combining it with the gradient enhancement denoising network architecture, it is possible to effectively remove noise in the image while retaining important structural information in the image, especially retaining the edges and details of fluorescence signals in digital PCR images, thereby improving the image quality after denoising.
[0056] The gradient information enhancement loss function described in this embodiment uses a Sobel filter to calculate the gradients of the image in both the X and Y directions, and then calculates the L1 loss function between the gradient of the denoised image and the target image. Noise often manifests as subtle variations or local perturbations, especially in low-contrast regions. By focusing on gradient information, such noise can be better identified and removed while preserving critical structural details. This is particularly important in biomedical imaging, as noise is more prevalent in smooth regions, and the gradient information enhancement loss function encourages the denoising model to prioritize the preservation of edge regions, thereby improving the overall denoising quality. The L1 loss function is highly effective in preserving structural details and is robust to noise, while the L2 loss function excels at reducing uniform noise but may blur fine details and edges. To further improve performance, this embodiment combines the L1 loss function, L2 loss function, and structural similarity loss function with the gradient loss to supervise the network's noise learning process.
[0057] This implementation method weights and fuses the L1 loss function, L2 loss function, and SSIM (structural similarity loss function), and superimposes a gradient consistency constraint based on the Sobel operator to form a composite gradient information enhancement loss function, specifically:
[0058] Step 11: Import the necessary libraries, including path concatenation, numerical computation (numpy), image processing (OpenCV, PIL and skimage), random number generation (random), PyTorch (open source deep learning framework) related modules (torch, torch.nn and torchvision, etc.), SSIM library (pytorch_ssim), perceptual metrics (lpips), and functional API (torch.nn.functional).
[0059] Step 12 defines a function named `resetRNGseed`, which is used to uniformly set the seeds of different random number generators used in the program. This function accepts an integer parameter `seed`, which is the random seed value manually specified in this implementation. Internally, the function sequentially calls the random number seed setting methods of three libraries: first, it uses `numpy.random.seed(seed)` to fix the random number generation order in the NumPy library; then, it calls Python's built-in `random.seed(seed)` to ensure the same random results are generated when using Python's standard random number library; finally, it sets the PyTorch random number generator using `torch.manual_seed(seed)`, allowing control over the randomness involved in tensor operations and neural network training.
[0060] Step 13 creates three commonly used loss function instances: nn.L1Loss() is used to calculate the mean absolute error between the predicted and the true values, which is usually used to measure the overall deviation of image reconstruction; nn.MSELoss() is used to calculate the mean squared error, which is more sensitive to pixels with larger deviations; and pytorch_ssim.SSIM() is a structural similarity index, which can evaluate the similarity between the generated image and the real image from the perspective of structural information.
[0061] Create three loss functions: L1, MSE, and SSIM, and set the device to specify the hardware environment for running the model and data. If a GPU is available in the current system, set it to "cuda" to fully utilize the GPU's parallel computing capabilities; otherwise, use "cpu".
[0062] Step 14 defines a dataset class named OpenDataset (inherited from torch.utils.data.Dataset) to load "damaged images" and their corresponding "ground images" in pairs. In __init__, the class accepts three parameters: image_dir (the directory containing the damaged / input images), gt_dir (the directory containing the ground / target images), and optional transforms (such as ToTensor, normalization, and data augmentation). During initialization, both directories are traversed, filenames are read and sorted, assuming a one-to-one correspondence between the files on both sides. The directory paths and transform functions are saved as member variables for later access. __len__ returns the number of samples in the dataset, i.e., the number of damaged image files, to ensure correct iteration by the DataLoader. The `__getitem__(idx)` function reads one image from each of two directories based on the given index `idx` and the filenames in the previously sorted order. It first opens the image with PIL, then converts it to grayscale mode "L" (single channel). If `transform` is provided during initialization, it applies the transformation to both the input image and the ground truth image in the same way. Finally, it returns a tuple `(image, gt)`, where `image` is the tensor of the corrupted image (or the transformed object), and `gt` is the paired ground truth image.
[0063] The gradient-enhanced loss function combines the advantages of L1 and L2 loss functions, enabling the gradient-enhanced denoising network architecture to effectively reduce noise in smooth regions while preserving sharp details and edges. By combining these loss functions with gradient-based loss functions, denoising performance can be significantly improved, ensuring that key image features are preserved while effectively removing noise.
[0064] By preparing three loss functions simultaneously, subsequent training can flexibly combine or weigh different error metrics according to needs. However, it still suffers from problems such as excessive computational resource consumption, unstable training, poor adaptability to complex noise, and insufficient generalization ability. Therefore, to solve the above technical problems, this implementation introduces an adversarial discriminator as an extension to constrain local consistency, specifically as follows:
[0065] Step 15 defines a discriminator class named GANDiscriminator (inherited from nn.Module) to implement PatchGAN-style local discrimination. Its __init__ method accepts the parameter input_channels (default is 1, taking a grayscale image as input), and internally constructs 5 convolutional layers sequentially. Each layer uses kernel_size=3, stride=2, and padding=1 to downsample layer by layer in the spatial dimension: Conv(input_channels→32), Conv(32→64), Conv(64→128), Conv(128→256), and finally Conv(256→input_channels) to map the number of channels back to input_channels. At the same time, ReLU is defined as the activation of the intermediate layer and Sigmoid is defined as the activation of the final layer (to compress the output to the [0,1] interval). In the forward pass, the input is passed sequentially through the first four "convolution + ReLU" blocks, downsampling to obtain multi-scale features. The last convolution is followed by a sigmoid function to obtain a patch probability map corresponding to approximately 1 / 32 of the input size (each position represents the confidence that a local patch is "true"). This structure is suitable for judging the local consistency of the generated results. If it is subsequently used with BCELoss, retaining the sigmoid function is reasonable. If BCEWithLogitsLoss is used instead, the sigmoid function is usually removed at the end of the network to obtain more stable numerical performance.
[0066] The input image I has dimensions H×W×C, where C is the number of input channels (default is 1, indicating a grayscale image).
[0067] The process is performed using five convolutional layers, each with the following parameters: kernel_size=3, stride=2, padding=1. Each convolutional layer uses the ReLU activation function, and the last layer uses the Sigmoid activation function.
[0068] Convolutional layer 1: I→Conv(C→32);
[0069] Convolutional layer 2: 32→Conv(32→64);
[0070] Convolutional layer 3: 64→Conv(64→128);
[0071] Convolutional layer 4: 128→Conv(128→256);
[0072] Convolutional layer 5: 256→Conv(256→C)256;
[0073] After processing through five convolutional layers, the output is a pixel of size [size missing]. The local probability plot represents the confidence level of whether each local patch is "true".
[0074] ;
[0075] in, The Sigmoid activation function is defined as follows: O represents the confidence level that a local patch is "true", and Convn represents the nth convolutional layer.
[0076] By using adversarial discriminators to constrain local consistency, the effects of reducing computational resource consumption, maintaining stable training, adapting to various complex noises, and enhancing generalization ability can be achieved. However, adversarial training often introduces additional uncertainties and oscillations, making it difficult to maintain the balance between the discriminator and the generator. Furthermore, the complex network structure and iterative game process increase the difficulty of model convergence, resulting in difficulties in obtaining stable and consistent denoising effects in practical applications. Therefore, to address these technical problems, this implementation proposes a binary classification loss function. This function aligns the discrimination results of real and generated images with the target labels (1 for real samples and 0 for pseudo samples), and uses a binary cross-entropy loss function for constraint, thereby effectively avoiding the instability problems in traditional adversarial training. Specifically:
[0077] Step 16 defines a binary classification loss function `gan_discriminator_loss(real_pred, fake_pred)` to calculate the binary classification loss of the discriminator. The function receives two sets of outputs from the discriminator: `real_pred` (the discrimination result for the real image) and `fake_pred` (the discrimination result for the generated image). Internally, `nn.BCELoss()` is used to calculate two errors: `real_pred` is aligned with the target tensor of all 1s, indicating that a real sample should be classified as "true"; `fake_pred` is aligned with the target tensor of all 0s, indicating that a fake sample should be classified as "false". The final scalar loss is then obtained by averaging the "real loss" and "fake loss" and returned.
[0078] BCELoss (Binary Cross-Entropy Loss Function) is used to calculate the loss between the output probability and the true label.
[0079] This design is equivalent to maximizing the discriminator's confidence in real samples and minimizing its confidence in generated samples, thereby improving the discriminator's ability to distinguish between real and fake samples. If the final layer of the adversarial discriminator does not include a Sigmoid function, then BCELoss in this function is usually replaced with the more stable BCEWithLogitsLoss (the goal and meaning remain unchanged).
[0080] Step 17 creates `lpips_model=lpips.LPIPS(net='vgg').to('cuda')`, which instantiates the VGG version of LPIPS as a perceptual similarity metric model and loads it onto the GPU to accelerate forward computation. If running in an environment without a GPU, it's usually changed to `.to(device)` to maintain consistency with the previously unified `device` variable. Then, the function `compute_lpips_gray(pred,truth)` is defined to compute LPIPS in the grayscale image case: the function accepts two tensors `pred` and `truth` (grayscale prediction image and ground truth image) of shape B×1×H×W. First, it uses `repeat(1,3,1,1)` on the channel dimension to copy the single channel to three channels to match the LPIPS model's requirement for RGB input. Then, these two three-channel images are fed into the previously created `lpips_model` to obtain the per-sample perceptual distance, and the output is mean() to obtain a scalar. Finally, `.item()` returns a Python floating-point number as the final result. In practice, a common practice is to ensure that the input conforms to the numerical range expected by LPIPS (e.g., linearly mapping [0,1] to [-1,1]) in order to obtain a stable and comparable perceived distance.
[0081] Step 18 defines a function `gradient_loss(Sobel)` to measure the difference between the prediction and the ground truth using edge / texture consistency. The function accepts two tensors of shape B×1×H×W: `pred` and `truth` (the grayscale prediction image and the ground truth image). Internally, it first constructs a classic Sobel convolution kernel: `sobel_x=[[1,0,-1],[2,0,-2],[1,0,-1]]`, and transposes it to obtain `sobel_y`. Then, both are reshaped to 1×1×3×3 to fit the weight shape of `F.conv2d`. Subsequently, the convolution kernel is moved to the same device as `pred` (e.g., `pred.is_cuda`) to avoid errors during cross-device computation. Next, convolutions are performed in two directions on the `pred` and `truth` maps: `grad_output_x = F.conv2d(pred, sobel_x, padding=1)` and `grad_output_y = F.conv2d(pred, sobel_y, padding=1)`, yielding the predicted gradient maps in the x and y directions. `grad_target_x` and `grad_target_y` are reference gradient maps obtained by performing the same operation on the ground truth map (with `padding=1` to maintain the spatial dimensions). Finally, the L1 loss function is used to compare the gradient differences between the predicted and ground truth maps in the x and y directions: `L1(grad_output_x, grad_target_x) + L1(grad_output_y, grad_target_y)`. These two values are added together to obtain a scalar, which is returned as the total gradient (edge / texture) consistency loss. This loss encourages the model to better fit the ground truth at object boundaries and textures, and is often used in conjunction with pixel-level losses (such as L1 / MSE) or perceptual losses (such as LPIPS) to improve visual quality.
[0082] In summary, the gradient information enhancement loss function described in this embodiment, combined with the specific noise and signal characteristics of digital PCR images, forms a hierarchical, multi-constraint coupled integrated loss system, such as... Figure 1 The diagram shown illustrates the comparison results of gradient information enhancement loss functions. The gradient information enhancement loss functions specifically include:
[0083] 1. Pixel-level constraint layer:
[0084] Based on L1 and L2 loss functions, a dynamic weight adjustment strategy is used for autonomous optimization. In the early stages of training, the weight of the L2 loss function is increased to accelerate the convergence of the gradient-enhanced denoising network architecture and prevent large-error pixels from dominating training. In the later stages of training, the weight of the L1 loss function is gradually increased to enhance robustness to the overall image and improve the smoothness and consistency after denoising. This dynamic weight adjustment strategy is independently designed to address the characteristics of low signal-to-noise ratio and unstable training in digital PCR images.
[0085] 2. Structural similarity constraint layer:
[0086] The SSIM metric is introduced, but not used alone; instead, it is used in conjunction with pixel-level constraints for joint optimization. Considering the typically regular geometric distribution of reaction cells in digital PCR images, a geometric weighting strategy is implemented, assigning higher weights to the boundary regions of rectangular cells to ensure that structural regularity is preserved while denoising.
[0087] 3. Gradient Consistency Constraint Layer:
[0088] The Sobel operator is used to extract gradient information between the predicted and ground truth images, and the difference is calculated. This implementation introduces orientation-sensitive weights, assigning different weights to horizontal and vertical edges, thereby enhancing the preservation of approximately circular fluorescent dot mutation boundaries. This strategy is specifically designed for positive units with "obvious edge mutations" in digital PCR images.
[0089] 4. Layer that resists consistency constraints:
[0090] A lightweight PatchGAN discriminator is designed for the adversarial consistency constraint layer, used for local consistency constraints. Unlike general GANs, this implementation employs a small receptive field convolutional kernel to precisely focus on the neighborhood texture of fluorescent points, using a local probability map output by the sigmoid activation function to avoid instability caused by global adversarial interactions. This mechanism effectively suppresses over-smoothing and enhances the preservation of local details.
[0091] Implementation Method 2. This implementation method further defines the deep learning-based adaptive digital predistorter design method described in Implementation Method 1. The gradient enhancement denoising network architecture in step 2 includes an encoder, a CBAM attention module, and a decoder, specifically:
[0092] The input image is feature extracted by an encoder, the CBAM attention module is used to enhance the attention of the feature-extracted image, and the attention-enhanced image is decoded and reconstructed by a decoder to obtain the output image.
[0093] The aforementioned feature extraction from the input image via the encoder specifically includes:
[0094] The input image is processed by channel mapping and channel expansion through the first and second convolutional layers, respectively, and two levels of downsampling are performed. The third and fourth convolutional layers are used to enhance the channels of the input image after two levels of downsampling to obtain the channel features of the input image. The fifth convolutional layer reduces the number of channels of the attention-enhanced image and outputs it to the decoder.
[0095] The aforementioned decoding and reconstruction of the attention-enhanced image via a decoder specifically includes:
[0096] The image is upsampled in two stages by using the first transposed convolutional layer and the second transposed convolutional layer, while compressing the number of channels. The image is then output based on the sixth convolutional layer.
[0097] The gradient-enhanced denoising network architecture also includes three skip branches, specifically:
[0098] The first hop branch includes multiple convolutions and activation functions, which fuse the shallow features of the input image with the output image;
[0099] The second hop branch uses convolution to map the 32-channel features of the first convolutional layer to the 64-channel features of the first transposed convolutional layer.
[0100] The third hop branch uses convolution to extend the 64-channel features of the second convolutional layer to the 128-channel features of the fifth convolutional layer.
[0101] This implementation constructs a lightweight U-Net encoder-decoder architecture, including an encoder, a decoder, and a CBAM attention module at the bottleneck, such as... Figure 2 As shown, the gradient-enhanced denoising network architecture is trained and optimized using the gradient information enhancement loss function described in step 1, which improves the ability to preserve edges and details while ensuring real-time performance. Specifically, it includes the following steps:
[0102] Step 21: Import the relevant libraries, including PyTorch and its submodules torch.nn and torch.nn.functional, torchsummary.summary for model structure and parameter statistics, time for timing, and finally, CBAMBlock attention module from fightingcv_attention.attention.CBAM.
[0103] Step 22: Define the network class BDNet. Create a class BDNet that inherits from nn.Module for feature extraction and reconstruction of single-channel grayscale images. The overall structure adopts a symmetrical structure of "encoder → attention → decoder" and uses multiple skip branches to preserve and fuse detailed information from different levels. The encoder performs two levels of downsampling through Conv2d(1→32,k3s2p1) and Conv2d(32→64,k3s2p1), and then continues to enhance the channel representation with Conv2d(64→128) and Conv2d(128→256). CBAMBlock (channel / spatial attention) is embedded at channel 256 to adaptively enhance salient regions, and then Conv2d(256→128) is used to transition to the decoder.
[0104] The decoder uses two layers of deconvolution, ConvTranspose2d(128→64,k2s2) and ConvTranspose2d(64→32,k2s2), to progressively upsample back to the original resolution, and finally outputs a single-channel reconstructed image using Conv2d(32→1,k3s1p1).
[0105] The three skip branches are: skipConv1 (three 1→1 convolutions + ReLU concatenation) for shallow residual extraction of the input, and skipConv2 (32→64) and skipConv3 (64→128) for aligning the intermediate encoding features to the decoding side. During the forward pass, these branches are added to the corresponding stage features to enhance details and stabilize training. The weights are initialized using KaimingNormal for Conv2d (current implementation does not cover ConvTranspose2d). At the end of the forward pass, ReLU is applied to the output and the pixel values are constrained to [0,1] using torch.clamp(max=1).
[0106] Step 23, in the `__init__` method, firstly, the model name `self.name='BDNet'` is set and a general ReLU activation function is defined, then the backbone branch of the network is constructed. This branch extracts features step by step through convolutional layers: the first convolutional layer maps the input single-channel image to 32 channels and performs initial downsampling through convolution with a stride of 2, thereby compressing the spatial resolution; the second convolutional layer further expands the number of channels to 64, while downsampling again to obtain a larger receptive field; the following third and fourth convolutional layers keep the feature map size unchanged, but gradually increase the number of channels to 128 and 256, respectively, to enrich deep semantic features. After obtaining 256 channels of features, a CBAM (Convolutional Block Attention) module is added to enhance the expression of key regions and suppress redundant information through joint weighting of channels and space; finally, the fifth convolutional layer reduces the number of feature channels to 128 through a 256→128 convolution, preparing for upsampling and skip-connection fusion in the decoding stage.
[0107] Step 24: After backbone feature extraction and attention enhancement, the network enters the decoding and reconstruction stage: First, the feature map is upsampled once through the first transposed convolutional layer transConv1 (deconvolution 128→64, kernel size 2, stride 2) to restore the spatial resolution by one time and reduce the number of channels to 64; then, the second transposed convolutional layer transConv2 (deconvolution 64→32, kernel size 2, stride 2) is used to upsample again to further restore the resolution to the same scale as the input, while compressing the number of channels to 32.
[0108] Finally, a single-channel output image is generated using the sixth convolutional layer conv6 (convolution 32→1, kernel size 3, stride 1, padding 1), maintaining the boundary dimensions unchanged. This decoder reconstructs spatial details using a "stepwise upsampling + stepwise channel reduction" approach, and integrates local information with a 3×3 convolution at the end, outputting a grayscale result of the same size as the input, facilitating direct alignment with the supervision signal.
[0109] However, current gradient-enhanced denoising network architectures suffer from detail loss and insufficient semantic information because they do not directly combine shallow and deep features. This results in the decoder being unable to effectively recover high-frequency details and low-level features of the image, thus affecting image quality. Especially in image reconstruction tasks, the fusion of detail and semantic information is crucial for improving output quality. To address these technical issues, this implementation design incorporates three skip connections between the encoder and decoder to transmit feature information at different depths, preventing detail loss during downsampling. Through these three skip connections, the gradient-enhanced denoising network architecture can balance shallow details and deep semantics during reconstruction, achieving higher-quality output. Specifically:
[0110] Step 25, skipConv1 (first skip branch) is a sequence module consisting of three layers of alternating 1→1 convolutions and ReLU activations. It directly acts on the input image, extracting and retaining the shallowest low-level features for fusion with the final output during the decoding stage.
[0111] However, designing only the first hop branch results in insufficient high-level semantic information. The first hop branch only maps low-level features to mid-level features through 1×1 convolutions, which, while preserving some shallow details, lacks sufficient supplementation from mid-level and deep features. Without the second and third hop branches, the gradient-enhanced denoising network architecture lacks rich high-level semantic information during decoding, thus failing to effectively recover the high-level structure and semantic details of the image. This leads to a lack of structural consistency and semantic expression in the final output image. Therefore, to address the aforementioned technical problems, this implementation design includes a second and third hop branch, specifically:
[0112] skipConv2 (the second skip branch) uses a 1×1 convolution to map 32-channel features to 64 channels, serving as residual supplementation for the intermediate skip branches and enabling the decoder to reintroduce intermediate details during upsampling. skipConv3 (the third skip branch) similarly expands the 64-channel features to 128 channels using a 1×1 convolution, acting as a deeper skip branch to help high-semantic-level features maintain consistency with the main stream during decoding. In the decoding stage, the skip branches progressively reconstruct the original image from the features extracted by the encoder. Through this progressive expansion design, the decoder can effectively integrate multi-level features, contributing to high-quality image restoration.
[0113] The progression from 32 to 64 and from 64 to 128 represents the gradual deepening and enrichment of image features. Without this gradual change from low-level features (such as edges and textures) to mid-level features (such as shape and object structure) and then to high-level features (such as semantic information), feature fusion during the decoding process could become difficult, thus affecting the decoder's recovery performance.
[0114] `skipConv2` and `skipConv3` expand the number of channels in mid-level and deep features using 1×1 convolutions, increasing them from 32 to 64 and from 64 to 128, respectively. During this process, low-level and high-level features are supplemented through appropriate channel matching. This design ensures smooth feature fusion and avoids information loss or mismatch during decoding. Directly connecting 32 to 128 or 64 to 256 channels could lead to breaks in feature representation because their feature scales are mismatched. The decoder would struggle to effectively connect low-level and high-level features, potentially resulting in reduced image quality. Furthermore, drastic changes in the number of skipped channels can cause conflicts during feature fusion because the semantic information and spatial resolution differences between low-level and high-level features are too large.
[0115] If the number of channels in the skip branches is not connected in the manner of 32→64 or 64→128, it may lead to inconsistency between the input and output channels. The decoding stage cannot effectively recover the details of the image. This can easily result in information loss or redundancy during feature fusion, and cause the gradient to be unstable during backpropagation, resulting in gradient vanishing or gradient explosion, which affects the stability of model training.
[0116] Therefore, this implementation method, by appropriately varying the number of channels, introduces and fuses features at different levels layer by layer, maintaining a smooth transition between low-level, mid-level, and high-level features. This design ensures the gradual restoration of image details, avoids information loss, and enables more stable gradient propagation during training. Thus, the gradual variation in the number of channels is not only to balance the feature flow in the decoder but also to efficiently utilize features at different levels at each stage of image generation, ensuring efficient restoration of the final image quality.
[0117] Step 26 defines a weight initialization callback function `_initialize_weights(m)` within `__init__`, used to initialize network parameters according to custom rules based on module type. When the input module `m` is `nn.Conv2d`, `nn.init.kaiming_normal_(m.weight)` is called to initialize the convolutional kernels with a He / Kaiming normal distribution, thereby maintaining the stability of the output variance of each layer under ReLU activation and mitigating the risk of gradient vanishing or exploding. If the convolutional layer contains a bias term that has not been removed by the upstream module, `m.bias` is usually set to zero in practice and can be added as needed. Subsequently, `self.apply(_initialize_weights)` recursively traverses all sub-modules in the model and executes this initialization strategy, ensuring that the backbone convolutions and skip convolutions have a reasonable initial distribution after construction, providing a good starting point for subsequent training. It should be noted that the current rules only cover nn.Conv2d and do not handle modules such as nn.ConvTranspose2d separately. To further improve the stability of the decoder, the same or appropriate initialization scheme can be added to transposed convolution and other layers.
[0118] Step 27: In forward(x), the model completes the mapping from input to reconstruction by concatenating multi-level residuals and upsampling / downsampling: First, skipConv1 is applied to the input x to obtain shallow residual res1; then x is downsampled for the first time by conv1→ReLU, and the middle residual res2 is extracted by skipConv2; it continues to be downsampled for the second time by conv2→ReLU, and the deep residual res3 is extracted by skipConv3; then, 256-channel deep features are obtained by conv3→ReLU and conv4→ReLU at the same scale, and they are fed into the CBAM attention module. The block is added to the original features to enhance the response of salient regions; the attention-enhanced features are input to conv5, reduced to 128 channels, added to res3, and then ReLU is performed to fuse deep semantics and encoding side information; then, it is upsampled by transConv1 and added to res2, followed by ReLU, and then upsampled by transConv2 again and ReLU is performed to gradually restore spatial resolution; finally, a single-channel reconstruction map is generated by conv6, added to res1 to inject shallow details, and then ReLU is performed. Finally, the pixel values are restricted to the [0,1] interval by torch.clamp(max=1) to form the model output.
[0119] Step 28: In the main function `__main__`, the running device is first specified as the first GPU by `device=torch.device('cuda:0')`, thus fully utilizing the parallel computing capabilities of the GPU during subsequent inference. Then, `torch.randn(1,1,512,512)` is called to generate a random tensor of shape 1×1×512×512, simulating a single-channel, 512×512-sized input image. The tensor is then copied to the GPU using `.to(device)`, providing test data for model inference and performance evaluation.
[0120] Step 29, in the "Model Building and Inference Mode" stage, first instantiate BDNet and load the model weights to the selected device (e.g., cuda:0) using .to(device). Then call model.eval() to switch to evaluation mode, disable training-state behaviors such as BatchNorm / Dropout, and ensure that the forward feed results are stable and reproducible. To accurately measure inference time, create CUDA events (torch.cuda.Event(enable_timing=True)) as timers (usually used in pairs, such as starter and ender), and use torch.cuda.synchronize() to synchronize devices before and after timing to avoid time deviations caused by asynchronous queues. In the actual forward loop, combine with withtorch.no_grad(): disable gradient recording to reduce GPU memory usage and computational overhead, thereby obtaining more objective inference performance metrics (e.g., FPS).
[0121] Step 210: In the FPS testing and model summarization phase, the number of test iterations is first set to num_frames=100, and the gradient is disabled in the torch.no_grad() environment to reduce overhead. Then, with the cooperation of torch.cuda.synchronize() twice, the timestamps before and after are recorded, and forward inference is performed 100 times in a loop (each time using the same random input tensor as a sample). The total elapsed time is obtained by subtracting the start time from the end time. Then, fps=num_frames / elapsed_time is calculated to obtain the average frame rate, and the total elapsed time and FPS metric are printed to evaluate the real-time performance of the model. Finally, summary(model,(1,512,512)) is called to output a network structure summary, including the output size, number of parameters, and usage information of each layer, which facilitates a quick review of model complexity and memory requirements.
[0122] In summary, regarding the design of gradient enhancement denoising network architectures, this implementation proposes the BDNet (gradient enhancement denoising) network architecture, specifically addressing the characteristics of digital PCR images: "local fluorescent spots + large-area background noise." The architecture includes:
[0123] 1. Main structure:
[0124] Based on the lightweight U-Net encoder-decoder framework, it ensures basic denoising and reconstruction capabilities, reduces computational complexity, and improves real-time performance by reducing the number of redundant convolutional kernels.
[0125] 2. Attention Module
[0126] Introducing the CBAM attention module (channel + spatial dual attention) into the bottleneck layer enables the gradient enhancement denoising network architecture to simultaneously capture the high-frequency features of local fluorescent points and the low-frequency noise features of large background areas, effectively improving the ability of the gradient enhancement denoising network architecture to highlight key signal points.
[0127] 3. Three jump branches:
[0128] This implementation method features a self-designed three-level jump branch, specifically including:
[0129] 1) The first hop connection branch is a shallow residual compensation branch, which directly transmits low-level textures to avoid early feature loss;
[0130] 2) The second hop connection branch is a mid-level channel mapping compensation branch to ensure the alignment of features at different resolutions and prevent information mismatch;
[0131] 3) The third hop branch is a deep channel compression compensation branch, which provides high semantic information reconstruction at the decoding end and enhances the ability to distinguish fluorescent points.
[0132] Implementation Method 3. The real-time digital PCR image denoising system based on gradient information enhancement described in this implementation method is constructed based on the method described in Implementation Method 1, and includes the following modules:
[0133] The design module designs a gradient information enhancement loss function, which is specifically as follows:
[0134] The L1 loss function, L2 loss function, and structural similarity loss function are weighted and fused, and gradient consistency constraints are superimposed. An adversarial discriminator and a binary classification loss function are introduced. The adversarial discriminator consists of five sequentially constructed convolutional layers, specifically:
[0135] ;
[0136] in, The Sigmoid activation function is defined as follows: , is the ReLU activation function, O is the confidence level that the local patch is "true", and Convn is the nth convolutional layer;
[0137] The training module constructs a gradient enhancement denoising network architecture, uses gradient information to enhance the loss function, and trains the gradient enhancement denoising network architecture to obtain the trained gradient enhancement denoising network architecture.
[0138] The denoising module uses the trained gradient boosting denoising network architecture to denoise the input image, resulting in a denoised image.
[0139] Implementation Method 4. A gradient-enhanced denoising network architecture evaluation method, wherein the method is implemented based on any one of the methods in Implementation Methods 1 and 2, specifically as follows:
[0140] We define multidimensional metrics, provide result visualization and storage tools, enhance the loss function based on gradient information and multidimensional metrics, test the trained gradient enhancement denoising network architecture, evaluate the test results and the original input using multidimensional metrics, and obtain the evaluation results.
[0141] This implementation constructs a complete evaluation and assistance system for image reconstruction models: on the one hand, it defines multi-dimensional indicators such as LPIPS, Gradient Loss, PSNR, RMSE (Root Mean Square Error), and SSIM, covering the measurement of differences at the pixel, structural, and perceptual levels; on the other hand, it designs a gradient information enhancement loss function, consistent with the gradient information enhancement loss function in step 1 (supporting L1 loss function, L2 loss function, SSIM, and gradient constraints, and optionally incorporating adversarial terms); it also provides result visualization and storage tools (montage mosaic and batch saving), and implements the test function test, such as... Figure 3 and Figure 4 As shown, where Noised represents noise, Target represents the target object to be detected, Channel attn represents channel attention, and Spatial attn represents spatial attention, the prediction results of the gradient enhancement denoising network architecture trained in step 2 and the original input are statistically evaluated using multiple metrics. This achieves integrated support from training optimization to performance quantification and result display, specifically including the following steps:
[0142] Step 31, LPIPS (Grayscale) computation, is used to calculate perceptual similarity (LPIPS) in a grayscale scene: First, the predicted and ground truth grayscale tensors `pred` and `truth` (shape B×1×H×W) are each copied into three channels in the channel dimension (`repeat(1,3,1,1)`) to adapt to the `lpips_model` which only accepts RGB input; then, both are fed into the instantiated LPIPS model for forward computation to obtain a tensor representing perceptual differences; the average of this tensor in the batch and spatial dimensions is calculated (`mean()`) to obtain the overall metric; finally, the scalar tensor is converted to a Python floating-point value using `.item()` as the final result. This corresponds to step 17: In step 1, `lpips_model` has already been instantiated and the `compute_lpips_gray` function has been defined. Step 31 simply calls and uses it as an evaluation metric.
[0143] Step 32, Gradient Loss, is used to constrain the consistency between the predicted and ground truth maps in terms of edges and textures: The function first constructs a classic Sobel convolution kernel, sobel_x / sobel_y (shape 1×1×3×3), and moves the kernel to the same device as the input pred to avoid cross-device computation; then, gradient convolutions are performed on pred and truth in the x and y directions using F.conv2d (usually with padding=1 to maintain size), resulting in the predicted gradient map and the ground truth gradient map; finally, the global L1 loss function l1_func is used to calculate the difference between the gradient maps in the two directions and sum them as the total loss. This loss effectively encourages the model to closely approximate the ground truth at object boundaries and detailed textures, and is often used in conjunction with pixel-level (L1 / MSE) and structural similarity (SSIM / LPIPS) to improve reconstruction quality. Corresponding to step 18: In step 1, gradient_loss(pred, truth) is defined, which calculates edge consistency using a Sobel convolution kernel. Step 32 then references it as part of the evaluation metrics / loss.
[0144] Step 33, loss_fn (comprehensive loss), loss_fn(pred, truth, loss_option) is used to generate a comprehensive loss by combining multiple error metrics according to the configuration: The function first calculates and retains l2_loss = l2_func(pred, truth) for return or monitoring; then, it constructs total_loss according to the loss_option branch, supporting pure pixel terms 'L1', 'L2', mixed pixel terms 'L1+L2', structure term 'SSIM' (using 1-ssim(pred, truth) as loss), and its combination with pixel terms 'L1+SSIM', 'L2+SSIM', 'L1+L2+SSIM'. In the case of 'L1+L2+SSIM+Gradient', an additional Sobel-based edge consistency term gradient_loss(pred, truth) is superimposed to enhance the reconstruction of edges and textures; while the 'L1+L2+SSIM+Gradient+GAN' branch is currently implemented the same as the previous branch, and the GAN term has not yet been actually added (placeholder). The final result is a tuple (total_loss, l2_loss), where total_loss is used for backpropagation optimization, and l2_loss is commonly used for log recording and metric comparison. This corresponds to steps 13+, 17+, 18+, and 15 / 16 (optional GAN): from step 13, the three basic losses: L1 loss function, L2 loss function, and SSIM; from step 18, GradientLoss; from step 17, LPIPS can also be used for extension (although not directly fused in the main function, it exists as a perceptual constraint); from steps 15 and 16, the adversarial discriminator and adversarial loss (currently placeholder). Step 33 combines these scattered loss terms into a configurable comprehensive loss function.
[0145] Step 34: Define PSNR (Peak Signal-to-Noise Ratio), calculate MSE using the global l2_func, and calculate the peak signal-to-noise ratio as PSNR = 10*log10(1 / MSE) and return the scalar (assuming the pixel range has been normalized to [0,1]). This corresponds to step 13 (related to the L2 loss function): the calculation of PSNR depends on MSE (i.e., the L2 loss function). Therefore, it echoes nn.MSELoss() in step 13.
[0146] Step 35 is used to calculate the peak signal-to-noise ratio (PSNR) of the predicted and ground truth images: The function first calls the global `l2_func(pred,truth)` to obtain the mean squared error (MSE), and then calculates the PSNR using the formula PSNR = 10 × log10(1 / MSE) (assuming by default that the image has been normalized to [0,1], i.e., peak value MAX_I = 1). In the implementation, `torch.log10` is used to perform logarithmic operations in the tensor domain, and finally, `.item()` returns a Python scalar. If the input is not normalized, the numerator should be replaced with MAX_I^2 (e.g., 255). 2 To obtain the correct PSNR.
[0147] Step 36 returns the structural similarity score between the predicted and ground truth maps: it directly calls the global function `ssim_loss_func(pred, truth)` to calculate the similarity (typically a value between 0 and 1, with higher values indicating greater similarity), and converts the result to a Python scalar before returning it. This function by default aggregates the input batches and spatial locations (a common implementation is averaging), so the output is a single score. Note that this is a similarity score, not a loss. If used as a loss during training, 1-SSIM is usually used instead. It's also important to ensure that `pred` and `truth` have consistent shapes, numerical ranges, and device characteristics (e.g., B×C×H×W, and normalized according to implementation requirements). This corresponds to step 13, where `pytorch_ssim.SSIM()` is defined as the structural similarity metric in step 1. Step 36 then calls this instance as a test metric.
[0148] Step 37, used to return the perceptual distance between the prediction and the truth: as a thin wrapper, it directly calls compute_lpips_gray(pred, truth); this called function copies the B×1×H×W grayscale tensor into three channels in the channel dimension to adapt to the LPIPS model input, feeds it into the instantiated LPIPS network for forward computation, and takes the mean in the batch and spatial dimensions, finally returning the Python floating-point value using .item(). When using this method, ensure that the tensor and the model are on the same device and provide input according to the numerical range agreed upon by LPIPS (commonly mapping [0,1] to [-1,1]) to obtain stable and comparable metrics. This is consistent with steps 17 and 31, both based on lpips_model and compute_lpips_gray defined in step 1. Table 1 compares the denoising experimental results of different networks.
[0149] Table 1
[0150]
[0151] Implementation Method 5. A computer program product, comprising a computer program or instructions that, when executed by a processor, implement the real-time digital PCR image denoising method based on gradient information enhancement as described in any of the above embodiments.
[0152] Implementation method six. An electronic device, comprising a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;
[0153] Memory, used to store computer programs;
[0154] When the processor executes the program stored in the memory, it implements the real-time digital PCR image denoising method based on gradient information enhancement as described in any of the above embodiments.
[0155] Implementation Method 7. A computer-readable storage medium storing a computer program, wherein when executed by a processor, the computer program implements the real-time digital PCR image denoising method based on gradient information enhancement as described in any of the above embodiments.
[0156] The above provides a detailed description of the real-time digital PCR image denoising method and system based on gradient information enhancement proposed in this invention. Specific examples have been used to illustrate the principles and implementation methods of this invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this invention. Therefore, the content of this specification should not be construed as a limitation of this invention.
Claims
1. A real-time denoising method for digital PCR images based on gradient information enhancement, characterized in that, Includes the following steps: Step 1: Design the gradient information enhancement loss function, which is specifically as follows: The gradients of the denoised image and the target image in the X and Y directions are calculated using a Sobel filter to obtain the L1 loss function between the gradients of the denoised image and the target image. The L1 loss function, L2 loss function, and structural similarity loss function are then weighted and fused. An adversarial discriminator is introduced to perform local consistency judgment on the generated results. A binary classification loss function is used to calculate the loss between the output probability and the true label in the discrimination result, resulting in a gradient information enhancement loss function. The adversarial discriminator consists of five sequentially constructed convolutional layers, specifically: ; in, The Sigmoid activation function is defined as follows: , is the ReLU activation function, O is the confidence level that the local patch is "true", and Convn is the nth convolutional layer; Step 2: Construct a gradient enhancement denoising network architecture, and train the gradient enhancement denoising network architecture using the gradient information enhancement loss function to obtain the trained gradient enhancement denoising network architecture. The gradient enhancement denoising network architecture in step 2 includes an encoder, a CBAM attention module, and a decoder, specifically: The input image is feature extracted by an encoder, the CBAM attention module is used to enhance the attention of the feature-extracted image, and the enhanced image is decoded and reconstructed by a decoder to obtain the output image. Step 3: Use the trained gradient boosting denoising network architecture to denoise the input image to obtain the denoised image.
2. The real-time denoising method for digital PCR images based on gradient information enhancement according to claim 1, characterized in that, The aforementioned feature extraction from the input image via the encoder specifically includes: The input image is processed by channel mapping and channel expansion through the first and second convolutional layers, respectively, and two levels of downsampling are performed. The third and fourth convolutional layers are used to enhance the channels of the input image after two levels of downsampling to obtain the channel features of the input image. The fifth convolutional layer reduces the number of channels of the attention-enhanced image and outputs it to the decoder.
3. The real-time denoising method for digital PCR images based on gradient information enhancement according to claim 1, characterized in that, The aforementioned decoding and reconstruction of the attention-enhanced image using a decoder specifically involves: The image is upsampled in two stages by using the first and second transposed convolutional layers, while compressing the number of channels. The image is then output based on the sixth convolutional layer.
4. The real-time denoising method for digital PCR images based on gradient information enhancement according to claim 2 or 3, characterized in that, The gradient-enhanced denoising network architecture also includes three skip branches, specifically: The first hop branch includes multiple convolutions and activation functions, which fuse the shallow features of the input image with the output image; The second hop branch uses convolution to map the 32-channel features of the first convolutional layer to the 64-channel features of the first transposed convolutional layer. The third hop branch uses convolution to extend the 64-channel features of the second convolutional layer to the 128-channel features of the fifth convolutional layer.
5. A real-time denoising system for digital PCR images based on gradient information enhancement, wherein the system is constructed based on the method described in claim 1, characterized in that, Includes the following modules: The design module designs a gradient information enhancement loss function, which is specifically as follows: The L1 loss function, L2 loss function, and structural similarity loss function are weighted and fused, and gradient consistency constraints are superimposed. An adversarial discriminator and a binary classification loss function are introduced. The adversarial discriminator consists of five sequentially constructed convolutional layers, specifically: ; in, The Sigmoid activation function is defined as follows: , is the ReLU activation function, O is the confidence level that the local patch is "true", and Convn is the nth convolutional layer; The training module constructs a gradient enhancement denoising network architecture, uses gradient information to enhance the loss function, and trains the gradient enhancement denoising network architecture to obtain the trained gradient enhancement denoising network architecture. The denoising module uses the trained gradient boosting denoising network architecture to denoise the input image, resulting in a denoised image.
6. A computer program product, comprising a computer program or instructions, characterized in that, When the computer program or instructions are executed by a processor, they implement the real-time denoising method for digital PCR images based on gradient information enhancement as described in any one of claims 1-4.
7. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; The processor, when executing a program stored in memory, implements the real-time denoising method for digital PCR images based on gradient information enhancement as described in any one of claims 1-4.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the real-time denoising method for digital PCR images based on gradient information enhancement as described in any one of claims 1-4.
Citation Information
Patent Citations
Ultrasonic image denoising method based on multi-attention fusion
CN114663310A
Method for eliminating noise and bubbles of PCR detection image based on dynamic deep learning
CN117689610A
Joint denoising training method combining noise-free image and noise image
CN119831886A
Image denoising method and apparatus based on wavelet high-frequency channel synthesis
US20240161251A1