An agarose gel electrophoresis image automatic analysis method and system based on image recognition
By combining deep learning and rolling ball algorithms in image recognition, the problems of band localization and quantification in agarose gel electrophoresis image analysis were solved, achieving high-precision automated analysis and providing reliable biological experimental data.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SUZHOU ZHONGYAN BIO-INFORMATION CO LTD
- Filing Date
- 2026-02-25
- Publication Date
- 2026-06-05
AI Technical Summary
Existing agarose gel electrophoresis image analysis methods suffer from insufficient band localization accuracy and errors in quantitative analysis, making it difficult to achieve sub-pixel-level precise localization and automatic compensation for diffuse signal loss.
A deep learning-based image recognition method is adopted. The deep learning model is trained to perform image annotation and rotation cropping, and the rolling ball algorithm is combined to remove the background. The grayscale projection integral is used to perform swimlane segmentation and strip integral calculation to calculate the strip purity and molecular weight.
It achieves high-precision strip localization and quantitative analysis, eliminates the differences in analysis results caused by human intervention, improves detection sensitivity and the objectivity of quantitative analysis, and provides comprehensive and objective biological experimental data support.
Smart Images

Figure CN122156613A_ABST
Abstract
Description
Technical Field
[0001] This invention proposes an automatic analysis method and system for agarose gel electrophoresis images based on image recognition, belonging to the field of image analysis technology. Background Technology
[0002] Agarose gel electrophoresis is a core technique for nucleic acid isolation, identification, and quantification in biochemical and molecular biology research. With the increasing demand for high-throughput analysis, higher requirements are being placed on the accuracy and automation of electrophoresis image data processing.
[0003] Currently, existing electrophoresis image analysis methods suffer from the following technical shortcomings: Insufficient band localization accuracy: Existing techniques mostly use the geometric center method or gray-scale peak method to determine band positions. However, electrophoretic bands often exhibit tailing or asymmetrical distribution, and the center is easily shifted downwards due to long-tail interference, while the peak points are easily affected by random noise, making it difficult to achieve sub-pixel-level precise localization, leading to errors in migration distance measurement. Systematic bias in quantitative analysis: When performing nucleic acid quantification, the conventional threshold segmentation method ignores the band diffusion effect. As the migration distance increases, the bands physically diffuse, and a large number of low gray-scale signals at the edges are truncated and lost because they are below the background threshold; some techniques lack an automatic compensation mechanism for the degree of band diffusion (variance), resulting in the content of diffused bands often being significantly underestimated.
[0004] Therefore, there is an urgent need for an automatic analysis method for agarose gel electrophoresis images that can accurately locate the centroid using gray-scale weighted centroids and automatically correct for diffuse signal loss through mathematical models. Summary of the Invention
[0005] This invention provides an automatic analysis method and system for agarose gel electrophoresis images based on image recognition, to solve the problems mentioned above: This invention proposes an automatic analysis method for agarose gel electrophoresis images based on image recognition, characterized in that the method includes: Obtain grayscale images from agarose gel electrophoresis, annotate the grayscale images, and train a deep learning model using the annotated image dataset; A grayscale image of the agarose gel electrophoresis to be analyzed is obtained and input into the deep learning model. The deep learning model outputs the image information of the grayscale image of the agarose gel electrophoresis to be analyzed. The image to be analyzed is rotated and cropped according to the image information. The rolling ball algorithm is used to remove the background from the rotated and cropped image. Based on the image after background removal, the gray-scale projection integral in the vertical direction is performed to segment the swimlanes in the image. Based on the image after swimlane segmentation, the gray-scale projection integral in the horizontal direction is performed. Calculate the integral value of all sample molecular weight bands detected in a single lane in the image after lane segmentation, and obtain the band purity based on the integral value; After obtaining the purity of the bands, the estimated molecular weight of the sample bands is calculated.
[0006] Further, agarose gel electrophoresis grayscale images are obtained, the grayscale images are labeled, and a deep learning model is trained using the labeled image training dataset, including: Obtain grayscale images from agarose gel electrophoresis, and annotate the grayscale images to construct an image training dataset; The annotation process includes: for the sample molecular weight bands in the grayscale image, using oriented bounding boxes for annotation, generating band annotation information containing first spatial coordinate parameters and first category labels, the first spatial coordinate parameters including center x1, center y1, width w1, height h1 and rotation angle θ1; for the agarose gel region in the grayscale image, using horizontal rectangles for annotation, generating gel annotation information containing second spatial coordinate parameters and second category labels, the second spatial coordinate parameters including center x2, center y2, width w2 and height h2; The strip annotation information and the gel annotation information are associated with the grayscale image to construct the image training dataset; The deep learning model based on the YOLO-OBB architecture is trained using the image training dataset, and the model parameters are optimized using the loss function to obtain the trained deep learning model.
[0007] Further, the grayscale image of the agarose gel electrophoresis to be analyzed is acquired and input into the deep learning model. The deep learning model outputs image information of the grayscale image of the agarose gel electrophoresis to be analyzed. Based on the image information, the image to be analyzed is rotated and cropped, including: A grayscale image of the agarose gel electrophoresis sample to be analyzed is obtained. The grayscale image is then input into the pre-trained deep learning model. The deep learning model outputs the directional bounding box information of the molecular weight bands of the sample in the image and the bounding box information of the agarose gel region. Based on the directional bounding box information of the sample molecular weight bands, the overall rotation angle of the grayscale image to be analyzed is calculated, including: From the directional bounding box information of the multiple sample molecular weight bands, the angle value of each directional bounding box relative to the horizontal axis of the image is extracted, the arithmetic mean of multiple angle values is calculated, and the arithmetic mean is used as the overall rotation angle of the grayscale image. Based on the overall rotation angle, an affine transformation is performed on the grayscale image to complete the image rotation correction; Based on the bounding box information of the agarose gel region and the position of the sample molecular weight band in the rotated image, the rotated image is rectangularly cropped.
[0008] Further, based on the bounding box information of the agarose gel region and the position of the sample molecular weight bands in the rotated image, the rotated image is rectangularly cropped, including: When performing rotation correction on the grayscale image, the same rotation correction is performed on the directional bounding box information and the bounding box information of the agarose gel region to obtain the sample molecular weight band coordinate information and agarose gel region coordinate information in the rotated image. Based on the left and right boundary abscissas in the corrected agarose gel region coordinate information, the horizontal range of the clipping region is obtained; Based on the corrected band coordinate information, the minimum and maximum ordinates of all sample molecular weight bands in the vertical direction are obtained. Based on the minimum and maximum ordinates, the preset safety margins are extended upward and downward respectively to obtain the vertical range of the cutting area. Based on the horizontal and vertical ranges, the rotated image is rectangularly cropped.
[0009] Furthermore, the rolling ball algorithm is used to remove the background from the rotated and cropped image. Based on the image with the background removed, a vertical grayscale projection integral is performed to segment the swimlanes in the image. Based on the image with segmented swimlanes, a horizontal grayscale projection integral is performed, including: The rolling ball algorithm is used to remove the background from the rotated and cropped image, resulting in an image with the background removed. Based on the background-removed image, perform vertical grayscale projection integration, including: traversing each column of the background-removed image, calculating the sum of grayscale values of all pixels in the column, obtaining the projection value of the column, and connecting the projection values of all columns in sequence to form a one-dimensional vertical projection curve. On the vertical projection curve, the trough point is found by the extreme value detection algorithm. The trough point corresponds to the interval position between the lanes. The image is segmented into multiple lane region images according to the trough point. For each segmented swimlane region image, perform horizontal grayscale projection integration, including: traversing each row of the swimlane region image, calculating the sum of the grayscale values of all pixels in the row, obtaining the average grayscale value of the pixels in the row, and connecting the projection values of all rows in sequence to form a one-dimensional horizontal projection curve. On the horizontal projection curve, the peak point is found by the extreme value detection algorithm. The peak point corresponds to the center position of the sample molecular weight band. The position of the sample molecular weight band in the swim lane is obtained based on the peak point.
[0010] Further, the integral value of all sample molecular weight bands detected in a single lane in the image after lane segmentation is calculated, and the band purity is obtained based on the integral value, including: Acquire a single lane image after lane segmentation, and determine the pixel region R of each sample molecular weight band within the lane image; For each sample molecular weight band, calculate the sum of the gray values of all pixels within its pixel region, which serves as the original integrated intensity of the total nucleic acid content of that band: in, R represents the raw integrated intensity of the total nucleic acid content of the sample molecular weight band, and R represents the two-dimensional pixel area occupied by a single sample molecular weight band. Represents pixel coordinates. (x,y) represents the grayscale value of the pixel at coordinate (x,y) after background removal for the sample molecular weight band. For each sample molecular weight band, calculate the variance of its grayscale distribution along the migration direction of the swim lane. : Where y represents the ordinate of the pixel. This represents the variance of the grayscale distribution of the molecular weight bands in the migration direction of the swim lanes. This indicates the position of the centroid of the sample molecular weight band in the direction of migration within the lane; The shape dispersion correction factor for each molecular weight band of the sample was calculated based on the variance. ; Calculate the effective integral intensity of each sample molecular weight band after correction based on the shape dispersion correction factor: ,in, Indicates the strength of the effective integral; Calculate the sum of the corrected effective integrated intensities of all molecular weight bands within the lane: ,in, This represents the sum of the effective integral intensities after correction; The relative purity value of each sample molecular weight band is calculated based on the sum of the effective integrated intensities.
[0011] Furthermore, the position of the centroid is calculated in the following manner: Furthermore, the shape dispersion correction factor is calculated in the following manner: Where λ represents the diffusion penalty coefficient.
[0012] Further, after obtaining the band purity, the estimated molecular weight of the target sample molecular weight band is calculated, including: Based on the known molecular weights of the standard molecular weight bands in agarose gel electrophoresis images and their measured migration distances in the images, a standard mathematical relationship model between molecular weight and migration distance is established through curve fitting: ,in, denoted by , where d represents the migration distance, and a and b represent empirical constants. For each molecular weight band in the swim lane of the sample to be analyzed, its migration distance is determined based on image processing algorithms; Substitute the migration distance of the sample molecular weight band into the standard mathematical relationship model to output the estimated value of the sample molecular weight band.
[0013] This invention proposes an automatic image analysis system for agarose gel electrophoresis based on image recognition, the system comprising: A deep learning model training module is used to acquire grayscale images from agarose gel electrophoresis, annotate the grayscale images, and train a deep learning model using the annotated image dataset. The rotation and cropping module is used to acquire the grayscale image of the agarose gel electrophoresis to be analyzed, input it into the deep learning model, and output the image information of the grayscale image of the agarose gel electrophoresis to be analyzed. The image is then rotated and cropped according to the image information. The module for obtaining the average gray value uses the rolling ball algorithm to remove the background from the rotated and cropped image. Based on the image after background removal, it performs vertical gray-scale projection integration to segment the swimlanes in the image. Based on the image after swimlane segmentation, it performs horizontal gray-scale projection integration to obtain the average gray value of each row of pixels in the image. The strip purity acquisition module calculates the integral value of all sample molecular weight strips detected in a single lane in the image after lane segmentation, and obtains the purity of the sample molecular weight strip based on the integral value. The molecular weight estimation module is used to calculate the estimated molecular weight of the sample molecular weight band after obtaining the band purity.
[0014] The beneficial effects of this invention are as follows: By cascading multiple algorithms, it solves the pain points of traditional electrophoresis analysis, such as excessive manual intervention, large background interference, and inaccurate quantification. Traditional methods require manual selection of the gel area and manual delineation of the lanes. This invention automatically outputs image information and completes rotation and cropping through a deep learning model, and automatically segments the lanes through projection integration. It eliminates the differences in analysis results caused by different subjective judgments of operators (such as differences in background baseline caused by different cropping ranges), and realizes the standardization of the analysis process and high-throughput processing capabilities.
[0015] To enhance anti-interference capabilities in complex environments, a rolling ball algorithm is introduced for background removal, effectively addressing background unevenness caused by the smile effect (curved edges) commonly found in electrophoretic imaging, or background noise resulting from incomplete staining and decolorization. Compared to simple global threshold subtraction, this local background subtraction method better preserves weak strip signals and improves detection sensitivity.
[0016] To improve the accuracy and objectivity of quantitative analysis, gray-scale projection integration is used for segmentation and calculation. Compared with contour extraction based on edge detection, the integration method utilizes the overall optical density information of the bands, making the quantification of diffuse bands more accurate. It can simultaneously output band purity and molecular weight estimates, providing comprehensive and objective data support for biological experiments (such as plasmid extraction, PCR product detection, and protein purification).
[0017] To optimize image preprocessing quality, deep learning-based rotation and cropping are performed first, followed by subsequent processing, ensuring that the swimlanes are strictly vertical during subsequent vertical projection. If the image is tilted, vertical projection will cause swimlane signal overlap, severely impacting segmentation results. The logical order of this scheme (correction before segmentation) guarantees the geometric premise of the algorithm, thus ensuring the reliability of the final data. Intelligent alignment is achieved through deep learning, background cleaning is performed using morphological algorithms, and precise quantization is finally achieved through signal processing techniques (projection). This transforms unstructured electrophoresis images into structured physicochemical data (purity, molecular weight), providing a highly robust and accurate biological image analysis solution. Attached Figure Description
[0018] Figure 1 This is a schematic diagram of an automatic image analysis method for agarose gel electrophoresis based on image recognition, as described in this invention. Detailed Implementation
[0019] To better understand the above-mentioned objectives, features, and advantages of the present invention, the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that, unless otherwise specified, the embodiments and features described in these embodiments can be combined with each other.
[0020] Numerous specific details are set forth in the following description to provide a thorough understanding of the invention. The described embodiments are only a part of, and not all, of the embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0021] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.
[0022] Example 1, as Figure 1 As shown in the figure, this invention discloses an automatic analysis method for agarose gel electrophoresis images based on image recognition, the method comprising: Obtain grayscale images from agarose gel electrophoresis, annotate the grayscale images, and train a deep learning model using the annotated image dataset; A grayscale image of the agarose gel electrophoresis to be analyzed is obtained and input into the deep learning model. The deep learning model outputs the image information of the grayscale image of the agarose gel electrophoresis to be analyzed. The image to be analyzed is rotated and cropped according to the image information. The rolling ball algorithm is used to remove the background from the rotated and cropped image. Based on the image after background removal, the gray-scale projection integral in the vertical direction is performed to segment the swimlanes in the image. Based on the image after swimlane segmentation, the gray-scale projection integral in the horizontal direction is performed. Calculate the integral value of all sample molecular weight bands detected in a single lane in the image after lane segmentation, and obtain the band purity based on the integral value; After obtaining the purity of the bands, the estimated molecular weight of the sample bands is calculated.
[0023] The working principle and effect of the above technical solution are as follows: First, by manually annotating a large number of grayscale images of agarose gel electrophoresis, the computer is taught to identify what the gel body is and what the molecular weight bands are. The deep learning model learns image features and establishes a mapping relationship between grayscale images and image information. The image information includes the bounding box coordinates, tilt angles, or key points of the gel and molecular weight bands. When a new image to be analyzed is input, the trained deep learning model will directly output the position parameters of the image. Using these parameters, a rotation matrix is calculated to perform rotation correction on the image (correcting the tilt caused by improper electrophoresis placement), and cropping is performed according to the boundary information. Utilizing the powerful feature extraction capabilities of deep learning, it replaces the traditional localization method based solely on threshold or edge detection, and can more robustly handle original images with complex backgrounds or poor shooting conditions.
[0024] Cropped images often suffer from uneven illumination or background noise from the gel itself. The RollingBall Algorithm is a classic morphological algorithm for background subtraction. The part that the ball touches is considered a smooth background, while the peaks that it cannot touch (i.e., electrophoretic bands) are preserved. By subtracting the smooth background surface defined by the ball, the effects of uneven gel staining or gradual illumination are eliminated, significantly improving the signal-to-noise ratio of subsequent band detection.
[0025] Structured segmentation based on projection integral, i.e., lane and strip identification, performs vertical grayscale integration on the denoised image (i.e., accumulating the pixel values of each column). Since the lane region contains stripes, its integral value is higher, while the integral value of the gaps between lanes is lower. By analyzing these peaks and troughs, the system automatically determines the lane segmentation line, dividing the entire agarose gel electrophoresis image into independent single-lane images.
[0026] Within a single lane, horizontal grayscale integration is performed, and the rows containing the bands will form obvious grayscale peaks. This converts the two-dimensional image signal into a one-dimensional waveform signal, and waveform analysis is used to locate the migration position of the molecular weight bands with great accuracy.
[0027] The sample concentration is reflected by calculating the sum of pixel intensities (integral value) within the identified band region. The principle is to calculate the percentage of the integral value of the target sample molecular weight band relative to the sum of the integral values of all detected sample molecular weight bands in that lane.
[0028] By cascading multiple algorithms, this invention addresses the pain points of traditional electrophoresis analysis, such as excessive manual intervention, significant background interference, and inaccurate quantification. Traditional methods require manual selection of the gel area and manual delineation of lanes. This invention automatically outputs image information and performs rotational cropping through a deep learning model, and automatically segments lanes through projection integration. It eliminates the differences in analysis results caused by different subjective judgments of operators (such as differences in background baseline due to different cropping ranges), and achieves standardization of the analysis process and high-throughput processing capabilities.
[0029] To enhance anti-interference capabilities in complex environments, a rolling ball algorithm is introduced for background removal, effectively addressing background unevenness caused by the smile effect (curved edges) commonly found in electrophoretic imaging, or background noise resulting from incomplete staining and decolorization. Compared to simple global threshold subtraction, this local background subtraction method better preserves weak strip signals and improves detection sensitivity.
[0030] To improve the accuracy and objectivity of quantitative analysis, gray-scale projection integration is used for segmentation and calculation. Compared with contour extraction based on edge detection, the integration method utilizes the overall optical density information of the bands, making the quantification of diffuse bands more accurate. It can simultaneously output band purity and molecular weight estimates, providing comprehensive and objective data support for biological experiments (such as plasmid extraction, PCR product detection, and protein purification).
[0031] To optimize image preprocessing quality, deep learning-based rotation and cropping are performed first, followed by subsequent processing. This ensures that the swimlanes are strictly vertical during subsequent vertical projection. If the image is tilted, vertical projection will cause swimlane signals to overlap, severely affecting segmentation results. The logical order of this scheme (correction before segmentation) guarantees the geometric premise of the algorithm, thus ensuring the reliability of the final data.
[0032] This invention achieves intelligent alignment through deep learning, cleans the background using morphological algorithms, and finally achieves precise quantization through signal processing technology (projection). It transforms unstructured electrophoretic images into structured physicochemical data (purity, molecular weight), providing a highly robust and accurate biological image analysis solution.
[0033] One embodiment of the present invention involves acquiring agarose gel electrophoresis grayscale images, labeling the grayscale images, and using the labeled images to train a deep learning model using a training dataset, including: Obtain grayscale images from agarose gel electrophoresis, and annotate the grayscale images to construct an image training dataset; The annotation process includes: for the sample molecular weight bands in the grayscale image, using oriented bounding boxes for annotation, generating band annotation information containing first spatial coordinate parameters and first category labels, the first spatial coordinate parameters including center x1, center y1, width w1, height h1 and rotation angle θ1; for the agarose gel region in the grayscale image, using horizontal rectangles for annotation, generating gel annotation information containing second spatial coordinate parameters and second category labels, the second spatial coordinate parameters including center x2, center y2, width w2 and height h2; The strip annotation information and the gel annotation information are associated with the grayscale image to construct the image training dataset; The deep learning model based on the YOLO-OBB architecture is trained using the image training dataset, and the model parameters are optimized using the loss function to obtain the trained deep learning model.
[0034] The working principle and effects of the above technical solution are as follows: This invention employs different annotation strategies for the entire agarose gel and the molecular weight bands of the sample. A horizontal bounding box (HBB) is used to annotate the entire gel because the gel is usually a regular rectangle and is mainly kept horizontal or vertical during imaging. Using HBB allows for quick location of the region of interest (ROI) and elimination of background noise (such as the imaging platform and edge shadows). An oriented bounding box (OBB) is used to annotate the molecular weight bands. During electrophoresis, due to uneven voltage, differences in gel concentration, or thermal effects, the bands often exhibit tilting, bending, or a "smiley face" effect. OBB introduces an angle parameter (θ) to conform to the actual geometry of the bands.
[0035] By using the above annotations, image pixel information is associated with spatial coordinates (x, y, w, h, θ) and category labels (Gel, Band) to construct an image training dataset. x and y represent the pixel position of the geometric center of the target object (gel or strip), usually with the top left corner of the image as the origin (0, 0). w and h are the width and height, representing the scale of the target object. θ represents the angle between the long side of the bounding box and the horizontal axis (x-axis) of the image. Category labels (Gel, Band) define identity and attributes. In order for the model to distinguish whether the object it detects is a background container or experimental data, these labels are converted into numeric indices (IDs) inside the computer.
[0036] The model training is based on the YOLO-OBB architecture. YOLO (You Only Look Once) is a single-stage detection algorithm, and YOLO-OBB adds the ability to predict rotation angles. Unlike traditional YOLO, the regression branch of YOLO-OBB predicts not only the center point coordinates and width and height, but also the rotation angle. During training, the model minimizes the difference between the predicted bounding box and the manually labeled bounding box through a loss function, thereby learning how to automatically determine the tilt and position of the strip based on the grayscale distribution.
[0037] In one embodiment of the present invention, an agarose gel electrophoresis grayscale image to be analyzed is acquired and input into the deep learning model. The deep learning model outputs image information of the agarose gel electrophoresis grayscale image to be analyzed. The image to be analyzed is then rotated and cropped based on the image information, including: A grayscale image of the agarose gel electrophoresis sample to be analyzed is obtained. The grayscale image is then input into the pre-trained deep learning model. The deep learning model outputs the directional bounding box information of the molecular weight bands of the sample in the image and the bounding box information of the agarose gel region. Based on the directional bounding box information of the sample molecular weight bands, the overall rotation angle of the grayscale image to be analyzed is calculated, including: From the directional bounding box information of the multiple sample molecular weight bands, the angle value of each directional bounding box relative to the horizontal axis of the image is extracted, the arithmetic mean of multiple angle values is calculated, and the arithmetic mean is used as the overall rotation angle of the grayscale image. Based on the overall rotation angle, an affine transformation is performed on the grayscale image to complete the image rotation correction; Based on the bounding box information of the agarose gel region and the position of the sample molecular weight band in the rotated image, the rotated image is rectangularly cropped.
[0038] The working principle and effect of the above technical solution are as follows: After the grayscale image to be analyzed is input into the pre-trained model, the model outputs two types of geometric information in parallel: identify each individual molecular weight band and output its oriented bounding box containing the rotation angle; identify the entire gel region and output its horizontal boundary coordinates (x2, y2, w2 and h2) to define the physical boundary of the effective data. Ideally, electrophoretic bands should be horizontally distributed. The tilt of the grayscale image is mainly caused by two factors: systematic errors (such as skewed shooting angles or improper gel placement) and local random errors (such as the smiley face effect or tailing of individual bands). By extracting the angle values of all band OBBs and calculating the arithmetic mean, the algorithm uses statistical principles to offset local random errors (i.e., the interference of individual band bending on angle judgment), thus accurately extracting the overall rotation angle representing systematic errors. A rotation matrix based on the calculated overall rotation angle is constructed, and an affine transformation is performed on the original image pixel matrix. This step mathematically simulates the process of rotating a tilted physical world back to normal, forcibly aligning the image coordinate system with the horizontal axis of the experimental bands. After the image is straightened, the agarose gel region (HBB) predicted by the model is used as a mask. This step is equivalent to removing all imaging background outside the gel (such as experimental table texture and edge black boxes) in this aligned coordinate system, retaining only the core experimental data.
[0039] In one embodiment of the present invention, based on the bounding box information of the agarose gel region and the position of the sample molecular weight bands in the rotated image, a rectangular cropping of the rotated image is performed, including: When performing rotation correction on the grayscale image, the same rotation correction is performed on the directional bounding box information and the bounding box information of the agarose gel region to obtain the sample molecular weight band coordinate information and agarose gel region coordinate information in the rotated image. Based on the left and right boundary abscissas in the corrected agarose gel region coordinate information, the horizontal range of the clipping region is obtained; Based on the corrected band coordinate information, the minimum and maximum ordinates of all sample molecular weight bands in the vertical direction are obtained. Based on the minimum and maximum ordinates, the preset safety margins are extended upward and downward respectively to obtain the vertical range of the cutting area. Based on the horizontal and vertical ranges, the rotated image is rectangularly cropped.
[0040] In one embodiment of the present invention, a rolling ball algorithm is used to remove the background from a rotated and cropped image. Based on the image with the background removed, a vertical grayscale projection integral is performed to segment the swimlanes in the image. Based on the image with the swimlanes segmented, a horizontal grayscale projection integral is performed, including: The rolling ball algorithm is used to remove the background from the rotated and cropped image, resulting in an image with the background removed. Based on the background-removed image, perform vertical grayscale projection integration, including: traversing each column of the background-removed image, calculating the sum of grayscale values of all pixels in the column, obtaining the projection value of the column, and connecting the projection values of all columns in sequence to form a one-dimensional vertical projection curve. On the vertical projection curve, the trough point is found by the extreme value detection algorithm. The trough point corresponds to the interval position between the lanes. The image is segmented into multiple lane region images according to the trough point. For each segmented swimlane region image, perform horizontal grayscale projection integration, including: traversing each row of the swimlane region image, calculating the sum of the grayscale values of all pixels in the row, obtaining the average grayscale value of the pixels in the row, and connecting the projection values of all rows in sequence to form a one-dimensional horizontal projection curve. On the horizontal projection curve, the peak point is found by the extreme value detection algorithm. The peak point corresponds to the center position of the sample molecular weight band. The position of the sample molecular weight band in the swim lane is obtained based on the peak point.
[0041] The working principle and effect of the above technical solution are as follows: A two-dimensional grayscale image is considered as a three-dimensional topological surface, where pixel grayscale values represent height. The algorithm simulates a sphere with a specific radius rolling below this surface. Due to the large radius of the sphere, it cannot roll into narrow peaks (i.e., molecular weight bands) and can only contact gently changing valleys (i.e., the background). The trajectory of the sphere's contact points constitutes the background baseline. By subtracting this background baseline from the original image, low-frequency background noise caused by uneven gel thickness or uneven illumination is eliminated, retaining only high-frequency band signals. On an image with a clean background, the algorithm integrates (accumulates) the pixel grayscale values along the vertical direction. This compresses the two-dimensional image into a vertically projected curve. On this curve, high grayscale accumulation areas represent lanes (signal areas), and low grayscale accumulation areas represent gaps between lanes (blank areas). An extremum detection algorithm finds local minima (valleys) on the curve. These valleys mathematically define the physical boundaries of the lanes, thus cutting the entire gel image into independent single-lane images. For each individual lane image, the algorithm performs integration or averaging along the horizontal direction to generate a horizontal projection curve. This curve is essentially the optical density chromatogram of that lane. Each local maximum (peak) on the curve represents the center of the highest gray density at that location, i.e., the center of the highest DNA / protein concentration. By locking these peak coordinates, the system accurately obtains the center position of the band in the migration direction.
[0042] In one embodiment of the present invention, the integral value of all sample molecular weight bands detected in a single lane in an image after lane segmentation is calculated, and the band purity is obtained based on the integral value, including: Acquire a single lane image after lane segmentation, and determine the pixel region R of each sample molecular weight band within the lane image; For each sample molecular weight band, calculate the sum of the gray values of all pixels within its pixel region, which serves as the original integrated intensity of the total nucleic acid content of that band: in, R represents the raw integrated intensity of the total nucleic acid content of the sample molecular weight band, and R represents the two-dimensional pixel area occupied by a single sample molecular weight band. Represents pixel coordinates. (x,y) represents the grayscale value of the pixel at coordinate (x,y) after background removal for the sample molecular weight band. For each sample molecular weight band, calculate the variance of its grayscale distribution along the migration direction of the swim lane. : Where y represents the ordinate of the pixel. This represents the variance of the grayscale distribution of the molecular weight bands in the migration direction of the swim lanes. This indicates the position of the centroid of the sample molecular weight band in the direction of migration within the lane; The shape dispersion correction factor for each molecular weight band of the sample was calculated based on the variance. ; Calculate the effective integral intensity of each sample molecular weight band after correction based on the shape dispersion correction factor: ,in, Indicates the strength of the effective integral; Calculate the sum of the corrected effective integrated intensities of all molecular weight bands within the lane: ,in, This represents the sum of the effective integral intensities after correction; The relative purity value of each sample molecular weight band is calculated based on the sum of the effective integrated intensities.
[0043] The working principle and effect of the above technical solution are as follows: The formula for calculating the original integral intensity indicates that the gray value of a pixel in the stained gel image is proportional to the nucleic acid / protein concentration at that location; the gray value (Peak Height) of a single point can only represent the highest concentration, not the total amount. Only by performing a double integral (cumulative summation) of the gray values of all pixels within the strip region can it be mathematically equivalent to the total mass of the substance contained in that strip. The formula for calculating the variance is a gray-weighted second-order central moment calculation formula. Describes the distance of a pixel from the center of the strip (centroid) The geometric distance of ) multiplied by This means that when calculating the degree of dispersion, we look at the width of the quality distribution, not the width of the shape. Points with higher gray values (more concentrated quality) contribute more to the result; noise at the edges... A small variance has a smaller impact on the results. In electrophoresis, molecules undergo thermal diffusion as the migration distance increases. Variance can accurately quantify this physical diffusion effect, distinguishing between sharp bands (small variance) and diffuse bands (large variance). To address threshold truncation errors in digital image processing, a highly diffuse strip (large) is used. These weak edges tend to be elongated and have very low grayscale. During background removal or image segmentation, these faint edges are often mistaken for background and removed because they fall below a detection threshold. (Simple...) Accumulation can underestimate the amount of diffuse stripes due to the loss of edge signals. (A follower) The increased positive correlation function uses statistical laws to estimate how much of the cut-off edge signal is and then restores it.
[0044] In one embodiment of the present invention, the centroid position is calculated in the following manner: The working principle and effect of the above technical solution are as follows: It resists tailing and asymmetric interference. Many electrophoretic bands exhibit tailing, meaning a long, faint tail appears below the band. If the geometric center is used, the long tail will pull the center point downwards significantly, leading to misjudgment of its position. The highest point is often easily affected by random noise (such as an isolated bright spot), causing positional jumps. The formula for calculating the centroid position above considers the overall distribution. Although the tail is long, its grayscale value (weight) is low; the main band, although narrow, has an extremely high grayscale value (weight). The centroid method can firmly... It will be locked in the place where the main band material is most concentrated, with only a slight influence from the tail, which best matches the physical fact that most molecules migrate to that location.
[0045] In one embodiment of the present invention, the shape dispersion correction factor is calculated in the following manner: Where λ represents the diffusion penalty coefficient.
[0046] The working principle and effect of the above technical solution are as follows: simulating the nonlinear edge loss characteristic phenomenon, the electrophoretic bands become wider ( When the band width increases, the signal loss is not linear; when the band width increases slightly, the peak value is still much higher than the background threshold, and the signal loss is almost zero; when the band width continues to increase, the peak value begins to approach the background noise line, and the tail of the edge is largely embedded in the background, and the signal loss accelerates sharply. Linear functions (such as y=ax+b) cannot describe this loss process that is slow at first and then fast. Exponential functions have a very strong ability to change nonlinearly and are very suitable for simulating signal attenuation (or the compensation required) that increases exponentially with the degree of diffusion. The gray-scale distribution of electrophoretic bands is theoretically approximately Gaussian, and its mathematical form itself contains an exponential term. When trying to recover the Gaussian distribution tails lost due to threshold truncation, using the isomorphic exponential function for inverse operation and compensation is mathematically the simplified model with the highest fit and the smallest residual. For sharp bands ( The exponential function changes very smoothly (close to 1), meaning that high-quality, sharp bars are treated with minimal intervention, preserving the authenticity of the original data. For diffuse bars ( The value of the exponential function changes rapidly. This means that once the stripe diffusion exceeds a certain critical point, the system will provide strong compensation. This on-demand compensation mechanism is more intelligent than linear compensation.
[0047] In one embodiment of the present invention, after obtaining the purity of the band, the estimated molecular weight value of the target sample molecular weight band is calculated, including: Based on the known molecular weights of the standard molecular weight bands in agarose gel electrophoresis images and their measured migration distances in the images, a standard mathematical relationship model between molecular weight and migration distance is established through curve fitting: ,in, The value represents the molecular weight, d represents the migration distance (the distance from the front edge of the sample well to the center of the strip, in mm), and a and b represent empirical constants. For each molecular weight band in the swim lane of the sample to be analyzed, its migration distance is determined based on image processing algorithms; Substitute the migration distance of the sample molecular weight band into the standard mathematical relationship model to output the estimated value of the sample molecular weight band.
[0048] Example 2: An automatic image analysis system for agarose gel electrophoresis based on image recognition, the system comprising: A deep learning model training module is used to acquire grayscale images from agarose gel electrophoresis, annotate the grayscale images, and train a deep learning model using the annotated image dataset. The rotation and cropping module is used to acquire the grayscale image of the agarose gel electrophoresis to be analyzed, input it into the deep learning model, and output the image information of the grayscale image of the agarose gel electrophoresis to be analyzed. The image is then rotated and cropped according to the image information. The module for obtaining the average gray value uses the rolling ball algorithm to remove the background from the rotated and cropped image. Based on the image after background removal, it performs vertical gray-scale projection integration to segment the swimlanes in the image. Based on the image after swimlane segmentation, it performs horizontal gray-scale projection integration to obtain the average gray value of each row of pixels in the image. The strip purity acquisition module calculates the integral value of all sample molecular weight strips detected in a single lane in the image after lane segmentation, and obtains the purity of the sample molecular weight strip based on the integral value. The molecular weight estimation module is used to calculate the estimated molecular weight of the sample molecular weight band after obtaining the band purity.
[0049] The embodiments of the present invention are based on the same inventive concept as Embodiment 1 and have the same technical effects, which will not be repeated here.
[0050] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0051] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0052] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0053] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0054] Obviously, the above embodiments are merely illustrative examples for clear explanation and are not intended to limit the implementation. Those skilled in the art will recognize that other variations or modifications can be made based on the above description. It is neither necessary nor possible to exhaustively list all possible implementations here. However, obvious variations or modifications derived therefrom are still within the scope of protection of this invention.
Claims
1. An automatic analysis method for agarose gel electrophoresis images based on image recognition, characterized in that, The method includes: Obtain grayscale images from agarose gel electrophoresis, annotate the grayscale images, and train a deep learning model using the annotated image dataset; A grayscale image of the agarose gel electrophoresis to be analyzed is obtained and input into the deep learning model. The deep learning model outputs the image information of the grayscale image of the agarose gel electrophoresis to be analyzed. The image to be analyzed is rotated and cropped according to the image information. The rolling ball algorithm is used to remove the background from the rotated and cropped image. Based on the image after background removal, the gray-scale projection integral in the vertical direction is performed to segment the swimlanes in the image. Based on the image after swimlane segmentation, the gray-scale projection integral in the horizontal direction is performed. Calculate the integral value of all sample molecular weight bands detected in a single lane in the image after lane segmentation, and obtain the band purity based on the integral value; After obtaining the purity of the bands, the estimated molecular weight of the sample bands is calculated.
2. The automatic analysis method for agarose gel electrophoresis images based on image recognition according to claim 1, characterized in that, Obtaining grayscale images from agarose gel electrophoresis, labeling the grayscale images, and training a deep learning model using the labeled image training dataset include: Obtain grayscale images from agarose gel electrophoresis, and annotate the grayscale images to construct an image training dataset; The annotation process includes: for the sample molecular weight bands in the grayscale image, using oriented bounding boxes for annotation, generating band annotation information containing first spatial coordinate parameters and first category labels, the first spatial coordinate parameters including center x1, center y1, width w1, height h1 and rotation angle θ1; for the agarose gel region in the grayscale image, using horizontal rectangles for annotation, generating gel annotation information containing second spatial coordinate parameters and second category labels, the second spatial coordinate parameters including center x2, center y2, width w2 and height h2; The strip annotation information and the gel annotation information are associated with the grayscale image to construct the image training dataset; The deep learning model based on the YOLO-OBB architecture is trained using the image training dataset, and the model parameters are optimized using the loss function to obtain the trained deep learning model.
3. The automatic analysis method for agarose gel electrophoresis images based on image recognition according to claim 1, characterized in that, The process involves acquiring a grayscale image of the agarose gel electrophoresis image to be analyzed, inputting it into the deep learning model, and the deep learning model outputting image information of the grayscale image. Based on this image information, the image is then rotated and cropped, including: A grayscale image of the agarose gel electrophoresis sample to be analyzed is obtained. The grayscale image is then input into the pre-trained deep learning model. The deep learning model outputs the directional bounding box information of the molecular weight bands of the sample in the image and the bounding box information of the agarose gel region. Based on the directional bounding box information of the sample molecular weight bands, the overall rotation angle of the grayscale image to be analyzed is calculated, including: From the directional bounding box information of the multiple sample molecular weight bands, the angle value of each directional bounding box relative to the horizontal axis of the image is extracted, the arithmetic mean of multiple angle values is calculated, and the arithmetic mean is used as the overall rotation angle of the grayscale image. Based on the overall rotation angle, an affine transformation is performed on the grayscale image to complete the image rotation correction; Based on the bounding box information of the agarose gel region and the position of the sample molecular weight band in the rotated image, the rotated image is rectangularly cropped.
4. The automatic analysis method for agarose gel electrophoresis images based on image recognition according to claim 3, characterized in that, Based on the bounding box information of the agarose gel region and the position of the sample molecular weight bands in the rotated image, the rotated image is rectangularly cropped, including: When performing rotation correction on the grayscale image, the same rotation correction is performed on the directional bounding box information and the bounding box information of the agarose gel region to obtain the sample molecular weight band coordinate information and agarose gel region coordinate information in the rotated image. Based on the left and right boundary abscissas in the corrected agarose gel region coordinate information, the horizontal range of the clipping region is obtained; Based on the corrected band coordinate information, the minimum and maximum ordinates of all sample molecular weight bands in the vertical direction are obtained. Based on the minimum and maximum ordinates, the preset safety margins are extended upward and downward respectively to obtain the vertical range of the cutting area. Based on the horizontal and vertical ranges, the rotated image is rectangularly cropped.
5. The automatic analysis method for agarose gel electrophoresis images based on image recognition according to claim 1, characterized in that, The rolling ball algorithm is used to remove the background from the rotated and cropped image. Based on the background-removed image, a vertical grayscale projection integral is performed to segment the swimlanes in the image. Based on the image with segmented swimlanes, a horizontal grayscale projection integral is performed, including: The rolling ball algorithm is used to remove the background from the rotated and cropped image, resulting in an image with the background removed. Based on the background-removed image, perform vertical grayscale projection integration, including: traversing each column of the background-removed image, calculating the sum of grayscale values of all pixels in the column, obtaining the projection value of the column, and connecting the projection values of all columns in sequence to form a one-dimensional vertical projection curve. On the vertical projection curve, the trough point is found by the extreme value detection algorithm. The trough point corresponds to the interval position between the lanes. The image is segmented into multiple lane region images according to the trough point. For each segmented swimlane region image, perform horizontal grayscale projection integration, including: traversing each row of the swimlane region image, calculating the sum of the grayscale values of all pixels in the row, obtaining the average grayscale value of the pixels in the row, and connecting the projection values of all rows in sequence to form a one-dimensional horizontal projection curve. On the horizontal projection curve, the peak point is found by the extreme value detection algorithm. The peak point corresponds to the center position of the sample molecular weight band. The position of the sample molecular weight band in the swim lane is obtained based on the peak point.
6. The automatic analysis method for agarose gel electrophoresis images based on image recognition according to claim 1, characterized in that, Calculate the integral value of all sample molecular weight bands detected in a single lane in the image after lane segmentation, and obtain the band purity based on the integral value, including: Acquire a single lane image after lane segmentation, and determine the pixel region R of each sample molecular weight band within the lane image; For each sample molecular weight band, calculate the sum of the gray values of all pixels within its pixel region, which serves as the original integrated intensity of the total nucleic acid content of that band: in, R represents the raw integrated intensity of the total nucleic acid content of the sample molecular weight band, and R represents the two-dimensional pixel area occupied by a single sample molecular weight band. Represents pixel coordinates. (x,y) represents the grayscale value of the pixel at coordinate (x,y) after background removal for the sample molecular weight band. For each sample molecular weight band, calculate the variance of its grayscale distribution along the migration direction of the swim lane. : Where y represents the ordinate of the pixel. This represents the variance of the grayscale distribution of the molecular weight bands in the migration direction of the swim lanes. This indicates the position of the centroid of the sample molecular weight band in the direction of migration within the lane; The shape dispersion correction factor for each molecular weight band of the sample was calculated based on the variance. ; Calculate the effective integral intensity of each sample molecular weight band after correction based on the shape dispersion correction factor: ,in, Indicates the strength of the effective integral; Calculate the sum of the corrected effective integrated intensities of all molecular weight bands within the lane: ,in, This represents the sum of the effective integral intensities after correction; The relative purity value of each sample molecular weight band is calculated based on the sum of the effective integrated intensities.
7. The automatic analysis method for agarose gel electrophoresis images based on image recognition according to claim 6, characterized in that, The position of the centroid is calculated in the following way: 。 8. The automatic analysis method for agarose gel electrophoresis images based on image recognition according to claim 6, characterized in that, The shape dispersion correction factor is calculated in the following manner: Where λ represents the diffusion penalty coefficient.
9. The automatic analysis method for agarose gel electrophoresis images based on image recognition according to claim 1, characterized in that, After obtaining the band purity, calculate the estimated molecular weight of the target sample's molecular weight band, including: Based on the known molecular weights of the standard molecular weight bands in agarose gel electrophoresis images and their measured migration distances in the images, a standard mathematical relationship model between molecular weight and migration distance is established through curve fitting: ,in, denoted by , where d represents the migration distance, and a and b represent empirical constants. For each molecular weight band in the swim lane of the sample to be analyzed, its migration distance is determined based on image processing algorithms; Substitute the migration distance of the sample molecular weight band into the standard mathematical relationship model to output the estimated value of the sample molecular weight band.
10. An automated image analysis system for agarose gel electrophoresis based on image recognition, characterized in that, The system includes: A deep learning model training module is used to acquire grayscale images from agarose gel electrophoresis, annotate the grayscale images, and train a deep learning model using the annotated image dataset. The rotation and cropping module is used to acquire the grayscale image of the agarose gel electrophoresis to be analyzed, input it into the deep learning model, and output the image information of the grayscale image of the agarose gel electrophoresis to be analyzed. The image is then rotated and cropped according to the image information. The module for obtaining the average gray value uses the rolling ball algorithm to remove the background from the rotated and cropped image. Based on the image after background removal, it performs vertical gray-scale projection integration to segment the swimlanes in the image. Based on the image after swimlane segmentation, it performs horizontal gray-scale projection integration to obtain the average gray value of each row of pixels in the image. The strip purity acquisition module calculates the integral value of all sample molecular weight strips detected in a single lane in the image after lane segmentation, and obtains the purity of the sample molecular weight strip based on the integral value. The molecular weight estimation module is used to calculate the estimated molecular weight of the sample molecular weight band after obtaining the band purity.