Automatic focusing image quality calculation method and device based on SVR and storage medium
Through the SVR-based automatic focus image quality calculation method, the Laplace operator sharpness value and GLCM texture information feature vectors are used to solve the problem of low focus accuracy in the prior art, and more accurate focus position recognition and image quality evaluation are achieved.
Patent Information
- Application Number
- CN202510326929.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-19
- Publication Date
- 2025-06-24
AI Technical Summary
The existing image evaluation algorithms are susceptible to impurities during focusing on pathological images, and the focus position cannot be accurately identified in areas with low contrast or uniform staining, resulting in low focus accuracy.
Using the automatic focus image quality calculation method based on support vector regression (SVR), the image's Laplace operator sharpness value and grayscale symbiosis matrix (GLCM) texture information are obtained by collecting sample data sets of images with different quality, combining them into feature vectors, input them into the SVR model for prediction, and outputting image quality scores, thereby optimizing the focus process.
Through the combination of multi-dimensional features, the image quality characteristics are comprehensively characterized, the focus accuracy is improved, the impact of impurities is reduced, and the focus position can be accurately identified in areas with low contrast or uniform dyeing.
Smart Images

Figure CN120201301A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and specifically, to a method, device, and storage medium for calculating the quality of an auto-focus image based on SVR. Background Art
[0002] Digital slide scanners are medical devices that have developed rapidly in recent years. They can perform all-round and rapid digital scanning of the pathological information on glass slides, transforming traditional physical glass slides into a new generation of digital pathological sections. The imaging quality of digital slide scanners depends to a large extent on the accuracy of the focal plane establishment. Especially during the Z-axis focusing process, finding the clearest sample position is crucial. In this process, the evaluation algorithm for the acquired images plays a core role and is decisive for the evaluation of image quality and the optimization of the focus position.
[0003] There are mainly two existing image evaluation algorithms: 1. Sharpness calculation method: This method evaluates the sharpness of an image by calculating the sharpness of the image (such as gradients, Laplacian operators, etc.). Its advantages are simple and intuitive calculation. However, traditional sharpness calculation methods are easily affected by impurities (such as dust, bubbles, or other non-tissue substances on the glass slide), thus affecting the imaging quality. Especially in pathological images, impurities and tissue structures are often intertwined. 2. Contrast calculation method: This method evaluates the sharpness of an image by calculating the contrast of local regions or the whole of the image. Common contrast metrics include contrast in the gray-level co-occurrence matrix (GLCM), standard deviation, etc. These metrics can reflect the intensity of brightness changes in the image, thereby indirectly evaluating the sharpness of the image. However, the contrast-based algorithm also has certain limitations. Since the contrast in the image is affected not only by the focus sharpness but also by factors such as the staining degree of the sample and the tissue type, in some low-contrast or uniformly stained regions, the algorithm cannot accurately identify the focus position. Summary of the Invention
[0004] Aiming at the defects in the prior art, the purpose of the present invention is to provide a method, device, and storage medium for calculating the quality of an auto-focus image based on SVR that can improve the focusing accuracy.
[0005] To solve the above problems, the technical solution of the present invention is as follows:
[0006] A method for calculating the quality of an auto-focus image based on SVR includes the following steps:
[0007] Collect a sample data set of images with different qualities and label each image with a quality score;
[0008] Obtain the Laplacian sharpness value and GLCM texture information of the image, and combine them into a feature vector;
[0009] Input the feature vector into the SVR model to predict and output the image quality score;
[0010] Divide the dataset into a training set and a test set, train the SVR model, and find the best parameter combination;
[0011] Use the trained SVR model to predict and output the image quality.
[0012] Preferably, the step of collecting a sample dataset of images with different qualities and annotating each image with a quality score specifically includes:
[0013] Move the microscope along the Z-axis direction and collect N images at a predetermined interval;
[0014] Perform a quality score on each image, and record the quality score corresponding to each image and its Z-axis height at the time of acquisition.
[0015] Preferably, the step of obtaining the Laplacian sharpness value and GLCM texture information of the image and combining them into a feature vector specifically includes:
[0016] Calculate the Laplacian sharpness value of the image as an input feature to measure the clarity of the image;
[0017] Extract the texture features of the image through GLCM, and calculate the contrast, homogeneity, and energy texture of the image as input features respectively;
[0018] Generate a feature vector, and combine the features into a new feature vector as:
[0019] X = [sharpness, GLCM contrast, GLCM homogeneity, GLCM energy].
[0020] Preferably, the step of dividing the dataset into a training set and a test set, training the SVR model, and finding the best parameter combination specifically includes:
[0021] Data division: Divide the dataset according to the ratio of 80% training set and 20% test set;
[0022] Train the SVR model: Use the support vector regression algorithm to train the model, and select the radial basis function kernel as the kernel function;
[0023] Parameter tuning and optimization: Use grid search to find the best parameter combination of the SVR model;
[0024] Combined with cross-validation, evaluate the performance of each parameter combination and select the best parameter combination.
[0025] Furthermore, the present invention also provides an SVR-based automatic focusing image quality calculation device, including a processor and a memory for storing executable instructions of the processor. The processor is configured to execute the above-mentioned SVR-based automatic focusing image quality calculation method by executing the executable instructions.
[0026] Furthermore, the present invention also provides a computer-readable storage medium for storing program codes for executing the above-mentioned SVR-based automatic focusing image quality calculation method.
[0027] Compared with the prior art, the present invention comprehensively characterizes the image quality characteristics through multi-dimensional feature combination. Most of the existing image quality calculation methods only rely on a single sharpness metric, while the present invention measures the sharpness of an image by calculating the gradient, Laplacian operator or edge information of the image, and comprehensively considers factors such as texture, noise, and impurities, thereby improving the focusing accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Other features, objects, and advantages of the present invention will become more apparent by reading the following detailed description of non-limiting embodiments with reference to the accompanying drawings:
[0029] Figure 1 It is a flowchart of the SVR-based automatic focusing image quality calculation method of the present invention;
[0030] Figure 2 It is an overall architecture diagram of the SVR-based automatic focusing image quality calculation method of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0031] The present invention will be described in detail below with reference to specific embodiments. The following embodiments will help those skilled in the art to further understand the present invention, but do not limit the present invention in any form. It should be noted that those of ordinary skill in the art can make several changes and improvements without departing from the concept of the present invention. These all belong to the protection scope of the present invention.
[0032] Specifically, the present invention provides an SVR-based automatic focusing image quality calculation method, as Figure 1 shown, the method includes the following steps:
[0033] S1: Collect a sample data set of images with different qualities and label each image with a quality score;
[0034] Specifically, as Figure 2 shown, it specifically includes the following steps:
[0035] Step 1: Move the microscope along the Z-axis direction and collect N images at a predetermined interval;
[0036] Step 2: Perform quality scoring on each image, and record the quality score corresponding to each image and its Z-axis height at the time of acquisition.
[0037] S2: Obtain the Laplacian sharpness value and GLCM texture information of the image, and combine them into a feature vector;
[0038] Specifically, the step S2 includes the following steps:
[0039] Step 1: Calculate the Laplacian sharpness value of the image, which is used as one of the input features to measure the sharpness of the image.
[0040] The Laplacian operator highlights the edge information of the image by performing second-order derivative processing on the image, thereby reflecting the sharpness of the image, as follows:
[0041]
[0042] Step 2: Use the gray-level co-occurrence matrix (GLCM) to extract the texture features of the image. Specifically, it includes:
[0043] ① Contrast: Reflects the local change intensity of the image texture. The higher the value, the richer the details, as follows:
[0044]
[0045] where P(i,j) is the joint probability between gray levels i and j in the gray-level co-occurrence matrix, and i and j are the gray values of the image.
[0046] ② Homogeneity: Describes whether the texture of the image is uniform. A higher value indicates that the texture is more uniform, and a lower value indicates
[0047] that the texture changes greatly and the image is clearer, as follows:
[0048]
[0049] ③ Energy: Also known as the uniformity of the texture, it measures the smoothness of the texture. A higher energy value indicates that the texture in the image has stronger regularity, as follows:
[0050]
[0051] Step 3: Generate a feature vector, and combine the above features into a new feature vector as:
[0052] X = [sharpness, GLCM contrast, GLCM homogeneity, GLCM energy].
[0053] S3: Input the feature vector into the SVR model to predict and output the image quality score;
[0054] Specifically, the feature vector is input into the SVR model to predict and output the image quality score. By analogy, the image quality scores are obtained N times, compared, and the maximum score is output; the best position of the Z-axis movement is controlled, and the process ends.
[0055] S4: Divide the data set into a training set and a test set, train the SVR model, and find the best parameter combination.
[0056] Specifically, step S4 includes the following steps:
[0057] ① Data division: Divide the data set according to the ratio of 80% training set and 20% test set.
[0058] ② Train the SVR model: Use the support vector regression (SVR) algorithm to train the model, and select the RBF (radial basis function) kernel as the kernel function. The RBF kernel can effectively handle non-linear relationships and fit the data by optimizing the support vectors.
[0059] ③ Parameter tuning and optimization: Use grid search to find the best parameter combination of the SVR model.
[0060] Combined with cross-validation, evaluate the performance of each parameter combination. Finally, select the best hyperparameter configuration to ensure that the model has strong prediction ability.
[0061] S5: Use the trained SVR model to predict and output the image quality.
[0062] The specific embodiments of the present invention have been described above. It should be understood that the present invention is not limited to the above specific embodiments, and those skilled in the art can make various changes or modifications within the scope of the claims, which do not affect the essence of the present invention. Without conflict, the embodiments of the present application and the features in the embodiments can be combined with each other arbitrarily.
Claims
1. A method for calculating auto-focus image quality based on SVR, characterized in that: The method comprises the following steps: Collect a sample dataset of images of different qualities and annotate each image with a quality score; Get the Laplacian sharpness value and GLCM texture information of the image and combine them into a feature vector; Input the feature vector into the SVR model to predict and output the image quality score; Divide the data set into training set and test set, train the SVR model, and find the best parameter combination; Use the trained SVR model to predict the image quality.
2. The SVR-based auto-focus image quality calculation method according to claim 1, characterized in that: The step of collecting sample data sets of images of different qualities and labeling a quality score for each image specifically includes: Move the microscope along the Z-axis direction and collect N images at predetermined intervals; The quality of each image is scored, and the quality score of each image and its Z-axis height when it was acquired are recorded.
3. The SVR-based auto-focus image quality calculation method according to claim 1, characterized in that: The step of obtaining the Laplacian sharpness value and GLCM texture information of the image and combining them into a feature vector specifically includes: Calculate the Laplacian sharpness value of the image as an input feature to measure the clarity of the image; The texture features of the image are extracted through GLCM, and the contrast, homogeneity, and energy texture of the image are calculated as input features; Generate feature vectors and combine the features into a new feature vector: X = [sharpness, GLCM contrast, GLCM homogeneity, GLCM energy].
4. The SVR-based auto-focus image quality calculation method according to claim 1, characterized in that: The steps of dividing the data set into a training set and a test set, training the SVR model, and finding the best parameter combination specifically include: Data division: The data set is divided into 80% training set and 20% test set; Training SVR model: Use support vector regression algorithm to train the model and select radial basis function kernel as kernel function; Parameter adjustment and optimization: Use grid search to find the best parameter combination for the SVR model; Combined with cross-validation, the performance of each parameter combination is evaluated and the best parameter combination is selected.
5. An auto-focus image quality calculation device based on SVR, characterized in that: The apparatus comprises a processor and a memory for storing executable instructions of the processor, wherein the processor is configured to perform the SVR-based auto-focus image quality calculation method according to any one of claims 1 to 4 by executing the executable instructions.
6. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store program codes, and the program codes are used to execute the SVR-based auto-focus image quality calculation method according to any one of claims 1 to 4.