A white light endoscope virtual staining method, system, storage medium and computer product

By using medical-guided image processing technology and employing a one-step diffusion mapper for pixel-by-pixel affine transformation, high-quality, real-time, and locally adaptive virtual staining images are generated. This solves the problems of false textures and lesion drift in virtual staining, reduces equipment costs, and improves diagnostic reliability.

CN123160703APending Publication Date: 2026-11-24CHONGQING BITMAP INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611195109.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-07
Publication Date
2026-11-24

AI Technical Summary

Technical Problem

Existing virtual staining methods are prone to producing false textures, lesion drift, and changes in blood vessel morphology, making it difficult to balance real-time performance with local adaptive enhancement, and they are also costly.

Method used

By extracting multiple medical priors such as blood vessels, mucosal texture, reflection, and lesions to construct a guidance map, a one-step diffusion map trained by staining prior distillation is used to generate a medical guidance local modulation table, and pixel-by-pixel affine transformation is performed to generate a virtual staining image.

Benefits of technology

Without altering the original tissue structure, high-quality, real-time, locally adaptive, and continuously adjustable virtual staining is achieved, improving the reliability of lesion boundaries and blood vessel courses while reducing equipment costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123160703A_ABST
    Figure CN123160703A_ABST
Patent Text Reader

Abstract

This invention discloses a virtual staining method, system, and storage medium for white light endoscopy, belonging to the field of medical image processing technology. The method first extracts and encodes a medical guidance map from a white light endoscopy image; then, in a low-resolution latent space, it predicts intermediate features using a one-step diffusion map trained with staining prior distillation, and generates a medical guidance local modulation table recording local color transformation parameters by combining the medical guidance map and the target staining pattern; finally, it queries the modulation table based on pixel spatial coordinates and guidance encoding to obtain the local affine matrix and color offset, and performs a pixel-by-pixel affine transformation on the original white light endoscopy image to generate a virtual staining image. This invention avoids false textures and lesion drift from a mechanistic perspective, achieves differentiated enhancement with high gain in the vascular area and zero gain in the reflective area, and meets the real-time processing requirements of endoscopic video through a training and inference separation design, while supporting continuous adjustment of enhancement intensity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of medical image processing technology, and in particular to a white light endoscope virtual staining method, system, storage medium, and computer product. Background Technology

[0002] Endoscopic examination is an important tool for screening, diagnosing, and treating diseases of the digestive, respiratory, and urinary tracts. Traditional white light endoscopy provides images of tissue surfaces in natural colors and has advantages such as widespread availability, stable imaging, and familiarity with physicians. However, it often lacks contrast when it comes to mucosal microstructures, superficial blood vessels, glandular openings, lesion boundaries, and subtle color differences. This is especially true in cases of early cancer, inflammation, atrophy, intestinal metaplasia, and polyp classification, where some diagnostic clues are subtle and rely on physician experience, leading to the risk of missed diagnoses or misdiagnoses. To improve lesion visibility, various staining or enhancement endoscopic techniques have been developed clinically. For example, dyes such as indigo carmine, methylene blue, and Lugol's iodine can enhance mucosal surface structures or specific tissue areas through spraying or absorption mechanisms; optical enhancement techniques such as narrow-band imaging, blue laser imaging, and linked imaging can reconstruct and highlight blood vessels and surface textures using specific wavelengths or spectra.

[0003] However, chemical dye spraying increases operation time and consumable costs, and may affect the clarity of the field of view; some optical enhancement modes rely on dedicated endoscope units and light sources, resulting in high equipment costs. Therefore, converting ordinary white light endoscope images into virtual stained images with similar staining or optical enhancement effects through image processing algorithms has become a research hotspot in recent years.

[0004] Existing virtual coloring methods mainly include cross-modal image translation based on generative adversarial networks, CycleGAN, diffusion models, or encoder-decoder networks. These methods can simulate the color and contrast of the target coloring domain to a certain extent, but they still have the following shortcomings:

[0005] First, generative models typically generate the entire output image directly, which can easily introduce textures, boundaries, or artifacts that are inconsistent with the original tissue structure. In medical settings, this "redrawing" generation can lead to false lesions, altered blood vessel morphology, or mucosal structure drift, affecting doctors' judgment.

[0006] Second, the transition from white light to stained images is not a typical style transfer. Staining or narrowband enhancement should primarily alter local color, brightness, contrast, and tissue visibility, rather than changing the true geometry, lesion outlines, vascular pathways, and mucosal texture. Therefore, how to enhance the display while maintaining content fidelity is a core issue in medical virtual staining.

[0007] Third, endoscopes typically operate in real-time as video streams, requiring low latency, high frame rates, and temporal stability. Multi-step generation methods such as diffusion models have slow inference speeds, making them difficult to deploy directly to real-time endoscope systems; even if ordinary image translation models are fast, they may produce color flickering, texture jumps, and unstable lesion boundaries between adjacent frames.

[0008] Fourth, existing methods mostly learn the mapping from white light to the target domain directly from the image domain or feature domain, lacking explicit constraints on endoscopic imaging mechanisms and medical structural information. For example, factors such as blood vessel probability, mucosal texture, reflective areas, lesion attention, instrument occlusion, and liquid foam have a significant impact on virtual staining quality, but are usually not fully utilized in traditional image translation models.

[0009] Therefore, there is an urgent need for a virtual staining generation method for white light endoscopic images or videos that can generate images with target staining or optical enhancement effects in real time without changing the original tissue structure, and support different staining modes, different enhancement intensities, and stable continuous video display. Summary of the Invention

[0010] To address the shortcomings of existing technologies, this invention aims to solve the problems of existing redrawing-based virtual staining methods, which are prone to producing false textures, lesion drift, and changes in blood vessel morphology, and are difficult to balance real-time performance with local adaptive enhancement. It proposes a non-redrawing white light endoscopic virtual staining scheme. This scheme extracts multi-source medical priors, such as blood vessels, mucosal textures, reflections, and lesions, to construct a guidance map. In a low-resolution latent space, a one-step diffusion map trained by staining prior distillation is used to generate a medical guidance local modulation table. Then, a pixel-by-pixel affine transformation is performed on the original high-resolution image. This achieves high-quality, real-time, locally adaptive, and continuously adjustable virtual staining while strictly maintaining the anatomical structure.

[0011] According to an embodiment of the present invention, a white light endoscope virtual staining method includes the following steps:

[0012] Acquire white light endoscopic images and determine the target virtual staining pattern;

[0013] Extract a medical guidance map from the white light endoscope image, the medical guidance map including spatial guidance information related to tissue structure;

[0014] The medical guidance map is encoded to obtain pixel-by-pixel guidance codes;

[0015] The white light endoscope image is downsampled and encoded into a low-resolution latent space. Combined with the encoded representation of the target virtual staining pattern, an intermediate feature is predicted using a real-time staining mapper.

[0016] Based on the intermediate features, the medical guidance map, and the encoded representation of the target virtual staining pattern, a medical guidance local modulation table is generated by a local modulation parameter generator. The medical guidance local modulation table records local color transformation parameters under different spatial locations and medical guidance conditions.

[0017] For each pixel in the white light endoscope image, based on the spatial coordinates of the pixel and the guidance code, the medical guidance local modulation table is queried to obtain the local affine matrix and local color offset of the pixel;

[0018] Based on the local affine matrix and local color offset, an affine transformation is performed pixel by pixel on the white light endoscope image to generate a virtual stained image.

[0019] As a further solution, the medical guidance map includes a vascular probability map, a mucosal texture map, a reflectivity suppression map, a lesion attention map, and a brightness guidance map.

[0020] As a further solution, encoding the medical guidance map to obtain pixel-by-pixel guidance codes includes: using a small multilayer perceptron consisting of three linear layers and a ReLU activation function to fuse and encode each channel of the medical guidance map, and outputting the guidance codes.

[0021] As a further solution, the vascular probability map is obtained by calculating the hemoglobin response index and combining it with a vascular segmentation network;

[0022] The mucosal texture map is obtained by fusing multi-scale gradients, Gaussian Laplace responses, and local binary modes.

[0023] The reflection suppression map is obtained by detecting high-brightness and low-saturation regions through brightness and saturation thresholds and by morphological processing.

[0024] The lesion attention map is obtained by an attention network that takes the white light endoscopic image, the vascular probability map, the mucosal texture map, and the reflectivity confidence region determined according to the reflectivity suppression map as input.

[0025] As a further solution, the medical guidance map also includes a quality confidence map, which is generated by a quality assessment branch network based on the white light endoscope image, brightness gradient, reflection suppression map, and instrument mask, and is used to represent the confidence level of each pixel.

[0026] As a further solution, the downsampling and encoding of the white light endoscopic image into a low-resolution latent space, combined with the encoded representation of the target virtual staining pattern, and the prediction of intermediate features using a real-time staining mapper, includes:

[0027] The downsampled white light endoscope image was encoded using a variational autoencoder to obtain the white light conditional latent variable.

[0028] The target virtual coloring pattern is encoded using a pattern encoder to obtain a pattern condition vector;

[0029] Using random noise, the white light conditional latent variable, and the pattern conditional vector as input, the target coloring latent variable is predicted in a single step by a one-step diffusion denoising unit in the real-time coloring mapper, and the intermediate feature is output; wherein, the one-step diffusion denoising unit is configured to directly predict the target coloring latent variable from random noise in a single step forward propagation.

[0030] As a further solution, the generation of the medical-guided local modulation table includes:

[0031] The local modulation parameter generator generates an initial bilateral grid based on the intermediate features and the mode condition vector;

[0032] Generate a spatial modulation mask based on the medical guidance diagram;

[0033] The spatial modulation mask is applied cell-by-cell to the initial bilateral grid to obtain the medical guidance local modulation table, wherein each cell of the bilateral grid stores a set of local affine transformation parameters.

[0034] As a further solution, querying the medical-guided local modulation table to obtain the local affine matrix and local color offset of the pixel includes:

[0035] The spatial coordinates of the pixel are normalized to the spatial dimension of the bilateral grid, and the corresponding guiding code is normalized to the guiding dimension of the bilateral grid;

[0036] In the bilateral grid, multilinear interpolation is performed based on the normalized spatial coordinates and guiding coordinates to obtain the local affine matrix and local color offset of the pixel.

[0037] As a further solution, the virtual stained image is generated by performing an affine transformation pixel-by-pixel on the white light endoscope image using the following formula:

[0038]

[0039] in, This indicates the generated virtual stained image in pixels. color vector, Represents a local affine matrix. This indicates the local color offset. This indicates that the white light endoscopic image is in pixels. The color vector.

[0040] As a further solution, it also includes:

[0041] Control parameters by staining intensity Generate virtual staining images with adjustable intensity:

[0042]

[0043] in, Corresponding white light endoscopic image, Corresponding to the standard virtual staining image, by changing The parameters are continuously adjusted to enhance the strength.

[0044] As a further solution, the real-time staining mapper is trained through knowledge distillation, which includes a staining prior instructor. The training process includes:

[0045] A pre-trained multi-step generative model is set as a frozen coloring prior guide, and a trainable regular guide is set. The trainable regular guide updates its parameters synchronously with the real-time coloring mapper during the training process.

[0046] After the real-time staining mapper predicts the target staining latent variable, it obtains the intermediate noise latent variable by adding noise.

[0047] The intermediate noise latent variable is predicted using the staining prior guide and the trainable regular guide, respectively, and a variational fractional distillation loss is constructed based on the difference between the two prediction results.

[0048] By minimizing the variational fractional distillation loss, the staining domain prior knowledge of the staining prior instructor is transferred to the real-time staining mapper.

[0049] As a further solution, the training process also includes a data supervision loss, which is calculated based on the downsampling results of the low-resolution predicted image output by the real-time staining mapper and the paired target staining image.

[0050] As a further solution, the training process also includes a medical staining alignment loss, which is used to constrain the embedding of the output image in the feature space to align with the encoded representation of the target virtual staining pattern.

[0051] As a further solution, the training process also includes a structure-preserving loss, which constrains the consistency of image gradients and deep structural features between the virtual stained image and the white light endoscope image.

[0052] As a further solution, the training process also includes a local modulation regularization loss, which includes a multidimensional Laplacian smoothing constraint applied to the medical-guided local modulation table, and / or an out-of-bounds penalty for the virtual staining image exceeding the legal color range.

[0053] As a further solution, when the training samples are endoscopic videos, the training process also includes:

[0054] Obtain the optical flow between the current frame and the previous frame;

[0055] The optical flow is used to align the virtual staining image of the previous frame and / or the medical-guided local modulation table of the previous frame to the coordinate system of the current frame.

[0056] Based on the aligned results, a temporal consistency loss is constructed to constrain the smooth transition of color and enhancement intensity between adjacent frames and suppress video flicker.

[0057] On the other hand, according to embodiments of the present invention, a white light endoscope virtual staining system is also provided, comprising:

[0058] The medical guidance image extraction module is used to extract medical guidance images from white light endoscopy images;

[0059] The guidance coding module is used to encode the medical guidance diagram to obtain pixel-by-pixel guidance codes;

[0060] A real-time staining mapper is used to predict intermediate features in a low-resolution latent space based on downsampled coded features of the white light endoscope image and the target virtual staining pattern.

[0061] A local modulation parameter generator is used to generate a medical guidance local modulation table based on the intermediate features, the medical guidance map, and the encoded representation of the target virtual staining pattern.

[0062] The query module is used to query the medical guidance local modulation table for each pixel in the white light endoscope image, based on its spatial coordinates and the guidance code, to obtain the local affine matrix and local color offset.

[0063] The transformation module is used to perform a pixel-by-pixel affine transformation on the white light endoscope image based on the local affine matrix and the local color offset to generate a virtual staining image.

[0064] As a further solution, a variational autoencoder is used to downsample and encode the white light endoscope image into a low-resolution latent space to obtain white light conditional latent variables.

[0065] A pattern encoder is used to encode the target virtual coloring pattern to obtain a pattern condition vector;

[0066] The real-time coloring mapper is specifically used to predict the target coloring latent variable in a single step through a one-step diffusion denoising device, taking random noise, the white light conditional latent variable, and the pattern conditional vector as input, and outputting the intermediate features.

[0067] As a further solution, the local modulation parameter generator is specifically used for:

[0068] An initial bilateral mesh is generated based on the intermediate features and the encoded representation of the target virtual coloring pattern;

[0069] A spatial modulation mask is generated based on the aforementioned medical guidance diagram;

[0070] The spatial modulation mask is applied to the initial bilateral grid cell by cell to obtain the medical guidance local modulation table.

[0071] On the other hand, according to embodiments of the present invention, a computer-readable storage medium is also provided, on which a computer program is stored, which, when executed by a processor, implements a white light endoscope virtual staining method as described in any of the above technical solutions.

[0072] On the other hand, according to embodiments of the present invention, a computer program product is also provided, the computer program product including a computer program, which, when executed by a processor, implements a white light endoscope virtual staining method as described in any of the above technical solutions.

[0073] Compared with the prior art, the present invention has the following beneficial effects:

[0074] The white light endoscopy virtual staining method provided by this invention, compared with the existing technical route of directly generating the whole staining image based on generative adversarial networks, U-shaped networks or diffusion models, transforms the staining task from generating pixel values ​​to predicting local color transformation parameters, and uses these parameters to perform pixel-by-pixel affine transformation on the original white light endoscopy image. This eliminates the risk of false textures, lesion drift and changes in blood vessel morphology at the mechanism level, so that the lesion boundary and blood vessel course in the enhancement result are strictly consistent with the original white light endoscopy image, which significantly improves the credibility of virtual staining in clinical scenarios with extremely high requirements for structural accuracy, such as early cancer screening.

[0075] This invention constructs a multi-branch parallel medical guidance map extraction module, fusing multi-source medical prior information such as vascular probability, mucosal texture, reflectivity suppression, lesion attention, and quality confidence into a unified guidance representation, which guides the generation and querying of local modulation tables. This medical guidance mechanism can apply differentiated enhancement strategies to different tissue regions: applying higher gain to vascular regions to highlight microvascular morphology, attenuating transformation parameters to near zero in reflective regions to avoid artifacts, moderately enhancing lesion regions to aid diagnosis, and reducing enhancement intensity or using stable parameters in low-quality regions such as motion blur or instrument occlusion. Compared to existing methods that apply uniform processing to the entire image, this invention achieves local adaptive enhancement, ensuring that each tissue type receives enhancement intensity most suitable for its clinical observation needs.

[0076] While achieving high-quality staining results, this invention also resolves the contradiction between real-time performance and generation quality. During the training phase, a pre-trained multi-step diffusion model is used as a frozen staining prior guide. Its staining domain knowledge is transferred to a lightweight real-time staining mapper through variational fractional distillation loss, and a trainable regularized guide that updates synchronously with the mapper is set to stabilize the gradient of the distillation process. In the inference phase, the guide is completely removed, retaining only single-step denoising prediction and table-based parameter acquisition operations. The computational complexity of the entire inference path is reduced from the order of magnitude of the multi-step diffusion model to single-step prediction plus parallelizable pixel-wise affine transformation in low-resolution space. Furthermore, this invention simultaneously constrains the output images and modulation tables of adjacent frames through temporal consistency loss, suppressing color flicker and enhancement intensity jumps between video frames at the source. Through linear adjustment of the staining intensity control parameters, doctors can continuously switch between the original white light image and the standard virtual staining image, meeting the clinical observation needs of different stages from screening to detailed examination. Attached Figure Description

[0077] Figure 1 A flowchart of a white light endoscope virtual staining method provided by the present invention;

[0078] Figure 2 This is a schematic diagram of the structure of the medical guidance map extraction module provided by the present invention;

[0079] Figure 3 A schematic diagram of the structure of the low-resolution real-time staining mapper and staining prior guidance training provided by the present invention;

[0080] Figure 4 This is a schematic diagram of the parameter mapping and application architecture of the medical guidance local modulation table provided by the present invention;

[0081] Figure 5 This is a schematic diagram of the structure of a white light endoscope virtual staining system provided by the present invention. Detailed Implementation

[0082] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are only a part of the embodiments of this invention, and not all of them. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.

[0083] like Figure 1 As shown, this embodiment provides a virtual staining method for white light endoscopy, including the following steps:

[0084] Acquire white light endoscopic images and determine the target virtual staining pattern;

[0085] Extract a medical guidance map from the white light endoscope image, the medical guidance map including spatial guidance information related to tissue structure;

[0086] The medical guidance map is encoded to obtain pixel-by-pixel guidance codes;

[0087] The white light endoscope image is downsampled and encoded into a low-resolution latent space. Combined with the encoded representation of the target virtual staining pattern, an intermediate feature is predicted using a real-time staining mapper.

[0088] Based on the intermediate features, the medical guidance map, and the encoded representation of the target virtual staining pattern, a medical guidance local modulation table is generated by a local modulation parameter generator. The medical guidance local modulation table records local color transformation parameters under different spatial locations and medical guidance conditions.

[0089] For each pixel in the white light endoscope image, based on the spatial coordinates of the pixel and the guidance code, the medical guidance local modulation table is queried to obtain the local affine matrix and local color offset of the pixel;

[0090] Based on the local affine matrix and local color offset, an affine transformation is performed pixel by pixel on the white light endoscope image to generate a virtual stained image.

[0091] It should be noted that this invention employs a non-redrawing image transfer strategy, replacing whole-image generation with local photometric / color transformation. This ensures that each pixel value in the output image is strictly derived from the corresponding pixel of the original white-light endoscope image through color transformation, rather than being redrawn by the generative model. This mechanism avoids the risks of false textures, lesion drift, and changes in blood vessel morphology. Furthermore, by decomposing the virtual staining task into a training phase and an inference phase: the training phase introduces a pre-trained high-capacity generative model as a staining prior guide to learn high-quality staining domain distributions, and then transfers its staining domain prior knowledge to a lightweight real-time staining mapper through knowledge distillation; the inference phase removes the staining prior guide, retaining only the real-time staining mapper, the medical guidance map extraction module, and the local modulation parameter generator, thus balancing high-quality staining effects with real-time processing requirements.

[0092] Example 1

[0093] Existing virtual staining methods typically use generative models to directly generate the entire output image. However, in actual endoscopic fields of view, there are multiple tissue types, such as blood vessels, mucosa, reflective areas, and lesion areas. Ideally, enhancement should be applied to the vascular area to highlight the vascular morphology, enhancement should be reduced or avoided in the reflective area to prevent artifacts, and enhancement should be applied appropriately in the lesion area to aid in diagnosis.

[0094] Therefore, this embodiment details the extraction process of the medical guidance map, which provides structured control signals for the subsequent local modulation parameter generator, enabling it to apply differentiated enhancement effects to different tissue regions. The medical guidance map extraction module can be implemented using a combination of traditional image processing and lightweight networks, or it can be implemented end-to-end using a multi-task neural network. For ease of explanation, this embodiment adopts a combined scheme of "rule-based prior + lightweight learning branch + quality confidence fusion". This scheme combines the interpretability of traditional image processing with the data-driven advantages of deep learning: rule-based prior can stably extract known features using medical domain knowledge, lightweight learning branches can learn more complex patterns from data, and quality confidence fusion can evaluate the reliability of the outputs of each branch.

[0095] like Figure 2 As shown, the medical guidance image extraction module uses standardized white light images. As input, the system extracts six types of guidance maps—a vascular probability map (V), a mucosal texture map (T), a reflectivity suppression map (R), a lesion attention map (S), a quality confidence map (Q), and a brightness guidance map (Y)—through multiple parallel branches. These six guidance maps are then input into the channel normalization function. This is integrated into the final medical guidance diagram. The multi-branch parallel structure allows each type of medical prior information to be extracted independently and professionally. Different branches perform their respective functions while complementing each other. For example, the reflection suppression map can help the lesion attention map eliminate the interference of highlight artifacts, and the vascular probability map can provide clues about the abnormal distribution of blood vessels in the lesion attention map. The specific implementation and fusion encoding process of each branch are described below.

[0096] Acquiring white light endoscope images Where H and W represent the height and width of the image, respectively, and 3 represents the RGB three channels. After inputting the original white light frame, the system first performs visual area extraction, black border cropping, color normalization, brightness correction, and scale unification to obtain a standardized white light image. Specifically, if there are lens vignetting, edge black areas, or circular field of view boundaries in the endoscope, an effective field of view mask can be obtained through threshold segmentation and morphological closing operations. The above preprocessing process can be expressed as:

[0097]

[0098] in, This is a frame of the original white light endoscope image. This indicates cropping of the field of view and removal of black borders. This represents white balance, brightness normalization, and scale normalization. To standardize white light images, preprocessing is used to eliminate image differences caused by different endoscopic devices and lighting conditions, providing a consistent input benchmark for subsequent branches.

[0099] The brightness guide image Y is derived from a standardized white light image. The weighted calculation of the three color channels yields:

[0100]

[0101] Among them, R, G, and B are The spatial gradient of the three color channels and the brightness guide image Y. Calculated using the Sobel or Scharr operator, i.e.: The brightness guide map and its gradient, as the most basic image structural information, will be reused in several subsequent branches.

[0102] The vascular probability map V is used to identify superficial blood vessels, areas related to hemoglobin uptake, and microvascular structures that need enhancement.

[0103] Unlike existing methods that rely solely on general image features to extract blood vessels, this embodiment fully utilizes the absorption spectral characteristics of hemoglobin in a specific wavelength band. First, the hemoglobin response index is calculated:

[0104]

[0105] in, A stability constant is used to prevent logarithmic operations from overflowing. These represent the spatial coordinates of pixels in the image. The hemoglobin response index utilizes the characteristic that hemoglobin has strong absorption in the green light band (G channel) and weak absorption in the red light band (R channel), enhancing the differences in the red and green channels related to vascular absorption through logarithmic difference operations. Compared to directly using the original RGB channels, the hemoglobin response index can more stably highlight vascular areas and has a certain robustness to changes in illumination.

[0106] Then the hemoglobin response index Standardized white light image Spatial gradient of brightness guide map After splicing by channel, input a small number of vascular branches. , Lightweight network architectures such as MobileNet, lightweight U-Net, or convolutional attention modules can be used. The hemoglobin response index... Standardized white light image Spatial gradient of brightness guide map By combining these three inputs, the network can both leverage domain knowledge for guidance and autonomously learn and supplement features from the data. Finally, the Sigmoid function is used to... Activation yields a blood vessel probability map:

[0107]

[0108] Mucosal texture maps (T) are used to indicate glandular openings, villous structures, fold edges, and the surface irregularities of lesions. These texture features are of significant clinical value in determining the benign or malignant nature of lesions and in determining the extent of resection.

[0109] A single texture description operator is insufficient to fully capture the complex texture of the mucosal surface. This embodiment obtains the mucosal texture map by fusing multi-scale gradients, Gaussian Laplacian responses, and local binary modes:

[0110]

[0111] in, It is a Gaussian Laplacian operator, which can detect speckled structures (corresponding to glandular opening morphology) at different scales. LBP is a local binary mode, a classic texture description operator that is robust to changes in illumination and can effectively describe the local microscopic arrangement of villi and folds. For normalization function, and , where is the weighting coefficient. The fusion of multiple scales and multiple operators enables texture maps to simultaneously capture coarse-grained fold orientations and fine-grained glandular structures.

[0112] The combination of vascular probability maps and mucosal texture maps can provide complementary structural information for virtual staining: vascular probability maps indicate which areas need to be enhanced with hemoglobin-related color enhancement, while mucosal texture maps indicate which areas need to have their texture contrast enhanced to highlight the microstructure.

[0113] Endoscopic images often exhibit specular reflections, liquid highlights, and bubble highlights. Forcibly enhancing these areas with staining can easily produce artifacts. Existing methods typically enhance these highlighted areas indiscriminately, resulting in unnatural color blocks or textures in the reflected areas of the output image. Therefore, this embodiment generates a reflection suppression map R to reduce the staining intensity of highlighted, low-texture areas.

[0114] First, detect the initial reflective area:

[0115]

[0116] in, This is the initial reflective area. The brightness threshold. For color saturation, The saturation threshold, Let be the spatial coordinates of the pixels in the image, and Y be the brightness guide map. High-brightness and low-saturation areas typically correspond to specular reflections. By simultaneously constraining both brightness and saturation dimensions, it is possible to effectively distinguish true specular reflections from mucosal areas with high brightness but diagnostic value (such as superficial raised lesions).

[0117] Then, a reflection suppression map is obtained through morphological closing and dilation operations:

[0118]

[0119] in, This is a reflection suppression diagram. This is a morphological closing operation. For expansion operation, This indicates the size of the structural element. The purpose of morphological processing is to eliminate small voids and slightly extend the suppression range to the neighborhood of the reflective area to avoid abrupt changes in the enhancement effect at the reflective boundary and achieve a smooth transition.

[0120] The lesion attention map (S) is used to highlight polyps, erosions, ulcers, abnormal blood vessels, poorly defined areas, or other areas of concern to the physician. It is not a diagnostic conclusion, but rather used to determine the spatial weight of virtual staining enhancement. The lesion attention map utilizes light lesion attention branches. get:

[0121]

[0122] Where S represents the lesion attention map. For minor lesions, the attention branch is represented, and 1-R indicates the area of ​​reliable reflection.

[0123] By using reflective, reliable regions as input, the network learns the prior knowledge that reflective regions should not generate lesion attention, thus avoiding misclassification of brightness anomalies caused by reflection as lesion areas of interest. Simultaneously, the vascular probability map V and mucosal texture map T extracted in the preceding steps are included as input, enabling lesion attention to comprehensively utilize two key lesion features: vascular abnormalities and texture disturbances.

[0124] During endoscopic examinations, motion blur, defocusing, obstruction, fluid coverage, or instrument entry are unavoidable. Forcibly enhancing these low-quality areas not only fails to provide useful information but may also introduce misleading artifacts. Therefore, a quality confidence map Q is introduced to identify such low-confidence areas. In low-confidence areas, the enhancement intensity can be reduced or the stable parameters from the previous frame can be reused. The quality confidence map uses a quality assessment branch... get:

[0125]

[0126] in, For optional instrument or foreign body obstruction maps, non-physiological tissue areas within the endoscopic field of view are marked; this portion can be generated by an obstruction segmentation model. In general implementations, it can be assumed that the endoscopic image is unobstructed. All zeros; The quality evaluation branch is a lightweight fully convolutional network with a 6-channel input (3 channels for RGB, 1 channel for gradient, 1 channel for reflection, and 1 channel for instrument mask) and a single-channel confidence map output. The rationale for incorporating gradient information into quality assessment is that the gradient magnitude in motion-blurred and out-of-focus areas is typically significantly lower than that in sharp areas.

[0127] Reflection suppression map, lesion attention map, and quality confidence score Figure 3 These together constitute an enhanced safety and attention mechanism: the reflection suppression map prevents artifacts, the lesion attention map guides enhancement to focus on clinically relevant areas, and the quality confidence map avoids unreliable enhancement of low-quality areas.

[0128] Please see Figure 2 The outputs of each branch are concatenated by channel and then normalized using a channel normalization function. Obtain the medical guidance map tensor The aforementioned branches characterize tissue features within the endoscopic field of view from different dimensions. The outputs of each branch are concatenated by channel, and numerical normalization and confidence constraints are applied to obtain the medical guidance map tensor:

[0129]

[0130] in, For channel normalization and range clipping functions, This is a medical guidance map tensor that can be directly used in guided queries of local modulation tables or input into a local modulation parameter generator to predict color transformation parameters for different regions.

[0131] Through the above integration, medical guidance maps By integrating multi-dimensional medical prior information such as brightness, blood vessels, texture, reflection, lesions, and quality into a unified multi-channel representation, rich spatial control signals are provided for the subsequent local modulation parameter generator.

[0132] Through the above integration, medical guidance maps By integrating multi-dimensional medical prior information such as brightness, blood vessels, texture, reflection, lesions, and quality into a unified multi-channel representation, rich spatial control signals are provided for the subsequent local modulation parameter generator.

[0133] However, higher dimensions Directly using the modulation table would result in excessively high query dimensions and computational complexity. To address this issue, the medical guidance image is encoded to obtain pixel-by-pixel guidance codes. :

[0134]

[0135] in, This is the guiding code for pixel p. The guiding encoding function is calculated by a three-layer linear multilayer perceptron; in this embodiment, a small multilayer perceptron consisting of three linear layers and a ReLU activation function is used. right Perform fusion encoding:

[0136]

[0137]

[0138]

[0139] in, , , This is the weight matrix. , , This is a bias term. After this encoding, the bootstrap encoding is performed. Multi-channel medical guidance information is compressed into a single scalar value (the output range of the sigmoid function is [0, 1]) for subsequent modulation table lookups. The three-layer MLP can learn the nonlinear interactions between channels without introducing excessive computational overhead. After this encoding, the guidance dimension d of the modulation table can be set to a smaller value (e.g., d=8 or d=16), making trilinear interpolation lookups computationally feasible.

[0140] In a preferred embodiment, the medical guided image extraction module is jointly trained with the subsequent real-time staining mapper and local modulation parameter generator, enabling better collaborative optimization among the modules. When the amount of data is limited, pseudo-labels can be generated first using manual annotation or traditional image processing, followed by supervised or semi-supervised training of the vascular branch, texture branch, reflection branch, and lesion attention branch. This staged training strategy effectively alleviates the problem of scarce medical image annotation data: traditional image processing methods can provide reliable initial supervision signals, enabling the network to converge to a reasonable solution even with limited annotation data.

[0141] Example 2

[0142] Existing image generation methods based on diffusion models typically require dozens or even hundreds of iterative denoising steps. While generating high-quality images, their inference speed cannot meet the real-time requirements of endoscopic videos (usually requiring at least 30 frames per second). The core design idea of ​​this embodiment is to perform single-step prediction in a low-resolution latent space and transfer the color domain knowledge of the multi-step diffusion model to a lightweight single-step mapper through knowledge distillation, thereby achieving a balance between inference speed and generation quality.

[0143] like Figure 3 As shown, the overall architecture of this embodiment is divided into four parts: encoding / condition acquisition, core generation, decoding, and distillation / loss.

[0144] In the encoding / conditional acquisition section, input a white light endoscope image. After downsampling module and VAE encoder Obtain the conditional latent variables of white light Target virtual staining mode via pattern encoder Obtain the pattern condition vector .

[0145] In the core generation part, random noise is used. White light conditional latent variables and mode condition vector Common Input Real-Time Stain Mapper , Output intermediate features And predict the target staining latent variables .

[0146] In the decoding section, via VAE decoder Generate low-resolution staining prediction results .

[0147] In the distillation / loss section Obtained through noise addition process They were respectively sent into the frozen staining prior guide. and trainable regularization guide Noise prediction is performed, and variational fractional distillation loss is calculated based on the difference between the two prediction results. .

[0148] The specific implementation of each part is described below.

[0149] Assume the input is a white light endoscope image. Where H and W are the height and width of the image, respectively, and 3 represents the RGB three channels.

[0150] The target virtual staining pattern is denoted as ,in, This indicates narrowband imaging enhancement. Indicates indigo-carmine staining. Indicates methylene blue staining. Indicates Lugol's iodine staining, This indicates a customizable medical enhancement mode. This multi-mode design allows a single system to cover a variety of clinical staining needs, and physicians can freely choose between different enhancement modes without switching devices or changing software.

[0151] Extracting a medical guidance map from the input image. In one implementation, the medical guidance map output by the medical guidance map extraction module can be initially represented as:

[0152]

[0153]

[0154] in, For the medical guidance image extraction module, This is a probability map of blood vessels. This is a mucosal texture map. This is a reflection suppression diagram. Attention map of the lesion. This is a brightness guide diagram.

[0155] First, the white light endoscopic image is downsampled to obtain a low-resolution white light image:

[0156]

[0157] Where D represents the downsampling operation, This represents a low-resolution white light image;

[0158] Then, a variational autoencoder is used to... Encoding yields the conditional latent variables for white light:

[0159]

[0160] in This refers to the VAE encoder. The VAE encoder further compresses low-resolution images into a compact latent variable representation, minimizing data dimensionality while preserving the semantic information required for coloring.

[0161] Simultaneously, the target virtual coloring pattern M is encoded using a pattern encoder to obtain the pattern condition vector:

[0162]

[0163] This can be achieved using a text encoder, a category embedding network, or a multimodal medical encoder. When using a category embedding network, each staining pattern corresponds to a learnable embedding vector, allowing the differences between different patterns to be expressed in the embedding space.

[0164] like Figure 3 As shown in the core generation section, a trainable real-time coloring mapper With random noise White light conditional latent variables and mode condition vector Using the input as input, a single-step diffusion denoising process is used to predict the target coloring latent variables:

[0165]

[0166] And output intermediate features Real-time staining mapper Its internal structure is the same as Stable Diffusion's UNet, the difference being that it performs only one-step denoising instead of multi-step iterations. The one-step diffusion denoiser is configured to predict the target coloring latent variables directly from random noise in a single-step forward propagation.

[0167] During the inference phase, the VAE decoder can be used. Will Decoded into low-resolution staining prediction results However, the final image in the inference phase does not depend on this low-resolution output. The low-resolution prediction is only used to provide a supervision signal during the training phase. During the inference phase, a virtual stained image is generated by applying a subsequent medical-guided local modulation table to the original high-resolution white light endoscope image, thereby simultaneously achieving high resolution and structural fidelity.

[0168] like Figure 2 As shown in the distillation / loss section, during the training phase, a pre-trained multi-step generative model is set up as a frozen coloring prior guide. This guide is a pre-trained multi-step diffusion model whose weights are frozen during the distillation stage to provide high-quality prior knowledge of the chromatid domains. The model structure of the chromatid prior guide can be the same as that of Stable Diffusion 1.5UNet. The reason for freezing the weights is that the multi-step diffusion model has already learned a rich distribution of chromatid domains, and retraining is not only computationally expensive but may also destroy the learned prior knowledge.

[0169] Simultaneously, a trainable regularization guide is configured. . This indicates a trainable regularized guide or low-rank incremental guide for stabilizing the distillation process. The regularized guide is used in conjunction with a low-resolution real-time staining mapper. A lightweight regularizer that updates synchronously and tracks online. The current distribution provides The output is the gradient direction for calculating the variational fractional distillation loss.

[0170] Real-time staining mapper before distillation training begins The weights are based on a pre-trained multi-step diffusion model (i.e., a coloring prior guide). The weights are initialized. Because... and With the same UNet structure, directly loading pre-trained weights can... It has basic denoising capabilities in the early stages of training, thereby accelerating the convergence of distillation training and avoiding convergence difficulties or instability problems that may occur when training starts from random initialization.

[0171] The specific steps for distillation training are as follows: First, the real-time staining mapper... Predicting target staining latent variables Then, noise is added to it to obtain the intermediate noise latent variable:

[0172]

[0173] in, Standard Gaussian noise, and For the spread noise scheduling coefficient, This is the diffusion time step.

[0174] Then, the frozen staining prior guide was used respectively. and trainable regularization guide right Noise prediction yields:

[0175]

[0176]

[0177] Based on the difference in the two prediction results, a variational fractional distillation loss is constructed, the gradient of which is:

[0178]

[0179] in This is the time step weighting function. Its function is to enable the real-time color mapper The output distribution of the model approximates the high-quality staining prior, and the difference in noise prediction between the two is the distribution gap that the student model needs to narrow, so that the real-time staining mapper can obtain the staining domain representation ability of the multi-step generative model.

[0180] Regarding training data, when paired white light endoscope images and target staining images exist, data-supervised loss can be used for training simultaneously; when only white light endoscope images exist (without paired staining images), training can be performed solely based on variational fractional distillation loss. The prior knowledge provided by the staining prior instructor can guide the mapper to learn a reasonable staining domain distribution without paired supervision.

[0181] The training of this method requires simultaneously satisfying multiple optimization objectives: realistic coloring effects, invariant structure, smooth modulation table, and stable video frames. A single loss function is difficult to satisfy these requirements simultaneously. Therefore, this embodiment adopts a strategy of weighted combination of multiple losses, with each loss performing its own function to jointly guide the model to converge to the ideal state.

[0182] Training is performed using a two-stage asymptotic optimization: Stage I optimizes only the real-time coloring mapper. (Low-resolution branch), activate variational fractional distillation loss Data supervision loss Medical staining alignment loss Phase II Freeze Jointly optimize the local modulation parameter generator Enable local modulation regularization loss and structural retention loss For video scenarios, additional timing consistency loss is enabled. The rationale for a two-phase design lies in: firstly, ensuring the mapper... Having acquired the correct chromatin domain expression capability, the modulation table generator is then trained on this basis. If training is done first Then it may be because The lack of convergence has led to The incorrect mapping relationship was learned.

[0183] Data supervision loss If true or half-paired target staining images exist Data-supervised loss is employed:

[0184]

[0185] in, For low-resolution staining prediction output, To color paired target images The true value after downsampling. L1 loss constrains pixel-level color accuracy, while LPIPS uses perceptual similarity loss to constrain overall perceptual quality. To balance the weights, this loss is used to ensure that the low-resolution real-time color mapper learns the overall color and style of the target color domain. The reason for using both L1 loss and perceptual loss is that L1 loss can constrain pixel-level precise color matching but is insensitive to texture and structure perception; perceptual loss LPIPS extracts high-level semantic features through pre-trained deep networks for comparison, which can constrain the consistency of the overall visual style. The two are complementary.

[0186] Medical staining alignment loss Pixel-level supervision alone cannot guarantee that the output image matches the target staining pattern in terms of global feature distribution. Therefore, a medical staining alignment loss is introduced to align the feature distribution of the output image with that of the target pattern in the embedding space. This is achieved using a medical image encoder. Final output Mapped to embedding vector , the mode condition vector Embedded representation of target coloring pattern Calculate cosine similarity loss .in ResNet-50 pre-trained on ImageNet or ViT fine-tuned on the endoscopy dataset can be used. For color pattern encoders (such as text encoder CLIP or learnable category embedding tables). and Training must be performed in the same embedding space. This loss does not require pixel-level paired data; it only needs to know which coloring mode the output belongs to, thus reducing the dependence on labeled data.

[0187] Structural retention loss To prevent medical structure drift and to constrain lesion boundaries, vascular morphology, and glandular structure from alteration, a structural preservation loss is introduced.

[0188]

[0189] in, For the image gradient operator (computed via the Sobel operator), the first term constrains the gradient difference to prevent blurring or offset of lesion edges and blood vessel boundaries; the second term... For structural feature extractors, such as pre-trained VGG-16 Layers and Layers, or medical-grade structural encoders, constrain the consistency of deep structural features, ensuring that anatomical structures such as glandular openings, fold morphology, and mucosal texture are not altered. The two-level structural constraint design considers different scales: shallow gradient constraints protect underlying structures such as edges and boundaries, while deep feature constraints protect semantic-level tissue structures. Together, they constitute a complete structural protection system from pixel to semantic level.

[0190] Local modulation canonical loss To ensure smooth, stable, and error-free color transitions in medical-guided local modulation tables, a local modulation regularization loss is introduced.

[0191]

[0192] The first constraint determines the pixel-level difference between the final output and the paired target; the second constraint... For modulation table Multidimensional Laplace operator L1 constraints penalize parameter abrupt changes between adjacent grid cells, ensuring the smoothness of the modulation table in both spatial and guiding dimensions, and preventing color jumps; the third term As a penalty for color out-of-bounds errors, when the RGB value exceeds... Linear penalty is applied within the legal display range to prevent over-enhancement from causing color saturation or truncation artifacts. The penalty uses the ReLU form and is activated only when the color exceeds the limit, allowing free transformation within the legal color range.

[0193] Temporal consistency loss Existing methods for processing endoscopic videos are prone to color flickering and abrupt changes in enhancement intensity between adjacent frames. The flickering primarily originates from two sources: inter-frame inconsistency in the output image and inter-frame instability in the modulation parameters. To address this, a temporal consistency loss is introduced to constrain the process at both the image and parameter levels. First, the colorized output of the previous frame is aligned to the coordinate system of the current frame based on optical flow.

[0194]

[0195] in, This represents an optical flow-based image alignment operation. The previous frame will be colored and output according to optical flow. Align to the current frame coordinate system ; The optical flow for adjacent frames is calculated using a lightweight optical flow network (such as RAFT or GMFlow). Simultaneously, the modulation table of the previous frame is aligned based on the optical flow to obtain... .

[0196] Constructing the timing consistency loss:

[0197]

[0198] in, For effective area masking, based on reflectance map Instrument mask The confidence level of optical flow is generated, and the areas of occlusion, reflection, instrument entry, and rapid movement are marked as 0 to exclude them from the loss calculation; ⊙ represents element-wise multiplication.

[0199] It is based on optical flow Aligned modulation table of the previous frame Constraining the consistency of modulation tables between adjacent frames to suppress color flicker, The smoothing weights are used for the timing modulation table.

[0200] In occluded or instrument-entered areas, the content between frames has already changed, and output consistency should not be required; in reflective areas, optical flow estimation is often inaccurate, and forced constraints may introduce artifacts. The first constraint constrains the consistency of the aligned image, and the second constraint constrains the consistency of the modulation tables of adjacent frames to suppress color flicker at the source.

[0201] The overall training objective is a weighted combination of the above losses:

[0202]

[0203] each To account for the loss weights, adjustments can be made based on different staining patterns and clinical tasks; Provide generative priors to make the student distribution approximate the teacher multi-step diffusion distribution; Provides pixel-level supervision of paired data; Semantic alignment of constrained coloring patterns; Prevent anatomical structure drift; Ensure the modulation table is smooth and the output colors are valid; Ensure stable timing between video frames.

[0204] Example 3

[0205] Existing virtual coloring methods typically output RGB pixel values ​​directly when generating the final image. This approach allows the generating model to control the final pixel values, posing a risk of tampering with the tissue structure. In this embodiment, the model's output is not pixel values, but a set of local color transformation parameters. The final image is obtained by performing mathematical transformations on the original image using these parameters.

[0206] like Figure 4 As shown, this embodiment describes the complete data flow from modulation table generation to the final virtual stained image output. This diagram carries... Figure 2 Medical guidance diagram Output and Figure 3 intermediate features and mode condition vector Output.

[0207] Figure 4 Medical guidance diagram in the left branch After the bootstrap coding function Processing to generate pixel-by-pixel guiding codes ; Figure 4 In the right branch, the middle feature and mode condition vector Common input local modulation parameter generator Generate a medical-guided local modulation table Then, bootstrapping coding. and modulation table The common input Lookup query module obtains the local affine matrix of each pixel through multilinear interpolation. and local color offset Finally, the staining intensity control parameters are incorporated into the Apply module. The parameters retrieved Acting on raw white light endoscopic images Generate the final virtual staining image The following describes the specific implementation of each step.

[0208] Please see Figure 4 The real-time staining mapper uses a local modulation parameter generator. Predictive Medicine-Guided Local Modulation Table:

[0209]

[0210] Wherein, P represents the medical-guided local modulation table. Represents a real-time coloring mapper intermediate features, Its function is to translate the semantic understanding results (from...) intermediate features ) and medical structural information (from This is transformed into a content-decoupled photometric transformation parameter grid. This grid does not directly store pixel values, but only stores the affine transformation rules for each color-space-medical-guided local neighborhood, thus ensuring that the tissue structure is not altered when applying transformations to the original high-resolution image during inference.

[0211] The specific process is as follows: A bilateral grid predictor in the style of HDRNet. Low-resolution branch reception. The intermediate feature map, after being reduced to low-channel size by 1×1 convolution, is then compared with the pattern conditional vector. The meshes are then fed into a three-layer fully connected network, and the output is reshaped into a bilateral mesh, i.e., the initial bilateral mesh. The advantage of using a bilateral mesh instead of dense prediction is that the bilateral mesh stores parameters in a low-resolution space, and recovers high resolution through interpolation, which greatly reduces the number of parameters and computational cost. At the same time, the mesh structure naturally provides spatial smoothness.

[0212] Meanwhile, medical guidance maps The image is mapped using a 3×3 pointwise convolution to, for example, a 16×16×1 spatial modulation mask, the size of which matches the spatial dimensions of the bilateral grid. The spatial modulation mask is multiplied by the initial bilateral grid on slices of each grid cell to achieve high-gain medical guidance modulation in the vascular region and zero-gain modulation in the reflective region, as described in Example 1, resulting in a medical guidance local modulation table: , where h and w are the low-resolution spatial dimensions, d is the number of bootstrap dimensions (corresponding to the dimension of bootstrap coding g(p), and K is the number of local modulation parameters stored in each entry.

[0213] The physical meaning of the multiplication operation is that the high value (corresponding to the blood vessel region) in the spatial modulation mask maintains the amplitude of the original transformation parameter of the grid cell, while the low value or zero value (corresponding to the reflective region) attenuates the parameter of the cell to near zero, so that the reflective region is hardly subjected to color transformation and maintains the appearance of the original white light image.

[0214] Modulation table P is from Generated from three sources: intermediate features Describe "what style should it be dyed in" (semantic / dyeing intention), medical guidance diagram Describe "where are the blood vessels, lesions, and reflections" (space medicine priors), pattern condition vector This describes "which coloring mode to use" (NBI / IC / MB, etc.). The three elements work together to ensure that the modulation table knows not only what color to use, where to use it, but also how much to use, corresponding to the three dimensions of coloring style, spatial location, and enhancement intensity, respectively.

[0215] like Figure 4As shown in the query section, for any pixel in a high-resolution white light endoscope image Based on its spatial coordinates and guidance code, the local affine matrix of the pixel is obtained by querying the medical guidance local modulation table. and local color offset .

[0216] First, through the bootstrap encoding function Obtain the guiding code of this pixel Then, multilinear interpolation queries are performed based on spatial coordinates and guided coding. Lookup is a trilinear / multilinear interpolation lookup operation based on spatial coordinates and medically guided values. The specific process is as follows: For any pixel in the output image... First, its spatial coordinates are normalized to the size of a low-resolution bilateral mesh. At the same time, the guiding code g(p) corresponding to the pixel is normalized to the guiding dimension. Then with Perform trilinear interpolation (or multilinear interpolation if the guide map is multichannel) on the 8 neighboring grid vertices in the four-dimensional modulation table P, and take the weighted average result as the local affine matrix A(p) and local color offset b(p) of the pixel.

[0217] Multilinear interpolation ensures that spatially adjacent pixels with similar medical features receive smoothly transitioned transformation parameters. Its effects are twofold: first, spatial interpolation avoids blocky artifacts in the enhancement results, resulting in a continuous spatial transition of color changes; second, guiding interpolation ensures differentiated enhancement effects for different medical feature regions (such as vascular areas and normal mucosal areas), while providing a smooth transition at the boundaries between the two types of regions, avoiding harsh dividing lines.

[0218] Furthermore, based on the obtained local affine matrix A(p) and local color offset b(p), and combined with the staining intensity control parameter α, a pixel-by-pixel affine transformation is performed on the white light endoscope image to generate a virtual staining image:

[0219]

[0220] in, Let p be the color vector of the white light endoscope image at pixel p. Let p be the color vector of the generated virtual stained image. This formula is key to structural fidelity: the model only changes the local luminosity and color, without directly redrawing the tissue structure.

[0221] Example 4

[0222] This embodiment describes the complete execution flow of the inference phase, and how doctors can adjust the enhancement intensity in real time according to clinical needs.

[0223] The coloring prior guide is no longer used in the reasoning phase. and trainable regularization guide It also does not generate the final image through a VAE decoder. The key to this method's ability to meet real-time requirements is its heavy training and lightweight inference design, which means fully utilizing the knowledge of a high-capacity model during training and retaining only lightweight execution paths during inference.

[0224] The system performs only one low-resolution real-time color mapper forward propagation, one local modulation table prediction, and one high-resolution guided application. The complete inference path can be expressed by the following formula:

[0225]

[0226]

[0227]

[0228] This inference path has low computational complexity, making it suitable for real-time display of endoscopic video, and its single-frame processing time can meet the real-time requirement of no less than 30 frames per second.

[0229] The specific execution steps are as follows: Step 1, extract the medical guidance image. And encode the medical guidance diagram to obtain the guidance code. The second step involves downsampling and encoding the white light endoscopic image, combining it with the encoded representation of the target virtual staining pattern, and then predicting intermediate features using a real-time staining mapper. The encoded representation of the target virtual coloring pattern (i.e., the pattern condition vector) The coloring patterns can be pre-calculated and stored during system initialization. Since the number of coloring patterns is limited and fixed, the values ​​of each pattern... The calculation can be completed in one forward propagation after the model is loaded, and the result can be directly obtained by looking up the table during inference, without the need for repeated encoding in each frame; the third step is to generate a medical guidance local modulation table through a local modulation parameter generator. Fourth, for each pixel in the white light endoscope image, the local affine matrix A(p) and local color offset b(p) are obtained by querying the modulation table P based on its spatial coordinates and the guided code. Fifth, an affine transformation is performed pixel-by-pixel on the white light endoscope image according to the local transformation parameters to generate a virtual stained image. .

[0230] Existing virtual staining methods typically only output a fixed intensity of enhancement. However, in actual clinical practice, the required enhancement intensity varies depending on the type of lesion and the stage of observation: stronger enhancement may be needed in the screening stage to detect minute lesions, while moderate enhancement may be needed in the detailed examination stage to avoid over-enhancing and interfering with diagnosis.

[0231] To address the aforementioned issues, this method allows physicians to continuously adjust the enhancement intensity. After generating the virtual stained image in step five, a stained intensity control parameter is introduced. A virtual staining image with adjustable intensity is generated according to the following formula:

[0232]

[0233] in, Output the original white light image at the time. Output standard virtual staining image When it is weak, The time is strongly enhanced. In this linear interpolation method, It controls the size of the "enhancement increment," rather than simply blending the final image. When When the enhancement increment is zero, the output is exactly equal to the original white light image; when The output is exactly equal to the standard virtual staining result. This design allows doctors to continuously adjust between the original white light and virtual staining without generating multiple intermediate results. This linear interpolation method has extremely low computational cost, requiring only one scalar multiplication and one vector addition of the retrieved A(p) and b(p), without affecting the real-time performance of the inference. Doctors can adjust the output in real time during the endoscopic examination using buttons or knobs. The value allows for free switching between different enhancement intensities to meet the clinical needs of different lesion types and observation stages.

[0234] Example 5

[0235] In the above embodiments, the medical guidance map extraction module adopts a combination of rule-based priors and lightweight learning branches. The advantages of this approach are strong interpretability, low training data requirements, clear physical meaning for each branch, and the ability to generate pseudo-labels for pre-training using traditional methods. In alternative embodiments, when sufficient labeled data is available, the medical guidance map extraction module can also be implemented end-to-end using a multi-task neural network to fully leverage the representational capabilities of deep learning.

[0236] Specifically, a multi-task convolutional neural network is constructed, which uses a normalized white light image as the input. As input, a shared feature extraction backbone network (such as a lightweight version of ResNet or EfficientNet) is used, with multiple output branches set on top of the backbone network to output a blood vessel probability map (V), a mucosal texture map (T), a reflectivity suppression map (R), a lesion attention map (S), and a brightness guidance map (Y), respectively. Each branch can adopt a structure of 1×1 convolutional layers followed by a sigmoid activation function. The shared backbone network design allows each task to share low-level visual features, reducing the number of parameters and computational redundancy. When the amount of data is limited, pseudo-labels for each branch can be generated first using manual annotation or traditional image processing, and then each branch can be trained in a supervised or semi-supervised manner. The medical guidance map extraction module can be jointly trained end-to-end with the subsequent real-time staining mapper and local modulation parameter generator, enabling better collaborative optimization among the modules. The advantage of end-to-end training is that the extraction of the medical guidance map is no longer independent of the subsequent staining task, but is learned with the final staining effect as the optimization goal, which may discover features that traditional rules cannot capture but are beneficial to staining.

[0237] This method can be applied to a variety of clinical endoscopic examination scenarios.

[0238] In early gastrointestinal cancer screening, doctors can choose narrow-band imaging-like enhancement mode. Narrow-band imaging utilizes the strong absorption of specific wavelengths of blue-green light by hemoglobin, enhancing the contrast between superficial mucosal vessels and the background mucosa, thus aiding in the assessment of lesion boundaries and vascular morphological abnormalities. This method... The model simulates this physical optical effect by applying targeted color changes to the vascular region through a local modulation table, thereby achieving a vascular enhancement effect similar to narrowband imaging.

[0239] In endoscopic mucosal resection or endoscopic mucosal dissection, physicians can choose the indigo carmine staining pattern. Indigo carmine staining can deposit in mucosal depressions, highlighting the morphology of glandular openings and fine mucosal structures, thus aiding in determining the extent of resection. This method... The mode simulates this effect by enhancing the contrast of textured areas, achieving a mucosal structure highlighting similar to indigo staining.

[0240] In early esophageal cancer screening, doctors can choose the Lugol iodine staining pattern. Lugol's iodine reacts with glycogen in the squamous epithelium of the esophagus, producing a brownish stain. Areas of dysplasia or cancer, due to reduced glycogen, remain unstained or are lightly stained. This method... The pattern simulates this staining contrast feature through color mapping, achieving lesion area identification similar to Lugol's iodine staining.

[0241] In addition, doctors can customize medical enhancement modes as needed. Specific color mappings and enhancement weights can be set to adapt to the observation needs of special lesion types. Custom modes can be configured by providing sample images or manually adjusting color parameters, enabling the system to be expanded to adapt to new clinical scenarios.

[0242] Compared to directly using GAN, U-Net, or diffusion models to generate the entire image, the output of this method is limited by the local affine transformation of the original white light endoscope image, making it more suitable for medical endoscopy scenarios. Specifically, this method achieves the following technical effects: First, by employing a non-redrawing strategy, it fundamentally eliminates the generation of false textures and lesion drift, ensuring that the lesion boundaries and vascular morphology in the enhanced result are completely consistent with the original image. This is crucial for early cancer diagnosis, which relies on precise boundary judgment. Second, through a medically guided local modulation table, it achieves differentiated enhancement with high gain in vascular areas and zero gain in reflective areas. Each tissue region obtains the enhancement intensity most suitable for its clinical observation needs, avoiding the artifacts and missed diagnosis risks caused by the "one-size-fits-all" enhancement of existing methods. Third, through staining prior distillation training, it utilizes the knowledge of a high-capacity model during the training phase, requiring only a lightweight network to perform single-step inference during the inference phase. The single-frame processing time can meet the real-time endoscopic video display requirements of no less than 30 frames / second, balancing high quality and real-time performance. Fourth, through the dual constraint of temporal consistency loss on the modulation table and output image, it effectively suppresses color flicker and enhancement intensity jumps between video frames, improving visual stability during continuous observation. Fifth, it controls parameters through staining intensity. With linear adjustment, doctors can continuously switch between the original white light image and the virtual staining image as needed, adapting to the clinical needs of different lesion types and observation stages, such as screening, detailed examination, and treatment.

[0243] Example 6

[0244] like Figure 5 As shown, according to another embodiment of the present invention, a white light endoscope virtual staining system is also provided, which can be used to perform the virtual staining method described in any of the above method embodiments. The system includes a medical guidance map extraction module, a guidance encoding module, a real-time staining mapper, a local modulation parameter generator, a query module, and a transformation module.

[0245] The medical guidance image extraction module is used to extract medical guidance images from white light endoscopic images. The medical guidance image refers to a feature image that reflects key clinical diagnostic information such as tissue surface structure, blood vessel distribution, and lesion boundaries, such as texture feature maps, enhanced blood vessel maps, or tissue segmentation maps. The guidance encoding module is used to encode the medical guidance image to obtain pixel-by-pixel guidance codes. These guidance codes convert the structural information in the medical guidance image into a coded representation that can be used for subsequent queries.

[0246] A real-time staining mapper is used to predict intermediate features in a low-resolution latent space based on downsampled coded features of the white light endoscopic image and the target virtual staining pattern. By performing feature prediction in the low-resolution latent space, computational complexity can be significantly reduced, meeting the real-time requirements of endoscopic surgery.

[0247] A local modulation parameter generator is used to generate a medical guidance local modulation table based on the intermediate features, the medical guidance map, and the encoded representation of the target virtual staining pattern. This local modulation table fuses the medical guidance information with the staining pattern information, providing modulation parameters for subsequent pixel-by-pixel color transformation.

[0248] The query module is used to query the medical guidance local modulation table for each pixel in the white light endoscopic image, based on its spatial coordinates and the guidance code, to obtain the local affine matrix and local color offset. The transformation module is used to perform a pixel-by-pixel affine transformation on the white light endoscopic image according to the local affine matrix and local color offset, generating a virtual staining image. Through pixel-by-pixel affine transformation, the color distribution of the white light image can be mapped to the color distribution of the target staining mode while maintaining the tissue texture structure.

[0249] Through the coordinated operation of the above modules, the system in this embodiment realizes the function of converting white light endoscopy images into virtual stained images with clinical diagnostic value in real time.

[0250] In some implementations, the system further includes a variational autoencoder and a pattern encoder. The variational autoencoder downsamples the white light endoscopic image and encodes it into a low-resolution latent space to obtain white light conditional latent variables. The pattern encoder encodes the target virtual staining pattern to obtain a pattern conditional vector. Based on this, the real-time staining mapper specifically uses random noise, the white light conditional latent variables, and the pattern conditional vector as inputs to predict the target staining latent variables in a single step using a one-step diffusion denoising device, and outputs the intermediate features. By employing a one-step diffusion denoising device, latent space feature prediction can be completed in a single-step inference, further improving the staining processing speed and meeting the needs of real-time surgical scenarios.

[0251] In some implementations, the local modulation parameter generator is specifically used to: generate an initial bilateral grid based on the intermediate features and the encoded representation of the target virtual staining pattern; generate a spatial modulation mask based on the medical guidance map; and apply the spatial modulation mask to the initial bilateral grid cell by cell to obtain the medical guidance local modulation table. By introducing the medical guidance map to generate the spatial modulation mask, the local modulation table can have stronger spatial adaptability at key locations such as tissue boundaries and lesion areas, improving the detail fidelity and clinical readability of the virtual staining image.

[0252] The above methods can be implemented by a computer program. The computer program can be stored on a computer-readable storage medium, and when executed by a processor, it implements the steps described in any of the above method embodiments. The computer-readable storage medium can be any medium capable of storing program code, such as ROM, RAM, disk, optical disk, flash memory, etc.

[0253] The above methods can also be provided as computer program products. The computer program product includes a computer program that, when executed by a processor, implements the steps described in any of the above method embodiments. The computer program product can be distributed and deployed in the form of software installation packages, cloud downloads, or SaaS services.

[0254] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.

Claims

1. A virtual staining method for white light endoscopy, characterized in that, Includes the following steps: Acquire white light endoscopic images and determine the target virtual staining pattern; Extract a medical guidance map from the white light endoscope image, the medical guidance map including spatial guidance information related to tissue structure; The medical guidance map is encoded to obtain pixel-by-pixel guidance codes; The white light endoscope image is downsampled and encoded into a low-resolution latent space. Combined with the encoded representation of the target virtual staining pattern, an intermediate feature is predicted using a real-time staining mapper. Based on the intermediate features, the medical guidance map, and the encoded representation of the target virtual staining pattern, a medical guidance local modulation table is generated by a local modulation parameter generator. The medical guidance local modulation table records local color transformation parameters under different spatial locations and medical guidance conditions. For each pixel in the white light endoscope image, based on the spatial coordinates of the pixel and the guidance code, the medical guidance local modulation table is queried to obtain the local affine matrix and local color offset of the pixel; Based on the local affine matrix and local color offset, an affine transformation is performed pixel by pixel on the white light endoscope image to generate a virtual stained image.

2. The virtual staining method for white light endoscopy according to claim 1, characterized in that, The medical guidance map includes a vascular probability map, a mucosal texture map, a reflectivity suppression map, a lesion attention map, and a brightness guidance map.

3. The white light endoscope virtual staining method according to claim 1, characterized in that, The step of encoding the medical guidance map to obtain pixel-by-pixel guidance codes includes: using a small multilayer perceptron consisting of three linear layers and a ReLU activation function to perform fusion encoding on each channel of the medical guidance map and output the guidance codes.

4. The virtual staining method for white light endoscopy according to claim 2, characterized in that: The vascular probability map is obtained by calculating the hemoglobin response index and combining it with a vascular segmentation network; The mucosal texture map is obtained by fusing multi-scale gradients, Gaussian Laplace responses, and local binary modes. The reflection suppression map is obtained by detecting high-brightness and low-saturation regions through brightness and saturation thresholds and by morphological processing. The lesion attention map is obtained by an attention network that takes the white light endoscopic image, the vascular probability map, the mucosal texture map, and the reflectivity confidence region determined according to the reflectivity suppression map as input.

5. The virtual staining method for white light endoscopy according to claim 2, characterized in that, The medical guidance map also includes a quality confidence map, which is generated by a quality assessment branch network based on the white light endoscope image, brightness gradient, reflection suppression map, and instrument mask, and is used to represent the confidence level of each pixel.

6. The white light endoscope virtual staining method according to claim 1, characterized in that, The process of downsampling and encoding the white light endoscopic image into a low-resolution latent space, combining it with the encoded representation of the target virtual staining pattern, and predicting intermediate features using a real-time staining mapper includes: The downsampled white light endoscope image was encoded using a variational autoencoder to obtain the white light conditional latent variable. The target virtual coloring pattern is encoded using a pattern encoder to obtain a pattern condition vector; Using random noise, the white light conditional latent variable, and the pattern conditional vector as input, the target coloring latent variable is predicted in a single step by a one-step diffusion denoising unit in the real-time coloring mapper, and the intermediate feature is output; wherein, the one-step diffusion denoising unit is configured to directly predict the target coloring latent variable from random noise in a single step forward propagation.

7. The white light endoscope virtual staining method according to claim 6, characterized in that, The generation of the medical-guided local modulation table includes: The local modulation parameter generator generates an initial bilateral grid based on the intermediate features and the mode condition vector; Generate a spatial modulation mask based on the medical guidance diagram; The spatial modulation mask is applied cell-by-cell to the initial bilateral grid to obtain the medical guidance local modulation table, wherein each cell of the bilateral grid stores a set of local affine transformation parameters.

8. The virtual staining method for white light endoscopy according to claim 7, characterized in that, The process of querying the medical-guided local modulation table to obtain the local affine matrix and local color offset of the pixel includes: The spatial coordinates of the pixel are normalized to the spatial dimension of the bilateral grid, and the corresponding guiding code is normalized to the guiding dimension of the bilateral grid; In the bilateral grid, multilinear interpolation is performed based on the normalized spatial coordinates and guiding coordinates to obtain the local affine matrix and local color offset of the pixel.

9. The virtual staining method for white light endoscopy according to claim 1, characterized in that, The virtual stained image is generated by performing a pixel-by-pixel affine transformation on the white light endoscope image using the following formula: in, This indicates the generated virtual stained image in pixels. color vector, Represents a local affine matrix. Indicates the local color offset. This indicates that the white light endoscopic image is in pixels. The color vector.

10. A method for virtual staining with white light endoscopy according to any one of claims 1-8, characterized in that, Also includes: Control parameters by staining intensity Generate virtual staining images with adjustable intensity: in, Corresponding white light endoscopic image, Corresponding to the standard virtual staining image, by changing The parameters are continuously adjusted to enhance the strength.

11. The virtual staining method for white light endoscopy according to claim 6, characterized in that, The real-time staining mapper is trained through knowledge distillation, which includes a staining prior instructor. The training process includes: A pre-trained multi-step generative model is set as a frozen coloring prior guide, and a trainable regular guide is set. The trainable regular guide updates its parameters synchronously with the real-time coloring mapper during the training process. After the real-time staining mapper predicts the target staining latent variable, it obtains the intermediate noise latent variable by adding noise. The intermediate noise latent variable is predicted using the staining prior guide and the trainable regular guide, respectively, and a variational fractional distillation loss is constructed based on the difference between the two prediction results. By minimizing the variational fractional distillation loss, the staining domain prior knowledge of the staining prior instructor is transferred to the real-time staining mapper.

12. The white light endoscope virtual staining method according to claim 11, characterized in that, The training process also includes a data supervision loss, which is calculated based on the downsampling results of the low-resolution predicted image output by the real-time staining mapper and the paired target staining image.

13. The virtual staining method for white light endoscopy according to claim 11, characterized in that, The training process also includes a medical staining alignment loss, which is used to constrain the embedding of the output image in the feature space to align with the encoded representation of the target virtual staining pattern.

14. The white light endoscope virtual staining method according to claim 11, characterized in that, The training process also includes a structure preservation loss, which constrains the consistency of image gradients and deep structural features between the virtual stained image and the white light endoscope image.

15. The white light endoscope virtual staining method according to claim 11, characterized in that, The training process also includes a local modulation regularization loss, which includes a multidimensional Laplacian smoothing constraint applied to the medical-guided local modulation table, and / or an out-of-bounds penalty for the virtual staining image exceeding the legal color range.

16. The virtual staining method for white light endoscopy according to claim 11, characterized in that, When the training samples are endoscopic videos, the training process further includes: Obtain the optical flow between the current frame and the previous frame; The optical flow is used to align the virtual staining image of the previous frame and / or the medical-guided local modulation table of the previous frame to the coordinate system of the current frame. Based on the aligned results, a temporal consistency loss is constructed to constrain the smooth transition of color and enhancement intensity between adjacent frames and suppress video flicker.

17. A white light endoscopic virtual staining system, characterized in that, include: The medical guidance image extraction module is used to extract medical guidance images from white light endoscopy images; The guidance coding module is used to encode the medical guidance diagram to obtain pixel-by-pixel guidance codes; A real-time staining mapper is used to predict intermediate features in a low-resolution latent space based on downsampled coded features of the white light endoscope image and the target virtual staining pattern. A local modulation parameter generator is used to generate a medical guidance local modulation table based on the intermediate features, the medical guidance map, and the encoded representation of the target virtual staining pattern. The query module is used to query the medical guidance local modulation table for each pixel in the white light endoscope image, based on its spatial coordinates and the guidance code, to obtain the local affine matrix and local color offset. The transformation module is used to perform a pixel-by-pixel affine transformation on the white light endoscope image based on the local affine matrix and the local color offset to generate a virtual staining image.

18. A white light endoscope virtual staining system according to claim 17, characterized in that, Also includes: A variational autoencoder is used to downsample and encode the white light endoscope image into a low-resolution latent space to obtain white light conditional latent variables; A pattern encoder is used to encode the target virtual coloring pattern to obtain a pattern condition vector; The real-time coloring mapper is specifically used to predict the target coloring latent variable in a single step through a one-step diffusion denoising device, taking random noise, the white light conditional latent variable, and the pattern conditional vector as input, and outputting the intermediate features.

19. A white light endoscope virtual staining system according to claim 17, characterized in that, The local modulation parameter generator is specifically used for: An initial bilateral mesh is generated based on the intermediate features and the encoded representation of the target virtual coloring pattern; A spatial modulation mask is generated based on the aforementioned medical guidance diagram; The spatial modulation mask is applied to the initial bilateral grid cell by cell to obtain the medical guidance local modulation table.

20. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the program implements a white light endoscope virtual staining method as described in any one of claims 1 to 16.

21. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements a white light endoscope virtual staining method as described in any one of claims 1 to 16.