Image recognition method, electronic device, and storage medium
By processing the grayscale image of the colloidal gold test strip, the boundary of the test strip detection area is determined and cut. The color line is identified by curve recognition, which solves the problem of low efficiency of manual recognition and achieves efficient and accurate color line recognition.
Patent Information
- Application Number
- CN202110432582.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-21
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2041-04-21
AI Technical Summary
In existing technologies, the efficiency of manually identifying the color lines of colloidal gold test strips is low.
By using grayscale images of colloidal gold test strips, the left and right boundaries of the test strip detection area are determined and cut. Color lines are identified using first and second curves, including determining the upper and lower boundaries, seed point region growth, and binarization processing, thereby improving the accuracy of boundary and color line identification.
It improves the efficiency and accuracy of color line recognition, reduces misjudgments caused by visual fatigue, and enhances the robustness of the recognition method.
Smart Images

Figure CN115311466B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of image processing, and in particular to an image recognition method, an electronic device and a storage medium. BACKGROUND
[0002] Since the colloidal gold immunochromatography technology has the advantages of rapidness, sensitivity and convenience, the colloidal gold test paper prepared based on the colloidal gold immunochromatography technology is widely used in immune detection, and the color line display result obtained by the reaction between the colloidal gold test paper and the sample to be measured is an important basis for judging whether the sample to be measured carries the corresponding virus, but in the related art, the color line display result of the colloidal gold test paper needs to be recognized manually, which is low in efficiency. SUMMARY
[0003] Therefore, the embodiments of the present application provide an image recognition method, an electronic device and a storage medium to solve the technical problem of low efficiency in manually recognizing the color line display result of the colloidal gold test paper in the related art.
[0004] To achieve the above object, the technical scheme of the present application is as follows:
[0005] The embodiments of the present application provide an image recognition method, comprising:
[0006] Based on a first curve of a first gray scale image corresponding to a colloidal gold test paper image, the left and right boundaries of a test paper detection area in the first gray scale image are determined; the left and right boundaries are parallel to the color line direction in the test paper detection area;
[0007] The first gray scale image is cut along the left and right boundaries of the test paper detection area to obtain a second gray scale image;
[0008] Based on a second curve of the second gray scale image, the color line displayed in the test paper detection area is determined; wherein,
[0009] The first curve represents the total gray scale value corresponding to each row of pixel points in the first gray scale image; and the second curve represents the total gray scale value corresponding to each column of pixel points in the second gray scale image.
[0010] In the above scheme, the determination of the left and right boundaries of the test paper detection area in the first gray scale image comprises:
[0011] Based on the first curve, the upper and lower boundaries of the test paper detection area in the first gray scale image are determined;
[0012] Based on the upper and lower boundaries of the test paper detection area, a seed point is determined outside the test paper detection area in the first gray scale image;
[0013] Determine the left and right boundaries of the test paper detection area based on the connected domain and the non-connected domain obtained by region growing on the determined seed points; wherein the left and right boundaries of the test paper detection area are perpendicular to the upper and lower boundaries of the test paper detection area.
[0014] In the above scheme, the upper and lower boundaries of the test paper detection area in the first grayscale image are determined based on the first curve, comprising:
[0015] Determine the upper and lower boundaries of the test paper detection area in the first grayscale image based on the row coordinates corresponding to the peak values of the first curve.
[0016] In the above scheme, the method further comprises:
[0017] In the case where the number of peaks included in the first curve is less than 2, output a prompt information; the prompt information represents that the test paper detection area does not exist in the first grayscale image.
[0018] In the above scheme, the color line displayed in the test paper detection area is determined based on the second curve, comprising:
[0019] Determine the color line displayed in the test paper detection area based on the column coordinates corresponding to the peak values in the second curve.
[0020] In the above scheme, the method further comprises:
[0021] The peak value in the first curve or the second curve is determined by the following method:
[0022] Determine the local maximum value in the curve;
[0023] Determine the mean value of the absolute gray difference between the local maximum value and the M adjacent curve values on the left and right; the M represents a set positive integer;
[0024] In the case where the determined mean value is greater than a set threshold value, the corresponding local maximum value is determined as the peak value in the curve.
[0025] In the above scheme, the left and right boundaries of the test paper detection area are determined based on the connected domain and the non-connected domain obtained by region growing on the determined seed points, comprising:
[0026] The determined connected domain and non-connected domain are binarized to obtain a mask image;
[0027] The mask image and the first grayscale image are processed by bitwise AND to obtain a foreground image of the mask image;
[0028] Determine the left and right boundaries of the test paper detection area in the first grayscale image based on the foreground image.
[0029] This invention also provides an electronic device, comprising:
[0030] The first determining unit is used to determine the left and right boundaries of the test strip detection area in the first grayscale image based on the first curve of the first grayscale image corresponding to the colloidal gold test strip image; the left and right boundaries are parallel to the direction of the color lines in the test strip detection area.
[0031] An image cutting unit is used to cut the first grayscale image along the left and right boundaries of the test strip detection area to obtain a second grayscale image;
[0032] The second determining unit is used to determine the color line displayed in the detection area of the test strip based on the second curve of the second grayscale image; wherein,
[0033] The first curve represents the total gray value corresponding to each row of pixels in the first grayscale image; the second curve represents the total gray value corresponding to each column of pixels in the second grayscale image.
[0034] This invention also provides an electronic device including: a processor and a memory for storing a computer program capable of running on the processor.
[0035] When the processor runs the computer program, it executes the steps of the image recognition method described above.
[0036] This invention also provides a storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the above-described image recognition method.
[0037] In this embodiment of the invention, the left and right boundaries of the test strip detection area in the first grayscale image are determined based on the first curve of the first grayscale image corresponding to the colloidal gold test strip image. The first grayscale image is then cut along the left and right boundaries of the test strip detection area to obtain a second grayscale image. Based on the second curve of the second grayscale image, the color line displayed in the test strip detection area is determined. In this solution, even if the boundary of the test strip detection area is not parallel to the boundary of the colloidal gold test strip image, the left and right boundaries of the test strip detection area can be accurately determined based on the first curve. Cutting the first grayscale image along the left and right boundaries of the test strip detection area can avoid misjudging the left and right boundaries of the test strip detection area as the color line displayed in the test strip detection area. Even if the color line displayed in the test strip detection area is not obvious, the color line displayed in the test strip detection area can be determined based on the second curve. This solution has strong robustness. Furthermore, compared with manual identification of the color line displayed in the test strip detection area, this solution can avoid misjudgment due to visual fatigue, and can improve the efficiency and accuracy of color line recognition. Attached Figure Description
[0038] Figure 1 This is a schematic diagram illustrating the implementation process of the image recognition method provided in an embodiment of the present invention;
[0039] Figure 2 This is a schematic diagram of a colloidal gold test strip provided in an embodiment of the present invention;
[0040] Figure 3 This is a schematic diagram of the first grayscale image corresponding to the colloidal gold test strip image provided in an embodiment of the present invention;
[0041] Figure 4 A schematic diagram of the first curve before and after filtering provided in an embodiment of the present invention;
[0042] Figure 5 This is a schematic diagram illustrating the implementation process of determining the left and right boundaries of the test strip detection area in the image recognition method provided in this embodiment of the invention;
[0043] Figure 6 This is a schematic diagram illustrating the refinement process for determining the left and right boundaries of the test strip detection area in the image recognition method provided in this embodiment of the invention;
[0044] Figure 7 A schematic diagram of a mask image provided in an embodiment of the present invention;
[0045] Figure 8 This is a schematic diagram of the second grayscale image corresponding to the colloidal gold test strip image provided in an embodiment of the present invention;
[0046] Figure 9 A schematic diagram of the second curve before and after filtering provided in an embodiment of the present invention;
[0047] Figure 10 A schematic diagram illustrating the implementation flow of the image recognition method provided in an application embodiment of the present invention;
[0048] Figure 11 A schematic diagram of the server architecture provided for an embodiment of the present invention;
[0049] Figure 12 A schematic diagram of the test data provided in the embodiments of the present invention;
[0050] Figure 13 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention;
[0051] Figure 14 This is a schematic diagram of the structure of an electronic device provided in another embodiment of the present invention. Detailed Implementation
[0052] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0053] Figure 1This is a schematic diagram illustrating the implementation flow of the image recognition method provided in an embodiment of the present invention, wherein the execution subject of the flow is an electronic device such as a terminal or server. Figure 1 As shown, image recognition methods include:
[0054] Step 101: Based on the first curve of the first grayscale image corresponding to the colloidal gold test strip image, determine the left and right boundaries of the test strip detection area in the first grayscale image; wherein, the left and right boundaries are parallel to the direction of the color lines in the test strip detection area; the first curve represents the total grayscale value corresponding to each row of pixels in the first grayscale image.
[0055] Here, users use mobile devices or other terminal devices to photograph the collected colloidal gold test strips, obtaining an image of the colloidal gold test strip. The collected colloidal gold test strip refers to the colloidal gold test strip that reacts with the sample being tested; colloidal gold test strips generally refer to test strips, test cards, or reagent kits made using colloidal gold immunochromatography technology; a colloidal gold test strip includes a detection area, where the sample reacts. The image of the colloidal gold test strip includes an image of the detection area. In practical applications, users use terminal devices to photograph the detection area of the colloidal gold test strip to obtain an image of the colloidal gold test strip.
[0056] Users upload the captured images of the colloidal gold test strips and the corresponding identity information of the tested samples to the server via their terminal devices.
[0057] In practical applications, users can log in to a designated testing system, such as a pneumonia testing system, via a terminal device. On the system's settings page, users fill in the identity information corresponding to the sample being tested and trigger the terminal device's camera to take a picture of the colloidal gold test strip. The terminal device loads the captured image of the colloidal gold test strip onto the system's settings page. Upon receiving confirmation from the user, the terminal device associates the colloidal gold test strip image with the corresponding sample's identity information and uploads it to the server. The server then associates and stores the received colloidal gold test strip image and sample identity information in a designated database, which can be a local database or a cloud database.
[0058] It should be noted that before uploading the colloidal gold test strip image, the terminal device also checks the image quality. If the image quality meets the set conditions, the colloidal gold test strip image and the corresponding identity information of the tested sample are associated and uploaded to the server. If the image quality does not meet the set conditions, a prompt message is output to remind the user to retake the image. This ensures the image quality of the colloidal gold test strip image uploaded to the server, avoiding the inability to successfully identify the color line displayed in the colloidal gold test strip image due to poor image quality. The image quality evaluation indicators include image sharpness.
[0059] The electronic device retrieves colloidal gold test strip images from a pre-defined database and preprocesses the retrieved images. The preprocessing includes: converting the colloidal gold test strip image to a grayscale image; inverting the grayscale image to obtain a post-inverted grayscale image; and enhancing the edges of the post-inverted grayscale image to obtain a first grayscale image. In the application scenario of using colloidal gold test strips to detect the novel coronavirus, the electronic device performs the following steps: Figure 2 The first grayscale image obtained after preprocessing the colloidal gold test paper image shown is as follows: Figure 3 As shown. It should be noted that in some embodiments, during the preprocessing of the colloidal gold test strip image, the grayscale image corresponding to the colloidal gold test strip image may not be inverted.
[0060] The preprocessing procedure for colloidal gold test strip images is as follows:
[0061] Electronic devices use the following formula to convert colloidal gold test strip images into grayscale images:
[0062] Gray = R×0.299 + G×0.587 + B×0.114
[0063] Here, Gray represents the grayscale value of a pixel in the colloidal gold test strip image, R represents the brightness value of the red channel of the pixel, G represents the brightness value of the green channel of the pixel, and B represents the brightness value of the blue channel of the pixel.
[0064] It should be noted that the weight values for the R, G, and B channels are not limited to 0.299, 0.587, and 0.114, and can be set according to actual needs. The value range of the R, G, and B channels is [0, 255]. Since the grayscale value of each pixel is the result of a weighted sum of the brightness values of the corresponding R, G, and B channels, the grayscale value of each pixel also ranges from [0, 255]; 0 represents complete black, and 255 represents complete white.
[0065] Considering that the background color of colloidal gold test strips is usually white, and the color line displayed when the sample reacts with the substance in the detection area of the test strip is usually red or dark red, in practical applications, the color line displayed in the detection area of the test strip may be unclear. In order to accurately identify the color line displayed in the detection area of the test strip, after converting the colloidal gold test strip image to a grayscale image, the grayscale image is inverted based on the formula Gray′=255-Gray, resulting in an inverted grayscale image. In the inverted grayscale image, the background color (or the color of the background image) is black, and the boundary of the test strip detection area and the color line in the test strip detection area are both white.
[0066] To accurately identify the boundaries and colored lines of the test strip detection area in a grayscale image, edge enhancement processing can be performed on the inverted grayscale image to enhance these boundaries and lines. Since the boundaries and colored lines of the test strip detection area differ significantly from adjacent areas in the grayscale image, they represent high-frequency information. In practical applications, a Fast Fourier Transform (FFT) is performed on the inverted grayscale image to remove low-frequency information within a set frequency range, retaining the high-frequency information. An Inverse Fast Fourier Transform (IFFT) is then performed on the FFT-processed grayscale image to obtain the IFFT-processed grayscale image. Finally, image fusion processing is performed between the IFFT-processed and inverted grayscale images to obtain the first grayscale image. The grayscale value of each pixel in the first grayscale image can be the average grayscale value of the corresponding group of pixels.
[0067] When the electronic device determines the first grayscale image corresponding to the colloidal gold test strip image, it sums the grayscale values of the pixels in the first grayscale image row by row to obtain the total grayscale value of each row of pixels in the first grayscale image. Based on the total grayscale value of each row of pixels, it determines the first curve of the first grayscale image; the first curve represents the total grayscale value corresponding to each row of pixels in the first grayscale image.
[0068] Considering that the total grayscale value corresponding to each row of pixels in the first grayscale image may be discontinuous, potentially leading to abrupt changes in grayscale values at local locations, the electronic device filters the first curve to more accurately identify the upper and lower boundaries of the test strip detection area in the first grayscale image, resulting in a filtered first curve. In practical applications, mean filtering can be applied to the first curve to obtain a smoother curve. The first curves before and after filtering are shown below. Figure 4 As shown, Figure 4 The curve on the left is Figure 3 The first curve corresponding to the first grayscale image on the left side of the image.Figure 4 The curve on the right side is Figure 3 The first curve corresponding to the first grayscale image on the right side of the image. (From...) Figure 4 It can be seen that the first curve after filtering is smoother than the first curve before filtering, and the first curve before filtering is discontinuous, while the first curve after filtering is continuous.
[0069] like Figure 3 As shown, since the pixels outside the test strip detection area in the first grayscale image are darker, while the boundaries and lines within the test strip detection area are brighter, and the darker the pixel, the smaller its corresponding grayscale value, the distribution characteristics of grayscale values in the first grayscale image can be determined as follows: the total grayscale value corresponding to the upper and lower boundaries of the test strip detection area in the first grayscale image is the largest, and the total grayscale value of the area outside the first region in the first grayscale image is the smallest. The first region refers to the area between the upper and lower boundaries of the test strip detection area. Based on the filtered first curve and the distribution characteristics of grayscale values in the first grayscale image, the electronic device determines the upper and lower boundaries of the test strip detection area from the first grayscale image.
[0070] Considering that users may make slight movements during the photo-taking process, potentially causing the colloidal gold test strip image to include the entire test strip detection area, to avoid misidentifying the left or right boundary of the test strip detection area as a C-line, M-line, or G-line, the electronic device determines the left and right boundaries of the test strip detection area in the first grayscale image based on the upper and lower boundaries of the test strip detection area and a region growing algorithm. This eliminates the influence of the left and right boundaries of the test strip detection area on the color line recognition results. The seed points used for region growing are located outside the test strip detection area in the first grayscale image.
[0071] Please refer to Figure 5 In some embodiments, determining the left and right boundaries of the test strip detection area in the first grayscale image includes:
[0072] Step 501: Based on the first curve, determine the upper and lower boundaries of the test strip detection area in the first grayscale image;
[0073] Step 502: Based on the upper and lower boundaries of the test strip detection area, determine seed points outside the test strip detection area in the first grayscale image;
[0074] Step 503: Based on the connected and disconnected regions obtained by region growing the determined seed points, determine the left and right boundaries of the test strip detection area; wherein the left and right boundaries of the test strip detection area are perpendicular to the upper and lower boundaries of the test strip detection area.
[0075] Here, since the total gray values corresponding to the upper and lower boundaries of the test strip detection area in the first grayscale image are the largest, the electronic device can analyze the change trend of the curve values in the first curve, and based on the change trend of the curve values in the first curve, determine the upper and lower boundaries of the test strip detection area in the first grayscale image; based on the upper and lower boundaries of the test strip detection area, determine seed points outside the test strip detection area in the first grayscale image.
[0076] In practical applications, in order to reduce the amount of data processing during the region growing process, when the upper and lower boundaries of the test strip detection area are determined, the first grayscale image is cut based on the upper and lower boundaries of the test strip detection area and a set distance, and the cut first grayscale image is obtained; where, when the upper and lower boundaries of the test strip detection area are h1 and h2 respectively, and h1 < h2, the upper and lower boundaries of the cut first grayscale image are h1' and h2' respectively, h1' = h1 - h, h2' = h2 + h, and h represents the set height.
[0077] The electronic device respectively determines n seed points in the areas at a height of the set distance from the upper and lower boundaries of the cut first grayscale image, and all n seed points are outside the test strip detection area. For example, in a coordinate system established with the upper left corner as the coordinate origin, the width as the x-axis, and the height as the y-axis, the electronic device takes 2n seed points in the range of height [h2 - h1 + 2h - s, h2 - h1 + 2h], (s <= h).
[0078] The electronic device performs region growing on the determined seed points based on the set growing criterion, and obtains the connected region and non-connected region corresponding to the seed points. Among them, the set growing criterion means that region growing is performed when the absolute value of the gray difference between adjacent pixel points is less than or equal to the first set threshold; the implementation process of region growing is as follows:
[0079] 1) Sequentially enter the pixel coordinates of the 2n seed points into the queue;
[0080] 2) Remove the first seed point from the queue, and the pixel coordinates of the first seed point are (x1, y1);
[0081] 3) Centered on (x1, y1), consider the 8 neighboring pixels of (x1, y1) in sequence: (x1-1, y1), (x1-1, y1-1), (x1-1, y1+1), (x1, y1-1), (x1, y1+1), (x1+1, y1), (x1+1, y1-1), (x1+1, y1+1). If a pixel is not classified and meets the set growth criteria, merge it with (x1, y1) into the same category and add it to the queue. Pixels that meet the growth criteria are classified as background pixels, and pixels that do not meet the growth criteria are classified as foreground pixels. Pixels of the same category are in the same area.
[0082] Repeat steps 2) and 3) until every pixel in the first grayscale image after cropping is classified (determined to be a foreground or background pixel). At this point, region growing ends, yielding the corresponding connected and disconnected regions. The connected region corresponding to the seed point is composed of background pixels, representing the outer region of the test strip detection area; the disconnected region corresponding to the seed point is composed of foreground pixels, representing the test strip detection area. In other words, the absolute value of the grayscale difference between a pixel in the connected region corresponding to the seed point and the seed point is less than or equal to a first set threshold. The absolute value of the grayscale difference between a pixel in the disconnected region corresponding to the seed point and the seed point is greater than the first set threshold, and the pixel is not adjacent to the seed point.
[0083] It should be noted that, after determining the connected and disconnected components, the first total number of pixels in the disconnected component and the second total number of pixels in the segmented first grayscale image are calculated. If the quotient of the first total and the second total is less than a set value, it indicates that the test strip detection area is too small and the region has grown into the test strip detection area. In this case, the first set threshold is too large, and the determined connected and disconnected components are invalid. The electronic device lowers the first set threshold and repeats the region growth process according to the above steps. If the quotient of the first total and the second total is greater than or equal to the set value, it indicates that the region did not grow into the test strip detection area during the region growth process, and the determined connected and disconnected components are valid.
[0084] Of course, electronic devices can also determine whether connected and disconnected components are valid in other ways:
[0085] Given the non-connected region corresponding to the seed point, calculate the third total number of pixels in the non-connected region. If the third total number is greater than a second preset threshold, determine if the quotient of the third total number and the fourth total number is greater than the third preset threshold. The fourth total number represents the total number of pixels in the bounding rectangle of the non-connected region. In practical applications, the second preset threshold is 7 × 10⁻⁶. 3 The third threshold is set at 0.8.
[0086] If the quotient of the third total and the fourth total is greater than the third set threshold, the determined connected and disconnected components are valid; if the third total is less than or equal to the second set threshold, or if the quotient of the third total and the fourth total is less than or equal to the third set threshold, the determined connected and disconnected components are invalid, and the electronic device lowers the first set threshold.
[0087] When the connected and disconnected regions corresponding to the seed point are determined, the electronic device can determine the boundary of the test strip detection area based on the connected and disconnected regions corresponding to the seed point. Since the connected region is composed of background pixels and represents the outer area of the test strip detection area, and the disconnected region is composed of foreground pixels and represents the test strip detection area, the electronic device can determine the boundary of the test strip detection area based on the connected and disconnected regions corresponding to the seed point. From the determined boundary of the test strip detection area, the upper and lower boundaries of the test strip detection area are excluded to obtain the left and right boundaries of the test strip detection area.
[0088] In some embodiments, in step 501, determining the upper and lower boundaries of the test strip detection area in the first grayscale image based on the first curve includes:
[0089] Based on the row coordinates corresponding to the peak value of the first curve, the upper and lower boundaries of the test strip detection area are determined in the first grayscale image.
[0090] Here, the electronic device determines the peaks included in the first curve based on the changing trend of the curve values, and obtains the corresponding peak values; in practical applications, the first curve includes two peaks. When the number of peaks included in the first curve is equal to two, the row coordinates of at least one row of pixels corresponding to the peak value of the first curve are determined based on the correspondence between each row of pixels represented by the first curve and the total grayscale value. For example, in Figure 4 In the left image, the peak values of the first curve after filtering correspond to approximately 70 and 210 row coordinates, respectively; in the right image, the peak values of the first curve after filtering correspond to approximately 160 and 300 row coordinates, respectively.
[0091] Since the total gray value corresponding to the upper and lower boundaries of the test strip detection area is higher than the gray value of other areas in the first grayscale image except for the upper and lower boundaries of the test strip detection area, the row coordinates corresponding to the peak value of the first curve represent the position of the upper and lower boundaries of the test strip detection area. The electronic device can determine the upper and lower boundaries of the test strip detection area based on the row coordinates corresponding to the peak value of the first curve.
[0092] In some embodiments, the method further includes:
[0093] If the number of peaks in the first curve is determined to be less than 2, a prompt message is output; the prompt message indicates that the test strip detection area does not exist in the first grayscale image.
[0094] Here, the electronic device determines whether the first curve includes peaks based on the changing trend of the curve values. If the number of peaks is less than 2, it indicates that there is no test strip detection area in the first grayscale image. At this time, image recognition ends and a prompt message is output. Specifically, if the first curve does not include peaks, it indicates that there are no upper and lower boundaries of the test strip detection area in the first grayscale image; if the number of peaks in the first curve is equal to 1, it indicates that the first grayscale image only includes the upper or lower boundary of the test strip detection area.
[0095] In practical applications, the output prompt information may include the identity information corresponding to the first grayscale image, so that the user can find the corresponding colloidal gold test strip based on the identity information, take a new photo of the found colloidal gold test strip, and upload the new colloidal gold test strip image.
[0096] In some embodiments, the peak value in the first curve is determined by the following method:
[0097] Identify the local maxima in the curve;
[0098] The mean of the absolute grayscale differences between the local maxima and the M adjacent curve values is determined; M represents a set positive integer.
[0099] If the determined mean is greater than the set threshold, the corresponding local maximum value is determined as the peak value in the curve.
[0100] Here, the electronic device determines local maxima in the first curve based on the changing trend of the curve values. It then identifies M curve values adjacent to the local maximum on either side of the first curve and calculates the average of the absolute grayscale values between the local maximum and these M adjacent values. If the determined average is greater than a fourth preset threshold, the local maximum is considered to be the total grayscale value corresponding to the upper or lower boundary of the test strip detection area, and this local maximum is defined as a peak value in the curve. If the determined average is less than or equal to the fourth preset threshold, the local maximum is not considered to be the total grayscale value corresponding to the upper or lower boundary of the test strip detection area. Furthermore, if at least two identical and adjacent peak values are identified, these peak values are considered to belong to the same peak, meaning the peak includes at least two identical peak values. The peak values corresponding to different peaks in the first curve can be the same or different.
[0101] In practical applications, when determining M curve values adjacent to the local maximum from the first curve, M curve values can be determined to the left of the local maximum and M curve values can be determined to the right of the local maximum; the M curve values can be continuous or discontinuous.
[0102] Please refer toFigure 6 To more accurately identify the left and right boundaries of the test strip detection area, in some embodiments, in step 503, determining the left and right boundaries of the test strip detection area based on the connected and disconnected regions obtained by region growing the determined seed points includes:
[0103] Step 601: Binarize the identified connected and disconnected components to obtain the mask image;
[0104] Step 602: Perform a bitwise AND operation on the mask image and the first grayscale image to obtain the foreground image of the mask image;
[0105] Step 603: Based on the foreground image, determine the left and right boundaries of the test strip detection area in the first grayscale image.
[0106] In practical applications, since the background pixels in the first grayscale image are black and their corresponding grayscale values are 0, and the determined connected components are composed of background pixels, when binarizing the connected and non-connected components, the grayscale values of the pixels included in the connected components are set to 0, and the grayscale values of the pixels included in the non-connected components are set to 1. Figure 7 In the mask image shown, the white area represents the test strip detection area; the mask image on the left is... Figure 3 The mask image corresponding to the first grayscale image on the left, and the mask image on the right is... Figure 3 The mask image corresponding to the first grayscale image on the right side of the image.
[0107] When the electronic device obtains the mask image, it performs a bitwise AND operation on the mask image and the first grayscale image, pixel by pixel, to obtain the foreground image of the mask image, that is, the foreground image of the white area in the mask image. This foreground image corresponds to the grayscale image of the test strip detection area.
[0108] Since the foreground image of the mask is a grayscale image of the test strip detection area, the left and right boundaries of the foreground image of the mask are the left and right boundaries of the test strip detection area. The electronic device can locate the test strip detection area in the first grayscale image based on the foreground image of the mask and the upper and lower boundaries of the test strip detection area in the first grayscale image. The left and right boundaries of the test strip detection area in the first grayscale image are determined based on the left and right boundaries of the foreground image. For example, based on the upper and lower boundaries of the test strip detection area in the first grayscale image, the foreground image of the mask is overlaid on the first grayscale image to locate the test strip detection area in the first grayscale image; the left and right boundaries of the test strip detection area in the first grayscale image are determined based on the position of the left and right boundaries of the foreground image in the first grayscale image.
[0109] Step 102: Cut the first grayscale image along the left and right boundaries of the test strip detection area to obtain the second grayscale image.
[0110] Here, the second grayscale image does not include the left and right boundaries of the test strip detection area.
[0111] In practical applications, after the electronic device cuts the first grayscale image along the left and right boundaries of the test strip detection area, it can further cut off the width of each side by k pixels to obtain the second grayscale image. This completely removes the left and right boundaries of the test strip detection area, preventing incompletely removed boundaries from being identified as colored lines displayed in the test strip detection area. Here, k is greater than or equal to the number of pixels occupied by the left and right boundaries of the test strip detection area in the horizontal direction.
[0112] In practical applications, the electronic device can also cut the first grayscale image along at least one of the upper and lower boundaries of the test strip detection area. For example... Figure 8 As shown, the second grayscale image on the left does not include the lower boundary of the test strip detection area, and the second grayscale image on the right does not include the upper and lower boundaries of the test strip detection area. Figure 8 The second grayscale image on the left is composed of Figure 3 The first grayscale image on the left side of the image is obtained by cutting it out. Figure 8 The second grayscale image on the right is composed of Figure 3 The first grayscale image on the right side of the image is obtained by cutting it out.
[0113] Step 103: Based on the second curve of the second grayscale image, determine the color line displayed in the test strip detection area; wherein, the second curve represents the total grayscale value corresponding to each column of pixels in the second grayscale image.
[0114] Here, the electronic device determines the total grayscale value corresponding to each column of pixels in the second grayscale image, and determines the second curve based on the total grayscale value corresponding to each column of pixels.
[0115] Considering that the total grayscale value corresponding to each column of pixels in the second grayscale image may be discontinuous, potentially leading to abrupt changes in grayscale values at local locations, the electronic device filters the second curve to more accurately identify the color line displayed in the test strip detection area, resulting in a filtered second curve. In practical applications, mean filtering can be applied to the second curve to obtain a smoother curve.
[0116] The second curve before and after filtering is as follows Figure 9 As shown, Figure 9 The curve on the left is Figure 8 The second curve corresponding to the second grayscale image on the left side of the image. Figure 9 The curve on the right side is Figure 8 The second curve corresponding to the second grayscale image on the right side of the image. (From...) Figure 9 It can be seen that the second curve after filtering is smoother than the second curve before filtering, and the second curve before filtering is discontinuous, while the second curve after filtering is continuous.
[0117] Since the total gray value of the column pixels where the colored line is located in the second grayscale image is higher than the total gray value of other areas, the electronic device can determine the colored line displayed in the test strip detection area based on the column coordinates corresponding to the determined peak value and the correspondence between the column coordinates and the colored line name, after determining the peak value in the second curve.
[0118] The method for determining the peak value in the second curve is similar to the method for determining the peak value in the first curve. Please refer to the relevant description above for the implementation process, which will not be repeated here.
[0119] To more accurately determine the color line displayed in the test strip detection area, in some embodiments, determining the color line displayed in the test strip detection area based on the second curve includes:
[0120] Based on the set interval of the column coordinate corresponding to the peak value in the second curve, the color line displayed in the test strip detection area is determined.
[0121] Here, the electronic device stores a predefined correspondence between column coordinate ranges and color line names. After determining the column coordinate corresponding to the peak value in the second curve, the electronic device determines the predefined range within which the column coordinate corresponding to the peak value lies. Based on the predefined correspondence between the predefined range and the color line names, it determines the color line displayed in the test strip detection area, thus obtaining the color line recognition result corresponding to the colloidal gold test strip image. It should be noted that, after determining the color line recognition result corresponding to the colloidal gold test strip image, the electronic device can also associate and store the color line recognition result with the identity information corresponding to the colloidal gold test strip image, or output the color line recognition result and the identity information corresponding to the colloidal gold test strip image.
[0122] In practical applications, when using colloidal gold test strips to detect the novel coronavirus, with the left endpoint of the left boundary of the test strip's detection area as the origin, the column coordinate of line C displayed in the test strip's detection area is less than 200, the column coordinate range of line G is set to [250, 350], and the column coordinate of line M is greater than 450. Here, column coordinates refer to the column coordinates within the test strip's detection area. Electronic devices are based on... Figure 9 The second curve on the left side of the middle section confirms that the test strip's detection area displays only line C, indicating that the corresponding sample does not carry the novel coronavirus; based on Figure 9 The second curve on the right side of the middle section identifies the colored lines displayed in the test strip's detection area, including the C, G, and M lines, which represent the corresponding tested samples carrying the novel coronavirus.
[0123] It should be noted that in some embodiments, during the preprocessing of the colloidal gold test strip image, when the grayscale image corresponding to the colloidal gold test strip image is not inverted, since the background pixel color of the preprocessed first grayscale image is white, the electronic device determines the upper and lower boundaries of the test strip detection area in the first grayscale image based on the row coordinates corresponding to the trough values of the first curve. When binarizing the determined connected and disconnected components, the grayscale values of pixels included in the connected components are set to 0, and the grayscale values of pixels included in the disconnected components are set to 1. When determining the color line displayed in the test strip detection area, the color line displayed in the test strip detection area is determined based on the set interval where the column coordinates corresponding to the trough values in the second curve are located. The method for determining the trough values is similar to the method for determining the peak values, and will not be elaborated here. In practical applications, the first curve includes two troughs. When the number of troughs in the first curve is less than two, a prompt message indicating that there is no test strip detection area in the first grayscale image is output.
[0124] In the solution provided by this embodiment of the invention, even if the boundary of the test strip detection area is not parallel to the boundary of the colloidal gold test strip image, the left and right boundaries of the test strip detection area in the first grayscale image can be accurately determined based on the first curve of the first grayscale image corresponding to the colloidal gold test strip image. By cutting the first grayscale image along the left and right boundaries of the test strip detection area to obtain the second grayscale image, the left and right boundaries of the test strip detection area can be avoided from being misjudged as the color lines displayed in the test strip detection area. Even if the color lines displayed in the test strip detection area are not obvious, the color lines displayed in the test strip detection area can be determined based on the second curve of the second grayscale image. Therefore, the image recognition method provided by this solution has strong robustness. Compared with manual recognition of the color lines displayed in the test strip detection area, this solution can avoid misjudgment caused by visual fatigue and can improve the efficiency and accuracy of color line recognition results.
[0125] Figure 10 This is a schematic diagram illustrating the implementation flow of the image recognition method provided in an application embodiment of the present invention. The execution entity of this flow is the server, such as... Figure 11 As shown, in practical applications, the server comprises a gateway layer, a business layer, and a storage layer. The gateway layer primarily provides functions such as interface access, interface authentication, interface signature verification, and access rate limiting. The business layer is responsible for implementing specific business logic, including storing and processing data uploaded by terminal devices, such as recognizing the color lines displayed in the colloidal gold test strip images uploaded by terminal devices and providing feedback on the recognition results. The storage layer consists of a database and a file storage server. The database stores the identity information of the tested samples and the corresponding test results, while the file storage server stores the colloidal gold test strip images.
[0126] like Figure 10 As shown, image recognition methods include:
[0127] Step 701: Convert the colloidal gold test strip image into a grayscale image.
[0128] Step 702: Invert the colors of the converted grayscale image to obtain the first grayscale image corresponding to the colloidal gold test paper image.
[0129] Step 703: Determine the first curve of the first grayscale image.
[0130] Step 704: Determine whether the number of peaks of the first curve is equal to 2, and obtain the first judgment result.
[0131] Step 705: If the number of peaks representing the first curve in the first judgment result is less than 2, return category 0.
[0132] Specifically, if the number of peaks in the first curve is less than 2, the image representing the test strip detection area does not meet the set quality control requirements, and a reliable identification result cannot be obtained based on the image of the test strip detection area. The image of the test strip detection area not meeting the set quality control requirements includes the absence of the test strip detection area in the first grayscale image, or the test strip detection area in the first grayscale image lacking an upper or lower boundary.
[0133] Returning category 0 means that the image recognition result is category 0, which indicates that the image recognition failed.
[0134] In practical applications, the server can also output a prompt message indicating that the image of the test strip detection area does not meet the quality control requirements.
[0135] Step 706: If the number of peaks of the first curve representing the first judgment result is equal to 2, determine the upper and lower boundaries of the test strip detection area in the first grayscale image based on the row coordinates corresponding to the peak values of the first curve.
[0136] Step 707: Cut the first grayscale image along the upper and lower boundaries of the test strip detection area to obtain the cut first grayscale image.
[0137] The first grayscale image after cutting includes the upper and lower boundaries of the test strip detection area, and the distance between the upper and lower boundaries of the first grayscale image after cutting and the upper and lower boundaries of the test strip detection area is equal to a set distance.
[0138] Step 708: Based on the upper and lower boundaries of the test strip detection area, determine the seed point outside the test strip detection area in the first grayscale image after cutting.
[0139] Step 709: Perform region growing on the determined seed point to obtain the connected and non-connected regions corresponding to the seed point.
[0140] Step 710: Determine whether the total number of pixels in the non-connected domains is greater than the set total number, and obtain the second determination result.
[0141] Here, the total number of pixels in the non-connected region refers to the total number of pixels contained within the non-connected region. Since the non-connected region corresponding to the seed point represents the test strip detection area, this actually determines whether the total number of pixels in the test strip detection area is greater than the set total number. In practical applications, the set total number can be 7 × 10^6 pixels. 3 .
[0142] Step 711: If the total number of pixels in the non-connected domains represented by the second judgment result is less than or equal to the set total number, return category 0.
[0143] Here, when the total number of pixels in non-connected regions is less than or equal to the set total number, the area of the test strip detection area is small, and the image of the test strip detection area does not meet the set quality control requirements.
[0144] Step 712: If the second judgment result indicates that the total number of pixels in the non-connected region is greater than the set total number, determine whether the quotient of the total number of pixels in the non-connected region and the total number of pixels in the circumscribed rectangle is greater than the set value, and obtain the third judgment result.
[0145] Here, when the total number of pixels in non-connected regions exceeds a set total, the area of the test strip detection region is considered large. The quality control requirements for the test strip detection region are determined by checking if the calculated quotient exceeds a set value. In practical applications, this set value can be 0.8.
[0146] Step 713: If the quotient determined by the third judgment result is less than or equal to the set value, return category 0.
[0147] Here, if the total number of pixels in the non-connected domains is less than or equal to the set total number, or if the determined quotient is less than or equal to the set value, it indicates that the image of the test strip detection area does not meet the set quality control requirements.
[0148] If the total number of pixels in non-connected regions is greater than the set total number, and the determined quotient is less than or equal to the set value, the image representing the test strip detection area meets the set quality control requirements.
[0149] Step 714: If the quotient determined by the third judgment result is greater than the set value, determine the left and right boundaries of the test strip detection area based on the determined connected and non-connected components. The process of determining the left and right boundaries of the test strip detection area based on the determined connected and non-connected components is described in the relevant text above and will not be repeated here.
[0150] Step 715: Cut the first grayscale image along the left and right boundaries of the test strip detection area to obtain the second grayscale image.
[0151] Step 716: Determine the second curve of the second grayscale image; the second curve represents the total grayscale value corresponding to each column of pixels in the second grayscale image.
[0152] Step 717: Based on the set interval where the column coordinates corresponding to the peak value in the second curve are located, determine the color line displayed in the test strip detection area.
[0153] In practical applications, such as using colloidal gold test strips to detect the novel coronavirus, the following methods are employed: Figure 10 The corresponding embodiment performed image recognition on 496 colloidal gold test strip images, and the test results are as follows: Figure 12 As shown. Among them,
[0154] When the color line recognition results of 496 colloidal gold test strip images were classified into four categories (1 to 4), the accuracy of this scheme was determined to be 0.9318 and the Kappa coefficient was 0.6523, based on the 4-class confusion matrix. The Kappa coefficient is an indicator used for consistency testing and can also be used to measure the effectiveness of classification.
[0155] When classifying the color line recognition results of 496 colloidal gold test strip images into two categories, 1 and 5, the accuracy of this scheme was determined to be 0.9705, the Kappa coefficient to be 0.8432, the sensitivity to be 0.8889, and the specificity to be 0.9797, based on the binary classification confusion matrix. This image recognition method exhibits relatively high performance indicators. Specificity describes the proportion of identified negative examples out of all negative examples; sensitivity describes the proportion of identified positive examples out of all positive examples. Negative examples refer to category 5, and positive examples refer to category 1.
[0156] To implement the methods of the embodiments of the present invention, the present invention also provides an electronic device that can correspondingly implement all the above-described embodiments of the image recognition methods. For example... Figure 13 As shown, the electronic device includes:
[0157] The first determining unit 131 is used to determine the left and right boundaries of the test strip detection area in the first grayscale image based on the first curve of the first grayscale image corresponding to the colloidal gold test strip image; the left and right boundaries are parallel to the direction of the color lines in the test strip detection area.
[0158] Image cutting unit 132 is used to cut the first grayscale image along the left and right boundaries of the test strip detection area to obtain a second grayscale image;
[0159] The second determining unit 133 is used to determine the color line displayed in the detection area of the test strip based on the second curve of the second grayscale image; wherein,
[0160] The first curve represents the total gray value corresponding to each row of pixels in the first grayscale image; the second curve represents the total gray value corresponding to each column of pixels in the second grayscale image.
[0161] In some embodiments, the first determining unit 131 is configured to:
[0162] Based on the first curve, the upper and lower boundaries of the test strip detection area in the first grayscale image are determined;
[0163] Based on the upper and lower boundaries of the test strip detection area, seed points are determined outside the test strip detection area in the first grayscale image;
[0164] Based on the connected and disconnected regions obtained by region growing the determined seed points, the left and right boundaries of the test strip detection area are determined; wherein the left and right boundaries of the test strip detection area are perpendicular to the upper and lower boundaries of the test strip detection area.
[0165] In some embodiments, the first determining unit 131 is configured to:
[0166] Binarize the identified connected and disconnected components to obtain the mask image;
[0167] Perform a bitwise AND operation on the mask image and the first grayscale image to obtain the foreground image of the mask image;
[0168] Based on the foreground image, the left and right boundaries of the test strip detection area in the first grayscale image are determined.
[0169] In some embodiments, the first determining unit 131 is configured to: determine the upper and lower boundaries of the test strip detection area in the first grayscale image based on the row coordinates corresponding to the peak value of the first curve.
[0170] In some embodiments, the electronic device further includes:
[0171] The prompting unit is used to output a prompting message when it is determined that the number of peaks included in the first curve is less than 2; the prompting message indicates that the test strip detection area does not exist in the first grayscale image.
[0172] In some embodiments, the second determining unit 133 is used to: determine the color line displayed in the test strip detection area based on the set interval where the column coordinate corresponding to the peak value in the second curve is located.
[0173] In some embodiments, the first determining unit 131 and the second determining unit 133 are further configured to determine the peak value in the first curve or the second curve by means of:
[0174] Identify the local maxima in the curve;
[0175] The mean of the absolute grayscale differences between the local maxima and the M adjacent curve values is determined; M represents a set positive integer.
[0176] If the determined mean is greater than the set threshold, the corresponding local maximum value is determined as the peak value in the curve.
[0177] In practical applications, the first determining unit 131, the image cutting unit 132, the second determining unit 133, and the prompting unit can be implemented by a processor in an electronic device, such as a central processing unit (CPU), a digital signal processor (DSP), a microcontroller unit (MCU), or a field-programmable gate array (FPGA). Of course, the processor needs to run programs stored in memory to implement the functions of each of the above program modules.
[0178] It should be noted that the above embodiments of the electronic device are only illustrated by the division of the above-described program modules when performing image recognition. In practical applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the device can be divided into different program modules to complete all or part of the processing described above. In addition, the electronic device and the image recognition method embodiments provided above belong to the same concept, and their specific implementation process can be found in the method embodiments, which will not be repeated here.
[0179] Based on the hardware implementation of the above program modules, and in order to implement the method of the embodiments of the present invention, the embodiments of the present invention also provide an electronic device. Figure 14 This is a schematic diagram of the hardware composition structure of the electronic device according to an embodiment of the present invention, such as... Figure 14 As shown, the electronic device 14 includes:
[0180] The communication interface 141 is capable of exchanging information with other devices, such as network devices;
[0181] The processor 142 is connected to the communication interface 141 to enable information interaction with other devices and to execute the image recognition method provided by one or more of the above-mentioned technical solutions when running a computer program. The computer program is stored in the memory 143.
[0182] Of course, in practical applications, the various components in electronic device 14 are coupled together through bus system 144. It can be understood that bus system 144 is used to realize the connection and communication between these components. In addition to a data bus, bus system 144 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, in... Figure 14 The general labeled all buses as Bus System 144.
[0183] The memory 143 in this embodiment of the invention is used to store various types of data to support the operation of the electronic device 14. Examples of such data include any computer program used to operate on the electronic device 14.
[0184] It is understood that memory 143 can be volatile memory or non-volatile memory, or both. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), ferromagnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM); magnetic surface memory can be disk storage or magnetic tape storage. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), SyncLink Dynamic Random Access Memory (SLDRAM), and Direct Rambus Random Access Memory (DRRAM).The memory 143 described in the embodiments of the present invention is intended to include, but is not limited to, these and any other suitable types of memory.
[0185] The methods disclosed in the above embodiments of the present invention can be applied to or implemented by processor 142. Processor 142 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit of the hardware in processor 142 or by instructions in software form. The processor 142 may be a general-purpose processor, DSP, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Processor 142 can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present invention. The general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the methods disclosed in the embodiments of the present invention can be directly manifested as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor. The software modules may be located in a storage medium, which is located in memory 143. Processor 142 reads the program in memory 143 and completes the steps of the aforementioned method in conjunction with its hardware.
[0186] Optionally, when the processor 142 executes the program, it implements the corresponding processes implemented by the electronic device in the various methods of the embodiments of the present invention. For the sake of brevity, these will not be described in detail here.
[0187] In an exemplary embodiment, the present invention also provides a storage medium, namely a computer storage medium, specifically a computer-readable storage medium, such as a first memory 143 storing a computer program, which can be executed by a processor 142 of an electronic device to complete the steps described in the foregoing method. The computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface memory, optical disc, or CD-ROM.
[0188] In the several embodiments provided by this invention, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.
[0189] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of this embodiment according to actual needs.
[0190] Furthermore, in the various embodiments of the present invention, all functional units can be integrated into one processing module, or each unit can be a separate unit, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in the form of hardware plus software functional units. Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0191] It should be noted that the technical solutions described in the embodiments of the present invention can be combined arbitrarily without conflict.
[0192] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. An image recognition method, characterized in that, include: Based on the first curve of the first grayscale image corresponding to the colloidal gold test strip image, the upper and lower boundaries of the test strip detection area in the first grayscale image are determined. Based on the upper and lower boundaries of the test strip detection area, seed points are determined outside the test strip detection area in the first grayscale image; The connected and disconnected regions obtained by region growing the determined seed points are binarized to obtain the mask image. Perform a bitwise AND operation on the mask image and the first grayscale image to obtain the foreground image of the mask image; Based on the foreground image, the left and right boundaries of the test strip detection area in the first grayscale image are determined; wherein, the left and right boundaries of the test strip detection area are perpendicular to the upper and lower boundaries of the test strip detection area; the left and right boundaries are parallel to the direction of the color lines in the test strip detection area; The first grayscale image is cut along the left and right boundaries of the test strip detection area to obtain the second grayscale image; Based on the second curve of the second grayscale image, the color line displayed in the detection area of the test strip is determined; wherein, The first curve represents the total gray value corresponding to each row of pixels in the first grayscale image; the second curve represents the total gray value corresponding to each column of pixels in the second grayscale image.
2. The method according to claim 1, characterized in that, The step of determining the upper and lower boundaries of the test strip detection area in the first grayscale image based on the first curve includes: Based on the row coordinates corresponding to the peak value of the first curve, the upper and lower boundaries of the test strip detection area are determined in the first grayscale image.
3. The method according to claim 2, characterized in that, The method further includes: If the number of peaks in the first curve is determined to be less than 2, a prompt message is output; the prompt message indicates that the test strip detection area does not exist in the first grayscale image.
4. The method according to claim 1, characterized in that, The step of determining the color line displayed in the detection area of the test strip based on the second curve includes: Based on the set interval of the column coordinate corresponding to the peak value in the second curve, the color line displayed in the test strip detection area is determined.
5. The method according to claim 2 or 4, characterized in that, The method further includes: The peak value in the first curve or the second curve is determined by the following method: Identify the local maxima in the curve; The mean of the absolute grayscale differences between the local maxima and the M adjacent curve values is determined; M represents a set positive integer. If the determined mean is greater than the set threshold, the corresponding local maximum value is determined as the peak value in the curve.
6. An electronic device, characterized in that, include: The first determining unit is used to determine the upper and lower boundaries of the test strip detection area in the first grayscale image based on the first curve of the first grayscale image corresponding to the colloidal gold test strip image. The second determining unit is used to determine seed points outside the test strip detection area in the first grayscale image based on the upper and lower boundaries of the test strip detection area; The first processing unit is used to perform binarization processing on the connected and disconnected regions obtained by region growing the determined seed points to obtain a mask image. The second processing unit is used to perform a bitwise AND operation on the mask image and the first grayscale image to obtain the foreground image of the mask image; The third determining unit is used to determine the left and right boundaries of the test strip detection area in the first grayscale image based on the foreground image; wherein the left and right boundaries of the test strip detection area are perpendicular to the upper and lower boundaries of the test strip detection area; and the left and right boundaries are parallel to the direction of the color lines in the test strip detection area. An image cutting unit is used to cut the first grayscale image along the left and right boundaries of the test strip detection area to obtain a second grayscale image; The fourth determining unit is used to determine the color line displayed in the detection area of the test strip based on the second curve of the second grayscale image; wherein, The first curve represents the total gray value corresponding to each row of pixels in the first grayscale image; the second curve represents the total gray value corresponding to each column of pixels in the second grayscale image.
7. An electronic device, characterized in that, include: The processor and the memory used to store computer programs that can run on the processor. When the processor is used to run the computer program, it performs the steps of the method according to any one of claims 1 to 5.
8. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Image gray-scale processing based data computing method and application thereof in detection field
CN105606608A
Colloidal gold test paper detection method
CN110161234A
Method for detecting concentration of substance to be detected, fluorescence immunoassay analyzer and storage medium
CN111879744A