CN112577967B - Method for detecting appearance quality of head of medical ampoule bottle - Google Patents

Method for detecting appearance quality of head of medical ampoule bottle Download PDF

Info

Publication number
CN112577967B
CN112577967B CN202011332783.5A CN202011332783A CN112577967B CN 112577967 B CN112577967 B CN 112577967B CN 202011332783 A CN202011332783 A CN 202011332783A CN 112577967 B CN112577967 B CN 112577967B
Authority
CN
China
Prior art keywords
head
contour
arc
image
ampoule bottle
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
CN202011332783.5A
Other languages
Chinese (zh)
Other versions
CN112577967A (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.)
Henan University of Technology
Original Assignee
Henan University of Technology
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 Henan University of Technology filed Critical Henan University of Technology
Priority to CN202011332783.5A priority Critical patent/CN112577967B/en
Publication of CN112577967A publication Critical patent/CN112577967A/en
Application granted granted Critical
Publication of CN112577967B publication Critical patent/CN112577967B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G01MEASURING; TESTING
    • G01NINVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
    • G01N21/00Investigating or analysing materials by the use of optical means, i.e. using sub-millimetre waves, infrared, visible or ultraviolet light
    • G01N21/84Systems specially adapted for particular applications
    • G01N21/88Investigating the presence of flaws or contamination
    • G01N21/95Investigating the presence of flaws or contamination characterised by the material or shape of the object to be examined
    • GPHYSICS
    • G01MEASURING; TESTING
    • G01BMEASURING LENGTH, THICKNESS OR SIMILAR LINEAR DIMENSIONS; MEASURING ANGLES; MEASURING AREAS; MEASURING IRREGULARITIES OF SURFACES OR CONTOURS
    • G01B11/00Measuring arrangements characterised by the use of optical techniques
    • G01B11/24Measuring arrangements characterised by the use of optical techniques for measuring contours or curvatures
    • 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
    • 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/13Edge detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20024Filtering details
    • G06T2207/20032Median filtering
    • 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
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/30Computing systems specially adapted for manufacturing

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Health & Medical Sciences (AREA)
  • Quality & Reliability (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Chemical & Material Sciences (AREA)
  • Analytical Chemistry (AREA)
  • Biochemistry (AREA)
  • General Health & Medical Sciences (AREA)
  • Immunology (AREA)
  • Pathology (AREA)
  • Image Analysis (AREA)

Abstract

The invention provides a method for detecting appearance quality of the head of a medicine ampoule bottle, which comprises the following steps: (1) intercepting an ampoule bottle head image; (2) Preprocessing the ampoule bottle head image by adopting median filtering; (3) Dividing the image by using a watershed algorithm based on distance transformation; (4) Completing contour extraction on the image by using a Suzuki boundary tracking algorithm; (5) Selecting contour points of m rows downwards from the top of the ampoule bottle head, and performing circle fitting by using a least square method; (6) Selecting contour points at the transition positions of the arc and the side contour points, and respectively performing straight line fitting by using a least square method; (7) extracting the arc characteristics of the top of the bottle head; (8) extracting transition characteristics of the arc and the side profile; (9) Ampoule bottle head appearance quality identification based on arc characteristics and arc and side profile transition characteristics of the bottle head top. The algorithm overcomes the problems of low manual detection efficiency, high cost and the like, and well meets the requirements of a medicine enterprise on ampoule bottle head appearance detection.

Description

Method for detecting appearance quality of head of medical ampoule bottle
Technical Field
The invention relates to a method for detecting appearance quality of a head of a medicine ampoule bottle, and belongs to the technical field of machine vision defect detection.
Background
In the process of fusing and sealing the medical ampoule bottle, the glass of the ampoule bottle mouth is fused under high-temperature flame and is wiredrawn and sealed. Because in the wire drawing process, the ampoule bottle head part is influenced by factors such as flame intensity, cam rotating speed, wire drawing clamp position and the like, defects such as a tip, a flat head, a drum head and the like can be generated. When the ampoule bottle with the head appearance defect is opened, the injury to medical staff and the pollution caused by falling glass fragments into the liquid medicine are likely to happen. In order to ensure the safety of medication, the appearance quality of the head of the ampoule is required to be detected.
Aiming at various appearance defects existing in the appearance of the head of the medical ampoule bottle, the appearance quality of the head of the ampoule bottle is detected according to the characteristic that the outer curve of the head of the ampoule bottle has symmetrical and downward parabolic change trend in the patent number 201210501356.4. Yu Xiaoyou, hu Xiaomei et al in the text "ampoule appearance detection method based on gradient vector feature extraction" detect the appearance quality of the ampoule head by symmetry and flatness of the ampoule head. According to the invention, the appearance quality of the ampoule head is detected according to whether the arc exists at the top of the ampoule head and whether the concave or convex phenomenon exists at the transition part of the arc and the side profile.
Disclosure of Invention
The invention provides a method for detecting appearance quality of a head part of a medicine ampoule bottle, and aims to provide a method with higher recognition rate, more comprehensive defect detection and higher detection efficiency.
The bottle heads appearing in this patent all refer to ampoule bottle heads.
The method for detecting the appearance quality of the head of the medicine ampoule bottle comprises the following steps: (a) intercepting an ampoule bottle head image; (b) Preprocessing the intercepted ampoule bottle head image by adopting median filtering; (c) Dividing the filtered image using a distance transform and watershed based algorithm; (d) Using a Suzuki boundary tracking algorithm to complete contour extraction of the segmented image to obtain ampoule bottle head contour points; (e) Selecting contour points of m rows downwards from the top of the ampoule bottle head, and completing circle fitting by using a least square method; (f) Selecting contour points at the transition positions of the arc and the side contour points, and respectively performing straight line fitting by using a least square method; (g) Extracting the circular arc characteristics of the top of the bottle head based on the circle fitting data; (h) Completing the extraction of the transition characteristics of the arc and the side profile based on the straight line fitting data; (i) Ampoule bottle head appearance quality identification based on arc characteristics and arc and side profile transition characteristics of the top of the bottle head.
The ampoule bottle head image is intercepted in the step aThe bottom of the original image G of the ampoule bottle is cut off to obtain the left part of n rows upwards to obtain an image G 1
The image filtering in the step b adopts median filtering to the image G in the process of acquisition and transmission 1 Noise points generated by environmental influence are removed to obtain an image G 2
The image segmentation in the step c uses a watershed algorithm based on distance transformation to segment the image G 2 Obtaining an ampoule bottle head edge image G 3
The image is segmented based on distance transformation and watershed algorithm, namely, the image G is segmented firstly 2 The marked image S is obtained by using a distance transformation algorithm, the image segmentation by a watershed algorithm is a process of simulating overflow, water is injected according to water injection points obtained by the marked image S, water levels gradually submerge catchment basins, and the limit of different catchment basins when water meets is the expected ampoule bottle head edge image G 3
And d, performing contour extraction in the step, and completing contour extraction by using a Suzuki boundary tracking algorithm. The algorithm is performed from ampoule head edge image G 3 Starting from the lower left corner, the image contour is tracked clockwise to obtain an ampoule bottle head contour point set C which is arranged in sequence.
In the step e, the least square method circle fitting means that the contour points with arc characteristics in m rows downwards from the top of the ampoule bottle head are selected to obtain a set C m And (3) finishing circle fitting on all the contour points by using a least square method to obtain circle center coordinates (A, B) and a radius R.
The least square method circle fitting in the step e comprises the following specific steps:
(1) Principle of selecting contour points
When the camera is fixed, the imaging position of the ampoule bottle head part is relatively fixed. The image takes the upper left corner as the origin of coordinates, the first row is right in the positive x-axis direction, and the first column is downward in the positive y-axis direction, and a coordinate system is established. For points (x) in the ampoule head profile point set C i ,y i ) In y i The values are ordered from small to large, where y i The point with the smallest value is the highest point of the head. Selecting from the highest point of the head downwardsContour point set C of m rows m And (5) performing circle fitting.
(2) Least squares circle fitting
1)C m All contour points (x) i ,y i ) Distance from center of circle is lambda i As shown in formula (1).
Figure BDA0002796287550000021
2)C m All contour points (x) i ,y i ) The sum of squares of deviation from the rounded edge P (a, b, c) is shown in equation (2).
Figure BDA0002796287550000022
3) According to the principle of minimizing P (a, B, c), P (a, B, c) is led to calculate partial derivatives of a, B, c respectively, so that the partial derivatives are equal to 0, and the center coordinates (A, B) and the radius R can be obtained by simultaneous calculation of three partial derivatives, so that a fit round equation can be obtained as shown in a formula (3).
(x-A) 2 +(y-B) 2 =R 2 (3)
The least square method straight line fitting in the step f means that contour point sets corresponding to the contours and the side contours at the transition positions of the arc and the side contours are respectively calculated, and the straight line fitting is carried out on the contour point sets by adopting a least square method to obtain the straight line slope k at the transition positions of the arc and the side contours l 、k r Slope k of side profile straight line ls 、k rs
The least square method straight line fitting in the step f comprises the following specific steps:
(1) Principle of selecting contour points
A set C of contour points selected from the B line to the B+R line and with the abscissa smaller than A L As a contour point at the transition of the arc and the left contour; a set C of contour points selected from the rows B to B+R and with the abscissa larger than A R As a contour point at the transition of the arc and the right contour; selecting a contour point set C from B+R rows to the bottom of the image, wherein the abscissa of the contour point set C is smaller than that of A LS As a left profile point; a contour point set C which is selected from the B+R row to the bottom of the image and has the abscissa larger than A RS As the right side contour point.
(2) Least squares line fitting
1) And fitting a straight line formula as shown in formula (4).
y=kx+b (4)
2) And calculating the square sum Q (k, b) of the deviation of the contour points from the fitting straight line, as shown in a formula (5).
Q(k,b)=∑[y i -(kx i +b)] 2 (5)
3) According to the principle of minimizing Q (k, b), the Q (k, b) is enabled to calculate partial derivatives of k, b respectively, so that two partial derivatives are equal to 0 and calculated in parallel, the slopes k and b can be obtained, and then a fitting straight line formula can be obtained.
4) For contour point set C L 、C R 、C LS And C RS Respectively performing straight line fitting according to the method to obtain corresponding slope k l 、k r 、k ls 、k rs And corresponding intercept to obtain a straight line y l 、y r 、y ls 、y rs As shown in formula (6).
y l =k l x+b l ,y r =k r x+b r ,y ls =k ls x+b ls ,y rs =k rs x+b rs (6)
The extraction of the circular arc characteristic of the top of the bottle head in the step g refers to the calculation of the maximum distance r from the inner contour point of the circle to the edge of the circle in And the maximum distance r from the contour point of the outer side of the circle to the edge of the circle out As a top circular arc feature of the bottle head. Multiple tests find out the corresponding proper threshold T in And T out . When r is in And r out Respectively smaller than T in And T out When the bottle is in use, the top of the bottle head is provided with an arc, and no arc exists in other cases.
The specific steps of extracting the circular arc characteristics of the top of the bottle head in the step g are as follows:
(1) Calculation C m All contour points in the inner part have small ordinateContour point (x) on the ordinate of the center of circle i ,y i ) Distance d to the center of circle i As shown in formula (7).
Figure BDA0002796287550000041
(2) Bottle top arc feature extraction
Find d i D is the maximum value of (d) max And a minimum value d min Then, r is calculated according to the formula (8) and the formula (9) in And r out As a top circular arc feature of the bottle head.
r in =R-d min (8)
r out =d max -R (9)
The step h of completing the extraction of the transition characteristics of the arc and the side profile based on the straight line fitting data refers to calculating the absolute value delta of the difference between the slope of the straight line of the profile at the transition position of the arc and the left side profile and the slope of the straight line of the left side profile l Absolute value delta of difference between slope of contour straight line at transition of arc and right contour and slope of right contour straight line r , Δ l And delta r Is a transitional characteristic of arc and side profile. Multiple tests find out the corresponding proper threshold T l And T r
When delta l >=T l When in use, the concave or convex phenomenon appears at the transition part of the arc and the left side profile. K is known according to the outline shape of the left side of the ampoule bottle ls <0. When k is l >0,k l And k ls When the difference value is larger, the concave phenomenon appears at the transition part of the arc and the left side profile. When k is l <=0,k l And when the difference value is larger, the convex phenomenon appears at the transition part of the arc and the left side profile.
When delta r >=T r When the arc is in the transition with the right side profile, the concave or convex phenomenon appears. K is known according to the outline shape of the right side of the ampoule bottle rs >0. When k is r >0,k r And k rs When the difference is large, the transition between the arc and the right side contour is formedThe outward convex phenomenon occurs. When k is r <=0,k r And k rs When the difference value is larger, the concave phenomenon appears at the transition part of the arc and the right side profile.
Thus when delta l And delta r Are all smaller than the corresponding threshold T l And T r When the ampoule bottle is used, the phenomenon that the transition part of the arc of the head of the ampoule bottle and the side profile is concave or convex is avoided, and in other cases, the phenomenon that the transition part of the arc of the head of the ampoule bottle and the side profile is concave or convex is avoided.
In the step h, delta is calculated to finish the extraction of the transition characteristics of the arc and the side profile based on the straight line fitting data l And delta r As shown in formulas (10) and (11).
Δ l =|k l -k ls | (10)
Δ r =|k r -k lr | (11)
In the step i, the ampoule bottle head appearance quality identification based on the arc characteristics and the arc-side profile transition characteristics of the top of the ampoule bottle is that when the arc and the arc-side profile transition position of the top of the ampoule bottle have no concave or convex phenomenon, the ampoule bottle head appearance is qualified, and the ampoule bottle head appearance is unqualified under other conditions.
The ampoule bottle head appearance quality identification specific steps are as follows:
(1) When 0 is<=r in <T in ,0<=r out <T out When the arc exists at the top of the ampoule bottle, the judgment step 2 is carried out, and otherwise, the condition that the appearance of the ampoule bottle head is unqualified is directly judged.
(2) When 0 is<=Δ l <T l ,0<=Δ r <T r When the ampoule bottle head is in the shape of a round arc, the transition part of the round arc and the side profile is not concave or convex, and the appearance of the ampoule bottle head can be judged to be qualified.
The beneficial effects of the invention are as follows: the method for detecting the appearance quality of the head of the medicine ampoule bottle can greatly improve the speed, precision and reliability of automatic detection of the appearance defects of the head of the ampoule bottle, can meet the requirement of batch detection, saves labor and reduces production cost.
Drawings
Fig. 1 is an ampoule head image coordinate system, fig. 2 is an ampoule head appearance image, fig. 2 (a) is a qualified ampoule head image, fig. 2 (b) is a tip ampoule head image, and fig. 2 (c) is a drum head ampoule head image.
Fig. 3 is a flow chart for judging the appearance quality of the head of the ampoule bottle.
Fig. 4, fig. 5, fig. 6 are diagrams of the process of identifying and judging the appearance image of the ampoule bottle head by using the algorithm of the present invention, and fig. 4 (a), fig. 5 (a) and fig. 6 (a) are original images of the qualified ampoule bottle head, the tip head and the drum head respectively; fig. 4 (b), 5 (b), 6 (b) are median filtered images; fig. 4 (c), 5 (c), and 6 (c) are images obtained by image segmentation; fig. 4 (d), 5 (d), and 6 (d) are ampoule bottle head profile views after profile extraction; fig. 4 (e), 5 (e) and 6 (e) are images obtained by fitting a circle to the contour points of the head of the ampoule bottle. Fig. 4 (f), 5 (f) and 6 (f) are images obtained by performing straight line fitting on the contour points at the transition between the arc of the head of the ampoule and the side contour and on the side contour points by using the least square method, respectively.
Detailed Description
The invention will be described in further detail below with reference to the drawings and the specific examples.
The appearance of the ampoule bottle head is divided into three types, the top of the bottle head is provided with an arc, the transition part of the arc and the side profile is provided with a drum head without the phenomenon of concave or convex, and the top of the bottle head is not provided with a pointed head and a flat head with the arc. The appearance of the head of an ampoule without an arc at the top and with spikes at the top or at both sides is called a spike.
The image takes the upper left corner as the origin of coordinates, the first row is positive x-axis to the right and the first column is positive y-axis to the bottom, creating a coordinate system as shown in fig. 1.
As shown in fig. 2 (a), an appearance image of a qualified bottle cap; as shown in fig. 2 (b), a tip appearance image; as shown in fig. 2 (c), a drum head appearance image is shown.
The method for detecting the appearance quality of the head of the medicine ampoule bottle comprises the following specific steps:
step 1: intercepting ampoule bottle head image
The remaining part of the original image of the ampoule bottle from the bottom of the image up to n rows is cut off, and fig. 4 (a), fig. 5 (a) and fig. 6 (a) are obtained.
Step 2: preprocessing cut ampoule bottle head images by median filtering
And removing noise points generated by the influence of the environment on the ampoule bottle head image in the acquisition and transmission process by adopting median filtering, so as to obtain the images (4 (b), 5 (b) and 6 (b).
Step 3: dividing the filtered image using a distance transform and watershed based algorithm;
the filtered image is segmented using a distance transform and watershed algorithm to obtain an ampoule head edge image, as shown in fig. 4 (c), 5 (c), and 6 (c).
Step 4: using Suzuki boundary tracking algorithm to complete contour extraction of the segmented image to obtain ampoule head contour points
And (3) according to the edge image obtained in the step (3), finishing contour extraction by using a Suzuki boundary tracking algorithm to obtain an ampoule bottle head contour point set C, wherein the contour diagrams are shown in fig. 4 (d), 5 (d) and 6 (d).
Step 5: selecting contour points of m rows downwards from the top of the ampoule bottle head, and performing circle fitting by using least square method
Selecting m rows of contour points downwards from the top of the ampoule bottle head to obtain a set C m And the circle fitting is completed on all the contour points by using a least square method to obtain circle center coordinates (A, B) and a radius R, wherein the circle fitting condition is shown in fig. 4 (e), 5 (e) and 6 (e), and the specific steps are as follows:
(1) Principle of selecting contour points
When the camera is fixed, the imaging position of the ampoule bottle head part is relatively fixed. For points (x i ,y i ) In y i The values are ordered from small to large, where y i The point with the smallest value is the highest point of the head. Since only the top of the bottle head has the circular arc feature,selecting a contour point set C of m rows downwards from the highest point of the head m And (5) performing circle fitting.
(2) Least squares circle fitting
1)C m All contour points (x) i ,y i ) Distance from center of circle is lambda i As shown in formula (12).
Figure BDA0002796287550000071
2)C m All contour points (x) i ,y i ) The sum of squares of deviation from the rounded edge P (a, b, c) is shown in equation (13).
Figure BDA0002796287550000072
3) According to the principle of minimizing P (a, B, c), P (a, B, c) is led to calculate partial derivatives of a, B, c respectively, so that the partial derivatives are equal to 0, and the center coordinates (A, B) and the radius R can be obtained by simultaneous calculation of three partial derivatives, so that a fit round equation can be obtained as shown in a formula (14).
(x-A) 2 +(y-B) 2 =R 2 (14)
Step 6: selecting contour points at the transition part of the arc and the side contour points, and respectively performing straight line fitting by using a least square method
Calculating contour point sets corresponding to contours and side contours at the transition positions of the arc and the side contours, and performing straight line fitting on the contour point sets by adopting a least square method to obtain a straight line slope k at the transition positions of the arc and the side contours l 、k r Slope k of side profile straight line ls 、k rs The straight line fitting condition is shown in fig. 4 (f), fig. 5 (f) and fig. 6 (f), and the specific steps are as follows:
(1) Principle of selecting contour points
A set C of contour points selected from the B line to the B+R line and with the abscissa smaller than A L As a contour point at the transition of the arc and the left contour; a set C of contour points selected from the rows B to B+R and with the abscissa larger than A R As a result ofContour points at the transition positions of the arc and the right side contour; selecting a contour point set C from B+R rows to the bottom of the image, wherein the abscissa of the contour point set C is smaller than that of A LS As a left profile point; a contour point set C which is selected from the B+R row to the bottom of the image and has the abscissa larger than A RS As the right side contour point.
(2) Least squares line fitting
1) The straight line formula is fitted as shown in formula (15).
y=kx+b (15)
2) The sum of squares of differences Q (k, b) between the contour points and the fitted straight line is calculated as shown in equation (16).
Q(k,b)=∑[y i -(kx i +b)] 2 (16)
3) According to the principle of minimizing Q (k, b), the Q (k, b) is enabled to calculate partial derivatives of k, b respectively, so that two partial derivatives are equal to 0 and calculated in parallel, the slopes k and b can be obtained, and then a fitting straight line formula can be obtained.
4) For contour point set C L 、C R 、C LS And C RS Respectively performing straight line fitting according to the method to obtain corresponding slope k l 、k r 、k ls 、k rs And corresponding intercept to obtain a straight line y l 、y r 、y ls 、y rs As shown in formula (17).
y l =k l x+b l ,y r =k r x+b r ,y ls =k ls x+b ls ,y rs =k rs x+b rs (17)
Step 7: bottle top arc feature extraction
(1) Calculation C m All contour points with the ordinate of the inner contour point smaller than the ordinate of the circle center (x i ,y i ) Distance d to the center of circle i As shown in formula (18).
Figure BDA0002796287550000081
(2) Bottle top arc feature extraction
Find d i D is the maximum value of (d) max And a minimum value d min Then, r is calculated according to the formula (19) and the formula (20) in And r out As a top circular arc feature of the bottle head.
r in =R-d min (19)
r out =d max -R (20)
Step 8: completing extraction of transition characteristics of circular arc and side profile based on straight line fitting data
Delta is calculated to complete extraction of arc and side profile transition characteristics based on straight line fitting data l And delta r As shown in formulas (21) and (22). Multiple tests find out the corresponding proper threshold T l And T r
Δ l =|k l -k ls | (21)
Δ r =|k r -k lr | (22)
Step 9: appearance quality judgment based on arc characteristics of top of bottle head and transition characteristics of arc and side profile
Ampoule bottle head appearance quality identification based on arc characteristics and arc and side profile transition characteristics of the bottle head top is that when arc and side profile transition positions do not have concave or convex phenomena at the bottle head top, ampoule bottle head appearance is qualified, and ampoule bottle head appearance is unqualified under other conditions.
The ampoule bottle head appearance quality identification specific steps are as follows:
(1) When 0 is<=r in <T in ,0<=r out <T out When the arc exists at the top of the ampoule bottle, the judgment step 2 is carried out, and otherwise, the condition that the appearance of the ampoule bottle head is unqualified is directly judged.
(2) When 0 is<=Δ l <T l ,0<=Δ r <T r When the ampoule bottle head is in the shape of a round arc, the transition part of the round arc and the side profile is not concave or convex, and the appearance of the ampoule bottle head can be judged to be qualified.
From experimentsObtaining T in And T out Are all 2.5, T l And T r Are all 6, and are obtained according to the above judging steps in combination with Table 1, because the head r of the qualified ampoule bottle in And r out Are all smaller than the threshold T in And T out And delta l <T l ,Δ r <T r To sum up, the head of the bottle is considered as a qualified bottle head; tip r in And r out Are all greater than a threshold T in And T out Can be directly identified as an unqualified bottle head; due to the drum head r in And r out Are all smaller than the threshold T in And T out Judging the existence of an arc at the top of the drum head, but determining the delta of the arc l >T l ,Δ r >T r And judging that the transition part of the arc and the side profile has a concave phenomenon, and judging that the drum head is a disqualified bottle head.
TABLE 1 ampoule head offset characteristics and arc and side profile transition characteristics
Figure RE-GDA0002884787170000091
/>

Claims (8)

1. The method for detecting the appearance quality of the head of the medicine ampoule bottle is characterized by comprising the following steps: (a) intercepting an ampoule head image; (b) Preprocessing the intercepted ampoule bottle head image by adopting median filtering; (c) Dividing the filtered image based on distance transformation and a watershed algorithm; (d) Using a Suzuki boundary tracking algorithm to complete contour extraction of the segmented image to obtain ampoule bottle head contour points; (e) Selecting contour points of m rows downwards from the top of the ampoule bottle head, and completing circle fitting by using a least square method; (f) Selecting contour points at the transition positions of the arc and the side contour points, and respectively performing straight line fitting by using a least square method; (g) Extracting the circular arc characteristics of the top of the bottle head based on the circle fitting data; (h) Completing the extraction of the transition characteristics of the arc and the side profile based on the straight line fitting data; (i) Ampoule bottle head appearance quality identification based on arc characteristics and arc and side profile transition characteristics of the bottle head top;
the least square method circle fitting in the step (e) meansSelecting contour points of m rows downwards from the top of the ampoule bottle head to obtain a set C m The circle fitting is completed on all the contour points by using a least square method, and circle center coordinates (A, B) and a radius R are obtained;
the least square method straight line fitting in the step (f) means that contour point sets corresponding to contour points and side contours at the transition positions of the arc and the side contours are respectively obtained, and the straight line fitting is carried out on the contour point sets by adopting a least square method to obtain the straight line slope k at the transition positions of the arc and the left side contours l Slope k of straight line at transition of arc and right side profile r Slope k of left profile straight line ls Slope k of right profile straight line rs
The extraction of the circular arc characteristic of the top of the bottle head in the step (g) refers to the calculation of the maximum distance r from the inner contour point of the circle to the edge of the circle in And the maximum distance r from the contour point of the outer side of the circle to the edge of the circle out As the arc feature of the top of the bottle head; multiple tests find out the corresponding proper threshold T in And T out
The specific steps of extracting the circular arc characteristics of the top of the bottle head are as follows:
12.1 calculation C m All contour points with the ordinate of the inner contour point smaller than the ordinate of the circle center (x i ,y i ) Distance d to the center of circle i As shown in formula (7);
Figure FDA0004180209400000011
12.2 bottle top arc feature extraction
Find d i D is the maximum value of (d) max And a minimum value d min Then, r is calculated according to the formula (8) and the formula (9) in And r out As the arc feature of the top of the bottle head;
r in =R-d min (8)
r out =d max -R (9)
completing the transition between the arc and the side profile based on the straight line fitting data in the step (h)The sign extraction refers to calculating the absolute delta of the difference between the slope of the contour straight line at the transition of the arc and the left contour and the slope of the left contour straight line l Absolute value delta of difference between slope of contour straight line at transition of arc and right contour and slope of right contour straight line r ,Δ l And delta r Is a transition characteristic of an arc and a side profile; multiple tests find out the corresponding proper threshold T l And T r
Delta is calculated to finish the extraction of the transition characteristics of the circular arc and the side profile based on the straight line fitting data l And delta r As shown in formulas (10) and (11);
Δ l =|k l -k ls | (10)
Δ r =|k r -k rs | (11)
the ampoule bottle head appearance quality identification step based on the arc characteristics and the arc and side profile transition characteristics of the top of the ampoule bottle in the step (i) comprises the following steps:
(1) When 0 is<=r in <T in ,0<=r out <T out If yes, the step (2) is carried out, and otherwise, the condition that the appearance of the head of the ampoule bottle is unqualified is directly judged;
(2) When 0 is<=Δ l <T l ,0<=Δ r <T r And when the appearance of the head of the ampoule bottle is judged to be qualified, and otherwise, the appearance of the head of the ampoule bottle is judged to be unqualified.
2. The method for detecting the appearance quality of the head of a medical ampoule bottle according to claim 1, wherein: the cutting of the ampoule bottle head image in the step (a) is to cut the rest part of the upper n rows from the bottom of the ampoule bottle original image G to obtain an image G 1
3. The method for detecting the appearance quality of the head of the medical ampoule bottle according to claim 2, wherein: the image filtering in the step (b) adopts median filtering to the image G in the process of acquisition and transmission 1 Noise points generated by environmental influence are removed to obtain an image G 2
4. A method for detecting the appearance quality of the head of a medical ampoule bottle according to claim 3, wherein: the image segmentation in the step (c) uses a distance transformation and watershed algorithm based segmentation image G 2 Obtaining ampoule bottle head edge image G 3
5. The method for detecting the appearance quality of the head of the medical ampoule bottle according to claim 4, wherein the method comprises the following steps: the image is segmented based on the distance transformation and watershed algorithm, namely, the image G is segmented firstly 2 Obtaining a marked image S by using a distance transformation algorithm, dividing the image by using a watershed algorithm is a process of simulating overflow, and the image G is paired with the water injection point obtained by the marked image S 2 Filling water, gradually submerging the catchment basins, and obtaining the expected ampoule bottle head edge image G when water in different catchment basins meets the limit 3
6. The method according to claim 5, wherein the contour extraction in the step (d) uses a Suzuki boundary tracking algorithm to image G 3 And (5) finishing contour extraction to obtain an ampoule bottle head contour point set C.
7. The method for detecting the appearance quality of the head of the medical ampoule bottle according to claim 1, wherein the specific least square method circle fitting step is as follows:
8.1 principle of selecting contour points
The image takes the upper left corner as the origin of coordinates, the first row is right in the positive x-axis direction, and the first column is downward in the positive y-axis direction, so as to establish a coordinate system; for points (x i ,y i ) In y i The values are ordered from small to large, where y i The point with the minimum value is the highest point of the head; selecting a contour point set C of m rows downwards from the highest point of the head m Performing circle fitting;
8.2 least squares circle fitting
1)C m All contours inPoint (x) i ,y i ) Distance from center of circle is lambda i As shown in formula (1);
Figure FDA0004180209400000031
2)C m all contour points (x) i ,y i ) The sum of squares of the deviations from the rounded edges is P (a, b, c), as shown in formula (2);
Figure FDA0004180209400000032
3) According to the principle of minimizing P (a, B, c), enabling P (a, B, c) to obtain partial derivatives of a, B and c respectively, enabling the partial derivatives to be equal to 0, and simultaneously calculating three partial derivatives to obtain a circle center coordinate (A, B) and a radius R, and further obtaining a fitting circle equation, wherein the fitting circle equation is shown in a formula (3);
(x-A) 2 +(y-B) 2 =R 2 (3)。
8. the method for detecting the appearance quality of the head of the medical ampoule bottle according to claim 1, wherein the specific step of least square straight line fitting in the step (f) is as follows:
10.1 principle of selecting contour points
A set C of contour points selected from the B line to the B+R line and with the abscissa smaller than A L As a contour point at the transition of the arc and the left contour; a set C of contour points selected from the rows B to B+R and with the abscissa larger than A R As a contour point at the transition of the arc and the right contour; selecting a contour point set C from B+R rows to the bottom of the image, wherein the abscissa of the contour point set C is smaller than A LS As a left profile point; a set C of contour points selected from the B+R row to the bottom of the image and with the abscissa larger than A RS As a right side contour point;
10.2 least squares Linear fitting
1) Fitting a straight line formula as shown in formula (4);
y=kx+b (4)
2) Calculating the square sum Q (k, b) of deviation of the contour points and the fitting straight line, as shown in a formula (5);
Q(k,b)=∑[y i -(kx i +b)] 2 (5)
3) According to the principle of minimizing Q (k, b), respectively solving partial derivatives of k and b by Q (k, b), enabling two partial derivatives to be equal to 0 and calculating in parallel, obtaining slopes k and b, and further obtaining a fitting straight line formula;
4) For contour point set C L 、C R 、C LS And C RS Respectively carrying out straight line fitting according to the method to obtain a corresponding slope k l 、k r 、k ls 、k rs And corresponding intercept to obtain a straight line y l 、y r 、y ls 、y rs As shown in formula (6);
y l =k l x+b l ,y r =k r x+b r ,y ls =k ls x+b ls ,y rs =k rs x+b rs (6)。
CN202011332783.5A 2021-01-06 2021-01-06 Method for detecting appearance quality of head of medical ampoule bottle Active CN112577967B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011332783.5A CN112577967B (en) 2021-01-06 2021-01-06 Method for detecting appearance quality of head of medical ampoule bottle

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011332783.5A CN112577967B (en) 2021-01-06 2021-01-06 Method for detecting appearance quality of head of medical ampoule bottle

Publications (2)

Publication Number Publication Date
CN112577967A CN112577967A (en) 2021-03-30
CN112577967B true CN112577967B (en) 2023-05-16

Family

ID=75123262

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011332783.5A Active CN112577967B (en) 2021-01-06 2021-01-06 Method for detecting appearance quality of head of medical ampoule bottle

Country Status (1)

Country Link
CN (1) CN112577967B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113538489B (en) * 2021-07-19 2022-09-09 武汉纺织大学 Method for measuring fiber diameter of non-woven fabric

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103018253A (en) * 2012-11-30 2013-04-03 湖南大学 Method for detecting ampoule bottle appearance quality through medical visual inspection robot
CN104657977A (en) * 2014-12-10 2015-05-27 天津普达软件技术有限公司 Method for positioning center of bottle body of bottle parison
CN105157563A (en) * 2015-04-28 2015-12-16 湖南大学 Beer bottleneck positioning method based on visual sense of machine
CN106251352A (en) * 2016-07-29 2016-12-21 武汉大学 A kind of cover defect inspection method based on image procossing
CN106875441A (en) * 2016-12-20 2017-06-20 浙江工业大学 A kind of online PE bottles of recognition positioning method based on machine vision
CN110220917A (en) * 2019-06-11 2019-09-10 江苏农林职业技术学院 A kind of crown plug surface defect online test method based on image procossing
CN111311618A (en) * 2018-12-11 2020-06-19 长春工业大学 Circular arc workpiece matching and positioning method based on high-precision geometric primitive extraction

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8275182B2 (en) * 2007-09-27 2012-09-25 The University Of British Columbia University-Industry Liaison Office Method for automated delineation of contours of tissue in medical images

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103018253A (en) * 2012-11-30 2013-04-03 湖南大学 Method for detecting ampoule bottle appearance quality through medical visual inspection robot
CN104657977A (en) * 2014-12-10 2015-05-27 天津普达软件技术有限公司 Method for positioning center of bottle body of bottle parison
CN105157563A (en) * 2015-04-28 2015-12-16 湖南大学 Beer bottleneck positioning method based on visual sense of machine
CN106251352A (en) * 2016-07-29 2016-12-21 武汉大学 A kind of cover defect inspection method based on image procossing
CN106875441A (en) * 2016-12-20 2017-06-20 浙江工业大学 A kind of online PE bottles of recognition positioning method based on machine vision
CN111311618A (en) * 2018-12-11 2020-06-19 长春工业大学 Circular arc workpiece matching and positioning method based on high-precision geometric primitive extraction
CN110220917A (en) * 2019-06-11 2019-09-10 江苏农林职业技术学院 A kind of crown plug surface defect online test method based on image procossing

Also Published As

Publication number Publication date
CN112577967A (en) 2021-03-30

Similar Documents

Publication Publication Date Title
CN110220917A (en) A kind of crown plug surface defect online test method based on image procossing
CN104504388B (en) A kind of pavement crack identification and feature extraction algorithm and system
CN106251352B (en) A kind of cover defect inspection method based on image procossing
CN106052575B (en) Online test method is worn away based on the pantograph carbon slide in train high-speed cruising
CN110211093A (en) A kind of water outlet control method for automatic drinking water apparatus
CN104537651B (en) Proportion detecting method and system for cracks in road surface image
CN112577967B (en) Method for detecting appearance quality of head of medical ampoule bottle
CN106373140B (en) Transparent and semitransparent liquid impurity detection method based on monocular vision
CN102445456A (en) Device and method for nondestructively detecting egg quality based on DSP (Dynamic Signal Processing) machine vision
CN104122271A (en) Automated optical inspection (AOI)-based bullet apparent defect detection method
CN104282018A (en) Method for on-line detection of overall diameter of industrial product based on machine vision
CN111862055B (en) Bubble turning cavity defect detection method based on image processing
CN105205437B (en) Side face detection method and device based on contouring head verifying
CN101315338A (en) Defect detecting system and method for glass product
CN116612123B (en) Visual detection method for peanut oil processing quality
CN103679146A (en) Safety belt intelligent detection method based on high-pass filter and Hough conversion
CN106651837A (en) White glass plate surface edge breakage defect detecting method
CN114022483B (en) Injection molding flash area identification method based on edge characteristics
CN115311294A (en) Glass bottle body flaw identification and detection method based on image processing
CN103759644A (en) Separating and refining type intelligent optical filter surface defect detecting method
CN109724988A (en) A kind of pcb board defect positioning method based on multi-template matching
CN111766245B (en) Button cell negative electrode shell defect detection method based on machine vision
CN114565848B (en) Liquid medicine level detection method and system in complex scene
CN112884746A (en) Character defect intelligent detection algorithm based on edge shape matching
CN104112123A (en) Defect characteristic extraction and identification method of AOI system used for bullet apparent defect 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
GR01 Patent grant
GR01 Patent grant