Method and device for calculating offset between visual fields when DICOM image is generated by fluorescent scanning slide and readable storage medium thereof
By improving the template matching calculation process and introducing GPU accelerated optimization, combined with confidence judgment and sample rate screening mechanism, the problem of low reliability and insufficient calculation efficiency of the calculation of the inter-field offset when generating DICOM images by fluorescence scanning slides is solved, and efficient and reliable offset calculation is achieved.
Patent Information
- Application Number
- CN202510566213.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-30
- Publication Date
- 2025-06-03
- Estimated Expiration
- 2045-04-30
AI Technical Summary
In the prior art, when generating DICOM images by fluorescence scanning slides, the calculation of inter-field offsets has problems such as low reliability and insufficient calculation efficiency, resulting in low slicing and computational efficiency of stitching images.
Through the improved template matching calculation process, combined with GPU accelerated optimization, a trustworthiness judgment and sample rate screening mechanism are introduced to achieve efficient and reliable calculation of inter-field offset. Specific steps include converting the image to the frequency domain for cross-correlation convolution calculation, calculating the integral square sum graph, and reducing Bank conflicts through GPU data access optimization.
It improves the reliability of the calculation of the offset between the field of view, reduces the phenomenon of stitching images, improves the calculation efficiency, and can meet real-time requirements.
Smart Images

Figure CN120089304A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of medical image processing, and particularly to a method, device and readable storage medium for calculating the offset amount between fields of view when generating DICOM images from fluorescence-scanned glass slides. Background Art
[0002] During the digital scanning of fluorescent biological tissues and cells, the scanner needs to calculate the offset amount between adjacent fields of view through the overlapping area of multi-field images for stitching. The traditional method uses cross-correlation normalization scoring for template matching, but there are the following problems: 1. Low matching reliability: Sparse samples or smooth background areas are prone to false matching, and the accumulation of incorrect offset amounts causes the stitched image to be fragmented; 2. Insufficient calculation efficiency: When relying on GPU acceleration implementation of a general library (such as OpenCV), due to problems such as frequent application and release of video memory and unaligned memory access, the hardware performance is not fully released, making it difficult to meet real-time requirements.
[0003] Therefore, there is an urgent need for a method, device and readable storage medium for calculating the offset amount between fields of view when generating DICOM images from fluorescence-scanned glass slides to solve the problems existing in the prior art. Summary of the Invention
[0004] The embodiments of the present invention provide a method, device and readable storage medium for calculating the offset amount between fields of view when generating DICOM images from fluorescence-scanned glass slides. Aiming at the problems existing in the current technology, the existing template matching technology lacks a reliable credibility evaluation mechanism and sample rate screening mechanism, and the matching speed is slow, resulting in unreliable calculation of the image offset amount and affecting the accuracy of subsequent image stitching and other applications.
[0005] The core technology of the present invention mainly improves the template matching calculation process (based on the mean square error matching formula), combines GPU acceleration optimization (reducing video memory access conflicts and improving calculation efficiency), and introduces a credibility judgment (such as match_confidence) and sample rate screening (such as non_zero_rate) mechanism to comprehensively obtain a reliable image matching result.
[0006] In the first aspect, the present invention provides a method for calculating the offset amount between fields of view when generating DICOM images from fluorescence-scanned glass slides, and the method includes the following steps: S1. Initialize the template matching class according to the width and height of the original image; S2. Convert the image to be matched and the template image to the frequency domain, implement the cross-correlation convolution through Fourier transform as the product in the frequency domain according to the convolution theorem, and then convert the complex domain to the real domain to complete the cross-correlation calculation to obtain the first result; S3. Calculate the sum of squared integral images of the image to be matched. Each time, data units are fetched by setting the data structure to meet the requirements of the GPU, reducing bank conflicts, and the second result is obtained through reduction calculation; S4. Obtain the matching result by synthesizing the first result and the second result; During the process of obtaining the matching result, a credibility judgment mechanism and a sample rate screening mechanism are introduced. The credibility judgment mechanism is used to compare the ratio of each value in the matching result to the maximum value with a preset threshold, count the proportion of the number of valid ratios, and judge the credibility of the result. The sample rate screening mechanism is used to calculate the proportion of non-zero elements in the image to screen abnormal results.
[0007] Further, in step S1, when initializing the template matching class, a handle from the real number domain to the complex number domain and a handle from the complex number domain to the real number domain are created. The video memory of the image to be matched and the template image required for the Fourier transform is pre-applied, and the processing operations of the image to be matched are performed in the video memory, including converting the image to be matched to the frequency domain, converting the template image to the frequency domain, and the product result in the complex frequency domain.
[0008] Further, in step S4, the credibility judgment mechanism is specifically as follows: count the proportion of the ratio of each value in the matching result to the maximum value that is lower than the preset threshold. If this proportion exceeds the set credibility threshold, it is determined as an untrustworthy result.
[0009] Further, in step S4, the sample rate screening mechanism specifically includes: performing Otsu threshold processing, false peak construction, and Gamma correction steps on the image, then calculating the proportion of non-zero elements, and screening abnormal results caused by too few samples or uneven illumination according to this proportion.
[0010] Further, in step S3, fetching each data unit by setting the data structure to meet the requirements of the GPU specifically means: Reasonably organize the data, including data alignment, layout optimization, conflict avoidance, and combined access, to ensure that data access meets the memory access rules of the GPU.
[0011] Further, in step S4, the preset threshold is 0.12, and the set credibility threshold is 0.12.
[0012] Further, in step S4, the false peak construction is specifically as follows: add a false peak of the mean plus three times the standard deviation to the template area histogram, adjust the histogram distribution, and then perform binarization using the Otsu threshold method.
[0013] In a second aspect, the present invention provides a device for calculating the offset between fields of view when a fluorescence scanning glass slide generates a DICOM image, including: A region acquisition module configured to acquire the overlapping region of two adjacent fields of view, and determine the ROI of the image to be matched and the template region; A matching calculation module, configured to calculate a matching result based on a squared - difference matching algorithm, including: An initialization unit, used to initialize a template matching class according to the width and height of the original image, create a Fourier transform handle, and apply for video memory; A frequency - domain processing unit, used to convert an image to the frequency domain and perform cross - correlation convolution calculation; A data optimization unit, used to calculate the integral sum of squares graph and perform GPU data access optimization; A credibility judgment module, configured to compare the ratio of each value in the matching result to the maximum value with a preset threshold, count the proportion of the number of valid ratios, and judge the result credibility; A sample rate screening module, configured to calculate the proportion of non - zero pixels in the template area by combining Otsu threshold, false peak construction, Gamma correction, and Renyi entropy binarization, and judge the sample validity.
[0014] In a third aspect, the present invention provides an electronic device, including a memory and a processor. A computer program is stored in the memory, and the processor is configured to run the computer program to execute the above - mentioned method for calculating the offset between fields of view when generating a DICOM image from a fluorescence - scanned glass slide.
[0015] In a fourth aspect, the present invention provides a readable storage medium. A computer program is stored in the readable storage medium, and the computer program includes program codes for controlling a process to execute the process, and the process includes the method for calculating the offset between fields of view when generating a DICOM image from a fluorescence - scanned glass slide as described above.
[0016] The main contributions and innovations of the present invention are as follows: 1. Improvement in reliability: Introduce a multi - dimensional judgment mechanism (matching significance score match_confidence, sample proportion non_zero_rate), effectively excluding incorrect offset amounts in sparse samples or blank areas; Adjust the histogram distribution through false peaks and perform Renyi entropy segmentation to enhance the robustness of binarization under complex fluorescence backgrounds.
[0017] 2. Optimization of calculation efficiency: CUDA self - implements template matching, avoiding redundant operations of general libraries, reducing Bank conflicts through shared memory and merged memory access, and improving GPU calculation efficiency; Engineer the ROI selection design (such as the formulaic sourcerect / templaterect), supporting fast parallel calculation of horizontal / vertical offset amounts.
[0018] 3. Application effects: Reduce the splitting of stitched images and provide high - integrity DICOM data for pathological analysis; Applicable to fluorescence scenarios with low sample density or high background noise, and compatible with supplementary schemes such as feature point registration.
[0019] Details of one or more embodiments of the present invention are set forth in the following drawings and description to make other features, objects, and advantages of the present invention more concise and understandable. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present invention. The illustrative embodiments and descriptions thereof are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings: Figure 1 is a flowchart of a method for calculating the offset between fields of view when generating a DICOM image from a fluorescence-scanned glass slide according to an embodiment of the present invention; Figure 2 is a selection scheme diagram of the roi of the image to be matched and the templ_roi of the template area according to an embodiment of the present invention; Figure 3 is a schematic hardware structure diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0021] Here, exemplary embodiments will be described in detail, and examples thereof are shown in the drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with one or more embodiments of this specification. On the contrary, they are merely examples of devices and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.
[0022] It should be noted that: In other embodiments, the steps of the corresponding methods are not necessarily executed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may also be combined into a single step for description in other embodiments.
[0023] Existing offset calculation methods are prone to incorrect matching results due to sparse samples or hardware errors in fluorescence glass slide scanning, and lack multi-dimensional credibility judgment and efficient GPU optimization schemes, resulting in fragmented stitched images and low calculation efficiency.
[0024] Based on this, the present invention solves the problems existing in the prior art based on square difference matching combined with credibility scoring.
[0025] Embodiment 1 The present invention aims to propose a method for calculating the offset between fields of view when generating DICOM images from fluorescence-scanned glass slides. By combining squared difference matching with confidence scoring (such as matching significance statistics and sample area ratio analysis) and GPU memory access optimization (shared memory and aligned access), high-precision and high-reliability calculation of the offset between fields of view is achieved.
[0026] Specifically, an embodiment of the present invention provides a method for calculating the offset between fields of view when generating DICOM images from fluorescence-scanned glass slides. Specifically, referring to Figure 1 , the method includes the following steps: Step 1: Obtain the overlapping region of two adjacent fields of view, and determine the ROI of the image to be matched and the template region; Step 2: Calculate the matching result between the ROI of the image to be matched and the template region based on the squared difference matching algorithm. The matching result is obtained in the following manner: a. Initialize the template matching class according to the width and height of the original image, create a handle for the transformation from the real number domain to the complex number domain and a handle for the transformation from the complex number domain to the real number domain, and pre-apply the video memory of the image to be matched and the video memory of the template image required for the Fourier transform; (corresponding to step S1, initialize the template matching class according to the width and height of the original image).
[0027] b. Convert the image to be matched and the template image to the frequency domain, perform cross-correlation convolution calculation through frequency domain product operation, and then convert back to the real number domain to obtain the cross-correlation matrix (i.e., the first result); (corresponding to step S2, convert the image to be matched and the template image to the frequency domain, realize cross-correlation convolution through Fourier transform as the product in the frequency domain according to the convolution theorem, and then convert from the complex number domain to the real number domain to complete cross-correlation calculation to obtain the first result).
[0028] c. Calculate the integral squared sum image of the image to be matched (abbreviated as the squared image), calculate the integral squared sum of the template image through the GPU data access optimization method (i.e., the second result, including the integral squared sum image of the image to be matched and the integral squared sum of the template image), and calculate the final matching result based on the cross-correlation matrix, the integral squared sum image of the image to be matched, and the integral squared sum of the template image; (corresponding to step S3, calculate the integral squared sum image of the image to be matched, reduce bank conflicts by taking data units each time in a way of setting data structures, and perform reduction calculation to obtain the second result).
[0029] In this embodiment, the specific steps are as follows: A1. During the scanning process, there is a certain overlapping region between two adjacent fields of view. Obtain the overlapping region of two adjacent fields of view, the roi of the image to be matched and the templ_roi of the template; A2. Perform squared difference matching on the roi region obtained in the previous step to obtain the result (implemented by cuda itself): match_result( ) This is the square difference matching formula, which can be decomposed into , the image energy part and the cross - correlation part. is the pixel value of the template image (templ_roi) at the coordinate (x', y'). is the pixel value of the image to be matched (roi) at the coordinate (x + x', y + y'), where (x, y) is the offset of the template in the image to be matched; R(x, y) represents the sum of the squares of the pixel value differences in the overlapping area between the template and the image to be matched when the offset is (x, y). R(x, y) measures the pixel differences between the template and the image to be matched at different offsets. The smaller the value, the higher the matching degree between the template and this area. Therefore, the (x, y) corresponding to the minimum R(x, y) is the optimal offset.
[0030] In this way, the square difference matching provides a basis for offset calculation by quantifying the pixel differences between the template and the image to be matched. The decomposition of the formula in the present invention not only reveals the core mechanism of the matching (the cross - correlation term dominates the difference), but also provides theoretical support for subsequent GPU acceleration optimization and reliability evaluation through the separation of the energy term and the cross - correlation term, ultimately achieving high - precision and high - robustness offset calculation.
[0031] A3. Calculate match_result. Under this formula, in match_result the coordinates where the minimum value minVal is located are the offset values within the template area. Calculate the offset between the fields of view through this value; obtain the minimum value minVal and the maximum value maxVal in the result image match_result, and simplify the calculation. Roughly calculate the matching score, where is an extremely small constant (such as 10 -8 ), which is used to avoid numerical errors caused by the denominator being zero and ensure calculation stability. score ∈ [0, 1]. The smaller the value, the more reliable the matching result; the larger the value, the less reliable the matching result.
[0032] In this way, through the "relative relationship between the minimum difference and the maximum difference", effective matching points are quickly identified. Combined with subsequent statistical analysis (such as the proportion of the credible region) and sample rate screening, a multi - dimensional reliability judgment mechanism is formed, fundamentally solving the misjudgment problem of traditional template matching in low - information areas and providing reliable technical support for high - precision scenarios such as medical slide scanning.
[0033] Preferably, the selection scheme for the image to be matched roi and the template area templ_roi is as follows: Such as Figure 2As shown, in the ideal state, there is no offset between two adjacent fields of view. sourcerect: the ROI area of the source image ( Figure 2 the area corresponding to the pink box), templaterect: the ROI area of the template image ( Figure 2 the area corresponding to the yellow box). The middle black box is the calculation formula corresponding to the ROI of the overlapping part of two adjacent fields of view.
[0034] For the purpose of facilitating the realization of the project engineering, in order to calculate the offset in the horizontal and vertical directions of each field of view and have a fixed and repeatable code implementation, Figure 2 the overlapping areas sourcerect and templaterect can be configured as: Implementation of the corresponding ROI of sourcerect and templaterect in the vertical direction:
[0035]
[0036] Similarly, implementation of the corresponding ROI of sourcerect and templaterect in the horizontal direction:
[0037]
[0038] Among them, Width: the width of the image.
[0039] Height: the height of the image.
[0040] matchW_X_Dim, matchH_X_Dim: the width and height of the matching area in the X direction.
[0041] matchW_Y_Dim, matchH_Y_Dim: the width and height of the matching area in the Y direction.
[0042] CutX, CutY: the image cropping amount. In the ideal situation, the overlapping area is twice the cropping amount.
[0043] corrangeXDir_X, corrangeYDir_X: the margins preset for the offsets in the X direction and Y direction.
[0044] matchdevide: the coefficient used to divide the matching area in sourcerect and templaterect, which is the number of parts into which the pink and yellow boxes in the figure are divided to improve the calculation speed.
[0045] m: Represents the current matching region index, which is used to loop among multiple matching regions. The number of loops is matchdevide. If the result calculated in the first time of m already meets the conditions for offset calculation, this offset calculation will end.
[0046] By self - implementing with cuda, operations such as Fourier transform in the opencv cuda sum of squared differences matching interface are solved to reduce the need for frequent resource application and release operations. At the same time, the merged memory access of grayscale images and the use of cuda shared memory are adjusted to maximize the cache hit rate and improve the running speed. (The values of grayscale images are in the range of 0 - 255, and only 8 - bit representation is required for computer expression, while the synchronization mechanism of cuda is 32 - bit, with 128 bytes per bank. If the number of bytes accessed each time is too small, it is easy to cause unaligned memory access, resulting in bank conflict and resource waste, and will also increase the number of memory access instructions, which is not conducive to giving full play to the computing advantages of the GPU).
[0047] Step 3: Judge the credibility of the matching result: Compare the ratio of each value in the matching result to the maximum value with a preset threshold, and count the proportion of the number of results whose ratio is less than the preset threshold in the total number. If this proportion is zero or exceeds the set credible threshold, it is determined that the matching result is not credible; (corresponding to step S4, obtaining the first half of the matching result by integrating the first result and the second result, that is, comparing the ratio of each value in the matching result to the maximum value with a preset threshold, counting the proportion of valid ratio numbers and judging the result credibility).
[0048] In this embodiment, the specific steps are as follows: Since there are cases where the number of samples in the overlapping region of adjacent two fields of view is small, resulting in each position in the entire result match_result being close to the minimum value. Directly selecting may lead to completely wrong offset selection. Under this condition, the minimum value point in the result is particularly important for judging whether it is credible enough: B1. Denote the ratio obtained by dividing each result value of match_result by the maxVal in step A3 as ratio, set a threshold thresh_ratio (take about 0.12), loop to count the value of ratio, and count the number of results count that meet the threshold when ratio is less than the threshold; B2. Divide count by the number of all values in match_result to obtain the credibility score, denoted as:
[0049] If the match_confidence is 0 or greater than a certain value (e.g., 0.12, indicating that more than 12% of the point values are close to the result value of the minimum point, then it is considered that the point result of the minimum value is not significant enough. This is a soft tolerance during the program execution process. At the same time, within this threshold range, it reflects the significance of the result from one aspect, which is conducive to the judgment of the result), the results are all untrustworthy; (The purpose of this operation is equivalent to creating a soft trust score. If the match_results are all relatively small, it means that each value can be used as a relatively close offset. In a certain aspect, the probability of having samples in this area is smaller or the overall is relatively smooth, and the information is too small and the credibility is low, which can be used as a basis for excluding the calculation results of this offset, providing tags for trust and untrustworthiness).
[0050] Step 4: Screen the sample rate for the template area: Binarize the template area through Otsu's method combined with false peak construction, and calculate the proportion of non-zero pixels; if the proportion is lower than the preset sample rate threshold, after performing Gamma correction and background subtraction on the image, recalculate the proportion of non-zero pixels through Renyi entropy binarization, and judge the sample validity based on the proportion. (Corresponding to step S4, the second half of obtaining the matching result by combining the first result and the second result, that is, the sample rate screening mechanism is used to calculate the proportion of non-zero elements in the image to screen abnormal results).
[0051] Among them, the simplified mathematical expression of Otsu's Method is:
[0052] Among them, is the segmentation threshold to be solved (the gray value range is usually 0 ≤ ≤ L - 1, where L is the total number of gray levels); p(i) is the probability (normalized frequency) of the gray level i appearing, satisfying ; is the average gray value of the pixels (background class) below the threshold ; is the average gray value of the pixels (foreground class) above the threshold . Through the threshold segmentation of this formula, the present invention realizes the automatic distinction between the background and foreground of the image, providing key data support for subsequent reliability evaluation.
[0053] In this embodiment, for the area of the image to be matched templ_roi denoted as image_template, judge the sample ratio. If the image_template has fewer samples but shows a more significant result, and the offset calculation is an abnormal result overall, it is necessary to provide a basis for excluding such abnormal results to facilitate offset calibration by other means: C1. Perform Otsu thresholding on the entire image and then invert it to generate a binary image. Calculate the background mean (mean) and standard deviation (stddev) for the binary image region. If the background gray level is too high, perform mean truncation (since the background gray levels in different fluorescence channels may vary). Since the probability of a single peak in the histogram distribution is relatively high in the case of fluorescence, this approach obtains the binary image of the image from a global scope, making a rough estimate of the image background to facilitate the design of the background false peak value later. Artificially creating a double peak is more conducive to the segmentation by the Otsu threshold.
[0054] C2. Perform a more detailed thresholding process on the image processed in C1: a) Under fluorescence conditions, the histograms of the captured images often concentrate on certain background gray levels. The simple triangular threshold segmentation effect is either too large or too small; b) Artificially create a false peak with a value of mean + 3stddev in the histogram to adjust the overall distribution of the histogram, and perform block binarization through the Otsu thresholding idea.
[0055] c) For the binarized image, only take the templ_roi to count the non-zero values, divide by the area of templ_roi to obtain the proportion of possible samples in the templ_roi region, denoted as non_zero_rate.
[0056] C3. When non_zero_rate < 0.1 in C2, it may be due to uneven illumination causing too many pixels of the samples in this region to be set to 0 during the binarization process. Perform the following operations: a) Perform 0.5 gamma correction to make the samples more prominent; b) Make a rough background for the corrected image through mean filtering, perform background subtraction, and obtain the sample image denoted as foreground; c) Perform binary segmentation on the foreground through Renyi entropy, and recalculate the non-zero proportion in the templ_roi region, denoted as non_zero_rate; Comprehensively judge whether the calculated result value is credible based on score, match_confidence, and non_zero_rate.
[0057] For the convenience of understanding, the following is a supplementary description of the professional terms and algorithms not detailedly explained in the present invention, elaborating their principles and functions in combination with the invention scenario: I. Image Processing Related Terms and Algorithms 1. Sum of Squared Differences (SSD) Principle: By calculating the sum of the squared differences of pixel values in the overlapping region between the template image and the image to be matched, the similarity between the two is measured. The smaller the difference value, the higher the matching degree.
[0058] 2. Otsu's Method Principle: Based on the image histogram, the binarization threshold is automatically determined by maximizing the between-class variance (or minimizing the within-class variance), and the image is divided into foreground (samples) and background.
[0059] 3. Gamma Correction Principle: Through the non-linear transformation I' = I γ Adjust the gray-scale distribution of the image to improve the details in areas with uneven illumination or low contrast. γ < 1 enhances the details in the dark part, and γ > 1 suppresses the bright part.
[0060] 4. Renyi Entropy Binarization Principle: An image segmentation method based on Renyi entropy (a generalized information entropy), which determines the threshold by maximizing the sum of the Renyi entropies of the foreground and background of the image, and is more robust to low-contrast or noisy images.
[0061] II. GPU Acceleration Related Terms 1. CUDA (Compute Unified Device Architecture) Definition: A general-purpose parallel computing architecture introduced by NVIDIA that allows the use of the parallel computing cores of the GPU to accelerate scientific computing and data processing.
[0062] Optimization Points of the Present Invention: Self-implemented Fourier transform process (avoiding the general overhead of the OpenCV library), reducing Bank conflicts through merging memory access (continuous memory access), shared memory reuse, 128-byte alignment, etc., and improving the video memory access efficiency.
[0063] 2. Bank Conflict Principle: The GPU video memory consists of multiple Banks (memory banks). If multiple threads access different addresses of the same Bank simultaneously, it will lead to serialized access and reduce the bandwidth utilization rate.
[0064] Countermeasures of the Present Invention: Through data reorganization (such as transposing matrices, aligning storage by thread blocks), ensure that adjacent threads access different addresses of the Banks to avoid conflicts and improve the utilization rate of the computing cores (the core goal of "reasonable data organization").
[0065] 3. Definition of Integral Image: A preprocessing technique that stores the sum of pixels in any rectangular region of an image, reducing the time complexity of region sum calculation to O(1). Application in this invention: In step A2, calculate the integral sum of squares image of the image to be matched (each point stores the sum of squares of pixels from this point to the upper left corner), accelerating the calculation of the energy term E I to avoid repeated pixel traversal in the calculation of (x,y).
[0066] III. Terms Related to Engineering Implementation 1. ROI (Region of Interest) Definition: A specific region extracted from an image for focusing on processing targets (such as overlapping regions).
[0067] 2. Fake Peak Construction Purpose: For the unimodal distribution of the fluorescence image histogram (dominated by the background), artificially add a peak (such as the mean + 3 times the standard deviation) to convert the unimodal into a bimodal, enabling Otsu's method to effectively segment the background and samples.
[0068] IV. Reliability Evaluation Metrics 1. match_confidence (matching confidence) Calculation: Statistically calculate the proportion of points with a difference value lower than 12% of the maximum value (threshold thresh_ratio = 0.12) in the matching results.
[0069] 2. non_zero_rate (non-zero pixel rate) Significance: The proportion of non-zero pixels (regarded as samples) after binarization in the template region to the total area, reflecting the richness of effective samples in the region.
[0070] V. Concepts Related to Frequency Domain Processing 1. Fourier Transform Function: Convert the image from the spatial domain to the frequency domain, turning the convolution operation into a frequency domain product (convolution theorem), significantly reducing the computational amount (the original spatial domain convolution complexity is O(N 4 ), and the frequency domain is O(N 2 log N)).
[0071] Process of this invention: In step A2, implement the Fourier transform (real domain → complex domain → real domain) through CUDA to accelerate the calculation of the cross-correlation matrix, and combine the integral image (integral sum of squares image) technology to efficiently solve the square difference matching.
[0072] 2. Cross-Correlation Convolution Definition: It measures the similarity between the template and the image. Essentially, it is the convolution operation after the template is flipped.
[0073] Frequency domain implementation: Utilize the conjugate symmetry of the Fourier transform to convert cross-correlation into the inverse transform after the product in the frequency domain, avoiding the high complexity of direct convolution in the spatial domain.
[0074] Example 2 Based on the same concept, the present invention also proposes a device for calculating the offset between fields of view when generating DICOM images from a fluorescence scanning glass slide, including: A region acquisition module, configured to acquire the overlapping regions of two adjacent fields of view and determine the ROI of the image to be matched and the template region; A matching calculation module, configured to calculate the matching result based on the sum of squared differences matching algorithm, including: An initialization unit, used to initialize the template matching class according to the width and height of the original image, create a Fourier transform handle and apply for video memory; A frequency domain processing unit, used to convert the image to the frequency domain and perform cross-correlation convolution calculation; A data optimization unit, used to calculate the sum of integral squares graph and perform GPU data access optimization; A reliability judgment module, configured to compare the ratio of each value in the matching result to the maximum value with a preset threshold, count the proportion of the number of valid ratios and judge the result reliability; A sample rate screening module, configured to calculate the proportion of non-zero pixels in the template region through Otsu threshold combined with false peak construction, Gamma correction and Renyi entropy binarization, and judge the sample validity.
[0075] Example 3 This embodiment also provides an electronic device. Refer to Figure 3 , including a memory 404 and a processor 402. A computer program is stored in the memory 404, and the processor 402 is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0076] Specifically, the above processor 402 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC for short), or may be configured as one or more integrated circuits implementing the embodiments of the present invention.
[0077] Among them, the memory 404 may include a mass memory 404 for data or instructions. By way of example and not limitation, the memory 404 may include a hard disk drive (HDD), a floppy disk drive, a solid state drive (SSD), a flash memory, an optical disc, a magneto-optical disc, a magnetic tape, or a universal serial bus (USB) drive, or a combination of two or more of these. In a suitable case, the memory 404 may include removable or non-removable (or fixed) media. In a suitable case, the memory 404 may be inside or outside the data processing device. In a specific embodiment, the memory 404 is a non-volatile memory. In a specific embodiment, the memory 404 includes a read-only memory (ROM) and a random access memory (RAM). In a suitable case, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically alterable ROM (EAROM), or a flash memory, or a combination of two or more of these. In a suitable case, the RAM may be a static random access memory (SRAM) or a dynamic random access memory (DRAM), where the DRAM may be a fast page mode dynamic random access memory (FPMDRAM), an extended data output dynamic random access memory (EDODRAM), a synchronous dynamic random access memory (SDRAM), etc.
[0078] The memory 404 can be used to store or cache various data files required for processing and / or communication, as well as possible computer program instructions executed by the processor 402.
[0079] By reading and executing the computer program instructions stored in the memory 404, the processor 402 implements the method for calculating the offset between fields of view when generating a DICOM image from a fluorescence-scanned glass slide in any of the above embodiments.
[0080] Optionally, the above electronic device may further include a transmission device 406 and an input / output device 408. Among them, the transmission device 406 is connected to the above processor 402, and the input / output device 408 is connected to the above processor 402.
[0081] The transmission device 406 can be used to receive or send data via a network. Specific examples of the above network may include wired or wireless networks provided by the communication provider of the electronic device. In one example, the transmission device includes a network adapter (Network Interface Controller, abbreviated as NIC), which can be connected to other network devices through a base station and thus communicate with the Internet. In one example, the transmission device 406 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0082] The input / output device 408 is used to input or output information.
[0083] Embodiment 4 This embodiment also provides a readable storage medium, in which a computer program is stored. The computer program includes program code for controlling a process to execute the process, and the process includes the method for calculating the offset between fields of view when generating a DICOM image from a fluorescence-scanned glass slide according to Embodiment 1.
[0084] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation manners, and will not be elaborated herein.
[0085] Generally, various embodiments can be implemented in hardware or dedicated circuits, software, logic, or any combination thereof. Some aspects of the present invention can be implemented in hardware, while other aspects can be implemented by firmware or software executed by a controller, microprocessor, or other computing device, but the present invention is not limited thereto. Although the various aspects of the present invention can be shown and described as block diagrams, flowcharts, or using some other graphical representation, it should be understood that, as a non-limiting example, the blocks, devices, systems, technologies, or methods described herein can be implemented in hardware, software, firmware, dedicated circuits or logic, general hardware or a controller or other computing device, or some combination thereof.
[0086] Embodiments of the present invention can be implemented by computer software, which can be executed by a data processor of a mobile device, such as in a processor entity, or by hardware, or by a combination of software and hardware. A computer software or program (also referred to as a program product), including software routines, applets, and / or macros, can be stored in any device-readable data storage medium, and they include program instructions for performing specific tasks. The computer program product can include one or more computer-executable components that are configured to execute the embodiments when the program runs. One or more computer-executable components can be at least one software code or a part thereof. Additionally, in this regard, it should be noted that any box in the logical flow as shown in the figure can represent a program step, or interconnected logical circuits, boxes, and functions, or a combination of program steps and logical circuits, boxes, and functions. The software can be stored on physical media such as memory chips or storage blocks implemented within a processor, magnetic media such as hard disks or floppy disks, and optical media such as, for example, DVDs and their data variants, CDs. The physical media is a non-transitory medium.
[0087] Those skilled in the art should understand that the technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered to be within the scope described in this specification.
[0088] The above embodiments merely represent several implementation manners of the present invention, and their descriptions are relatively specific and detailed. However, they should not be construed as limiting the scope of the present invention. It should be pointed out that for those of ordinary skill in the art, without departing from the concept of the present invention, several modifications and improvements can still be made, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the appended claims.
Claims
1. A method for calculating the offset between visual fields when generating DICOM images by fluorescent scanning slides, characterized in that: The following steps are involved: S1, initialize the template matching class according to the width and height of the original image; S2, converting the image to be matched and the template image into the frequency domain, converting the cross-correlation convolution into the product of the frequency domain through Fourier transformation according to the convolution theorem, and then converting the complex domain into the real domain to complete the cross-correlation calculation to obtain the first result; S3, calculating the integral square sum graph of the to-be-matched graph, taking data units each time by setting the data structure to meet GPU requirements, reducing bank conflicts, and obtaining the second result by calculation; S4, combining the first result and the second result to obtain a matching result; In the process of obtaining matching results, a credibility judgment mechanism and a sample rate screening mechanism are introduced. The credibility judgment mechanism is used to compare the ratio of each value in the matching result to the maximum value with a preset threshold, count the proportion of the number of valid ratios and judge the credibility of the result. The sample rate screening mechanism is used to calculate the proportion of non-zero elements in the image to screen abnormal results.
2. The method for calculating the offset between visual fields when generating DICOM images by fluorescent scanning slides as claimed in claim 1, characterized in that: In step S1, when the template matching class is initialized, a real domain to complex domain handle and a complex domain to real domain handle are created, the display memory of the image to be matched and the display memory of the template image required for Fourier transform are applied in advance, and the processing operations of the image to be matched are performed in the display memory, including the conversion of the image to be matched to the frequency domain, the conversion of the template image to the frequency domain and the complex frequency domain multiplication result.
3. The method for calculating the offset between visual fields when generating DICOM images by fluorescent scanning slides as claimed in claim 1, characterized in that: In step S4, the credibility judgment mechanism is specifically as follows: the ratio of each value in the statistical matching result to the maximum value is lower than the preset threshold, and if the ratio exceeds the set credibility threshold, it is judged as an unreliable result.
4. The method for calculating the offset between visual fields when generating DICOM images by fluorescent scanning slides as claimed in claim 1, characterized in that: In step S4, the sample rate screening mechanism specifically includes: calculating the non-zero element ratio after performing Otsu threshold processing, false peak construction, and Gamma correction on the image, and screening out abnormal results caused by too few samples or uneven illumination according to the ratio.
5. The method for calculating the offset between visual fields when generating DICOM images by fluorescent scanning slides as claimed in claim 1, characterized in that: In step S3, the data unit is taken each time by setting the data structure to meet the GPU requirements: Properly organize the data, including data alignment, layout optimization, conflict avoidance, and access merging, to ensure that data access meets the GPU's memory access rules.
6. The method for calculating the offset between visual fields when generating DICOM images by fluorescent scanning slides as claimed in claim 3, characterized in that: In step S4, the preset threshold is 0.12, and the set credible threshold is 0.
12.
7. The method for calculating the offset between visual fields when generating DICOM images by fluorescent scanning slides as claimed in claim 4, characterized in that: In step S4, the pseudo peak construction is specifically as follows: adding a pseudo peak of the mean plus three times the standard deviation to the template region histogram, adjusting the histogram distribution, and binarizing it using the Otsu threshold method.
8. A device for calculating the offset between visual fields when generating DICOM images by fluorescent scanning glass slides, characterized in that: include: A region acquisition module is configured to acquire the overlapping region of two adjacent fields of view and determine the ROI of the image to be matched and the template region; The matching calculation module is configured to calculate the matching result based on the square difference matching algorithm, including: Initialization unit, used to initialize the template matching class according to the width and height of the original image, create a Fourier transform handle and apply for video memory; A frequency domain processing unit, used for converting the image into the frequency domain and performing cross-correlation convolution calculation; Data Optimization Unit, which computes integral sum-of-squares graphs and performs GPU data access optimizations; A credibility judgment module is configured to compare the ratio of each value in the matching result to the maximum value with a preset threshold, count the proportion of the number of valid ratios and judge the credibility of the result; The sample rate screening module is configured to calculate the proportion of non-zero pixels in the template area through Otsu threshold combined with false peak construction, Gamma correction and Renyi entropy binarization to determine the sample validity.
9. An electronic device comprising a memory and a processor, characterized in that: The memory stores a computer program, and the processor is configured to run the computer program to execute the method for calculating the offset between visual fields when generating a DICOM image by fluorescent scanning a glass slide as described in any one of claims 1 to 7.
10. A readable storage medium, characterized in that: The readable storage medium stores a computer program, which includes a program code for controlling a process to execute a process, wherein the process includes the method for calculating the offset between visual fields when generating a DICOM image by fluorescent scanning a glass slide according to any one of claims 1 to 7.
Citation Information
Patent Citations
System and method for image processing
CN118056221A
Image registration and template construction method and apparatus, electronic device, and storage medium
WO2023246091A1