Summary of the invention
Present invention solves the technical problem that are as follows: it overcomes the shortage of prior art, provides a kind of based on matlab image procossingSurface mounting component counting method is based on matlab software development, carries out control to manual counting method and improves with emulation technology, realizesSurface mounting component material image in bulk is checked.
The technical solution that the present invention solves are as follows: a kind of material counting method based on matlab image procossing, steps are as follows:
(1) it using electronic product component as material, shoots material image and inputs;
(2) using segmentation counting method, the material image information of step (1) input is analyzed, identifies material imageIn active parts;
(3) gray processing processing carried out to step (2) active parts image, then by gray processing treated active parts imageIt is converted into only black and white image;
(4) binarization method is used, binary conversion treatment is carried out to the black and white image of step (3), obtains binary mapPicture;
(5) bianry image of step (4) is subjected to Morphological scale-space, i.e., obtained bianry image is corroded, inwardlyCorrode N number of pixel, then expand M pixel outward again, wherein (N ﹥ M), removes the interference in bianry image, until seeingAdjacent effective material boundary generates apparent objective contour in bianry image;
(6) pixel detection in connected domain is a target by the label connected domain of last adjacent active parts, final to countDestination number out realizes checking for material as active parts quantity.
Preferably, material image is material similar in surface mounting component and other forms;Material image, be surface mounting component andThe image photograph of material similar in other forms:
Preferably, active parts, specifically: according to the target devices that the extracted Pixel Information of device identifies, with areaNot in other objects.
Preferably, the material image of reading is analyzed, identifies the active parts in material image, specifically: it willIt wants the active parts in material to be identified to separate from material image by extracting feature, identifies active parts.
Preferably, by gray processing, treated that active parts image is converted into only black and white image, specifically: choosingTake a threshold value as the line of demarcation for handling black and white image, if the gray scale of gray processing treated image pixel is if be less thanThe threshold value, then be set as black, and use 0 indicates;Otherwise, it is set as white, use 0 indicates.
Preferably, after carrying out gray processing processing to step (2) active parts image, by gray processing treated effective deviceBefore part image is converted into only black and white image, the contrast of image after adjustment gray processing processing is that is, bright in adjustment imageThe disparity range of dark areas brightness level, so that the image information of active parts is more obvious.
Preferably, using binarization method, specifically: it is automatic from black and white image using Otsu threshold method (Otus)It chooses, i.e., is chosen using the maximum automatic Selection of Image Threshold of inter-class variance, form bianry image.
Preferably, adjacent active parts boundary generates apparent distance, specifically: it is the distinguishable distance out of human eye.
Preferably, connected region is detected as 1 target, preferably are as follows: by all pixels connected region in connected regionIt is detected as 1 target.
It preferably, is a target by pixel detection in connected region, specifically: if there is 8 pixels or more in connected domainIt connects together, decides that it is position where an active parts, that is, determine an active parts.
Preferably, material includes surface mounting component, standard component.
Preferably, material image is preferably that device in bulk (i.e. material) is placed horizontally at the station for being laid with antistatic mat applyingOn, the normal of camera focal plane is shot perpendicular to desktop, and the image of shooting is required with this.
The advantages of the present invention over the prior art are that:
(1) a kind of material counting method based on matlab image procossing of the invention proposes to open based on matlab softwareHair carries out control to artificial counting method and improves with emulation technology, realizes the technical solution of material image counting method.
(2) it is artificial to improve conventional bulk material for a kind of material counting method based on matlab image procossing of the inventionCounting method realizes that automation is checked;
(3) a kind of material counting method based on matlab image procossing of the invention, improving material check efficiency, reduceMaterial checks the time, avoids material quantity mistake of statistics;
(4) a kind of material counting method based on matlab image procossing of the invention will be read by " segmentation counting method "The image taken is split, and by the analysis to input picture, the material that will be checked identify simultaneously certainly by feature extractionDynamic label.
Specific embodiment
The present invention is described in detail with specific embodiment below in conjunction with the accompanying drawings.
As shown in Figure 1, a kind of material counting method based on matlab image procossing of the present invention, step is successively are as follows: (1) readsTake material image;(2) using segmentation counting method, the material image read to step (1) is analyzed, is identified in material imageActive parts image;(3) to step (2) active parts image carry out gray processing processing, then by gray processing treated effectivelyDevice image is converted into only black and white image;(4) binarization method is used, to the black and white image of step (3)Binary conversion treatment is carried out, bianry image is obtained;(5) bianry image of step (4) is subjected to Morphological scale-space, i.e., to two obtainedValue image is corroded, and to the N number of pixel of internal corrosion, then expands M pixel outward again, is removed dry in bianry imageIt disturbs, until seeing that adjacent active parts boundary generates obvious distance in bianry image;(6) connected domain is finally marked, by connected domainInterior pixel detection is a target, finally counts destination number, as active parts quantity, realizes surface mounting component material in bulkImage is checked.
The present invention applies the technical field in Electronic products manufacturing, and material preparation is the primary process of electronic product welding equipment,And material covers indispensable committed step in even more production preparation together.With the swift and violent hair of aerospace electron product technologyExhibition, electronic product is increasingly sophisticated, and component develops to fining, and surface mount device volume itself is smaller and smaller, pin and walksLine is closer and closer, and part category tends to diversification, diversification, fining.In current electronic product dress connection, first device is often hadPart is provided with bulk form, this just checks material and brings certain difficulty, causes Operational preparation process to take a long time, especiallyIt is capacitance-resistance class component in bulk, quantity is more, and it is longer to check the time.The present invention is directed to manual counting method and carries out technological improvement, realExisting material image auto inventory solves time length, checks low efficiency, statistical accuracy difference and personnel's waste, improvesElectronic product production efficiency.
The present invention is using segmentation counting method, and by the analysis to input picture, the material that will be checked is by extracting featureIt separates, identifies which object in way is active parts, pick up relevant information, gray processing processing is carried out to image, then will be greyDegreeization treated image is converted into only black and white bianry image, threshold value is to choose a point as minute for handling imageBoundary line is set as black 0 if the gray scale of image pixel is less than the threshold value;If more than the threshold value, then white 1 is set as.UsingBinarization method is chosen Otsu threshold algorithm (Otus) automatically, i.e. the maximum automatic Selection of Image Threshold of inter-class variance chooses figurePicture, then image is subjected to related Morphological processing, obtained bianry image is corroded, to 4 pixels of internal corrosion, then2 pixels of expansion outward again, remove the interference in image, until see in image adjacent two device boundaries generate significantly away fromFrom, be more nearly after expansion relative to original image, and do not influence the identification of image, finally mark connected domain, by neighbouring 8 pixel be connected toRegion detection is 1 target, if there is 8 pixels or more to connect together in image array, is considered as where this is a devicePosition, the final auto inventory for realizing material.
Present invention improves over the artificial counting method of conventional materials, realize that automation is checked;The present invention can be based on matlabImage processing logic exploitation, realizes image counting method;Improving material of the present invention checks efficiency, reduces material and checks the time, keeps awayExempt from material quantity mistake of statistics;By " segmentation counting method ", the image of reading is split, by dividing input pictureAnalysis, the material that will be checked are identified by feature extraction and are marked automatically;
--- downscaled images --- gray level image processing --- the adjustment comparison of basic ideas of the invention are as follows: shooting imageDegree --- binaryzation --- Morphological scale-space --- label UNICOM domain --- processing result;
Gray level image of the invention handles preferred embodiment are as follows: the identification for image is translated into only one-dimensionalGray image, i.e., 0~255 normalize the range, indicate black to white with 0~1.Tested metering device gray value and backgroundColour-difference is more easy to get " 1 " value away from bigger when being converted into bianry image, i.e., white, so as to image zooming-out identification;
Binaryzation preferred embodiment of the invention are as follows: treated that image need to be converted into only black and white two-value for gray processingImage.Threshold value is that the line of demarcation for choosing a point as processing image is set as if the gray scale of image pixel is less than the threshold valueBlack 0;If more than the threshold value, then white 1 is set as.Threshold value is using the Otsu threshold algorithm (Otus) in automatic selection method, i.e.,The maximum automatic Selection of Image Threshold of inter-class variance;
Morphological scale-space preferred embodiment of the invention are as follows: after bianry image generates, image need to be carried out at related MorphologicalReason i.e. corrosion and expansion.The corrosion of image is to eliminate boundary point, the process for shrinking boundary internally;On the contrary, the expansion of imageIt is that all background dots contacted with object are merged into the object, makes boundary to the process of outside expansion.It is first for the imageFirst obtained bianry image is corroded, to 4 pixels of internal corrosion, then expands 2 pixels outward again.Tiny is dryIt has not been observed after disturbing spot corrosion, that is, has eliminated the interference in image.And it can see two devices being located next in imagePart boundary produces apparent distance, is more nearly after expansion relative to original image, and does not influence the identification of image.Thus obtainBianry image after Morphological scale-space;
Label connected domain preferred embodiment of the invention are as follows: neighbouring 8 pixel connected region is detected as 1 target, is even schemedAs there is 8 pixels or more to connect together in matrix, being considered as this is the position where a device, is finally counted on image altogetherHow many device, convenient for human eye verification observation.
The present invention can be realized material auto inventory.
A kind of material counting method based on matlab image procossing of the present invention, steps are as follows for further preferred embodiment:
Step (1) reads material image, and preferred embodiment is as follows: inputting program in Matlab software, and will need to handleThe specified file of image deposit in, click " RUN " and automatically begin to image procossing, finally obtain read material image.--- --- opening software, --- write-in program --- operation program --- reads material figure to copy photo to step are as follows: shooting imagePicture.
Step (2) using segmentation counting method, analyze by the material image read to step (1), identifies material imageIn active parts image, preferred embodiment is as follows: by the analysis to input picture, the material that will be checked is by extracting featureIt separates, identifies which object is effective material, program operation result is shown by dialog box, and in material photograph imageOn " * " labelled notation is drawn to the central point of each device, can conveniently manually compare.First by material be placed horizontally at laying prevent it is quietOn the station of electric mat applying, taken pictures using camera to material.Influence in view of shooting angle difference to finally counting, willCamera is horizontally fixed on station, and if not having rigid condition, also hand-holdable camera is taken pictures, and being checked material should be located atCoverage is central, and during several pictures of taking pictures, holding height distance desktop as far as possible is consistent.For the ease of processing screened figurePicture can scale by a certain percentage image pixel.The identification of image is neither influenced, and improves the speed of service of image procossing.Obtained counting interface image is as shown in Figure 2.
(3) gray processing processing carried out to step (2) active parts image, then by gray processing treated active parts imageIt is converted into only black and white image.Pixel is to constitute the minimum unit of digital picture, and each pixel has its corresponding colorValue, preferred embodiment are as follows: operation for simplicity, the identification for image, convert colored image to the image of grey, coloredImage is by three colour cell of red, green, blue at being successively translated into only by black (0 0 0) to white (255 255 255)One-dimensional gray image, i.e., 0~255;The range is normalized, indicates black to white with 0~1.Obtained image is furtherAdjust contrast, obtained gray level image such as Fig. 3.
(4) binarization method is used, binary conversion treatment is carried out to the black and white image of step (3), obtains binary mapPicture;Preferred embodiment is as follows:
Treated that image need to be converted into only black and white bianry image for gray processing.Threshold value is to choose a point conductThe line of demarcation of image is handled, if the gray scale of image pixel is less than the threshold value, is set as black 0;If more than the threshold value, then it is arrangedFor white 1.For this research, there is no the background for placing material that will be shown as black on mat applying, the part for placing material willIt can be shown as white.Obtained bianry image such as Fig. 4.
The threshold value of this method is using the Otsu threshold method (Otus) in automatic selection method, the i.e. maximum automatic threshold of inter-class varianceIt is worth choosing method, it is simple, processing speed is fast, the case where being a kind of classic algorithm, be suitble to this segmentation object of this research.
(5) bianry image of step (4) is subjected to Morphological scale-space, i.e., obtained bianry image is corroded, inwardlyCorrode N number of pixel, then expand M pixel outward again, wherein (N ﹥ M), removes the interference in bianry image, until seeingThe distance that the apparent distance of adjacent active parts boundary generation in bianry image, i.e. human eye are easily differentiated, relative to original image after expansionIt is more nearly, and does not influence the identification of image.Preferred embodiment is as follows: firstly, the background (i.e. bench pad) of shooting photo is notIt is absolutely clean, such as Fig. 3 bianry image, certain small spot is had on mat applying, can also be divided in image recognition, be shown on imageIt is shown as white.In final count, it is necessary to exclude the interference of these noise spots.Second, some devices are being put and (poured out)When apart from close, closely, it is necessary to its is separated, and otherwise multiple devices can be detected as a device.Therefore, it needsRelated Morphological processing is carried out to image --- corrosion and expansion.The corrosion of image is to eliminate boundary point, receives boundary internallyThe process of contracting;On the contrary, the expansion of image is that all background dots contacted with object are merged into the object, keep boundary outsideThe process of portion's expansion.For the image, we corrode obtained bianry image first, to 4 pixels of internal corrosion, soExpand 2 pixels outward again afterwards.It has not been observed after tiny interference spot corrosion, that is, has eliminated the interference in image.AndAnd it can see two adjacent device boundaries of image and produce clearer objective contour distance.Shape shown in fig. 5 is obtainedState treated bianry image.
(6) pixel detection in connected domain is a target by the label connected domain of last adjacent active parts, final to countDestination number out realizes checking for material as active parts quantity.Preferred embodiment is as follows: adjacent pixel is detectedFor 1 target, if there is 8 pixels or more to connect together in image array, being considered as this is the position where a device.FinallyIt counts and shares how many a devices on image.It is in order to which human eye can be more square that red No. * will be marked on original color photoJust observation.Count results quantity is 80, is compared unanimously with artificial counting result.Illustrate that this method is feasible.
5, using the comparative experiments of artificial counting method and auto inventory material time
1) artificial counting method checks the material time
Operator's first, second that selection techniques are on close level, third, randomly select a certain number of 0805 from bulk solid packing bagCapacitor element.Loose unpacked material is counted using traditional-handwork number material mode.Record time such as the following table 1 that three people count material:
Table 1 manually counts material timetable
Unit: second
| Manually | 28 | 57 | 80 | 130 | 166 | 231 | 405 |
| First | 25 | 48 | 60 | 103 | 140 | 169 | 240 |
| Second | 29 | 55 | 69 | 95 | 134 | 175 | 234 |
| Third | 25 | 45 | 78 | 109 | 124 | 189 | 242 |
| It is average | 26 | 49 | 69 | 102 | 133 | 178 | 239 |
2) two kinds of counting method comparisons
According to result of study, a set of suitable counting method has been designed.This method is suitable for all Surface Mount capacitorsPart, after the completion of program composition can once and for all detected.
Automatic material checks the time=and=tweezers separate material+photo opporunity+computer operating time.
This method tweezers separate material and do not need to be counted device as checking material by hand and carefully carry out by certain amountStacking only needs simply to separate the material stacked.Every time according to device how much, device every 50, take about 10 seconds.
This method can handle the photo of different pixels size, simplicity of taking pictures, and about 5 seconds.
Average every photo is copied in computer about 5 seconds.The research method time is removed, after the completion of program, is checked every timeOnly input picture and program need to be run in the computer equipped with matlab software, 5 seconds figures that can be drawn in above method processPiece and display counting result.
Automatic material checks the total time about 25 seconds.It compares with 1 correlation test data of table, when device number is greater than 28When, the mode speed using this automatic identification photo is faster than manual count.See Fig. 6.
2 two kinds of counting method contrast tables of table
| 28 | 57 | 80 | 130 | 166 | 231 | 405 |
| The manual number material time | 26 | 49 | 69 | 102 | 133 | 178 | 239 |
| Automatic material checks the time | 25 | 35 | 35 | 45 | 55 | 65 | 105 |
| Save the time | 1 | 14 | 34 | 57 | 78 | 113 | 134 |
| Improved efficiency | 3.9% | 28.6% | 49.7% | 55.9% | 58.6% | 63.5% | 56.1% |
3) automatic material checks the popularization and application of method
The material method of checking can be used for the statistics of surface-mount resistor in bulk, capacitor class component with 50% or more raising efficiency,And also there is extensive and important application in all polymorphic similar materials.
A kind of material counting method based on matlab image procossing of the invention proposes to be based on matlab software development, rightArtificial counting method carries out control and improves with emulation technology, realizes the technical solution of material image counting method.The present inventionThe artificial counting method of conventional bulk material is improved, realizes that automation is checked;
A kind of material counting method based on matlab image procossing of the invention, improving material check efficiency, reduce objectMaterial checks the time, avoids material quantity mistake of statistics;The image of reading is split by the present invention by " segmentation counting method ",By the analysis to input picture, the material that will be checked is identified by feature extraction and is marked automatically.