Image processing method for calculating the width of methylene blue halo
Through image processing method, the width of the color halo ring in methylene blue droplet detection is solved, and the problems of strong subjectivity and large errors of manual judgment are achieved, efficient and accurate automatic identification is achieved, and the operation and maintenance costs are reduced. It is suitable for Multiple environments.
Patent Information
- Application Number
- CN202411216163.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-02
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2044-09-02
AI Technical Summary
In the detection of methylene blue drop liquid, there are problems such as strong subjectivity, low efficiency, large errors, and hardware equipment relying on manual judgments, resulting in large workloads and many errors for operators, especially when the shape of the tint is irregular. It is prone to mis-checking.
Image processing methods are adopted, including collecting methylene blue droplet images, performing drop area enhancement processing, color halo area refinement processing, edge extraction and circle detection, and using ring width estimation calculation method to calculate color halo width, through industrial cameras and circle shapes Light sources are automatically identified and manual intervention is reduced.
It realizes efficient methylene blue halo width calculation without manual participation, reduces operation and maintenance costs, improves identification efficiency and accuracy, reduces calculation amount, enhances the accuracy and stability of chromogenic halo area extraction, and is suitable for Various lighting conditions and background environments.
Smart Images

Figure CN118711182B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of image processing and analysis, and in particular to an image processing method applied to calculating the width of a methylene blue halo ring. Background Art
[0002] Methylene blue drop test is a common experimental method used to evaluate the adsorption performance of materials, surfactant concentration, etc. At present, the common way to determine whether the methylene blue halo is qualified is to rely on manual observation. Manual judgment is very subjective. If the feeding frequency is high, it will increase the workload of the operator. Long-term work will also cause visual fatigue, which will increase the judgment error and reduce efficiency. In addition, there will be operational errors in the process of manual proportioning, which will affect the final result.
[0003] In order to simplify the operation process of methylene blue testers, some manufacturers have designed hardware equipment that automatically prepares methylene blue solution instead of manual operation, which reduces the workload of operators to a certain extent and reduces the operating errors of operators, but the final result is still determined by the testers, and the subjectivity and efficiency of the determination cannot be avoided. The computer vision-based methylene blue value test system and method for machine-made sand disclosed in publication number CN115201188A proposes a method for calculating the width of the methylene blue halo, approximating the color area with the halo and the color area without the halo into a circle, and subtracting the radius of the color area with the halo and the color area without the halo to obtain the color halo width, but this algorithm is not ideal. When the shape of the halo is irregular, this method is prone to false detection. Summary of the invention
[0004] The technical problem to be solved by the present invention is to overcome the deficiencies of the prior art and provide an image processing method for calculating the width of a methylene blue halo.
[0005] The technical solution adopted by the present invention to solve the technical problem is: an image processing method applied to calculate the width of the methylene blue halo ring comprises the following steps:
[0006] Step 1: Collect the image information of methylene blue drops and obtain the image after processing ;
[0007] Step 2: Obtain the droplet area of image I0 and perform enhancement processing to obtain the enhanced image ;
[0008] Step 3: Image Perform fine processing on the color halo area to obtain the color halo target image ;
[0009] Step 4: Image Perform edge extraction and circle detection to obtain an image containing the center of the target area ;
[0010] Step 5: Image Perform color halo ring detection, use the ring width estimation algorithm to calculate the color halo width, and obtain the final color halo width value.
[0011] Said step 1 includes the following sub-steps:
[0012] 1-1: Place the methylene blue drop filter paper between the camera and the light source, and take a picture to obtain an image; the industrial camera used in this application is a color camera with a resolution of not less than 720p, with a lens of 25mm focal length, and a circular light source is located below the camera. When taking pictures, backlighting is used to enhance the color contrast and detail characteristics of the methylene blue drop.
[0013] 1-2: Resize the acquired image to 640*640 pixels. The resized image is recorded as , thus speeding up subsequent processing.
[0014] The step 2 includes the following sub-steps:
[0015] 2-1: Use the image mask to focus on a circular area around the droplet to obtain an image ; In this process, other useless areas are filtered out to speed up subsequent judgment. The specific location needs to be determined according to the actual titration position;
[0016] 2-2: Image Perform pixel judgment on the three RGB channels one by one, set blue as the target area for pixel screening, filter out non-blue pixels, and obtain the image ;
[0017] 2-3: Image The blue channel value is exponentially enhanced, and the red and green channel values are exponentially reduced to further enhance the pixels in the target area to obtain the image .
[0018] The pixel determination process in 2-2 is as follows:
[0019] At coordinates ( ) is recorded as , The color values on the three RGB channels are , , , then when or , the pixel is considered to belong to the target area pixel, where is the color channel ratio value.
[0020] The step three includes the following sub-steps:
[0021] 3-1: Image Perform binarization and morphological opening operations to initially filter the dark blue (non-halo) area in the center of the drop to obtain the image ;
[0022] 3-2: Image Conduct connected domain analysis to obtain each connected component;
[0023] 3-3: If the number of connected components is equal to 1, it is considered that there is no color halo in the current image; otherwise, filter out the image with an aspect ratio less than The connected components of (i.e. filtering out the noise area), is a preset empirical value, and the binary color halo image after noise filtering is obtained. ;
[0024] 3-4: Image Perform mean filtering to further filter out finer noise, smooth the edges, and then perform morphological closing operations to fill the holes to obtain a complete color halo area image. ;
[0025] 3-5: Image and Perform AND operation to obtain the color halo target image .
[0026] The step 4 includes the following sub-steps:
[0027] 4-1: Use Canny operator to image Do edge extraction and get the image ;
[0028] 4-2: Image Use the Hough circle detection algorithm to detect the circular area and get the center of the circle , the image is recorded as .
[0029] The step five includes the following sub-steps:
[0030] 5-1: Rotate the image ;
[0031] 5-2: Obtain the inner point set and the outer point set;
[0032] 5-3: Calculate the width of the color halo ring;
[0033] 5-4: Use the ellipse fitting algorithm to fit the inner and outer ellipses on the inner and outer point sets respectively to obtain an image containing the color halo annular area , repeat 5-1 to 5-3, Rotate the image counterclockwise by angle interval ,get The total internal and external point sets in each direction are calculated based on the total internal and external point sets to obtain the point distance sets in eight directions;
[0034] 5-5: Average the eight-directional point distance sets to obtain the final color halo ring width value.
[0035] In 5-2, As the starting point, The lines are emitted outward at an angle interval of The first point that intersects a non-zero pixel in the direction is , add it to the interior point set , the point where it intersects with a non-zero pixel for the last time is , add it to the external point set , and finally get The inner and outer point sets of the direction are:
[0036] ;
[0037] in, For images The rotation angle of
[0038] ;
[0039] .
[0040] In 5-3, the inner and outer point distances in eight directions are calculated respectively according to the inner and outer point sets. , is the width of the color halo ring in this direction. If , then it is believed that Valid, otherwise filter the value in this direction. They are respectively the minimum and maximum values of the reasonable width of the color halo ring, which can be set by those skilled in the art based on experience.
[0041] In 5-4 ;
[0042] The total internal and external point sets are respectively expressed as: , external point set ;
[0043] Eight-direction point distance set ,in, for In the direction directions;
[0044] Corresponding rotation angle , .
[0045] Compared with the prior art, the present invention has the following beneficial effects:
[0046] The present application adopts a purely visual method and a ring width estimation algorithm to calculate the color halo ring width. The entire process does not require human intervention, the recognition device is simple, and the operation and maintenance costs are low, which improves the recognition efficiency of methylene blue. The detection equipment only needs a camera and a light source, and can identify its color halo area without the help of any other optical instruments or hardware equipment. It has a simple structure, low cost, and is easy to maintain. Compared with the manual observation method, the calculation result will not have cumulative errors, is not affected by human factors, has high accuracy, and the recognition process is automated, without human intervention, and is highly real-time.
[0047] After identification, the methylene blue image is automatically stored and the result value is marked, which can be traced and facilitated for secondary inspection;
[0048] This application performs rough extraction and image enhancement on the image, effectively highlights the target area, and reduces the amount of calculation in subsequent processing; achieves accurate color halo area extraction; uses an image mask to focus on a circular area around the droplet, filters out irrelevant areas, and improves processing efficiency; based on pixel-level color judgment, it can accurately screen out pixel points in the target area, further enhancing the color halo features in the image; through exponential enhancement and reduction of channel values, the visibility of the color halo area is significantly improved, which is conducive to subsequent accurate extraction;
[0049] This application effectively removes the dark blue area in the center of the drop based on the morphological opening operation, which simplifies the subsequent analysis process; eliminates the noise area through connected domain analysis and aspect ratio filtering, and improves the accuracy of color halo detection; mean filtering and smooth edge processing, as well as morphological closing operations, ensure the integrity of the color halo area and the clarity of the boundaries;
[0050] The application of the Canny edge detection algorithm can accurately capture the edge of the color halo, providing a reliable input for subsequent circle detection. The Hough circle detection algorithm can quickly and accurately locate the center of the drop, providing key information for subsequent color halo width measurement.
[0051] By emitting rays in different directions, the pixel points of the inner and outer boundaries of the color halo can be accurately obtained, which provides a basis for the measurement of the color halo width; the application of the ellipse fitting algorithm improves the accuracy of the color halo annular area fitting, making the measurement results more accurate; the method of multi-directional measurement and average value calculation improves the stability and accuracy of the color halo width measurement.
[0052] The entire detection process is highly automated, reducing the need for human intervention and improving detection efficiency and consistency; the method is applicable to a variety of lighting conditions and background environments and has strong adaptability and robustness. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 It is a flow chart of the present invention;
[0054] Figure 2 This is the color halo diagram of methylene blue;
[0055] Figure 3 For images Schematic diagram;
[0056] Figure 4 For images Schematic diagram;
[0057] Figure 5 For images Schematic diagram;
[0058] Figure 6 Schematic diagram of color halo ring detection and ring width estimation. DETAILED DESCRIPTION
[0059] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0060] Reference Figure 1 , the image processing method applied to calculate the width of the methylene blue halo ring includes the following steps:
[0061] Step 1: Collect the image information of methylene blue drops and obtain the image after processing ; The step one includes the following sub-steps:
[0062] 1-1: Place the methylene blue drop filter paper between the camera and the light source, and take a photo to obtain an image; the industrial camera used in this application is a color camera with a resolution of not less than 720p, with a lens of 25mm focal length, and a circular light source is located below the camera, ensuring that the collected image has sufficient clarity and details, which is conducive to subsequent processing. When taking pictures, backlighting is used to enhance the color contrast and detail characteristics of the methylene blue drop, thereby improving the quality of the image.
[0063] 1-2: Resize the acquired image to 640*640 pixels. The resized image is recorded as , thus speeding up the subsequent processing and maintaining sufficient image information. Figure 2 shown.
[0064] Step 2: Obtain the droplet area of image I0 and perform enhancement processing to obtain the enhanced image ; The step 2 includes the following sub-steps:
[0065] 2-1: Use the image mask to focus on a circular area around the droplet to obtain an image ;like Figure 3 As shown, in this process, other useless areas are filtered to speed up subsequent judgment. The specific position needs to be determined according to the actual titration position;
[0066] 2-2: Image Perform pixel judgment on the three RGB channels one by one, set blue as the target area for pixel screening, filter out non-blue pixels, and obtain the image ; The pixel determination process in 2-2 is as follows:
[0067] At coordinates ( ) is recorded as , The color values on the three RGB channels are , , , then when or , the pixel is considered to belong to the target area pixel, where is the color channel ratio value.
[0068] 2-3: Image The blue channel value is exponentially enhanced, and the red and green channel values are exponentially reduced to further enhance the pixels in the target area to obtain the image ,like Figure 4 shown.
[0069] Step 3: Image Perform fine processing on the color halo area to obtain the color halo target image ; The step three includes the following sub-steps:
[0070] 3-1: Image Perform binarization and morphological opening operations to initially filter the dark blue (non-halo) area in the center of the drop to obtain the image ;
[0071] 3-2: Image Conduct connected domain analysis to obtain each connected component;
[0072] 3-3: If the number of connected components is equal to 1, it is considered that there is no color halo in the current image; otherwise, filter out the image with an aspect ratio less than The connected components of (i.e. filtering out the noise area), is a preset empirical value (set by technicians in this field based on actual conditions and experience), and the binary color halo image after noise filtering is obtained. ;
[0073] 3-4: Image Perform mean filtering to further filter out finer noise, smooth the edges, and then perform morphological closing operations to fill the holes to obtain a complete color halo area image. ;
[0074] 3-5: Image and Perform AND operation to obtain the color halo target image ,like Figure 5 shown.
[0075] Step 4: Image Perform edge extraction and circle detection to obtain an image containing the center of the target area ; The step 4 includes the following sub-steps:
[0076] 4-1: Use Canny operator to image Do edge extraction and get the image ;
[0077] 4-2: Image Use the Hough circle detection algorithm to detect the circular area and get the center of the circle , the image is recorded as .
[0078] Step 5: Image Perform halo ring detection and use the ring width estimation algorithm to calculate the halo width to obtain the final halo width value ,like Figure 6 The step five includes the following sub-steps:
[0079] 5-1: Rotate the image ;
[0080] 5-2: Obtain the inner point set and the outer point set;
[0081] In 5-2, As the starting point, The lines are emitted outward at an angle interval of The first point that intersects a non-zero pixel in the direction is , add it to the interior point set , the point where it intersects with a non-zero pixel for the last time is , add it to the external point set , and finally get The inner and outer point sets of the direction are:
[0082] ;
[0083] in, For images The rotation angle of
[0084] ;
[0085] .
[0086] 5-3: Calculate the width of the color halo ring; in 5-3, the inner and outer point distances in eight directions are calculated according to the inner and outer point sets. , is the width of the color halo ring in this direction. If , then it is believed that Valid, otherwise filter the value in this direction. They are respectively the minimum and maximum values of the reasonable width of the color halo ring, and are set by those skilled in the art based on experience.
[0087] 5-4: Use the ellipse fitting algorithm to fit the inner and outer ellipses on the inner and outer point sets respectively to obtain an image containing the color halo annular area , repeat 5-1 and 5-3, Rotate counterclockwise for the angle interval ,get The total set of internal and external points in each direction and ,according to and Calculate the eight-direction point distance set ,
[0088] in, for In the direction directions, corresponding to the rotation angle , ;
[0089] 5-5: Yes The final color halo width value can be obtained by averaging.
[0090] The above descriptions are only optional embodiments of the present invention, and are not intended to limit the patent scope of the present invention. All equivalent structural changes made using the contents of the present invention's specification and drawings, or directly / indirectly applied in other related technical fields, are included in the patent protection scope of the present invention.
Claims
1. An image processing method for calculating the width of a methylene blue halo, characterized in that: The steps include: Step 1: Collect the image information of methylene blue drops and obtain the image after processing ; Step 2: Obtain the droplet area of image I0 and perform enhancement processing to obtain the enhanced image ; Step 3: Image Perform fine processing on the color halo area to obtain the color halo target image ; Step 4: Image Perform edge extraction and circle detection to obtain an image containing the center of the target area ; Step 5: Image Perform halo ring detection, use the ring width estimation algorithm to calculate the halo width, and obtain the final halo width value; The step five includes the following sub-steps: 5-1: Rotate the image ; 5-2: Obtaining the inner point set and the outer point set; As the starting point, The lines are emitted outward at an angle interval of The first point that intersects a non-zero pixel in the direction is , add it to the interior point set , the point where it intersects with a non-zero pixel for the last time is , add it to the external point set , and finally get The inner and outer point sets of the direction are: Inner point collection ;Outer point collection · in, For images The rotation angle of , ; 5-3: Calculate the width of the color halo ring; In 5-3, the inner and outer point distances in eight directions are calculated respectively according to the inner and outer point sets. , is the width of the color halo ring in this direction. If , then it is believed that Valid, otherwise filter the value in this direction. and are the minimum and maximum values of the reasonable width of the color halo ring respectively; 5-4: Use the ellipse fitting algorithm to fit the inner and outer ellipses on the inner and outer point sets respectively to obtain an image containing the color halo annular area , repeat 5-1 to 5-3, Rotate the image counterclockwise by angle interval ,get The total internal and external point sets in each direction; the point distance sets in eight directions are calculated based on the total internal and external point sets; 5-5: Average the eight-directional point distance sets to obtain the final color halo ring width value.
2. The image processing method for calculating the width of a methylene blue halo according to claim 1, characterized in that: Said step 1 includes the following sub-steps: 1-1: Place the methylene blue drop filter paper between the camera and the light source, and take a photo to obtain an image; 1-2: Resize the acquired image to 640*640 pixels. The resized image is recorded as .
3. The image processing method for calculating the width of the methylene blue halo according to claim 1, characterized in that: The step 2 includes the following sub-steps: 2-1: Use the image mask to focus on a circular area around the droplet to obtain an image ; 2-2: Image Perform pixel judgment on the three RGB channels one by one, set blue as the target area for pixel screening, filter out non-blue pixels, and obtain the image ; 2-3: Image The blue channel value is exponentially enhanced, and the red and green channel values are exponentially reduced to obtain the image .
4. The image processing method for calculating the width of the methylene blue halo according to claim 3, characterized in that: The pixel determination process in 2-2 is as follows: At coordinates ( ) is recorded as , The color values on the three RGB channels are , , , then when or , the pixel is considered to belong to the target area pixel, where is the color channel ratio value.
5. The image processing method for calculating the width of the methylene blue halo according to claim 4, characterized in that: The step three includes the following sub-steps: 3-1: Image Perform binarization and morphological opening operations to initially filter the dark blue area in the center of the droplet to obtain the image ; 3-2: Image Conduct connected domain analysis to obtain each connected component; 3-3: If the number of connected components is equal to 1, it is considered that there is no color halo in the current image; otherwise, filter out the image with an aspect ratio less than The connected components of is a preset empirical value, and the filtered binary color halo image is obtained. ; 3-4: Image Perform mean filtering and then perform morphological closing operation to obtain a complete color halo area image ; 3-5: Image and Perform AND operation to obtain the color halo target image .
6. The image processing method for calculating the width of a methylene blue halo according to claim 5, characterized in that: The step 4 includes the following sub-steps: 4-1: Use Canny operator to image Do edge extraction and get the image ; 4-2: Image Use the Hough circle detection algorithm to detect the circular area and get the center of the circle , the image is recorded as .
7. The image processing method for calculating the width of a methylene blue halo according to claim 1, characterized in that: In 5-4 ; The total internal and external point sets are respectively expressed as: , external point set ; Eight-direction point distance set ,in, for In the direction directions; Corresponding rotation angle , .
