Research of the Defects in Anesthetic Masks

The article concerns the computer-assisted vision system created for the detection of the disposable anesthetic respiratory masks. This article provides the classification of defects which may be common to both rubber and plastic parts of the masks. The defects were divided into groups and the nature of them was investigated. The algorithms and methods for the detection of defective products were based on the segmentation of image and the detection of uneven contours. The experiment results are presented in this work. With reference to the results, the most effective masks’ filters were identified. The achieved specificity of the algorithm is 100 % and the sensitivity is 100 %.


Introduction
Image recognition systems due to their adaptability and the possibility to analyze the data continuously became especially popular in the 21c.The image processing algorithms (segmentation based on the threshold [1], spatial transformations [2], edge detection [3], classification methods [4]) together used with electronic optical systems [5], [6] enable to ensure rather good results in the image search.The image detection and object separation still remains a rather wide field for the scientific research.
Due to their versatility the systems of image observance and processing [7][8][9] are widely used for the industrial decisions.The especially promising area of application are the systems of automated image control, enabling to save or even absolutely refuse the usage of human resources.The automation is becoming more and more used in such areas as agriculture, transport, food and other industries.Computer vision systems are applied in the quality control of sweets, geometrical parameters, automated sorting of packages and, as well for the quality control of other food packages [10].In the timber industry the quality control is used in the detection of defects in the wood cuttings [11].The processing of images is applied by manufacturers both for the production of glass and plastic containers, for identifying the defects in shape, form, inap-propriate labels or inadequate liquid level [12].In the agriculture such system enables to identify ripe fruit or pests [13], as well rice are inspected [14], which may be classified according to their shape, size and color.
Image segmentation was used for the development of imaging system.The result of image segmentation is a set of segments that collectively cover the entire image or a set of contours extracted from the image.Image segmentation is used in a variety of algorithms.Gajendra Singh Chandel, Ravindra Kumar, Deepika Khare and Sumita Verma, et al. [15] considered the techniques under the following five groups: Edge-based, Clustering-based, Region-based, Threshold-based and Graph-based.Image processing systems also use machine learning algorithms.Machinelearning is an active research area within artificial intelligence that focuses on the design and development of new algorithms that allow computers to reason and decide based on data [16].The most commonly used machine learning classifiers -Bayesian Networks, Decision Trees, K-Nearest Neighbor, Support Vector Machines.The specificity and sensitivity of machine learning classifiers usually reaches up to 98 % [16][17][18][19].
Defect detection of visual material is very important to determine the edges.An edge may be defined as a set of connected pixels that forms a boundary between two image regions.Edge detection is basically a method of segmenting an image into regions of discontinuity.Various techniques are used for different defects recognition.The most commonly used edge detection techniques are Prewitt, Robert, Sobel, Marr Hildrith and Canny operators [20].
While analyzing the works of the contemporary authors the main phases of the automated computer vision functioning may be distinguished:  Image capture;  Image processing and analysis;  System communication and actions based on the results of analysis.
Tomislav Petkovic, et al. [21] tried to classify different defects, which occur in the production of the plastic surgery.The article mainly deals with the analysis of the necessity of the product shape analysis and how the surface defects on the plastic are identified.The process of defect detection starts with the image capture.An especially good contrast is achieved between the dark opaque object and the background lighting itself using the appropriate illumi-nation.The captured images go through the segmentation in accordance with the threshold value.The detected marginal values are combined into a vector model.These vectors are compared with prototypes.The result of the algorithms analysis is the defect positions and other characteristics, which, as well are compared with the product standard.Most development phases of the algorithms' designing were successfully tested with a limited number of samples.Bin Liu and Shengjin Wu, et al. [22] analyzed the automated computer vision systems in their research.The analysis of the necessary components for the algorithms of such systems is presented.Different lighting systems are chosen according to the nature of the defects.The most uniform lighting is achieved using the LED lights.Another important part of the system is a camera capturing the image.Nowadays the most frequently used cameras are with CCD (Charge Coupled Device) sensor.They can be characterized as having high image information processing speed while analyzing the image in a one-dimensional array form, i.e. the analysis is carried out immediately not for the full image.Using the appropriate algorithms helps to increase the object contrast which serves for the better investigation in the exclusion of its edges areas.The image segmentation is implemented for the identification of defects.All the separate modules are combined into one system, controlled by one main computer, eliminating the people work at product verification.Niky K. Jain, S. O. Khanna, Kavindra R. Jain, et al. [23] presented the examples of the computer vision application in the rice industry in their article.Usually rice is sorted and their quality is verified by the human resources.However, the main rice exporting countries are increasingly installing the image processing systems for the quality assessment of the rice kernels.In order to detect the defects, first of all, the rice cultures were distinguished into separate groups, according to the regions, where they are grown.This determines what defects are being searched for.As well the shape of the kernel itself differs.The succession of the processing is similar to the algorithms used in other spheres.After the experiments carried out the scientists conclude that work which is performed by people may be replaced by the computerized image processing system applying neural networks for the defect search.
Sivabalan, et al. [24] presented the attempts to identify the tissue defects using the image control system in the article.Different segmentation techniques of properties' exclusion are used to identify the defects in black and white digital images.The minimal, maximal and average values are calculated separately for each image's frame line.The averaging is necessary to eliminate the high frequency components.The image with low frequency components is used for the detection of defects.The abrupt change of the point intensity compared with the neighboring points or averaged value of all the lines are used.Point with an abrupt change, which difference with the average value of the line reaches about 60, is attributed to the defective field.The process of comparison detects points, which values are equal to zero in such a way making the detection of defects' algorithms faster.
In this paper, we present the research of the defects as well as the quality inspection of anesthetic masks.The review of already published works is presented in Sec. 1. Section 2 provides information about the types of masks' defects.Based on defects nature the algorithms are analyzed in Sec. 3. The experimental results are presented in Sec. 4. Discussion is made in Sec. 5, and Conclusions are given in Sec. 6.

Types of Defects in the Anesthetic Masks
Defects, which occur in the anesthetic masks, usually settle during the phase of casting and they can be divided into separate groups depending on their nature: holes both in the rubber and plastic parts of the mask (Fig. 1(a), Fig. 1(b)), parts of the mask which were insufficiently molded (not covered enough) or over-molded (covered too much) (Fig. 1(c), Fig. 1(d)), the defect in the inner rubber part contour's wholeness of the mask (Fig. 1(e)), detection of defects in the rubber -plastic contact areas (Fig. 1(c)) and, as well the detection of blobs, which occur on the plastic part of the mask (Fig. 1(a)).In general the mask defects can be divided into two main groups:  Holes on the rubber and plastic part of the mask, and blobs on the plastic part;  Insufficiently covered or over-molded parts of the mask with rubber and the uneven areas in the rubber part contour of the mask.

Methods
If any of the mentioned cases in Sec. 2 appear on the mask, it is considered as inappropriate to use.The investigation of masks' defects was divided into the following stages:  Investigation for holes and blobs, and The detection of unevenly molded areas with rubber and contour splits.
In the first case, the detection of holes was divided into two phases:  Investigation of holes in the rubber part of the mask;  Investigation of holes in the plastic part of the mask.
For the case when holes are in the rubber mask part, the algorithm is based on the segmentation with reference to the method of the threshold value.The rubber part of the mask is opaque and this leads that it remains dark while capturing it with the black and white camera (image consists of 256 levels of gray).In this zone it is aimed to distinguish light areas.The algorithm (Fig. 2) consists of the image capturing and its segmentation.
First of all the mask was captured by the camera.Then a chosen characteristic digital image area is cut out (Fig. 2(a)) and it is used in the further detection of the defect.Then the image segmentation is carried out (Fig. 2(b)) for the detection of the rubber mask.All the cavities of the found region are filled (Fig. 2(c)) and in such a way a homogeneous field is created.If several different regions are detected, the biggest one is chosen (Fig. 2(d)) as the analyzed sphere.The chosen region is cut out (Fig. 2(e)), the search for defects is carried out in this area.Defects are identified as light areas in the dark part of the rubber mask (Fig. 2(f)).

The detection of holes in the plastic mask part is based on the segmentation according to the threshold value, but it is affected by several factors:
 There are some manufacturer's markings on the plastic part;  In terms of ergonomics the roughened opaque areas on the mask are made for the convenience reasons in using the mask.The opaque areas are thicker compared with the remaining mask's surface and such areas in 100 cases of analysis were determined as problematic in all 100 cases.After the assessment that there were no defects detected, they were eliminated from the other research (Fig. 3).
The digital image captured by the camera is provided for the analysis of a mask.In order to reduce the analysis duration the image is cut out.The area cut shall embrace such an image that it would be possible to find a one-piece contour of the mask.Later only this area will be investigated.The mask in the system is always positioned in one and the same way.The possible error is up to 1°.Later the segmentation with reference to the threshold value is carried out.The black and white image captured consists of 256 shades of gray.The region distinguished in many cases can have cracked edges, because in the marginal parts of a mask due to the reflections, form/shape, the thickness of plastic changes, the level of gray in plastic may change.In order to ensure the smoothness of the distinguished area, the region marginal areas are fulfilled, which did not appear in the region part after the segmentation.As a result the expanded area with not only plastic, but as well rubber part of the mask appears in the sector.For the optimization the region is reduced so that it would not include the rubber part of the mask and the marginal zone between rubber The algorithm estimates holes in the masks plastic part when they are not in a peripheral part of it.If the defect is located on the edge of the analyzed region, the algorithm cannot find it.However, these defects are detected using multiple images.These image areas overlap and the whole mask's surface is analyzed.
A characteristic plastic area's image is cut out from a mask according to the region obtained.Blobs are searched for using the segmentation based on the threshold value.Accepting the condition that holes are usually round in shape, the searching for oval zones is carried out in accordance with the calculation of circularity.
The chosen areas are fulfilled and filtered according to their size assessing the biggest possible cavity on the surface of a mask.The latter values are determined throughout the analysis of the real manufacture defects.
The rubber part of a mask is the main zone of the defects in the group of the unevenly covered areas.The insufficient or too intensive amount of rubber covering on the plastic determines the problems of the mask tightness.The defect of the inner rubber contour's unevenness can be attributed to these defects.A few methods can be used for the analysis of the masks in the rubber part:  Comparison of the captured mask image with the example of a standard;  Analysis based on the division of the analyzed object into smaller-scale zones, assessing their reciprocal changes;  Using the smooth side.
The first algorithm requires that each type of the mask in the data base should have standard images, which could be used for the comparison of the mask analyzed.The mask is divided into small regions, where the analysis for marginal mask contour values is carried out.First of all the data of the standard mask is saved, the filter training is performed.After that, the differences between the standard and analyzed masks are calculated.According to the 2 nd algorithm, in each of zones the characteristic side should be found and the distance from the side to the upper frame part is calculated, as well the derivatives are calculated (Fig. 4).When the threshold value of the defects is determined, the problematic areas are detected.
However, this method does not practically react to slow changes in the side changes.Moreover, if the analyzed zones are especially small, it is not always possible to distinguish the marginal rubber zone's area (it is especially relevant when using a low resolution image camera).
The third algorithm (Fig. 5) uses the smooth side for the detection of the uneven areas filled with rubber and cracks in the rubber part of the mask.Firstly, the marginal rubber contour is distinguished from the rubber area.Then all the points of the curve are identified.The curve is smoothed.The smoothed curve is more similar to the ideal analyzed contour (i.e.without defects).By comparing these both curves, the defect areas are detected.The defect's threshold value should be taken into account.
During the investigation this sphere encompassed half of the mask's contour.The analysis is carried out in separate mask's contour parts due to the mechanical parts of the system (mask holder) and the simplification of the algorithm.
Firstly the image segmentation is carried out; then light regions are found according to the provided threshold value (Fig. 5(a)) in the analyzed area.The necessary region is chosen which adjoins with the inner rubber part contour (Fig. 5(b)).Then a digital extension is implemented so that the same area would occupy the edge of the mask (Fig. 5(c)).Later an image is cut out (Fig. 5(d)) according to the found region and the search for its contour according to the [25] method (Fig. 5(e)) starts.The contour most suitable in length is chosen (Fig. 5(f)).Next step is the smoothing of the contour (Fig. 5(g)) while selecting at a certain step the contour points and the averaging of its side is implemented.In such a way a side which is very close to the perfect contour side is achieved.
When a real mask contour is available and when the smooth contour is found, it is necessary to calculate the distance between these curves.The wholeness of the mask contour is analyzed after dividing it into smaller areas where in each of the areas the distance between the contour curves is calculated.For the calculation, a curve, which is perpendicular to the vector connecting the side points (Fig. 6 -AB), is drawn.Then two intersection points of the latter curve are found with:  a real contour of the mask,  a smoothed contour of the mask.
According to the obtained curve length between these points, the defect of uneven contour is detected.The dis-tance between the real and smooth contours is assessed depending on the desired detection accuracy of the defect.When using a high quality camera (in the experiment Basler acA2500-14um camera with 5 megapixels sensor was used) a great number of points was found, thus, to assess the defects in each point is inexpedient.Fig. 6 shows two points (A and B) of the smooth curve, where we look for the distance between the curves.For this purpose one more curve is drawn which intercrosses with the curves of the contour curves.The inclination angle x ( ABD  ) is calculated according to (1): where the length of vector AB is

Experimental Results
The automated computer vision system was used for experimental research.The final system consists of two main parts, i.e. software and hardware (Fig. 7).The black and white camera Basler acA640-90gm with a CCD sensor and resolution of 659 px × 494 px was used in the system.It supports the PoE standard.Camera resolution in millimeters depends on the size of the analyzed mask.When working with a EcoMask 0 size mask 1 mm 2 of the real object (the mask) corresponds to ~ 23 pixels, while with the largest mask to ~ 7 pixels.The wide angle lens Ricoh H614-MQ was used.For the purpose of the even lighting of the analyzed object the illuminator Falcon FLF-Si250 LED was used.The controller GARDASOFT RT820F-2 was used for the lighting control.The stepper motors Oriental motor AR26SAKD-3 and Oriental motor CRK564AKD -T20 were used for the mask positioning.The chosen components are widely used in the industry.Qualities and the high level of the reliability determined the choice of this equipment.
The mask holders with stepper motors are attached to the linear gears for their positioning.When a robot places the mask on the holder and after receding the system receives a signal about the mask's placing.If a mask is placed correctly, the optical sensor as well gives a signal and with a usage of the linear gear the mask is placed inside the system for an analysis.The mask is positioned due to the assistance of the stepper motors, while the necessary positions are determined from the user's interface.
The program was written in C# programming language.MVTec's Halcon software program packet libraries were used in the realization of filter in order to ensure the stable functioning of the algorithms.
The accuracy of the method is estimated as a ratio of detected defects to all existing defects.It is conditioned by the threshold value in detecting the defects dependable on the level of gray in the rubber area.First of all, the algo-   rithm is tested using synthetic defects to determine the rubber gray level.Defects are detected as the bright areas.LED lighting is used operating in pulse mode.In such case, the maximum illuminance is reached, which lets avoid surrounding lighting influence on the masks.The exposure time is set to 800-1300 µs and the average gray level of masks is 180, while the defect gray level is 30 (Fig. 8).These values must be chosen according to the masks color.Different mask color requires different exposure time.
The experimental results of the holes in the rubber are presented in Tab. 1.
The holes found on the plastic mask part are combined into one region and their quantity is calculated.The result obtained is displayed on the raw image captured by the camera (Fig. 9).The defects in the plastic part are detected according to the algorithm (Fig. 2) using different parameters of the segmentation.According to the latter algorithm the programme was created and used for different types of masks (2 types, 6 sizes, 11 colors [26], [27]).It was identified during the research that general algorithm reliability is 95.08 %.Additionally, if combining the lighting system (lighting source intensity, duration of the camera exposure) and selecting more accurate values of the segmentation threshold (the marginal value of the gray level in the rubber area is ≤ 100, holes ≥ 120) the reliability average reaches 99.9 %.Tab. 1 The experimental results of the holes in the rubber algorithm investigation.
For the investigation of the defect detection algorithm in masks' rubber part -the comparison of the captured mask image with the example of a standard-size 6 mask was used.The width of the quality mask was measured, which was considered as a standard and, as well two defective masks were measured.The diagrams of the measurement results are shown in Fig. 10.
For the algorithm of the defect detection it is necessary to have supporting (standard) values, according to which the mask's defectiveness could be assessed.The marginal value of the rubber width difference between the standard and defective masks in image points (pixels) is defined after some measurements are implemented.The diagrams of such measurements are presented in Fig. 11.According to the latter data, the regularities of the contour wholeness change may be identified.Figures 10 and 11 illustrate clearly the difference of width in defective and standard rubber masks.However, the immediate change of rubber width practically remains not assessed while analyzing the internal and external mask's contour which occurs at the juncture of rubber and plastic.Before determining the defect's marginal value, the difference between the defects of a mask shall be inspected.Whereas they are not identically the same, the standard values can be received after averaging the widths of the masks without rubber (for this purpose several quality masks shall be used).The difference of two standard masks' rubber width is presented in Fig. 12.
When the difference of the rubber width is less than 1 pixel, it is not a sufficient condition for evaluation.
The method of the defect detection according to the width of the rubber functions rather accurately.However, it requires a precise positioning, as well the standard values shall be found and stored.Moreover, the selection of the region positioning coordinates is rather elaborate and it is performed manually.
The repeatability measurements of the proposed system were carried out with the same mask 10 times (Fig. 13).The mask was placed, then the image was triggered, and finally the mask was removed.
Due to the lack of positioning precision the mask rotates each time when the image is captured.The mask rotation on the holder depends on the size of the mask.It varies from 2° for small masks up to 5° for the largest ones.As a result, there is the displacement of the measured rubber width (Fig. 13).
Using the inclination angle of the curve, a straight line is drawn crossing the contours (Fig. 6).According to the coordinates of the vector, its length can be calculated.The defects are detected while comparing this length with the allowed deviation.During the experimental research the defect limit was assessed -3 pixels.When the difference between the real and smooth contours is bigger than the latter value, the product is considered as defective.
A case of the uneven contour is possible, when a drawn curve crosses the mask's contour in two points.Then an array of the straight line and contour intersection  points is achieved.Such an array is verified and the correct point value is selected, through which a straight line is drawn, which is used in the analysis.The considered correct array element is the element closer to coordinates of the point, through which a line between real and smooth contour was drawn for the purpose of assessment.
A smooth contour is used for the check of the internal contour, which is compared with the real contour of the analyzed mask.The curve is smoothed using not all the points from the previously detected curve due to the sensitiveness of the contour's unevenness.The intensity of smoothness is chosen according to the particular analysis carried out in a real time.The smoothed curve is more similar to the ideal analyzed contour (i.e.without defects).This method does not require an additional image of the standard mask.The experimental research was carried out and during it the marginal values the defects were assessed (Fig. 14).This method also can be used for the analysis of the mask areas with insufficient rubber molding.This algorithm is characterized as having a high speed and accurate identification of defects.
The system was installed in the real industrial production.Its efficiency was tested not only with synthetic defects.The statistical analysis of the data is provided in the user's interface.Statistical information is meant to follow the amounts of the analyzed masks with defects or quality masks and to assess their interrelationship, calculating the production efficiency.Such data as the mask's type, size, analysis result and its duration are provided together with the above mentioned information.
The system working together with the robot analyzed 7101 masks.The specificity of the computer vision system is calculated according to (2): 7051 100 % 100 % 0 7051 Specificity     . ( The efficiency result is shown in Fig. 15.In 50 defective masks only 26 were identified as having real defects.In all the other cases the system was wrong.According to the mentioned results, the sensitivity is as given below: (3) In 14 images out of 24 the same error was identifiedthe detection of defects in the area of the rubber and plastic juncture (desired defect -"blots" and holes in the plastic).The functions of the region extension and reduction were used as the solutions for such errors.First of all, the region extension is carried out, in order that no cracks would be left in the plastic part of the mask after the plastic distinction.The next step takes the reduction of the analyzed area so much that no rubber mask area would be left in the region.After improvement, the same 14 masks were analyzed and no defects were detected.In other 10 the incorrectly identified defects were detected while investigating the unevenness of the internal mask contours.After assessing the saved result of the analysis it was determined that the latter defects are incorrectly identified due to the mask positioning errors.It is related with the mask holder, which will be improved with the next system update.Taking into account that it is mask positioning error, the achieved sensitivity of the updated algorithm is 100 % : During the system development the several of methods have been used for defect detection.The developed automated computer vision system analyzed 7101 masks.After initial evaluation the sensitivity of the algorithm was 52 %.However, the further investigation with the improved algorithm let the system to reach the sensitivity of 100 %.

Conclusions
This work presents the algorithms for the analysis of the anesthetic masks surface defects.The algorithms were created, which were determined as optimal for the image amount.An appropriate mask position to each of these images is determined.With reference to them, 90% of the mask surface is analyzed.It is assessed that the remaining surface is not informative (manufacturer's logo, or the joint of opaque and transparent plastic).
When the system was installed in the real production line, its work was synchronized with a robot.It was defined that positioning occupies 95 % of all the time of the analysis session of one mask.The rest of the time is spent on the image capturing and analysis of defects.The average mask analysis takes 18 seconds at a maximal robot's speed.
The described computer vision system showed good results.The sensitivity of the algorithm has been increased from 52 % to 100 % and achieved specificity is 100 %.
The updated mask holder will let to eliminate masks positioning errors and avoid the variation of the mask rubber width.Future work will mainly cover research and analysis of machine learning classifiers with the updated system.
The system advantages defined and distinguished are the following: high level of accuracy, autonomy and the presentation of the real-time analysis results.

Fig. 1 .
Fig. 1.Examples of the anesthetic masks' manufacturing defects: (a) blobs and holes in the plastic area of the mask in illustration; (b) holes in rubber; (c) rubber fluxes on the plastic part of a mask; (d) the part which was not sufficiently covered with rubber; (e) the defect of the inner contour wholeness.

Fig. 2 .
Fig. 2. The simplified algorithm for the detection of the holes in the rubber part of the mask: (a) a part of the image is cut out, (b) operation of the threshold segmentation, (c) region filling, (d) selection of the characteristic region, (e) cutting out a certain area, (f) determination of defects.

1 2 Fig. 3 .
Fig. 3.The mask areas not analyzed (image is given from the inner side of a mask). 1 -opaque areas of the mask; 2 -mask size and manufacturer initials' markings.andplastic.The background, rubber part of the mask and opaque areas are filtered.

Fig. 4 .
Fig. 4. One of the analysis' methods is to divide the object into small zones and search for the change among these zones.

Fig. 5 .
Fig. 5.The simplified algorithm to find the cracks in the rubber part of mask: (a) image threshold segmentation, (b) selection of the characteristic region, (c) digital extension of region, (d) the chosen part is cut out, (e) the chosen area contours are found, (f) the necessary contour is chosen, (g) the chosen contour smoothening, (h) difference between the real and smoothed contours.

Fig. 6 .
Fig. 6.The detection of the difference between real and smooth contour curves.

Fig. 8 .
Fig. 8.The defect of the anesthetic mask -a hole in the rubber part.The intensity of hole significantly differs from the intensity in the rubber part of the mask.

Fig. 9 .
Fig. 9.The analysis' result displayed.The detected cavity in the plastic area is marked by a certain color.

MVTec' s
Halcon software offers several techniques for sub-pixel precise edge detection and line extraction including:  Canny, Deriche, Lanser and Sobel edge detectors;  Facet model and Steger line detectors with the accuracy of up to 1/50 pixel;  Subpixel threshold.

Fig. 10 .Fig. 11 .
Fig. 10.Measurement results of the rubber part in a mask.

Fig. 12 .Fig. 13 .
Fig. 12. Difference in the rubber width of the two standard masks.