CN113643290B - Straw counting method and device based on image processing and storage medium - Google Patents

Straw counting method and device based on image processing and storage medium Download PDF

Info

Publication number
CN113643290B
CN113643290B CN202111194929.9A CN202111194929A CN113643290B CN 113643290 B CN113643290 B CN 113643290B CN 202111194929 A CN202111194929 A CN 202111194929A CN 113643290 B CN113643290 B CN 113643290B
Authority
CN
China
Prior art keywords
image
straw
matching
sample
processing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111194929.9A
Other languages
Chinese (zh)
Other versions
CN113643290A (en
Inventor
徐建海
王美兰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ningbo Changya New Material Technology Co ltd
Original Assignee
Ningbo Changya New Material Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ningbo Changya New Material Technology Co ltd filed Critical Ningbo Changya New Material Technology Co ltd
Priority to CN202111194929.9A priority Critical patent/CN113643290B/en
Publication of CN113643290A publication Critical patent/CN113643290A/en
Application granted granted Critical
Publication of CN113643290B publication Critical patent/CN113643290B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • G06T7/0004Industrial image inspection
    • G06T7/001Industrial image inspection using an image reference approach
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/20Image enhancement or restoration using local operators
    • G06T5/30Erosion or dilatation, e.g. thinning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/90Dynamic range modification of images or parts thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/12Edge-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/136Segmentation; Edge detection involving thresholding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/60Analysis of geometric attributes
    • G06T7/66Analysis of geometric attributes of image moments or centre of gravity
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10004Still image; Photographic image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30108Industrial image inspection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30242Counting objects in image

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Quality & Reliability (AREA)
  • Geometry (AREA)
  • Image Analysis (AREA)
  • Image Processing (AREA)

Abstract

The invention provides a straw counting method, a straw counting device and a storage medium based on image processing, wherein the method comprises the following steps: acquiring an end face image, wherein the end face image comprises end faces of a plurality of straws to be counted; performing combined enhancement pretreatment on the end face image according to a scene image gray enhancement algorithm and a gray morphological enhancement algorithm to obtain a pretreated image; extracting the closed edge contour of the suction pipe in the preprocessed image according to a morphological hole filling algorithm; generating a sample set according to the closed edge contour; performing morphological reconstruction according to the sample set to generate a weight template set, wherein the weight template set comprises a plurality of straw matching templates; and matching the straw matching template in the weight template set with the closed edge contour in the preprocessed image, and determining the number of the straws according to a matching result. The invention improves the accuracy of straw counting.

Description

Straw counting method and device based on image processing and storage medium
Technical Field
The invention relates to the technical field of straw production, in particular to a straw counting method and device based on image processing and a storage medium.
Background
In the traditional straw packaging process, the number of straws is generally counted by manual counting or weighing. However, the manual counting labor is large and the counting efficiency is low; the weighing rule has poor counting accuracy.
With the continuous development of image processing technology, the pipette counting is currently performed by the image processing technology, and commonly used image processing methods include a block-based detection counting method, a circle detection method based on Hough (Hough) transformation, a counting method based on least square circle fitting, and the like.
The block-based detection counting method is characterized in that the cross section image area of the straw is taken as independent blocks, the target is segmented through corresponding enhancement processing and morphological operation, and then the number of the independent blocks in the image is calculated, so that the number of the straw is obtained. The block-based detection counting method has high operation speed, but has unsatisfactory effects on straw detection and counting under the conditions of straw extrusion deformation and the like.
The circle detection method based on Hough transform is a practical and effective method for detecting a circle or an ellipse, and the essence of the method is to convert the space problem of an image into the mapping problem of a parameter space, convert the problem that the global detection is difficult in the space into the simple peak problem in the parameter space, and represent the conversion from a space coordinate system to a polar coordinate system. However, the circle detection method based on hough transform has the following disadvantages: firstly, the occupied internal storage is large, and the method is not suitable for the rapid counting of the straws on the industrial production line; secondly, the wall of the suction pipe is thin and easy to extrude and deform, and the circle detection method based on Hough transform has poor detection effect on irregular circle-like objects.
Counting method based on least squares ellipse fitting this method is a more common ellipse fitting method. The least square method is an optimal estimation method derived from the maximum likelihood method when the random error is normally distributed, and can minimize the sum of squares of the measurement errors. The fitting method adopted in the counting of the straws is to perform function fitting on the extracted image points of the edges of the straws to detect whether the detected edges are to-be-detected edges or not, and determine the correct number of the edges by checking each edge to obtain the number of the straws. Fitting the ellipse equation of the model, and constructing an ellipse fitting function of the edge by using continuous edge points. And if the ellipse parameters obtained by fitting the function are judged to be an ellipse, obtaining the description parameters of the ellipse by the parameters obtained by solving the equation. However, all sample points including the sample point with the larger error are directly subjected to ellipse fitting by the least square method, and the error is larger.
Neither of these methods is highly accurate when counting pipettes.
Disclosure of Invention
The problem to be solved by the invention is how to improve the accuracy of straw counting.
In order to solve the above problems, the present invention provides a pipette counting method, apparatus and storage medium based on image processing.
In a first aspect, the present invention provides a pipette counting method based on image processing, including:
acquiring an end face image, wherein the end face image comprises end faces of a plurality of straws to be counted;
performing combined enhancement pretreatment on the end face image according to a scene image gray enhancement algorithm and a gray morphological enhancement algorithm to obtain a pretreated image;
extracting the closed edge contour of the suction pipe in the preprocessed image according to a morphological hole filling algorithm;
generating a sample set according to the closed edge contours, wherein the sample set comprises geometric parameters of each closed edge contour;
performing morphological reconstruction according to the sample set to generate a weight template set, wherein the weight template set comprises a plurality of straw matching templates;
and matching each straw matching template in the weight template set with the closed edge contour in the preprocessed image respectively, and determining the number of the straws according to the matching result.
Optionally, the performing, according to a scene image gray scale enhancement algorithm and a gray scale morphology enhancement algorithm, joint enhancement preprocessing on the end face image includes:
carrying out graying processing on the end face image to obtain a grayscale image;
denoising and edge information enhancement are carried out on the gray level image by adopting a scene image gray level enhancement algorithm to obtain a first enhanced image;
performing median filtering on the first enhanced image to obtain a filtered image;
removing noise points in the filtered image by adopting a gray scale morphology enhancement algorithm to obtain a second enhanced image;
and carrying out mean value filtering on the second enhanced image to obtain the preprocessed image.
Optionally, the denoising and edge information enhancing the grayscale image by using the scene image grayscale enhancement algorithm includes:
sequentially selecting pixel points from the preprocessed image according to a preset sequence as pixel points to be processed;
generating a comparison sequence according to the pixel points to be processed;
determining a degree of gray correlation between the comparison sequence and a predetermined reference sequence;
comparing the grey correlation degree with a preset threshold value, and determining whether the pixel point to be processed is an edge point according to a comparison result;
if yes, no processing is carried out; if not, adjusting the pixel value of the pixel point to be processed to suppress noise.
Optionally, the removing noise in the filtered image by using a gray scale morphology enhancement algorithm to obtain a second enhanced image includes:
carrying out gray level opening operation on the filtering image to obtain an image after opening operation, wherein the gray level opening operation comprises the steps of sequentially carrying out corrosion treatment and expansion treatment on the filtering image through structural elements;
and simplifying the filtering image according to the image after the opening operation to obtain the second enhanced image.
Optionally, the extracting the closed edge contour of the straw in the preprocessed image according to a morphological hole filling algorithm includes:
extracting the straw contour edge in the preprocessed image by adopting a Canny operator, and filling morphological holes according to the straw contour edge to obtain a filled image;
and extracting the edge of the suction pipe in the filling image to obtain the closed edge contour corresponding to each suction pipe.
Optionally, the generating a sample set according to the closed edge contour comprises:
respectively calculating the geometric parameters of each closed edge contour, wherein the geometric parameters comprise a centroid coordinate and a radius;
composing the centroid coordinates and the radii of each of the closed edge profiles into the sample set, and determining a sample range that includes all of the closed edge profiles.
Optionally, the performing morphological reconstruction according to the sample set, and generating a weight template set includes:
processing the sample range in the preprocessed image to eliminate negative value influence to obtain a sample image related to a hole set, wherein the hole set comprises a pixel point set in a closed circle formed by eight connected lattices in the preprocessed image;
performing morphological reconstruction according to the sample image and the sample set, and determining each foreground graph in the sample image;
determining the geometric center point of each foreground graph, and calculating the offset of each foreground graph according to the geometric center point;
and carrying out offset convergence processing on each foreground graph according to the offset to obtain a weight template set, wherein the weight template set comprises a plurality of processed foreground graphs, and each processed foreground graph is a straw matching template.
Optionally, the matching, by the method for matching each straw matching template in the weight template set with the closed edge contour in the preprocessed image, respectively includes:
convolving each processed foreground graph in the weight template set with the preprocessed image respectively to obtain a matched image;
and determining matching graphs in the matching images by adopting a threshold segmentation method, and counting the matching graphs to obtain the number of the straws.
In a second aspect, the present invention provides a pipette counting apparatus based on image processing, comprising:
the acquisition module is used for acquiring an end face image, and the end face image comprises end faces of a plurality of straws to be counted;
the enhancement module is used for carrying out combined enhancement pretreatment on the end face image according to a scene image gray level enhancement algorithm and a gray level morphological enhancement algorithm to obtain a pretreated image;
the extraction module is used for extracting the closed edge contour of the suction pipe in the preprocessed image according to a morphological hole filling algorithm;
a processing module, configured to generate a sample set according to the closed edge contours, where the sample set includes geometric parameters of each closed edge contour;
the reconstruction module is used for carrying out morphological reconstruction according to the sample set to generate a weight template set, and the weight template set comprises a plurality of straw matching templates;
and the counting module is used for respectively matching each straw matching template in the weight template set with the closed edge contour in the preprocessed image, and determining the number of the straws according to a matching result.
In a third aspect, the present invention provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the image processing-based straw counting method as described above.
The straw counting method, the straw counting device and the storage medium based on image processing have the beneficial effects that: the method comprises the steps of obtaining an image of the end face of a plurality of straws to be counted, carrying out combined enhancement pretreatment on the end face image through a scene image gray level enhancement algorithm and a gray level morphology enhancement algorithm, enhancing the quality of the end face image, reducing noise in the end face image, and improving the accuracy of subsequent straw counting. Can fill the hole in the straw edge profile according to morphology hole filling algorithm, seal edge profile and draw again, can extract complete and confined straw edge profile, not only can realize the extraction to circular straw edge profile, also can extract the straw edge profile of irregular shape, prevent to extract incomplete straw edge profile, influence the degree of accuracy of follow-up straw count. And generating a sample set according to the closed edge contour, performing morphological reconstruction according to the sample set, and generating a weight template set, wherein the weight template set comprises a plurality of straw matching templates, each straw matching template is matched with the closed edge contour in the preprocessed image, if the matching is successful, the closed edge contour is indicated to correspond to one straw, and the number of straws to be counted can be quickly determined according to a matching result. According to the technical scheme, the counting accuracy of the straws is improved, the straws which are extruded and deformed can be counted, and the applicability is strong.
Drawings
FIG. 1 is a flowchart illustrating a pipette counting method based on image processing according to an embodiment of the present invention;
FIG. 2 is a schematic structural diagram of a pipette counting apparatus based on image processing according to an embodiment of the present invention.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in detail below.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein.
As shown in fig. 1, an embodiment of the present invention provides a pipette counting method based on image processing, including:
step S110, acquiring an end face image, wherein the end face image comprises end faces of a plurality of straws to be counted.
In particular, since different straws are different in thickness, length and shape, and have a large difference, and the end surfaces of the straws are usually circular or elliptical, the identification and detection of the end surfaces of the straws is simpler and more accurate than the identification of other characteristics of the straws. The camera with high frame rate can be used for shooting the end faces of the straws to be counted to obtain end face images, and the method can be used for detecting the straws on a conveyor belt in the straw production link or the straws bundled in the straw packaging link.
Step S120, performing joint Enhancement preprocessing on the end face Image according to a Gray Enhancement of Scene Image (GESI) and a Gray Morphology Enhancement (GME) algorithm to obtain a preprocessed Image.
Specifically, the face image is subjected to joint enhancement preprocessing, noise and useless information in the face image are removed, subsequent calculation amount can be reduced, and meanwhile, the quality of the scene image is enhanced.
Step S130, extracting the closed edge contour of the suction pipe in the preprocessed image according to a morphological hole filling algorithm.
Step S140, generating a sample set according to the closed edge contours, where the sample set includes geometric parameters of each closed edge contour.
And S150, performing morphological reconstruction according to the sample set to generate a weight template set, wherein the weight template set comprises a plurality of straw matching templates.
Step S160, matching each straw matching template in the weight template set with the closed edge contour in the preprocessed image respectively, and determining the number of the straws according to the matching result.
In the embodiment, the image of the end face of the plurality of straws to be counted is acquired, and the end face image is subjected to combined enhancement preprocessing by the scene image gray level enhancement algorithm and the gray level morphology enhancement algorithm, so that the quality of the end face image can be enhanced, the noise in the end face image is reduced, and the accuracy of subsequent straw counting is improved. Can fill the hole in the straw edge profile according to morphology hole filling algorithm, seal edge profile and draw again, can extract complete and confined straw edge profile, not only can realize the extraction to circular straw edge profile, also can extract the straw edge profile of irregular shape, prevent to extract incomplete straw edge profile, influence the degree of accuracy of follow-up straw count. And generating a sample set according to the closed edge contour, performing morphological reconstruction according to the sample set, and generating a weight template set, wherein the weight template set comprises a plurality of straw matching templates, each straw matching template is matched with the closed edge contour in the preprocessed image, if the matching is successful, the closed edge contour is indicated to correspond to one straw, and the number of straws to be counted can be quickly determined according to a matching result. According to the technical scheme, the counting accuracy of the straws is improved, the straws which are extruded and deformed can be counted, and the applicability is strong.
Optionally, the performing, according to a scene image gray scale enhancement algorithm and a gray scale morphology enhancement algorithm, joint enhancement preprocessing on the end face image includes:
and carrying out graying processing on the end face image to obtain a grayscale image.
Specifically, the end face image is converted from an RGB color space to a YUV color space, where Y represents the brightness of a pixel point in the end face image, and reflects the gray level of the pixel point, and the conversion relationship from the RGB color space to the YUV color space is shown as a first formula, where the first formula includes:
Figure DEST_PATH_IMAGE002
establishing a corresponding relation between the brightness Y and three color components R (red), G (green) and B (blue) of the end face image, and converting the end face image into a gray level image according to the corresponding relation, wherein the corresponding relation is shown as a second formula:
Figure DEST_PATH_IMAGE004
and denoising and edge information enhancement are carried out on the gray level image by adopting a scene image gray level enhancement algorithm to obtain a first enhanced image.
And carrying out median filtering on the first enhanced image to obtain a filtered image.
Specifically, after the scene image gray level enhancement algorithm is adopted to partially process the gray level image, the median filtering is performed on the processed first enhanced image, and the residual noise can be averaged.
Removing noise points in the filtered image by adopting a gray scale morphology enhancement algorithm to obtain a second enhanced image;
and carrying out mean value filtering on the second enhanced image to obtain the preprocessed image.
Specifically, the second enhanced image is subjected to mean filtering, so that a false edge effect caused by a gray-scale morphological enhancement algorithm can be removed, and the preprocessed image has a better enhancement effect.
Optionally, the denoising and edge information enhancing the grayscale image by using the scene image grayscale enhancement algorithm includes:
and sequentially selecting pixel points in the preprocessed image according to a preset sequence as pixel points to be processed.
And generating a comparison sequence according to the pixel points to be processed.
Specifically, the flat region is a set of non-edge points in the circular end surface region in the preprocessed image, and the reference sequence can be determined by obtaining pixels of the flat region and field pixels thereof in the preprocessed image, for example, assuming that the pixels are pixels
Figure DEST_PATH_IMAGE006
One pixel of the flat region represents the second pixel of the pre-processed imageiGo to the firstjThe pixel points of the column are determined according to the pixel points
Figure DEST_PATH_IMAGE007
And four neighborhood pixels thereof generate a reference sequence which is
Figure DEST_PATH_IMAGE009
. When the pixel point to be processed is not the pixel point on the four edges of the preprocessed image, generating a comparison sequence according to the pixel point to be processed and the pixel points in the four fields of the pixel point to be processedAnd (4) columns. And when the pixel points to be processed are pixel points on four edges of the preprocessed image, taking the pixel values of corresponding positions on adjacent rows or columns of the pixel points to be processed as the field pixel points missing from the pixel points to be processed, and generating a comparison sequence.
Determining a degree of gray correlation between the comparison sequence and a predetermined reference sequence;
and comparing the grey correlation degree with a preset threshold value, and determining whether the pixel point to be processed is an edge point according to a comparison result.
Specifically, edge points and non-edge points in the pre-processed image are identified using a gray relevance, which is used to determine the degree of relevance between the comparison sequence and the reference sequence.
If yes, no processing is carried out; if not, adjusting the pixel value of the pixel point to be processed to suppress noise.
Specifically, all pixel points in the preprocessed image are regarded as two sets, namely an edge point set and a non-edge point set, wherein the non-edge point set comprises an inner point in the end face of the straw and a noise point in the end face of the non-straw. And determining a comparison sequence according to the pixel points to be processed, and determining a reference sequence to distinguish the internal points from the noise points. And identifying the set to which the pixel point to be processed belongs by calculating the grey correlation degree between the two sequences, wherein when the pixel point to be processed is an edge point, the value of the pixel point to be processed is kept unchanged, and the edge information is unchanged. When the pixel point to be processed is a non-edge point, the pixel value of the pixel point to be processed is adjusted, the gray level is enhanced, the noise is suppressed, and the similarity between the internal points is enhanced.
In the optional embodiment, the preprocessed image is processed by the scene image gray level enhancement algorithm, so that the characteristics of the edge points of the end face of the straw can be highlighted, and the subsequent image recognition and straw counting are facilitated.
Optionally, the removing noise in the filtered image by using a gray scale morphology enhancement algorithm to obtain a second enhanced image includes:
and carrying out gray level opening operation on the filtering image to obtain an image after opening operation, wherein the gray level opening operation comprises the step of sequentially carrying out corrosion treatment and expansion treatment on the filtering image through structural elements.
And simplifying the filtering image according to the image after the opening operation to obtain the second enhanced image.
Specifically, in mathematical morphology, the basic transformation is iterative operation using a basic symmetric structure, the most basic shapes are squares, rectangles, diamonds, and the like, the matrix having the basic shape is called a structural element, and the structural element can be used to perform operations such as erosion and expansion. For example, a two-bit structuring element is understood to be a two-dimensional matrix, the values of the matrix elements being 0 or 1, the structuring element usually being smaller than the image to be processed.
Hypothesis filtered imagefx, y) Quantized to an arbitrary number of grey levels, by structural elements according to the extreme method of grey image expansionbFor imagesfx, y) The corrosion treatment and the expansion treatment, the corrosion treatment can be expressed by a third formula:
Figure DEST_PATH_IMAGE011
wherein the content of the first and second substances,
Figure DEST_PATH_IMAGE013
in order to obtain an image after the etching,
Figure DEST_PATH_IMAGE015
is the pixel center point coordinate of the filtered image.
The expansion process can be expressed using a fourth equation:
Figure DEST_PATH_IMAGE017
wherein the content of the first and second substances,
Figure DEST_PATH_IMAGE019
the expanded image.
Thus, to filterWave imagefx, y) Performing the gray-scale on operation can be expressed by a fifth formula:
Figure DEST_PATH_IMAGE021
wherein the content of the first and second substances,
Figure DEST_PATH_IMAGE023
the image is an on-operated image.
According to the image after the opening operation, a sixth formula can be adopted to simplify the filtering image, and the sixth formula comprises:
Figure DEST_PATH_IMAGE025
wherein the content of the first and second substances,
Figure DEST_PATH_IMAGE027
is the second enhanced image.
In this optional embodiment, carry out corrosion treatment and inflation processing to the filtering image in proper order, can filtering structure element's less strong bright detail, remove bright noise on the dark background in the filtering image promptly through opening the operation, can keep the whole grey scale of image and comparatively bright regional information unchangeable simultaneously, be convenient for extract the target characteristic in the image, reduce the influence of noise to the straw count, be favorable to follow-up straw count, improved the counting accuracy.
Optionally, the extracting the closed edge contour of the straw in the preprocessed image according to a morphological hole filling algorithm includes:
extracting the straw contour edge in the preprocessed image by adopting a Canny operator, and filling morphological holes according to the straw contour edge to obtain a filled image;
and extracting the edge of the suction pipe in the filling image to obtain the closed edge contour corresponding to each suction pipe.
In this optional embodiment, Canny operators and the like can be used to extract the straw edges in the filled image, and when Canny operators are used to directly extract the straw contour edges in the preprocessed image, the extracted contours are complete and closed when being inconsistent, and jagged fluctuation often occurs in the extracted contour edges, which is not beneficial to subsequent straw counting. Through filling according to the morphological hole of straw profile edge, then extract the straw edge in filling the image, can extract the straw edge profile of more ideal, can improve straw count degree of accuracy.
Optionally, the generating a sample set according to the closed edge contour comprises:
respectively calculating the geometric parameters of each closed edge contour, wherein the geometric parameters comprise a centroid coordinate and a radius;
composing the centroid coordinates and the radii of each of the closed edge profiles into the sample set, and determining a sample range that includes all of the closed edge profiles.
In particular, for any closed edge profile
Figure DEST_PATH_IMAGE029
Figure DEST_PATH_IMAGE031
For the set of all closed edge profiles, the centroid coordinates of the closed edge profile are calculated according to a seventh formula, which includes:
Figure DEST_PATH_IMAGE033
wherein the content of the first and second substances,
Figure DEST_PATH_IMAGE035
being the coordinates of any point in the closed edge profile,
Figure DEST_PATH_IMAGE037
is the centroid coordinate of the closed edge profile. The seal can be determined by geometric measurement according to the coordinates of the mass centerRadius of the closed edge profile.
Optionally, the performing morphological reconstruction according to the sample set, and generating a weight template set includes:
and processing the sample range in the preprocessed image to eliminate negative value influence, and obtaining a sample image related to a hole set, wherein the hole set comprises a pixel point set in a closed circle formed by eight connected lattices in the preprocessed image.
Specifically, the sample range in the pre-processed image is squared to eliminate the negative influence of the sample range.
And performing morphological reconstruction according to the sample image and the sample set, and determining each foreground graph in the sample image.
Specifically, the sample image is scanned by using a 3 × 3 block, and the number of points with a gray value of 255 among 9 pixel points covered by the block is recorded by using a counter. When any pixel point to be processed in the sample image is scanned, namely the central point of the block is located in the pixel point to be processed, if the gray value of at least 5 pixel points in 9 pixel points covered by the block is 255, the pixel point to be processed is determined as a foreground pixel point, the gray value of the pixel point to be processed is assigned to be 255, otherwise, the pixel point to be processed is determined as a background pixel point, and all foreground pixel points form a foreground graph.
And determining the geometric center point of each foreground graph, and calculating the offset of each foreground graph according to the geometric center point.
In particular, for any foreground graphic
Figure DEST_PATH_IMAGE039
Calculating the geometric center point of the foreground graph by adopting an eighth formula, wherein the eighth formula comprises:
Figure DEST_PATH_IMAGE041
wherein the content of the first and second substances,
Figure DEST_PATH_IMAGE043
as a foreground graphic
Figure DEST_PATH_IMAGE045
The geometric center point of (a) of (b),
Figure DEST_PATH_IMAGE047
as a foreground graphic
Figure DEST_PATH_IMAGE048
The set of abscissas of the individual points in (a),
Figure DEST_PATH_IMAGE050
as a foreground graphic
Figure 762478DEST_PATH_IMAGE045
A set of ordinates of the individual points in.
Assuming a foreground graphic
Figure 679618DEST_PATH_IMAGE045
Is m, is n, the foreground pattern
Figure 193776DEST_PATH_IMAGE045
The offset of (c) includes:
Figure DEST_PATH_IMAGE052
wherein the content of the first and second substances,
Figure DEST_PATH_IMAGE054
and
Figure DEST_PATH_IMAGE056
is an offset.
And carrying out offset convergence processing on each foreground graph according to the offset to obtain a weight template set, wherein the weight template set comprises a plurality of processed foreground graphs, and each processed foreground graph is a straw matching template.
In particular, for each foreground graphic
Figure DEST_PATH_IMAGE057
And performing offset centering processing by adopting a ninth formula, wherein the ninth formula comprises the following steps:
Figure DEST_PATH_IMAGE059
wherein n is the number of foreground graphics,
Figure DEST_PATH_IMAGE061
is a set of weight templates.
Optionally, the matching, by the method for matching each straw matching template in the weight template set with the closed edge contour in the preprocessed image, respectively includes:
convolving each processed foreground graph in the weight template set with the preprocessed image respectively to obtain a matched image;
and determining matching graphs in the matching images by adopting a threshold segmentation method, and counting the matching graphs to obtain the number of the straws.
Specifically, a threshold is set according to actual conditions, the gray value of each pixel point is compared with the threshold, when the gray value of the pixel point is greater than the threshold, the pixel point is a target pixel point, and when the gray value of the pixel point is less than or equal to the threshold, the pixel point is not the target pixel point. The target pixel points form matching patterns, and the central points of all the matching patterns are counted to obtain the number of the straws.
And respectively matching each processed foreground graph in the weight template set with the closed edge profile in the preprocessed graph, namely matching the straw matching template with the straw edge profile in the preprocessed graph.
In the optional embodiment, the edge profile of the suction pipe is extracted from the preprocessed image based on the morphological hole filling algorithm, so that a complete and closed edge profile can be extracted, counting errors caused by incomplete extracted profiles are avoided, and the counting accuracy is improved. The background noise and the contour of the non-target are removed, and then the number of the straws can be determined by detecting the number of the closed edge contours, so that the counting speed and the counting accuracy are improved.
As shown in fig. 2, an embodiment of the present invention provides an image processing-based pipette counting apparatus, including:
the acquisition module is used for acquiring an end face image, and the end face image comprises end faces of a plurality of straws to be counted;
the enhancement module is used for carrying out combined enhancement pretreatment on the end face image according to a scene image gray level enhancement algorithm and a gray level morphological enhancement algorithm to obtain a pretreated image;
the extraction module is used for extracting the closed edge contour of the suction pipe in the preprocessed image according to a morphological hole filling algorithm;
a processing module, configured to generate a sample set according to the closed edge contours, where the sample set includes geometric parameters of each closed edge contour;
the reconstruction module is used for carrying out morphological reconstruction according to the sample set to generate a weight template set, and the weight template set comprises a plurality of straw matching templates;
and the counting module is used for respectively matching each straw matching template in the weight template set with the closed edge contour in the preprocessed image, and determining the number of the straws according to a matching result.
Another embodiment of the present invention provides an electronic device including a memory and a processor; the memory for storing a computer program; the processor is configured to implement the pipette counting method based on image processing as described above when executing the computer program.
Yet another embodiment of the present invention provides a computer-readable storage medium having stored thereon a computer program, which, when executed by a processor, implements the pipette counting method based on image processing as described above.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like. In this application, the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment of the present invention. In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
Although the present disclosure has been described above, the scope of the present disclosure is not limited thereto. Various changes and modifications may be effected therein by one of ordinary skill in the pertinent art without departing from the spirit and scope of the present disclosure, and these changes and modifications are intended to be within the scope of the present disclosure.

Claims (10)

1. A pipette counting method based on image processing is characterized by comprising the following steps:
acquiring an end face image, wherein the end face image comprises end faces of a plurality of straws to be counted;
performing combined enhancement pretreatment on the end face image according to a scene image gray enhancement algorithm and a gray morphological enhancement algorithm to obtain a pretreated image;
extracting the closed edge contour of the suction pipe in the preprocessed image according to a morphological hole filling algorithm;
generating a sample set according to the closed edge contours, wherein the sample set comprises geometric parameters of each closed edge contour;
performing morphological reconstruction according to the sample set to generate a weight template set, wherein the weight template set comprises a plurality of straw matching templates, and the performing morphological reconstruction according to the sample set comprises: processing to eliminate negative value influence according to the preprocessed image to obtain a sample image; performing morphological reconstruction according to the sample image and the sample set, and determining each foreground graph in the sample image; performing offset convergence processing on each foreground graph to obtain the weight template set;
and matching each straw matching template in the weight template set with the closed edge contour in the preprocessed image respectively, and determining the number of the straws according to the matching result.
2. The image-processing-based straw counting method according to claim 1, wherein the joint enhancement preprocessing of the end face image according to a scene image gray scale enhancement algorithm and a gray scale morphology enhancement algorithm comprises:
carrying out graying processing on the end face image to obtain a grayscale image;
denoising and edge information enhancement are carried out on the gray level image by adopting a scene image gray level enhancement algorithm to obtain a first enhanced image;
performing median filtering on the first enhanced image to obtain a filtered image;
removing noise points in the filtered image by adopting a gray scale morphology enhancement algorithm to obtain a second enhanced image;
and carrying out mean value filtering on the second enhanced image to obtain the preprocessed image.
3. The image-processing-based straw counting method according to claim 2, wherein the denoising and edge information enhancement of the gray-scale image by using a scene image gray-scale enhancement algorithm comprises:
sequentially selecting pixel points from the preprocessed image according to a preset sequence as pixel points to be processed;
generating a comparison sequence according to the pixel points to be processed;
determining a degree of gray correlation between the comparison sequence and a predetermined reference sequence;
comparing the grey correlation degree with a preset threshold value, and determining whether the pixel point to be processed is an edge point according to a comparison result;
if yes, no processing is carried out; if not, adjusting the pixel value of the pixel point to be processed to suppress noise.
4. The image-processing-based straw counting method according to claim 2, wherein the removing noise in the filtered image by using a gray-scale morphology enhancement algorithm to obtain a second enhanced image comprises:
carrying out gray level opening operation on the filtering image to obtain an image after opening operation, wherein the gray level opening operation comprises the steps of sequentially carrying out corrosion treatment and expansion treatment on the filtering image through structural elements;
and simplifying the filtering image according to the image after the opening operation to obtain the second enhanced image.
5. The image-processing-based straw counting method according to any one of claims 1 to 4, wherein the extracting the closed edge profile of the straw in the pre-processed image according to a morphological hole filling algorithm comprises:
extracting the straw contour edge in the preprocessed image by adopting a Canny operator, and filling morphological holes according to the straw contour edge to obtain a filled image;
and extracting the edge of the suction pipe in the filling image to obtain the closed edge contour corresponding to each suction pipe.
6. The image-processing-based straw counting method according to any one of claims 1 to 4, wherein the generating a sample set from the closed edge profile comprises:
respectively calculating the geometric parameters of each closed edge contour, wherein the geometric parameters comprise a centroid coordinate and a radius;
composing the centroid coordinates and the radii of each of the closed edge profiles into the sample set, and determining a sample range that includes all of the closed edge profiles.
7. The image-processing-based straw counting method according to claim 6, wherein the performing morphological reconstruction based on the sample set and generating a set of weight templates comprises:
processing the sample range in the preprocessed image to eliminate negative value influence to obtain a sample image related to a hole set, wherein the hole set comprises a pixel point set in a closed circle formed by eight connected lattices in the preprocessed image;
performing morphological reconstruction according to the sample image and the sample set, and determining each foreground graph in the sample image;
determining the geometric center point of each foreground graph, and calculating the offset of each foreground graph according to the geometric center point;
and carrying out offset convergence processing on each foreground graph according to the offset to obtain a weight template set, wherein the weight template set comprises a plurality of processed foreground graphs, and each processed foreground graph is a straw matching template.
8. The image-processing-based straw counting method according to claim 7, wherein the matching each straw matching template in the weight template set with the closed edge contour in the preprocessed image comprises:
convolving each processed foreground graph in the weight template set with the preprocessed image respectively to obtain a matched image;
and determining matching graphs in the matching images by adopting a threshold segmentation method, and counting the matching graphs to obtain the number of the straws.
9. A pipette counting apparatus based on image processing, comprising:
the acquisition module is used for acquiring an end face image, and the end face image comprises end faces of a plurality of straws to be counted;
the enhancement module is used for carrying out combined enhancement pretreatment on the end face image according to a scene image gray level enhancement algorithm and a gray level morphological enhancement algorithm to obtain a pretreated image;
the extraction module is used for extracting the closed edge contour of the suction pipe in the preprocessed image according to a morphological hole filling algorithm;
a processing module, configured to generate a sample set according to the closed edge contours, where the sample set includes geometric parameters of each closed edge contour;
a reconstruction module, configured to perform morphological reconstruction according to the sample set, and generate a weight template set, where the weight template set includes a plurality of straw matching templates, and the performing morphological reconstruction according to the sample set includes: processing to eliminate negative value influence according to the preprocessed image to obtain a sample image; performing morphological reconstruction according to the sample image and the sample set, and determining each foreground graph in the sample image; performing offset convergence processing on each foreground graph to obtain the weight template set;
and the counting module is used for respectively matching each straw matching template in the weight template set with the closed edge contour in the preprocessed image, and determining the number of the straws according to a matching result.
10. A computer-readable storage medium, characterized in that the storage medium has stored thereon a computer program which, when being executed by a processor, carries out an image-processing-based straw counting method according to any one of claims 1 to 8.
CN202111194929.9A 2021-10-14 2021-10-14 Straw counting method and device based on image processing and storage medium Active CN113643290B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111194929.9A CN113643290B (en) 2021-10-14 2021-10-14 Straw counting method and device based on image processing and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111194929.9A CN113643290B (en) 2021-10-14 2021-10-14 Straw counting method and device based on image processing and storage medium

Publications (2)

Publication Number Publication Date
CN113643290A CN113643290A (en) 2021-11-12
CN113643290B true CN113643290B (en) 2022-04-08

Family

ID=78426747

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111194929.9A Active CN113643290B (en) 2021-10-14 2021-10-14 Straw counting method and device based on image processing and storage medium

Country Status (1)

Country Link
CN (1) CN113643290B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115619811B (en) * 2022-12-16 2023-04-14 北京远舢智能科技有限公司 Cigarette quantity determining method and device, electronic equipment and storage medium

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106056118B (en) * 2016-06-12 2018-08-24 合肥工业大学 A kind of identification method of counting for cell
CN207895488U (en) * 2018-02-07 2018-09-21 楼东来 A kind of suction pipe robot scaler
CN108765436A (en) * 2018-04-21 2018-11-06 卞家福 Method for detecting image edge is piled up based on the irregular beverage bottle for improving Roberts operators

Also Published As

Publication number Publication date
CN113643290A (en) 2021-11-12

Similar Documents

Publication Publication Date Title
CN113538433B (en) Mechanical casting defect detection method and system based on artificial intelligence
CN108898610B (en) Object contour extraction method based on mask-RCNN
CN109272489B (en) Infrared weak and small target detection method based on background suppression and multi-scale local entropy
CN109242853B (en) PCB defect intelligent detection method based on image processing
CN108229475B (en) Vehicle tracking method, system, computer device and readable storage medium
CN107490582B (en) Assembly line workpiece detection system
CN108898132B (en) Terahertz image dangerous article identification method based on shape context description
CN111489337B (en) Automatic optical detection pseudo defect removal method and system
CN108846844B (en) Sea surface target detection method based on sea antenna
CN111680690B (en) Character recognition method and device
CN109540925B (en) Complex ceramic tile surface defect detection method based on difference method and local variance measurement operator
CN116704516B (en) Visual inspection method for water-soluble fertilizer package
CN116883408B (en) Integrating instrument shell defect detection method based on artificial intelligence
CN113780110A (en) Method and device for detecting weak and small targets in image sequence in real time
CN110807763A (en) Method and system for detecting ceramic tile surface bulge
CN114549441A (en) Sucker defect detection method based on image processing
CN110276759B (en) Mobile phone screen bad line defect diagnosis method based on machine vision
CN113643290B (en) Straw counting method and device based on image processing and storage medium
CN117094975A (en) Method and device for detecting surface defects of steel and electronic equipment
CN117372487A (en) Image registration method, device, computer equipment and storage medium
CN117132503A (en) Method, system, equipment and storage medium for repairing local highlight region of image
CN116433978A (en) Automatic generation and automatic labeling method and device for high-quality flaw image
CN111353324A (en) Method for reading two-dimensional code of dot matrix in glass
CN104408430B (en) License plate positioning method and device
CN107704864A (en) Well-marked target detection method based on image object Semantic detection

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: 315221 No. 766, Dongsheng Road, Jiaochuan street, Zhenhai District, Ningbo City, Zhejiang Province (one photo multiple address)

Applicant after: Ningbo changya New Material Technology Co.,Ltd.

Address before: 315221 No. 766, Dongsheng Road, Jiaochuan street, Zhenhai District, Ningbo City, Zhejiang Province

Applicant before: Changya New Materials Technology Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant