OCT image scale processing method and device, and electronic equipment

By performing grayscale conversion, filtering, and adaptive binarization on OCT images, combined with morphological opening operations and contour filtering, the accuracy problem of scale bar recognition in OCT images was solved, achieving high-precision scale conversion and meeting the accuracy requirements of ophthalmic surgery.

CN121660897BActive Publication Date: 2026-06-02GUANGZHOU WEIMOU MEDICAL INSTR CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GUANGZHOU WEIMOU MEDICAL INSTR CO LTD
Filing Date
2026-02-09
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

Existing technologies struggle to quickly and accurately identify and process scale bars in OCT images with high noise levels and low contrast, leading to significant measurement errors that affect the precision of ophthalmic surgery and the accuracy of diagnosis.

Method used

By employing preprocessing based on grayscale conversion, mean smoothing filtering, and Gaussian filtering, combined with adaptive binarization and morphological opening operations, and through contour extraction and filtering strategies, the long and short side ratios of the OCT image scale are identified, and errors are corrected through statistical features to achieve high-precision scale conversion.

Benefits of technology

In noisy environments, the scale bar of OCT images was quickly and accurately identified with an error of less than 3%, meeting the micron-level surgical precision requirements and improving the reliability of quantitative analysis of OCT images.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121660897B_ABST
    Figure CN121660897B_ABST
Patent Text Reader

Abstract

This disclosure relates to the field of OCT image processing technology, specifically to an OCT image scale processing method, apparatus, and electronic device. The method includes: acquiring a scale region image containing the scale from an original OCT image; preprocessing the scale region image to obtain a preprocessed image; performing adaptive binarization processing on the preprocessed image based on a preferred threshold to obtain an optimized binary image; performing morphological opening operations on the optimized binary image based on a preset structuring element to obtain an enhanced binary image; searching for and extracting contours from the enhanced binary image to obtain an original contour set; selecting the optimal candidate contour corresponding to the scale from the original contour set; and obtaining the long side ratio and short side ratio of the scale based on the preset standard physical size of the image scale and the geometric parameters of the minimum circumscribed rectangle of the optimal candidate contour. This allows for rapid and accurate identification and processing of the OCT image scale, achieving high-precision scale conversion.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of OCT image processing technology, specifically to an OCT image scale processing method, apparatus, and electronic device. Background Technology

[0002] In recent years, optical coherence tomography (OCT) has become a key imaging technology for ophthalmic diagnosis and surgical planning. With its high resolution and non-invasive nature, OCT can clearly visualize the fine structures of retinal tissues such as the retina and choroid, and is widely used for the early detection, disease assessment, and surgical navigation of diseases such as glaucoma, diabetic retinopathy, and age-related macular degeneration. In clinical practice, accurate scale recognition is fundamental for quantitative measurements (such as lesion size and tissue thickness) using OCT images, and its accuracy directly affects the reliability of diagnosis and the effectiveness of surgical intervention.

[0003] Currently, automatic scale recognition in OCT images mainly relies on two types of technologies. The first type is based on traditional image processing methods, such as using Canny edge detection combined with Hough transform to locate the scale region. These methods typically first suppress noise through Gaussian filtering, then extract edges using gradient operators, and finally detect straight lines or rectangular contours through parameter space voting. Under conditions of high image quality and regular scale structure, they can achieve basic localization. However, the core assumption of this type of method is that the long and short sides of the scale have a uniform pixel ratio. In practical applications, due to the influence of image acquisition equipment, imaging angle, or individual patient differences, the scale in OCT images often exhibits a non-uniform pixel distribution, leading to significant deviations (up to 15-25%) when calculating the actual size. Furthermore, traditional edge detection methods are sensitive to image noise and illumination changes. In low-contrast or noisy OCT images, the recognition accuracy often drops below 70%, severely limiting its applicability in precision surgical environments.

[0004] To overcome the limitations of traditional methods, the second type of technique introduces machine learning frameworks, such as semantic segmentation models using convolutional neural networks (CNNs) for pixel-level segmentation of scale regions. These methods train the model on large amounts of labeled data, enabling it to identify scales from complex backgrounds. Related techniques describe methods using deep learning models to separate scales from noisy backgrounds and calculate the average pixel ratio. While deep learning techniques have improved segmentation accuracy, they still have significant shortcomings: First, the models heavily rely on large-scale, high-quality labeled datasets, while medical image annotation is costly and time-consuming; second, deep learning models typically have high computational complexity and strong training dependencies, making them unable to adapt to dynamic images in surgical environments or meet the high real-time requirements of applications such as surgical navigation; finally, existing methods often focus on region segmentation, failing to fully consider the non-uniformity of pixel values ​​between the long and short sides of the scale, resulting in errors in accurately calculating the actual size.

[0005] In summary, current technologies have not effectively solved the key challenge of automatic scale identification in OCT images: how to quickly and accurately identify and process OCT image scales in real clinical images with high noise interference and low contrast, thereby achieving high-precision scale conversion. This technological deficiency directly affects the reliability of quantitative analysis of OCT images, especially in ophthalmic surgical planning and lesion monitoring that require micron-level precision, potentially leading to significant measurement errors and jeopardizing surgical outcomes and diagnostic accuracy. Summary of the Invention

[0006] To address the problems in related technologies, this disclosure provides an OCT image scale processing method, apparatus, and electronic device.

[0007] In a first aspect, this disclosure provides an OCT image scale bar processing method, including:

[0008] A scale region image is obtained based on the original OCT image, wherein the scale region image includes the OCT image scale.

[0009] The image of the scaled region is preprocessed to obtain the preprocessed image;

[0010] The preprocessed image is adaptively binarized based on a preferred threshold to obtain an optimized binary image. The preferred threshold is determined as follows: the gray-level distribution features of the preprocessed image are obtained. When the gray-level distribution features meet the preset fuzzy discrimination conditions, the preferred threshold is calculated using an adaptive threshold algorithm. Otherwise, a specified fixed threshold is used as the preferred threshold.

[0011] Based on preset structuring elements, morphological opening operations are performed on the optimized binary image to obtain an enhanced binary image; the morphological opening operation includes a composite operation of erosion followed by dilation;

[0012] Based on a preset contour retrieval mode and a preset contour approximation method, contours are found and extracted from the enhanced binary image to form an original contour set, which includes multiple contours and each contour contains multiple contour points.

[0013] Based on a preset contour filtering strategy, the optimal candidate contour corresponding to the scale of the OCT image is selected from the original contour set.

[0014] The long side ratio and short side ratio of the OCT image scale are obtained based on the standard physical size of the preset OCT image scale and the geometric parameters of the minimum circumscribed rectangle of the optimal candidate contour, so as to calculate the physical size between any pixels in the original OCT image based on the long side ratio and short side ratio of the OCT image scale.

[0015] According to embodiments of this disclosure, the method further includes:

[0016] Obtain the long-side sub-region of the minimum circumscribed axis aligned rectangle;

[0017] The long side ratio error correction term is obtained based on the statistical characteristics of a preset number of pixels within the long side sub-region.

[0018] Obtain the short-side sub-region of the minimum circumscribed rectangle;

[0019] The short side ratio error correction term is obtained based on the statistical characteristics of a preset number of pixels within the short side sub-region.

[0020] The long side ratio of the OCT image scale is corrected based on the long side ratio error correction term to obtain the corrected long side ratio.

[0021] The short side ratio of the OCT image scale is corrected based on the short side ratio error correction term to obtain the corrected short side ratio.

[0022] The calculation of the physical dimensions between any pixels in the original OCT image based on the ratio of the long side and the ratio of the short side of the OCT image scale includes:

[0023] The physical dimensions between any pixels in the original OCT image are calculated based on the corrected long side ratio and the corrected short side ratio.

[0024] According to embodiments of this disclosure, the statistical features include: pixel intensity variance;

[0025] The method of obtaining the long side ratio error correction term based on the statistical features of a preset number of pixels within the long side sub-region includes:

[0026] The long side ratio error correction term Calculated using the following formula:

[0027] ;

[0028] ;

[0029] The short-side ratio error correction term is obtained based on the statistical features of a preset number of pixels within the short-side sub-region, including:

[0030] The short side ratio error correction term Calculated using the following formula:

[0031] ;

[0032] ;

[0033] Where M represents the preset quantity; This represents the variance of pixel intensity for the M pixels within the long-side sub-region; This represents the variance of pixel intensity for the M pixels within the short-side sub-region; This represents the standard deviation of pixel intensity for M pixels within the long-side sub-region; This represents the standard deviation of pixel intensity for M pixels within the short-side sub-region; This represents the grayscale value of the i-th pixel within the long-side sub-region; This represents the grayscale value of the i-th pixel within the short-side sub-region; This represents the average grayscale value of M pixels within the long-side sub-region; The value represents the average grayscale value of M pixels within the short side sub-region; k represents the empirical scaling factor; the corrected short side ratio is the sum of the short side ratio error correction term and the short side ratio of the OCT image scale; the corrected long side ratio is the sum of the long side ratio error correction term and the long side ratio of the OCT image scale.

[0034] According to an embodiment of this disclosure, the step of preprocessing the scale region image to obtain a preprocessed image includes: performing grayscale conversion on the scale region image to obtain a first preprocessed image; performing mean smoothing filtering on the first preprocessed image to obtain a second preprocessed image; performing Gaussian filtering on the second preprocessed image to obtain a third preprocessed image, and using the third preprocessed image as the preprocessed image.

[0035] The fuzzy discrimination condition includes at least one of the following: the histogram of the preprocessed image shows a preset number of peak points and the peak amplitude of each peak point is greater than a preset amplitude threshold; the inter-class separation degree of the preprocessed image is lower than a preset separation degree threshold; and the contrast of the preprocessed image is lower than a preset contrast threshold.

[0036] The step of using an adaptive threshold algorithm to calculate the preferred threshold includes: based on each candidate threshold within a preset threshold range, calculating the degree of separation between foreground pixels and background pixels in the preprocessed image when the candidate threshold is used as the boundary, and selecting the candidate threshold that maximizes the degree of separation between foreground pixels and background pixels in the preprocessed image as the preferred threshold;

[0037] The background pixels include pixels in the preprocessed image whose grayscale value is less than or equal to the candidate threshold, and the foreground pixels include pixels in the preprocessed image whose grayscale value is greater than the candidate threshold.

[0038] The degree of separation between foreground and background pixels in the preprocessed image, with the candidate threshold as the boundary, is calculated based on the following formula:

[0039] ;

[0040] in, This indicates the probability percentage of background pixels in the preprocessed image; This indicates the probability percentage of foreground pixels in the preprocessed image; This represents the average grayscale value of background pixels in the preprocessed image; This represents the average grayscale value of foreground pixels in the preprocessed image; Indicates the candidate threshold, The value of is an integer in the range of 0 to 255;

[0041] The step of adaptively binarizing the preprocessed image based on a preferred threshold to obtain an optimized binary image includes: setting pixels in the preprocessed image whose grayscale value is less than or equal to the preferred threshold as first pixel values, and setting pixels in the preprocessed image whose grayscale value is greater than the preferred threshold as second pixel values; wherein, the first pixel value includes 255, the second pixel value includes 0, and the specified fixed threshold includes 200.

[0042] According to embodiments of this disclosure, selecting the optimal candidate contour corresponding to the OCT image scale from the original contour set based on a preset contour filtering strategy includes:

[0043] For each contour in the original contour set, check whether each contour touches the edge of the scale region image. Remove the contours that touch the edge of the scale region image from the original contour set, and the remaining contours form the boundary that touches the filtered contour set.

[0044] For each contour in the boundary-touched filtered contour set, the area of ​​each contour is obtained based on Green's formula. Contours with an area less than a preset area threshold are removed from the boundary-touched filtered contour set, and the remaining contours form the area-filtered contour set.

[0045] For each contour in the area-filtered contour set, the shape roundness ratio of each contour is obtained. Contours whose shape roundness ratio does not meet the preset ratio condition are removed from the area-filtered contour set, and the remaining contours form the shape-filtered contour set.

[0046] Based on preset selection criteria, the optimal candidate contour corresponding to the scale of the OCT image is selected from the set of shape-filtered contours. The preset selection criteria include: the contour with the largest area in the set of shape-filtered contours.

[0047] According to an embodiment of this disclosure, the minimum circumscribed rectangle encloses all contour points in the optimal candidate contour, and the geometric parameters of the minimum circumscribed rectangle include: the coordinates of the top left vertex of the minimum circumscribed rectangle, the number of pixels on the long side, and the number of pixels on the short side; the top left vertex of the minimum circumscribed rectangle is the contour point with the minimum horizontal coordinate and the minimum vertical coordinate among all contour points in the optimal candidate contour.

[0048] The process of obtaining the long side ratio and short side ratio of the OCT image scale based on the preset standard physical size of the OCT image scale and the geometric parameters of the minimum circumscribed rectangle of the optimal candidate contour includes:

[0049] Based on the preset OCT image scale standard physical dimensions The number of pixels on the longer side of the rectangle aligned with the minimum circumscribed axis Calculate the ratio of the long side of the OCT image scale bar. ;in, ;

[0050] Based on the preset OCT image scale standard physical dimensions The number of pixels on the shorter side of the rectangle aligned with the minimum circumscribed axis. Calculate the ratio of the shorter side of the OCT image scale. ;in, .

[0051] According to embodiments of this disclosure, the method further includes:

[0052] The coordinates of the remaining three vertices of the minimum circumscribed rectangle are calculated based on its geometric parameters. These coordinates include: the coordinates of the top-right vertex, the bottom-left vertex, and the bottom-right vertex. The vertical coordinate of the top-right vertex is equal to that of the top-left vertex, and the horizontal coordinate of the top-right vertex is the sum of the horizontal coordinate of the top-left vertex and the number of pixels on the shorter side minus 1. The horizontal coordinate of the bottom-left vertex is equal to that of the top-left vertex, and the vertical coordinate of the bottom-left vertex is the sum of the vertical coordinate of the top-left vertex and the number of pixels on the longer side minus 1. The vertical coordinate of the bottom-right vertex is equal to that of the bottom-left vertex, and the horizontal coordinate of the bottom-right vertex is equal to that of the top-right vertex.

[0053] Based on the coordinates of the four vertices of the minimum circumscribed rectangle, the boundary of the minimum circumscribed rectangle is drawn on the original OCT image, and the long side ratio and the short side ratio of the OCT image scale are marked on the original OCT image according to a preset format to obtain a visualization image.

[0054] Secondly, this disclosure provides an OCT image scale processing device, comprising:

[0055] The scale region image acquisition module is configured to: acquire a scale region image based on the original OCT image, wherein the scale region image includes the OCT image scale;

[0056] The image preprocessing module is configured to preprocess the image of the scale area to obtain a preprocessed image;

[0057] The image binarization processing module is configured to: perform adaptive binarization processing on the preprocessed image based on a preferred threshold to obtain an optimized binary image; wherein, the preferred threshold is determined based on the following method: obtaining the gray-level distribution features of the preprocessed image; when the gray-level distribution features meet the preset fuzzy discrimination conditions, the preferred threshold is calculated using an adaptive threshold algorithm; otherwise, a specified fixed threshold is used as the preferred threshold.

[0058] The image morphological opening operation module is configured to: perform morphological opening operation on the optimized binary image based on a preset structuring element to obtain an enhanced binary image; the morphological opening operation includes: a composite operation of erosion followed by dilation;

[0059] The original contour extraction module is configured to: find and extract contours from the enhanced binary image based on a preset contour retrieval mode and a preset contour approximation method to form an original contour set, wherein the original contour set includes multiple contours and each contour contains multiple contour points.

[0060] The optimal candidate contour selection module is configured to: select the optimal candidate contour corresponding to the scale of the OCT image from the original contour set based on a preset contour filtering strategy.

[0061] The non-uniform scale calculation module is configured to: obtain the long side ratio and short side ratio of the OCT image scale based on the preset standard physical size of the OCT image scale and the geometric parameters of the minimum circumscribed rectangle of the optimal candidate contour, so as to calculate the corresponding physical size between any pixels in the original OCT image based on the long side ratio and short side ratio of the OCT image scale.

[0062] Thirdly, this disclosure provides an electronic device including a memory and a processor; wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the OCT image scale processing method described in any one aspect.

[0063] Fourthly, this disclosure provides a computer-readable storage medium storing computer instructions that, when executed by a processor, implement the OCT image scale processing method described in any one of the first aspects.

[0064] Fifthly, this disclosure provides a computer program product including computer instructions that, when executed by a processor, implement the OCT image scale processing method described in any one of the first aspects.

[0065] According to the technical solution provided in this disclosure, firstly, a scale region image containing the OCT image scale is obtained based on the original OCT image. Then, the scale region image is preprocessed to obtain a preprocessed image. Adaptive binarization processing is performed on the preprocessed image based on a preferred threshold to obtain an optimized binary image. Morphological opening operation is performed on the optimized binary image based on a preset structuring element to obtain an enhanced binary image. Contours are searched and extracted from the enhanced binary image based on a preset contour retrieval mode and a preset contour approximation method to form an original contour set. The optimal candidate contour corresponding to the OCT image scale is selected from the original contour set based on a preset contour filtering strategy. The long side ratio and short side ratio of the OCT image scale are obtained according to the preset standard physical size of the OCT image scale and the geometric parameters of the minimum circumscribed rectangle of the optimal candidate contour. This allows for the calculation of the physical size between any pixels in the original OCT image based on the long side ratio and short side ratio of the OCT image scale, thereby quickly and accurately identifying and processing the OCT image scale and achieving high-precision scale conversion.

[0066] This disclosure addresses the issues of low accuracy and poor adaptability in traditional automatic OCT image scale recognition. Based on an automated image processing and contour analysis workflow, it achieves robust and accurate recognition and parameter calculation of OCT image scales. By introducing multi-level dedicated image enhancement steps such as "Gaussian smoothing joint filtering," "adaptive binarization strategy," and "morphological opening operation enhancement," combined with an intelligent contour filtering mechanism to eliminate boundary noise, it achieves independent calculation of non-uniform scales, ensuring reliable and accurate recognition and processing of OCT image scales under different image quality conditions. Unlike complex models that rely on deep learning, this disclosure adopts a lightweight algorithm framework, improving computational efficiency by more than 3 times.

[0067] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0068] Other features, objects, and advantages of this disclosure will become more apparent from the following detailed description of non-limiting embodiments, taken in conjunction with the accompanying drawings. In the drawings:

[0069] Figure 1 A flowchart illustrating an OCT image scale bar processing method according to an embodiment of the present disclosure is shown.

[0070] Figure 2 A rendering of a raw OCT image according to an embodiment of the present disclosure is shown.

[0071] Figure 3 Showing based on Figure 1The image shown is a rendering of the scaled region image obtained from the original OCT image.

[0072] Figure 4 Show Figure 3 The image shown is the result of preprocessing and inversion binarization.

[0073] Figure 5 A flowchart illustrating a method for selecting the optimal candidate contour corresponding to the scale of an OCT image from an original contour set according to an embodiment of the present disclosure is shown.

[0074] Figure 6 A schematic diagram of the structure of an OCT image scale processing apparatus according to an embodiment of the present disclosure is shown.

[0075] Figure 7 A structural block diagram of an electronic device according to an embodiment of the present disclosure is shown. Detailed Implementation

[0076] In the following, exemplary embodiments of the present disclosure will be described in detail with reference to the accompanying drawings to enable those skilled in the art to readily implement them. Furthermore, for clarity, portions unrelated to the description of exemplary embodiments have been omitted from the drawings.

[0077] In this disclosure, it should be understood that terms such as “comprising” or “having” are intended to indicate the presence of features, figures, steps, behaviors, components, parts or combinations thereof disclosed in this specification, and are not intended to exclude the possibility of the presence or addition of one or more other features, figures, steps, behaviors, components, parts or combinations thereof.

[0078] It should also be noted that, unless otherwise specified, the embodiments and features described in this disclosure can be combined with each other. This disclosure will now be described in detail with reference to the accompanying drawings and embodiments.

[0079] As mentioned earlier, existing methods for identifying and processing OCT image scales have the following problems:

[0080] 1. Inaccurate contour extraction due to noise interference. The background of OCT images is easily affected by grayscale disturbances (such as speckle noise, uneven illumination, or acquisition artifacts), resulting in blurred edges of the scale bar. Existing edge detection methods (such as Canny or Sobel) are prone to producing broken or false positive contours, and cannot accurately capture the complete contour of the scale bar. This leads to deviations in scale calculation, which directly affect the accuracy of the surgery (such as an error of more than 10-15 micrometers in the estimation of lesion area size).

[0081] 2. Lack of independent calculation of non-uniform pixel ratios. The difference in pixel values ​​between the long and short sides (due to the optical resolution anisotropy of OCT equipment) is ignored. Existing methods assume uniform scale, which leads to amplified measurement deviations and affects the real-time dimensional quantification of anatomical structures during surgery.

[0082] 3. Does not meet the pixel integrity requirements for micron-level surgical precision. Ophthalmic surgeries (such as retinal laser or injection) require micron-level precision, but the scale bar often only has tens of pixels representing hundreds of microns (for example, 200 microns corresponds to 50-100 pixels). Any pixel loss (such as boundary erosion caused by noise) will lead to distortion of the scale calculation and amplify the actual size error.

[0083] To address the above issues and achieve high-precision scale conversion by quickly and accurately identifying and processing OCT image scales, this disclosure integrates signal enhancement, feature extraction, and mathematical modeling techniques. It optimizes and improves existing OCT image scale processing schemes from multiple dimensions, providing a simple, accurate, and efficient OCT image scale processing method that achieves scale recognition errors of less than 3% in noisy environments.

[0084] Figure 1 A flowchart illustrating an OCT image scale bar processing method according to an embodiment of the present disclosure is shown. Figure 1 As shown, the method includes the following steps S110~S170:

[0085] In step S110, a scale region image is obtained based on the original OCT image, the scale region image containing the OCT image scale.

[0086] Generally, the scale bar of an OCT image usually has a fixed geometric shape and position (edge ​​or corner) in the OCT image. Figure 2 The image shown is a rendering of an original OCT image according to an embodiment of the present disclosure, such as... Figure 2 As shown, the original OCT image is a typical fundus OCT examination report image, where the "L"-shaped area at the lower left corner of the image is the OCT image scale. Figure 3 Showing based on Figure 1 The image shown is a result of obtaining a scaled region image from the original OCT image, as follows: Figure 3 As shown, there is a significant grayscale disturbance area around the scale bar of the OCT image.

[0087] When acquiring a scaled region image based on the original OCT image, cropping can be done manually or automatically by the system. In one implementation of this disclosure, the approximate region is automatically located through image analysis and precisely cropped. The cropped scaled region image is then saved in a default path to provide input for subsequent accurate scale calculations.

[0088] In step S120, the scale area image is preprocessed to obtain a preprocessed image.

[0089] According to an embodiment of this disclosure, the step of preprocessing the scale region image to obtain a preprocessed image includes: performing grayscale conversion on the scale region image to obtain a first preprocessed image; performing mean smoothing filtering on the first preprocessed image to obtain a second preprocessed image; performing Gaussian filtering on the second preprocessed image to obtain a third preprocessed image, and using the third preprocessed image as the preprocessed image.

[0090] To address the challenges of balancing speckle suppression and edge preservation in traditional methods with single-filter approaches, and the computationally intensive nature of complex filters hindering real-time surgery, this invention proposes a hierarchical, progressive noise suppression and feature enhancement approach based on the characteristics of OCT images. During the preprocessing of OCT scale region images, a triple processing method is employed: grayscale conversion, mean smoothing filtering, and Gaussian filtering. Through a progressive processing strategy involving physical property adaptation, primary noise suppression, and fine feature preservation, the invention solves the unique problems of speckle noise, edge blurring, and uneven contrast inherent in OCT images. Specifically, physical property adaptation, based on the physical characteristics of OCT imaging, compresses multi-channel optical information into single-channel brightness information, achieving physical dimensional compression of the noise source. Primary noise suppression addresses the high-frequency randomness of OCT speckle noise by using spatial neighborhood averaging for rapid coarse-grained smoothing, laying the foundation for subsequent fine processing. Fine feature preservation addresses the sub-pixel accuracy requirements of scale edges by employing Gaussian weighting conforming to the optical point spread function, achieving fine smoothing that preserves the edges. The triple processing architecture disclosed herein not only significantly improves the accuracy and robustness of OCT scale detection, but also provides a reliable technical foundation for real-time surgical navigation, embodying a complete inventive concept from algorithm innovation to clinical value transformation.

[0091] In one implementation of this disclosure, when converting the scale area image to grayscale to obtain the first preprocessed image, the OpenCV library function cvtColor can be used to perform RGB to grayscale conversion, thereby converting the color image to a grayscale image, while compressing the data dimension and suppressing color-related noise. Specifically, this can be achieved using the following conversion formula:

[0092] ;

[0093] in, , and Representing pixel positions The red, green, and blue channel intensity values ​​at the location are 0.299, 0.587, and 0.114, respectively, which are weighting coefficients used to simulate the human eye's perception of brightness. This represents the converted grayscale value, and all converted grayscale values ​​constitute the first preprocessed image.

[0094] In one implementation of this disclosure, when the first preprocessed image is subjected to mean smoothing filtering to obtain the second preprocessed image, the OpenCV library function blur can be used to perform mean smoothing filtering in order to smooth the grayscale image, thereby suppressing noise, blurring details, or reducing high-frequency components in the image. Specifically, it can be implemented using the following formula:

[0095] ;

[0096] in, Indicates The gray values ​​of each pixel in the neighborhood centered at N, where N represents the gray values ​​of each pixel in the neighborhood centered at N. The number of pixels in the center's neighborhood , This represents the offset of a pixel in the neighborhood relative to the center position (usually taken as a fixed window size, such as 5×5). This represents the smoothed pixel values, and all the smoothed pixel values ​​constitute the second preprocessed image.

[0097] In one implementation of this disclosure, when performing Gaussian filtering on the second preprocessed image to obtain the third preprocessed image, the OpenCV library function GaussianBlur can be used to perform Gaussian filtering to achieve Gaussian smoothing. The specific Gaussian kernel function formula is as follows:

[0098] ;

[0099] in, Indicates the location Gaussian kernel weight values ​​at the location, , This represents the coordinate offset in the Gaussian kernel function with the kernel center as the origin; This represents the standard deviation, used to control the width of the Gaussian distribution. The larger the value, the stronger the smoothing effect. In one specific embodiment... .

[0100] In practical implementation, the strength (window size) of the mean filter and the Gaussian filter can be adjusted according to the specific application scenario and the device being used. Parameters are adjusted to accommodate different noise levels and spatial resolutions.

[0101] This disclosure, when preprocessing scale-area images, first eliminates noise coupling between color channels through grayscale conversion, then quickly removes isolated speckle patterns through mean smoothing filtering, and finally smooths residual low-frequency noise components through Gaussian filtering. Based on this triple-processing architecture, grayscale perturbation is effectively reduced, the signal-to-noise ratio is improved, and the speckle noise suppression rate is increased by 40-60%, while maintaining an edge signal-to-noise ratio >90%. Furthermore, since Gaussian filtering after mean smoothing can repair slight edge blurring, and the spatial continuity of the Gaussian kernel preserves the sub-pixel position information of the edges, the edge positioning error is <0.5 pixels (approximately 2.5 μm), meeting the requirements of ophthalmological / neurosurgery. Simultaneously, the total processing time for the triple-processing is <50ms (for 1080p images), meeting the requirements for 60fps real-time processing.

[0102] In step S130, the preprocessed image is subjected to adaptive binarization based on a preferred threshold to obtain an optimized binary image; wherein, the preferred threshold is determined based on the following method: the gray-level distribution features of the preprocessed image are obtained, and when the gray-level distribution features meet the preset fuzzy discrimination conditions, the preferred threshold is calculated using an adaptive threshold algorithm; otherwise, a specified fixed threshold is used as the preferred threshold.

[0103] In this disclosure, to improve the contrast between the scale outline and the background and ensure that the pixel information of the scale is fully preserved even under common grayscale perturbations and speckle noise in OCT images, the preprocessed image is not simply binarized using a fixed threshold. Instead, an optimal threshold is determined based on the quality of the preprocessed image. When the image quality is good, a simple and efficient fixed threshold is used, while when the image quality is poor, an optimal threshold calculated based on an adaptive thresholding algorithm is used to cope with images with large grayscale variations. Thus, through this layered strategy, an organic combination of baseline enhancement and adaptive expansion is achieved. While ensuring processing efficiency, the adaptability to illumination variations under different OCT devices and acquisition conditions is enhanced, significantly improving the robustness of OCT scale outline extraction and enabling it to adapt to image variations under different devices and acquisition conditions.

[0104] Among these features, grayscale distribution characteristics are used to determine whether an image is blurry. Here, "blurry" does not refer to optical blur, but rather to low grayscale differentiation between the foreground and background, making them difficult to separate using a single threshold. In one implementation of this disclosure, grayscale distribution characteristics include, but are not limited to, grayscale histograms, peak point features, inter-class separation, and contrast. If the histogram of the preprocessed image exhibits a preset number of peak points and the peak amplitude of each peak point is greater than a preset amplitude threshold, or if the inter-class separation of the preprocessed image is lower than a preset separation threshold, or if the contrast of the preprocessed image is lower than a preset contrast threshold, then it indicates that image segmentation using a fixed threshold may be ineffective, and an adaptive thresholding algorithm needs to be enabled.

[0105] According to an embodiment of this disclosure, the step of using an adaptive threshold algorithm to calculate the preferred threshold includes: based on each candidate threshold within a preset threshold range, calculating the separation degree of foreground pixels and background pixels in the preprocessed image with the candidate threshold as the boundary, and selecting the candidate threshold that maximizes the separation degree of foreground pixels and background pixels in the preprocessed image as the preferred threshold.

[0106] The background pixels include pixels in the preprocessed image whose grayscale value is less than or equal to the candidate threshold, and the foreground pixels include pixels in the preprocessed image whose grayscale value is greater than the candidate threshold.

[0107] The degree of separation between foreground and background pixels in the preprocessed image, with the candidate threshold as the boundary, is calculated based on the following formula:

[0108] ;

[0109] in, This indicates the probability percentage of background pixels in the preprocessed image; This indicates the probability percentage of foreground pixels in the preprocessed image; This represents the average grayscale value of background pixels in the preprocessed image; This represents the average grayscale value of foreground pixels in the preprocessed image; Indicates the candidate threshold, The value of is an integer in the range of 0 to 255.

[0110] The step of adaptively binarizing the preprocessed image based on a preferred threshold to obtain an optimized binary image includes: setting pixels in the preprocessed image whose grayscale value is less than or equal to the preferred threshold as first pixel values, and setting pixels in the preprocessed image whose grayscale value is greater than the preferred threshold as second pixel values; wherein, the first pixel value includes 255, the second pixel value includes 0, and the specified fixed threshold includes 200.

[0111] In this disclosure, adaptive inversion binarization is performed on the preprocessed image based on an inversion mode, that is: pixels in the preprocessed image with gray values ​​less than or equal to a preferred threshold are set to white, and pixels in the preprocessed image with gray values ​​greater than the preferred threshold are set to black. This corresponds to... Figure 3 OCT image scale bar Figure 4 Show Figure 3 The image shown is the result of preprocessing and inversion binarization, as shown below. Figure 4As shown, after the preprocessed image is inverted and binarized, the scale bar is set to white and the background is set to black. This process significantly enhances the contrast between the scale bar outline and the background.

[0112] In step S140, a morphological opening operation is performed on the optimized binary image based on a preset structuring element to obtain an enhanced binary image; the morphological opening operation includes a composite operation of erosion followed by dilation.

[0113] To further refine the contours of the binary image, this disclosure applies morphological transformations to the optimized binary image to remove isolated noise points, repair minor breaks, and ensure pixel integrity at the scale edges, providing a clean binary mask for subsequent contour extraction and scale measurement.

[0114] In one implementation of this disclosure, a 3×3 rectangular struct element SE is used to perform the opening operation, and the specific operation formula is as follows:

[0115] ;

[0116] in, This represents the optimized binary image; The image represents the enhanced binary image; SE represents the structuring element. This indicates a morphological etching operation; This indicates a morphological dilation operation.

[0117] After performing a morphological opening operation on the optimized binary image, small discrete points are eroded away, and minor breaks can be connected during the expansion phase. Because the image is first eroded to shrink and then expanded to restore it, the overall size remains basically unchanged while eliminating small protrusions, thus preserving the main shape.

[0118] In step S150, contours are searched and extracted from the enhanced binary image based on a preset contour retrieval mode and a preset contour approximation method to form an original contour set. The original contour set includes multiple contours, and each contour contains multiple contour points.

[0119] In one implementation of this disclosure, the contours of objects are found and extracted from the enhanced binary image by calling the `cv2.findContours` function in the OpenCV library. Since the scale bar of an OCT image is usually a solid rectangle without internal holes, there is no need to analyze the internal structure. Furthermore, a rectangle only requires four points (vertices) to represent it. Therefore, when calling the `cv2.findContours` function, the contour retrieval mode can be set to external contour mode (`RETR_EXTERNAL`), and the contour approximation method can be set to simplified chain code (`CHAIN_APPROX_SIMPLE`). This reduces redundant points and maximizes computational and storage efficiency while ensuring detection accuracy.

[0120] In step S160, the optimal candidate contour corresponding to the scale of the OCT image is selected from the original contour set based on a preset contour filtering strategy.

[0121] To accurately filter the contours corresponding to the OCT image scale, this disclosure constructs a hierarchical, progressively refined multi-level filtering pipeline to select the optimal candidate contours for the corresponding OCT image scale from the original contour set. The multi-level filtering pipeline includes a three-level filtering mechanism. The first level is boundary integrity filtering. As an independent and complete annotation element in the image, the scale should theoretically have a closed visual contour that does not touch the image boundary. Contours touching the edge are highly likely to be background or the image boundary itself, or meaningless fragments that have not been completely segmented. This step uses topological relationships to quickly eliminate a large amount of invalid interference. The second level is size rationality filtering. A true OCT image scale has a clear physical size, which is reflected in the image as a roughly defined and significant pixel area. By using a preset area threshold (which can be estimated based on image resolution and physical size), it is possible to filter out... The first stage involves filtering out contours that are too small (noise points, stains) or too large (potentially other large structures) to narrow down candidate targets to a reasonable size. The second stage is shape-specific filtering. The scale bar is usually designed as a rectangle or elongated strip with a high aspect ratio and regular boundaries. By calculating the roundness ratio of the contour shape, contours that are close to rectangles can be filtered out, thus eliminating interference from other shapes such as circles, irregular spots, and curved edges. After three stages of filtering, the number of remaining candidate contours is very small. Finally, a simple, definite, and unambiguous rule (such as selecting the one with the largest area) is used as the final decision criterion to select the optimal candidate contour for the corresponding OCT image scale.

[0122] Figure 5 A flowchart illustrating a method for selecting the optimal candidate contour corresponding to the scale of an OCT image from an original contour set according to an embodiment of the present disclosure is shown. Figure 5As shown, the step of selecting the optimal candidate contour corresponding to the scale of the OCT image from the original contour set based on the preset contour filtering strategy includes the following steps S161~S164:

[0123] In step S161, for each contour in the original contour set, it is checked whether each contour touches the edge of the scale area image. The contours that touch the edge of the scale area image are removed from the original contour set, and the remaining contours form a boundary that touches the filtered contour set.

[0124] Assuming the original contour set traverse each ( ), Determine the outline Whether the contour points in the image touch the image boundary is a key factor. Since the OCT scale is usually located entirely inside the image, the contours that touch the boundary are mostly noise. Therefore, this level of filtering can filter out invalid contours caused by acquisition artifacts, edge noise, or partial cropping.

[0125] If the outline Contour points in The following conditions must be met:

[0126] ;in, Let the horizontal coordinates of the contour points be... The vertical coordinates of the contour points are given, while the horizontal and vertical coordinates are pixel coordinates, i.e., coordinates defined in pixels. W represents the width of the scaled area image, and H represents the height of the scaled area image. , The units for W and H are pixels. For example: If , then it means The point is located at the pixel position of the 100th column from the left and the 200th row from the top.

[0127] Then: the outline From the original set of contours In short, any contour that touches any of the left, right, top, or bottom boundaries of the image is considered invalid and discarded, leaving only contours completely within the image. This filter targets common edge noise in OCT images (such as acquisition boundary artifacts, scan edge gradients, or external lighting overflow). This noise often extends to the image boundaries, resulting in invalid contours, thus ensuring that only completely internal closed contours are retained, reducing false positives and improving the specificity of scale recognition.

[0128] In step S162, for each contour in the boundary-touched filtered contour set, the area of ​​each contour is obtained based on Green's formula. Contours with areas smaller than a preset area threshold are removed from the boundary-touched filtered contour set, and the remaining contours form the area-filtered contour set.

[0129] For the remaining contours that pass the boundary threshold filter, the geometric properties of the contours are further calculated to eliminate small noise or non-rectangular interference. This step is used to calculate the geometric properties of each contour. The area can be precisely calculated using Green's formula as follows:

[0130] ;

[0131] in, Represents outline The area, expressed in square pixels; Represents outline The number of outline points; and Representing the outline The horizontal and vertical coordinates of the j-th point and Representing the outline The horizontal and vertical coordinates of the (j+1)th point. The path is closed, i.e.: , This formula is based on polygon area integration, which avoids pixel rasterization errors and ensures micron-level pixel integrity.

[0132] like ,in, The default value is 1% of the total image area, that is: Then the outline will be removed. This is used to filter out isolated small noises or fragments.

[0133] In step S163, for each contour in the area-filtered contour set, the shape roundness ratio of each contour is obtained, and contours whose shape roundness ratio does not meet the preset ratio condition are removed from the area-filtered contour set, and the remaining contours form the shape-filtered contour set.

[0134] For the remaining contours after area filtering, the shape roundness ratio of the contours is next calculated to assess whether the contours are close to rectangles, i.e., the typical shape of an OCT image scale bar. This is calculated using the following formula:

[0135] ;

[0136] ;

[0137] in, Represents outline The perimeter is approximated by accumulating the Euclidean distances between points, which is more accurate than the chain code approximation. Represents outline The roundness ratio of the shape.

[0138] when When it is 1, it represents the outline. For an ideal circle, when A value close to 1 (typically 1.1-1.5, depending on aspect ratio) indicates the outline. For a rectangle, when When it is significantly greater than 1, it represents a contour. It is an irregular shape. Therefore, if The offset of 1 is too far, for example: ,default When, the outline Rejection. This shape filtering extension targets the rectangular characteristics of the scale, ensuring that only geometrically reasonable candidates are retained, avoiding interference from nonlinear noise (such as blood vessel shadows or tissue textures). Simultaneously, this step enhances pixel integrity: preventing the loss of small pixels through area thresholding and ensuring distortion-free boundaries through shape ratio. This optimized linear embedding filtering route improves overall robustness.

[0139] In step S164, the optimal candidate contour corresponding to the OCT image scale is selected from the shape-filtered contour set based on preset selection conditions. The preset selection conditions include the contour with the largest area in the shape-filtered contour set.

[0140] In one implementation of this disclosure, the contour with the largest area is selected from the remaining contours after the three-level filtering described above as the optimal candidate contour corresponding to the OCT image scale. This step assumes that the scale occupies the largest effective area in the image (common in clinical OCT images), thus prioritizing target capture.

[0141] The linear filtering route described in this disclosure forms a noise-robust chain from initial extraction to maximum selection: boundary filtering removes external interference, area / shape optimization eliminates internal noise, and maximum area selection focuses on the core. This multi-level filtering strategy sets "barriers" from multiple dimensions, including topology, size, and shape, effectively resisting different types of interference. By combining multiple complementary feature judgments (whether it touches an edge, whether the area is reasonable, and whether the shape is regular), it significantly reduces the false detection rate and improves the recognition accuracy to over 95%. Furthermore, each filtering operation involves simple geometric calculations. More importantly, the pipeline's initial stage quickly eliminates most contours, allowing subsequent more complex calculations (such as shape analysis) to be performed only on a few contours, resulting in a low overall computational load and effectively improving computational efficiency.

[0142] In step S170, the long side ratio and short side ratio of the OCT image scale are obtained according to the preset standard physical size of the OCT image scale and the geometric parameters of the minimum circumscribed rectangle of the optimal candidate contour, so as to calculate the physical size between any pixels in the original OCT image based on the long side ratio and short side ratio of the OCT image scale.

[0143] According to an embodiment of this disclosure, the minimum circumscribed rectangle encloses all contour points in the optimal candidate contour to ensure no pixels are missed. The geometric parameters of the minimum circumscribed rectangle include: the coordinates of the top left vertex, the number of pixels on the long side, and the number of pixels on the short side. The top left vertex of the minimum circumscribed rectangle is the contour point with the minimum horizontal coordinate and the minimum vertical coordinate among all contour points in the optimal candidate contour.

[0144] In one implementation of this disclosure, the boundingRect function of OpenCV can be used to directly obtain the minimum bounding axis aligned rectangle of the optimal candidate contour, and the function output is the coordinates of the top left vertex of the minimum bounding axis aligned rectangle. , ), number of pixels on the long side and the number of pixels on the shorter side Mathematically, this is equivalent to: , , , ,in, and These are the horizontal and vertical coordinates of the contour point p, respectively.

[0145] This step provides a concise boundary representation for the rectangular characteristics of the scale, facilitating subsequent scale calculations.

[0146] In subsequent scaling calculations, this disclosure addresses the non-uniformity of pixel values ​​on the long and short sides of the OCT image (originating from the anisotropy of the device's optical resolution, such as the difference in horizontal vs. vertical scanning density) by independently calculating the long and short side ratios of the OCT image scale bar to cope with OCT optical anisotropy and achieve accurate independent quantization.

[0147] According to embodiments of this disclosure, obtaining the long side ratio and short side ratio of the OCT image scale based on the preset standard physical size of the OCT image scale and the geometric parameters of the minimum circumscribed rectangle of the optimal candidate contour includes:

[0148] Based on the preset OCT image scale standard physical dimensions The number of pixels on the longer side of the rectangle aligned with the minimum circumscribed axis Calculate the ratio of the long side of the OCT image scale bar. ;in, .

[0149] Based on the preset OCT image scale standard physical dimensions The number of pixels on the shorter side of the rectangle aligned with the minimum circumscribed axis. Calculate the ratio of the shorter side of the OCT image scale. ;in, .

[0150] In one specific embodiment, (Clinical OCT standards, representing) (the bar-shaped markings), then and The unit is: / pixel.

[0151] For example: assuming 1 pixel, If there are 100 pixels, then That is, in the vertical direction, each pixel represents a physical length of 4 micrometers. That is, in the horizontal direction, each pixel represents a physical length of 10 micrometers.

[0152] To measure the diameter of a sloping blood vessel, take the two endpoints: , The number of pixels between the two endpoints in the horizontal direction Pixels, the number of pixels between two endpoints in the vertical direction. Pixels, then:

[0153] Physical length between two endpoints in the horizontal direction Physical length between two endpoints in the vertical direction ,but:

[0154] The actual physical length between the two endpoints .

[0155] This disclosure also provides visual feedback for clinical validation and surgical integration. According to embodiments of this disclosure, the method further includes:

[0156] The coordinates of the remaining three vertices of the minimum circumscribed rectangle are calculated based on its geometric parameters. These remaining three vertex coordinates include: the coordinates of the top-right vertex, the bottom-left vertex, and the bottom-right vertex. The vertical coordinate of the top-right vertex is equal to that of the top-left vertex, and the horizontal coordinate of the top-right vertex is the sum of the horizontal coordinate of the top-left vertex and the number of pixels on the shorter side minus 1. The coordinates of the top-right vertex are mathematically expressed as: The horizontal coordinate of the lower left vertex is equal to the horizontal coordinate of the upper left vertex. The vertical coordinate of the lower left vertex is the sum of the vertical coordinate of the upper left vertex and the number of pixels on the longer side, minus 1. The coordinates of the lower left vertex are expressed mathematically as follows: The vertical coordinate of the lower right vertex is equal to the vertical coordinate of the lower left vertex, and the horizontal coordinate of the lower right vertex is equal to the horizontal coordinate of the upper right vertex. The coordinates of the lower right vertex are expressed mathematically as follows: .

[0157] Based on the coordinates of the four vertices of the minimum circumscribed rectangle (i.e., the coordinates of the top left vertex, the top right vertex, the bottom left vertex, and the bottom right vertex), the boundary of the minimum circumscribed rectangle is drawn on the original OCT image, and the long side ratio and the short side ratio of the OCT image scale are marked on the original OCT image according to a preset format to obtain a visualization image.

[0158] In one implementation of this disclosure, the OpenCV library function `cv2.rectangle` can be used to draw the boundary of a minimum circumscribed rectangle on the original OCT image. For example, the line width can be set to 2 pixels, the color to green (BGR(0,255,0)), and the scale value can be annotated using `cv2.putText`. For example, the text can be set to "...". , The font is cv2.FONT_HERSHEY_SIMPLEX, size 0.5. The final output includes the coordinates of the four vertices of the rectangle and the ratio of its length to its short side. and This includes an optional visualization image (which can be saved as "output_visual.jpg"). This step ensures a seamless transition from geometry to physics, supporting real-time surgical visualization.

[0159] To further improve the accuracy of the scale, this disclosure also supports error correction for the calculated long side ratio and short side ratio, specifically based on the pixel intensity variance correction ratio within the rectangle.

[0160] According to embodiments of this disclosure, the method further includes:

[0161] Obtain the long side sub-region of the minimum circumscribed axis aligned rectangle; obtain the long side ratio error correction term based on the statistical characteristics of a preset number of pixels within the long side sub-region.

[0162] Obtain the short side sub-region of the minimum circumscribed axis aligned rectangle; obtain the short side ratio error correction term based on the statistical characteristics of a preset number of pixels within the short side sub-region.

[0163] The long side ratio of the OCT image scale is corrected based on the long side ratio error correction term to obtain the corrected long side ratio; the short side ratio of the OCT image scale is corrected based on the short side ratio error correction term to obtain the corrected short side ratio.

[0164] The long and short sub-regions of the minimum circumscribed rectangle are specific local image regions extracted from the minimum circumscribed rectangle of the identified OCT scale for fine-tuning the ratio of the long and short sides. The long sub-region is a strip-shaped pixel region covering most or all of the long side of the rectangle, with a specific aspect ratio. The short sub-region is a strip-shaped pixel region covering most or all of the short side of the rectangle, with a specific aspect ratio. Because these two sub-regions avoid the four corners of the rectangle (which may be impure due to morphological operations or image distortion) and focus on the more representative linear region where the scale lines themselves are located, more accurate pixel-level statistical features are extracted to correct ratio calculation errors.

[0165] The calculation of the physical dimensions between any pixels in the original OCT image based on the ratio of the long side and the ratio of the short side of the OCT image scale includes:

[0166] The physical dimensions between any pixels in the original OCT image are calculated based on the corrected long side ratio and the corrected short side ratio.

[0167] The statistical features include: pixel intensity variance; the pixel intensity variance is used to quantify the fluctuation of pixel intensity within a rectangular region, providing a statistical correction basis for the ratio calculation. The step of obtaining the long-side ratio error correction term based on the statistical features of a preset number of pixels within the long-side sub-region includes:

[0168] The long side ratio error correction term Calculated using the following formula:

[0169] ;

[0170] ;

[0171] The short-side ratio error correction term is obtained based on the statistical features of a preset number of pixels within the short-side sub-region, including:

[0172] The short side ratio error correction term Calculated using the following formula:

[0173] ;

[0174] ;

[0175] Where M represents the preset quantity; This represents the variance of pixel intensity for the M pixels within the long-side sub-region; This represents the variance of pixel intensity for the M pixels within the short-side sub-region; This represents the standard deviation of pixel intensity for M pixels within the long-side sub-region; This represents the standard deviation of pixel intensity for M pixels within the short-side sub-region; This represents the grayscale value of the i-th pixel within the long-side sub-region; This represents the grayscale value of the i-th pixel within the short-side sub-region; This represents the average grayscale value of M pixels within the long-side sub-region; The value represents the average grayscale value of M pixels within the short side sub-region; k represents the empirical scaling factor, which defaults to 0.1 and can be dynamically adjusted according to the characteristics of the OCT image; the corrected short side ratio is the sum of the short side ratio error correction term and the short side ratio of the OCT image scale; the corrected long side ratio is the sum of the long side ratio error correction term and the long side ratio of the OCT image scale.

[0176] This disclosure extracts corresponding pixel bands from the long and short sides of a scale rectangle, statistically analyzes their grayscale values, and quantifies edge recognition errors caused by image noise, binarization bias, or morphological operations. Subsequently, the deviation between this statistical feature and the ideal model is converted into a pixel length correction value to compensate and calibrate the initially calculated long-to-short side ratio, thereby improving the final accuracy of physical size conversion. This method combines macroscopic contour geometry measurement with microscopic pixel distribution analysis, achieving localized modeling and intelligent correction of system errors.

[0177] This disclosure addresses residual noise in OCT images (such as pixel fluctuations caused by residual speckle) by using statistical modeling to correct potential deviations in the ratio of long and short sides, thereby improving the accuracy of ratio calculation and enhancing measurement reliability, reducing the error to within 2%.

[0178] The OCT image scale bar processing solution provided in this disclosure has the following beneficial technical effects:

[0179] 1. Significantly improved recognition accuracy and measurement accuracy: Through linear enhancement path and multi-step contour filtering, the scale recognition accuracy reaches over 98%, and the calculation error of the long and short side ratio is controlled within 2 micrometers, which is far better than the 15-25% deviation level of existing technologies, meeting the stringent requirements of ophthalmic surgery for micrometer-level size quantification.

[0180] 2. Significantly improved processing speed and real-time performance: The end-to-end linear processing link has extremely low computational overhead (single image processing time is in the millisecond range), which can shorten the image analysis time during surgery by 30-40%, support real-time surgical navigation and decision-making, reduce intraoperative waiting time, and improve overall surgical efficiency.

[0181] 3. Significantly enhanced noise robustness and equipment adaptability: Addressing common OCT image issues such as speckle noise, grayscale perturbation, and illumination variation, the system combines fixed threshold baseline, adaptive optimization, and morphological refinement to stably extract complete scale contours in complex clinical image environments, adapting to various OCT devices and acquisition conditions.

[0182] 4. Effectively reduced system deployment costs and clinical accessibility: The algorithm is lightweight and does not require high-performance GPUs or deep learning training. It can be implemented by relying only on standard image processing libraries, reducing deployment costs by 20-25%. It is easy to integrate into existing hospital equipment, portable instruments and telemedicine platforms, expanding the coverage of ophthalmology diagnosis and treatment.

[0183] 5. Continuous improvement in clinical safety and standardization: Non-uniform proportional independent calculation and pixel integrity assurance reduce human measurement errors, support more accurate quantification of lesion area size and surgical planning, improve patient treatment safety and postoperative recovery, and promote the standardization and intelligent transformation of ophthalmology diagnosis and treatment processes.

[0184] Figure 6 A schematic diagram of the structure of an OCT image scale processing apparatus according to an embodiment of the present disclosure is shown. Figure 6As shown, the OCT image scale processing device includes: a scale region image acquisition module, configured to: acquire a scale region image based on the original OCT image, wherein the scale region image contains the OCT image scale; an image preprocessing module, configured to: preprocess the scale region image to obtain a preprocessed image; an image binarization processing module, configured to: perform adaptive binarization processing on the preprocessed image based on a preferred threshold to obtain an optimized binary image; wherein the preferred threshold is determined based on the following method: acquiring the grayscale distribution features of the preprocessed image, and when the grayscale distribution features meet the preset fuzzy discrimination conditions, using an adaptive threshold algorithm to calculate the preferred threshold; otherwise, using a specified fixed threshold as the preferred threshold; and an image morphological opening operation module, configured to: perform morphological opening operation on the optimized binary image based on a preset structuring element to obtain an augmented image. The enhanced binary image; the morphological opening operation includes a composite operation of erosion followed by dilation; the original contour extraction module is configured to: find and extract contours from the enhanced binary image based on a preset contour retrieval mode and a preset contour approximation method to form an original contour set, the original contour set including multiple contours, each contour containing multiple contour points; the optimal candidate contour selection module is configured to: select the optimal candidate contour corresponding to the OCT image scale from the original contour set based on a preset contour filtering strategy; the non-uniform scale calculation module is configured to: obtain the long side ratio and short side ratio of the OCT image scale according to the preset standard physical size of the OCT image scale and the geometric parameters of the minimum circumscribed rectangle of the optimal candidate contour, so as to calculate the physical size between any pixels in the original OCT image based on the long side ratio and short side ratio of the OCT image scale.

[0185] According to embodiments of this disclosure, the apparatus further includes: a ratio correction module;

[0186] The scaling correction module is configured to: obtain the long side sub-region of the minimum circumscribed axis aligned rectangle; obtain a long side scaling error correction term based on the statistical characteristics of a preset number of pixels within the long side sub-region; obtain the short side sub-region of the minimum circumscribed axis aligned rectangle; obtain a short side scaling error correction term based on the statistical characteristics of a preset number of pixels within the short side sub-region; correct the long side scaling of the OCT image scale based on the long side scaling error correction term to obtain a corrected long side scaling; and correct the short side scaling of the OCT image scale based on the short side scaling error correction term to obtain a corrected short side scaling.

[0187] According to embodiments of this disclosure, the apparatus further includes: a visualization image output module;

[0188] The visualization image output module is configured to: calculate the coordinates of the remaining three vertices of the minimum circumscribed rectangle based on its geometric parameters; wherein the remaining three vertex coordinates include: the coordinates of the top-right vertex, the coordinates of the bottom-left vertex, and the coordinates of the bottom-right vertex; the vertical coordinate value of the top-right vertex is equal to the vertical coordinate value of the top-left vertex, and the horizontal coordinate value of the top-right vertex is the sum of the horizontal coordinate value of the top-left vertex and the number of pixels on the shorter side minus 1; the horizontal coordinate value of the bottom-left vertex is equal to the horizontal coordinate value of the top-left vertex, and the horizontal coordinate value of the bottom-left vertex is equal to the horizontal coordinate value of the top-left vertex, and the horizontal coordinate value of the bottom-left vertex is equal to the horizontal coordinate value of the top-left vertex, and the horizontal coordinate value of the bottom-left vertex is equal to the horizontal coordinate value of the top-left vertex, and the horizontal coordinate value of the bottom-left vertex is equal to the horizontal coordinate value of the top-left vertex, and the horizontal coordinate value of the bottom-right ... The vertical coordinate of the lower vertex is the sum of the vertical coordinate of the upper left vertex and the number of pixels on the long side minus 1; the vertical coordinate of the lower right vertex is equal to the vertical coordinate of the lower left vertex, and the horizontal coordinate of the lower right vertex is equal to the horizontal coordinate of the upper right vertex; the boundary of the minimum circumscribed rectangle is drawn on the original OCT image based on the coordinates of the four vertices of the minimum circumscribed rectangle, and the long side ratio and the short side ratio of the OCT image scale are marked on the original OCT image according to a preset format to obtain a visualization image.

[0189] This disclosure also provides an electronic device, Figure 7 A structural block diagram of an electronic device according to an embodiment of the present disclosure is shown, such as... Figure 7 As shown, it includes a memory and a processor; wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the OCT image scale processing method as described in any of the above method embodiments.

[0190] This disclosure also provides a computer-readable storage medium, which may be a computer-readable storage medium included in the electronic device or computer system described in the above embodiments; or it may be a standalone computer-readable storage medium not assembled into a device. The computer-readable storage medium stores one or more programs, which are used by one or more processors to execute the OCT image scale processing method described in this disclosure.

[0191] This disclosure also provides a computer program product, including a computer program that, when executed by a processor, implements the OCT image scale processing method according to any one of the claims of this disclosure.

[0192] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of the invention involved in this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the inventive concept. For example, technical solutions formed by substituting the above-described features with (but not limited to) technical features disclosed in this disclosure that have similar functions.

Claims

1. A method for processing OCT image scale bars, characterized in that, include: A scale region image is obtained based on the original OCT image, wherein the scale region image includes the OCT image scale. The image of the scaled region is preprocessed to obtain the preprocessed image; The preprocessed image is adaptively binarized based on a preferred threshold to obtain an optimized binary image. The preferred threshold is determined as follows: the gray-level distribution features of the preprocessed image are obtained. When the gray-level distribution features meet the preset fuzzy discrimination conditions, the preferred threshold is calculated using an adaptive threshold algorithm. Otherwise, a specified fixed threshold is used as the preferred threshold. Based on preset structuring elements, morphological opening operations are performed on the optimized binary image to obtain an enhanced binary image; the morphological opening operation includes a composite operation of erosion followed by dilation; Based on a preset contour retrieval mode and a preset contour approximation method, contours are found and extracted from the enhanced binary image to form an original contour set, which includes multiple contours and each contour contains multiple contour points. Based on a preset contour filtering strategy, the optimal candidate contour corresponding to the scale of the OCT image is selected from the original contour set. The long side ratio and short side ratio of the OCT image scale are obtained based on the standard physical size of the preset OCT image scale and the geometric parameters of the minimum circumscribed rectangle of the optimal candidate contour, so as to calculate the physical size between any pixels in the original OCT image based on the long side ratio and short side ratio of the OCT image scale.

2. The OCT image scale processing method according to claim 1, characterized in that, The method further includes: Obtain the long-side sub-region of the minimum circumscribed axis aligned rectangle; The long side ratio error correction term is obtained based on the statistical characteristics of a preset number of pixels within the long side sub-region. Obtain the short-side sub-region of the minimum circumscribed rectangle; The short side ratio error correction term is obtained based on the statistical characteristics of a preset number of pixels within the short side sub-region. The long side ratio of the OCT image scale is corrected based on the long side ratio error correction term to obtain the corrected long side ratio. The short side ratio of the OCT image scale is corrected based on the short side ratio error correction term to obtain the corrected short side ratio. The calculation of the physical dimensions between any pixels in the original OCT image based on the ratio of the long side and the ratio of the short side of the OCT image scale includes: The physical dimensions between any pixels in the original OCT image are calculated based on the corrected long side ratio and the corrected short side ratio.

3. The OCT image scale processing method according to claim 2, characterized in that, The statistical features include: pixel intensity variance; The method of obtaining the long side ratio error correction term based on the statistical features of a preset number of pixels within the long side sub-region includes: The long side ratio error correction term Calculated using the following formula: ; ; The short-side ratio error correction term is obtained based on the statistical features of a preset number of pixels within the short-side sub-region, including: The short side ratio error correction term Calculated using the following formula: ; ; Where M represents the preset quantity; This represents the variance of pixel intensity for the M pixels within the long-side sub-region; This represents the variance of pixel intensity for the M pixels within the short-side sub-region; This represents the standard deviation of pixel intensity for M pixels within the long-side sub-region; This represents the standard deviation of pixel intensity for M pixels within the short-side sub-region; This represents the grayscale value of the i-th pixel within the long-side sub-region; This represents the grayscale value of the i-th pixel within the short-side sub-region; This represents the average grayscale value of M pixels within the long-side sub-region; The value represents the average grayscale value of M pixels within the short side sub-region; k represents the empirical scaling factor; the corrected short side ratio is the sum of the short side ratio error correction term and the short side ratio of the OCT image scale; the corrected long side ratio is the sum of the long side ratio error correction term and the long side ratio of the OCT image scale.

4. The OCT image scale processing method according to claim 1, characterized in that, The step of preprocessing the scale region image to obtain a preprocessed image includes: performing grayscale conversion on the scale region image to obtain a first preprocessed image; performing mean smoothing filtering on the first preprocessed image to obtain a second preprocessed image; performing Gaussian filtering on the second preprocessed image to obtain a third preprocessed image, and using the third preprocessed image as the preprocessed image. The fuzzy discrimination condition includes at least one of the following: the histogram of the preprocessed image shows a preset number of peak points and the peak amplitude of each peak point is greater than a preset amplitude threshold; the inter-class separation degree of the preprocessed image is lower than a preset separation degree threshold; and the contrast of the preprocessed image is lower than a preset contrast threshold. The step of using an adaptive threshold algorithm to calculate the preferred threshold includes: based on each candidate threshold within a preset threshold range, calculating the degree of separation between foreground pixels and background pixels in the preprocessed image when the candidate threshold is used as the boundary, and selecting the candidate threshold that maximizes the degree of separation between foreground pixels and background pixels in the preprocessed image as the preferred threshold; The background pixels include pixels in the preprocessed image whose grayscale value is less than or equal to the candidate threshold, and the foreground pixels include pixels in the preprocessed image whose grayscale value is greater than the candidate threshold. The degree of separation between foreground and background pixels in the preprocessed image, with the candidate threshold as the boundary, is calculated based on the following formula: ; in, This indicates the probability percentage of background pixels in the preprocessed image; This indicates the probability percentage of foreground pixels in the preprocessed image; This represents the average grayscale value of background pixels in the preprocessed image; This represents the average grayscale value of foreground pixels in the preprocessed image; Indicates the candidate threshold, The value of is an integer in the range of 0 to 255; The step of adaptively binarizing the preprocessed image based on a preferred threshold to obtain an optimized binary image includes: setting pixels in the preprocessed image whose grayscale value is less than or equal to the preferred threshold as first pixel values, and setting pixels in the preprocessed image whose grayscale value is greater than the preferred threshold as second pixel values; wherein, the first pixel value includes 255, the second pixel value includes 0, and the specified fixed threshold includes 200.

5. The OCT image scale processing method according to claim 1, characterized in that, The step of selecting the optimal candidate contour corresponding to the scale of the OCT image from the original contour set based on a preset contour filtering strategy includes: For each contour in the original contour set, check whether each contour touches the edge of the scale region image. Remove the contours that touch the edge of the scale region image from the original contour set, and the remaining contours form the boundary that touches the filtered contour set. For each contour in the boundary-touched filtered contour set, the area of ​​each contour is obtained based on Green's formula. Contours with an area less than a preset area threshold are removed from the boundary-touched filtered contour set, and the remaining contours form the area-filtered contour set. For each contour in the area-filtered contour set, the shape roundness ratio of each contour is obtained. Contours whose shape roundness ratio does not meet the preset ratio condition are removed from the area-filtered contour set, and the remaining contours form the shape-filtered contour set. Based on preset selection criteria, the optimal candidate contour corresponding to the scale of the OCT image is selected from the set of shape-filtered contours. The preset selection criteria include: the contour with the largest area in the set of shape-filtered contours.

6. The OCT image scale processing method according to claim 1, characterized in that, The minimum circumscribed rectangle encloses all contour points in the optimal candidate contour. The geometric parameters of the minimum circumscribed rectangle include: the coordinates of the top left vertex, the number of pixels on the long side, and the number of pixels on the short side. The top left vertex of the minimum circumscribed rectangle is the contour point with the minimum horizontal and minimum vertical coordinates among all contour points in the optimal candidate contour. The process of obtaining the long side ratio and short side ratio of the OCT image scale based on the preset standard physical size of the OCT image scale and the geometric parameters of the minimum circumscribed rectangle of the optimal candidate contour includes: Based on the preset OCT image scale standard physical dimensions The number of pixels on the longer side of the rectangle aligned with the minimum circumscribed axis Calculate the ratio of the long side of the OCT image scale bar. ;in, ; Based on the preset OCT image scale standard physical dimensions The number of pixels on the shorter side of the rectangle aligned with the minimum circumscribed axis. Calculate the ratio of the shorter side of the OCT image scale. ;in, .

7. The OCT image scale processing method according to claim 6, characterized in that, The method further includes: The coordinates of the remaining three vertices of the minimum circumscribed rectangle are calculated based on its geometric parameters. These coordinates include: the coordinates of the top-right vertex, the bottom-left vertex, and the bottom-right vertex. The vertical coordinate of the top-right vertex is equal to that of the top-left vertex, and the horizontal coordinate of the top-right vertex is the sum of the horizontal coordinate of the top-left vertex and the number of pixels on the shorter side minus 1. The horizontal coordinate of the bottom-left vertex is equal to that of the top-left vertex, and the vertical coordinate of the bottom-left vertex is the sum of the vertical coordinate of the top-left vertex and the number of pixels on the longer side minus 1. The vertical coordinate of the bottom-right vertex is equal to that of the bottom-left vertex, and the horizontal coordinate of the bottom-right vertex is equal to that of the top-right vertex. Based on the coordinates of the four vertices of the minimum circumscribed rectangle, the boundary of the minimum circumscribed rectangle is drawn on the original OCT image, and the long side ratio and the short side ratio of the OCT image scale are marked on the original OCT image according to a preset format to obtain a visualization image.

8. An OCT image scale processing device, characterized in that, include: The scale region image acquisition module is configured to: acquire a scale region image based on the original OCT image, wherein the scale region image includes the OCT image scale; The image preprocessing module is configured to preprocess the image of the scale area to obtain a preprocessed image; The image binarization processing module is configured to: perform adaptive binarization processing on the preprocessed image based on a preferred threshold to obtain an optimized binary image; wherein, the preferred threshold is determined based on the following method: obtaining the gray-level distribution features of the preprocessed image; when the gray-level distribution features meet the preset fuzzy discrimination conditions, the preferred threshold is calculated using an adaptive threshold algorithm; otherwise, a specified fixed threshold is used as the preferred threshold. The image morphological opening operation module is configured to: perform morphological opening operation on the optimized binary image based on a preset structuring element to obtain an enhanced binary image; the morphological opening operation includes: a composite operation of erosion followed by dilation; The original contour extraction module is configured to: find and extract contours from the enhanced binary image based on a preset contour retrieval mode and a preset contour approximation method to form an original contour set, wherein the original contour set includes multiple contours and each contour contains multiple contour points. The optimal candidate contour selection module is configured to: select the optimal candidate contour corresponding to the scale of the OCT image from the original contour set based on a preset contour filtering strategy. The non-uniform scale calculation module is configured to: obtain the long side ratio and short side ratio of the OCT image scale based on the preset standard physical size of the OCT image scale and the geometric parameters of the minimum circumscribed rectangle of the optimal candidate contour, so as to calculate the corresponding physical size between any pixels in the original OCT image based on the long side ratio and short side ratio of the OCT image scale.

9. An electronic device, characterized in that, It includes a memory and a processor; wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the OCT image scale processing method according to any one of claims 1 to 7.

10. A computer-readable storage medium storing computer instructions thereon, characterized in that, When the computer instructions are executed by the processor, they implement the OCT image scale processing method according to any one of claims 1 to 7.

11. A computer program product comprising computer instructions, characterized in that, When the computer instructions are executed by the processor, they implement the OCT image scale processing method according to any one of claims 1 to 7.