A kind of coarse-fine second level paper counting method based on space and gray feature
Technical field
The present invention relates to a kind of method counted using paper space and gray feature paper, main application fields are
Printing and packaging and paper industry.
Background technique
In printing and packaging industry, in order to accurately hold the paper inventory amounts and Quantity Shipped of our company, often
It needs to carry out quantity to paper to check.Due in modern times printing and paper industry, number of paper is in large scale and modern life
In work people to environmentally protective theory advocate and to the high request of printing paper quality, and to production and print in present society
The mode that is counted of paper of brush packaging mostly all using manually checking by the way of or use mechanical equipment to paper into
Row counts, although the method accuracy rate manually counted to paper or banknote is guaranteed to a certain extent, paper
The speed counted especially when number of paper is more than 200 or more, will not only devote a tremendous amount of time, but also people also can slowly
It generates and counts fatigue, people can also become tired while causing to count accuracy rate decline, generate paper counting fatigue.And it uses
Although mechanical paper counting method counting efficiency is improved, due to connecing between paper and mechanical equipment
Touching, will lead to paper contact between mechanical equipment when being checked in this way causes paper that can be worn, especially current
Under conditions of people are more demanding to paper quality, mechanical equipment, which counts paper, can not meet the high standard of people and want
It asks, simultaneously because mechanical equipment is counted, mechanical equipment will necessarily issue noise in the process of running, to environment and one
Kind pollution, is not able to satisfy the life requirement of modern mans high standard, additionally due to be that mechanical equipment counts, necessarily one
One is checked paper, and when number of paper is larger, paper counting is also required to for a long time, and counting efficiency is not
To guarantee.Therefore, new a kind of just show based on efficient, noiseless, to the substantially harmless paper counting method of paper is developed
Must be particularly important, this also has great importance for the automated enumeration of printing industry.
Summary of the invention
The purpose of the present invention is to provide a kind of paper counting method based on space and gray feature, this method by pair
Image capture device is acquired the imaging effect figure of paper, after obtaining the image of paper, first to paper image feature into
Row analysis and pretreatment, the quantity of paper is calculated using Fuzzy Threshold and detection curve peak valley point algorithm, is fundamentally solved
Generated when it is slow and the shortcomings that cannot carry out for a long time manually to check speed, while solving mechanical equipment counting noise and
The shortcomings that being taken a long time in the case that number of paper is more.
A kind of paper second level method of counting based on space and gray feature provided by the invention inclines paper to be detected
Oblique being placed on scanner is scanned to obtain image, is then handled by the following method paper imaging effect figure.
A) image preprocessing: paper image is detected by acquired image gray processing, and using the method for Hough transform
In straight line image is subjected to rotation and does slant correction according to the tilt angle of the slope meter nomogram picture of straight line;Label paper exists
Start-stop point in image: in the acquired images according to feature of image, mainly according to the gray scale in image whether there is or not paper areas
It is worth the feature of significant change, with algorithm recording paper starting and ending position.
B) image projection: the pixels tall that image chooses 1-500 is projected to obtain drop shadow curve's figure, by paper image
Two dimensional character variation be one-dimensional characteristic, the direction and paper parallel stripes for projecting selection are consistent.
C) paper slightly counts:
The step of paper slightly counts is as follows:
(1) drop shadow curve obtained by projection finds out wave crest and trough all in curve, first root first with algorithm
Calculating wave crest point average gray according to all wave crest points found out ispeak, the average gray for calculating all trough points isvallery, step S101;
(2) gap length between two adjacent peaks or trough is then found out respectively, then to all peak to peak separations
Either paddy paddy interval is counted, and the higher gap length of the frequency of occurrences is found out, tentatively the thickness as a piece of paperlen.Together
When according to all wave crests and trough in drop shadow curve, be one since paper image can be initially believed that between wave crest and wave crest
Paper, step S102;
(3) use the function of Gaussian distributed as fuzzy subordinating degree function, with the thickness for the paper that primary Calculation obtains
Degree is used as window width.It is moved in the region of entire drop shadow curve, all wave crests and all troughs is weighted respectively
Summation, is worth biggish one group after finding out weighted sum, judges as preferable one group of property number of paper, step
S103;
(4) judge since first point of the good wave crest of property (trough), if [len-wid,len+wid] range it
It is interior, whereinwidBe in order to reduce the customized constant of counting error, value range be [0,len], if in range
Next step judgement is carried out, otherwise step S104 gives up the point, step S105;
(5) judge whether the crest value is greater than (peak+valley)/2(is preferable if it is trough property, then judges trough
Value whether be less than (peak+valley)/2), if meeting condition, the point is marked with box, otherwise step S106 gives up
The point is abandoned, the wave crest or trough at next place are judged, step S105;
(6) paper slightly counts: being marked according to the obtained wave crest quantity of statistics or trough quantity and with box
As a result paper is counted, the selection of wave crest quantity herein or the selection of trough quantity depend in step (d) to wave crest
Preferable one group of the property judged with trough property is as last counting foundation, step S107.
D) paper essence counts:
Paper width is obtained with statistical pixel method to image binaryzation with region-growing method, while calculating drop shadow curve's wave
The gray scale difference of valley point and drop shadow curve's mean value;Then drop shadow curve's average gray difference and paper mean breadth are calculated, it is wide with paper
Degree and gray scale difference constitute two-dimensional feature vector;Classification finally is carried out to feature vector with K-means clustering procedure and judges paper adhesion
Quantity.It completes to count the essence of paper, step S108.
Detailed description of the invention
Fig. 1 is the flow chart that the Algorithm of Paper Counting based on gray scale and space characteristics counts paper.
Fig. 2 is the flow chart that entire counting algorithm counts paper.
Fig. 3 is that the collected paper original graph of equipment is adopted using image.
Fig. 4 is the pilot process figure obtained using Algorithm of Paper Counting.
Fig. 5 is the paper effect picture finally detected, and black billet line is the paper position detected.
Fig. 6 is entire software system interface display schematic diagram.
Specific embodiment
Below in conjunction with attached drawing to the present invention to detailed description.
The present invention, which carries out processing to the paper image collected, to be completed by entire counting algorithm, main processes
It is as follows.
A) image preprocessing: by image gray processing, slant correction;The start-stop point of paper in the picture is marked simultaneously: design
The start-stop position of paper in algorithm automatic identification image.
B) image projection: to image longitudinal projection, drop shadow curve is obtained.
C) Fuzzy Threshold is handled: being handled drop shadow curve, is obtained Fuzzy Threshold treated curve.
D) paper slightly counts: being counted according to the quantity of curve medium wave peak (trough) to paper.
E) paper essence counts: thick the problem of counting identification can not be used mainly for number of paper at adhesion, it is special using extracting
Sign cluster mode specifically identifies number of paper at adhesion.
Final paper counting of the invention as a result, and other parameter settings and detection effect etc. in software systems
Interface on show, see Fig. 6, so that operator is understood the working condition of system in time and adjust in time, it is entire soft
Part system interface includes three big modules, first is that image acquisition parameter adjusts module, including the storage to resolution ratio and acquisition image
The setting of type;Second is that image display, is mainly used for the collected paper image and display number of paper of display load
Detection effect figure;Third is that acquisition image and counting module, the operation such as paper counting and display paper count results.
Following performance indicator may be implemented in paper counting method of the invention substantially:
(1) processing time < 2s of every stacker;
(2) count accuracy rate: disposable detection number of paper counts 99.7% or more accuracy rate less than 500;
(3) thickness of individual paper for being counted is in 0.07mm or more.
Illustrate the work of method of counting of the invention with folded 200 examples counted with a thickness of the paper of 0.09mm
Make process, Fig. 3 is the part effect picture of collected 200 paper images.
S201: into gray processing operation is carried out then slant correction is carried out to image first, mainly utilizes Hough transform
The straight line that paper striped is formed is detected, is then taken up an official post the two o'clock taken on different location in the straight line detected, according to being calculated
The slope of two o'clock obtains the tilt angle of image, which, which is not necessarily to slant correction, very high precision, as long as guaranteeing
Image inclination angle controls within the scope of -0.5-0.5 degree.
S202: image is projected to obtain projection histogram.Projection chooses the certain altitude of paper image to image
In in the region grey scale pixel value carry out longitudinal addition, obtain an one-dimensional vector, it is available with the data of this one-dimensional vector
The perspective view of image.
S203: the start-stop position of paper in algorithm for design automatic identification image.After image preprocessing, in order to obtain in image
The starting point and ending point of paper in the picture, according to the gray scale difference of paper areas in image and non-paper region, i.e. non-paper
Region can have the process of Gray Level Jump to paper areas, find out the initial position of paper areas and knot in image according to this feature
Beam position.
S204: the drop shadow curve obtained by Gray Projection finds out wave crest and trough all in curve first with algorithm,
Then the gap length between two adjacent peaks or trough is found out respectively, then between all peak to peak separations either paddy paddy
Every being counted, the higher gap length of the frequency of occurrences is found out, tentatively the thickness as a piece of paperlen.It is bent according to projection simultaneously
All wave crests and trough in line, are a piece of papers since paper image can be initially believed that between wave crest and wave crest, high with obeying
Function of this distribution is as the subordinating degree function obscured, and the thickness of the paper obtained using primary Calculation is as window width.Entirely throwing
The region of shadow curve is moved, and summation is weighted to all wave crests and all troughs respectively, after finding out weighted sum
It is worth biggish one group, number of paper is judged as preferable one group of property, Fig. 4 is to collected original image i.e. Fig. 3
Carry out Fuzzy Threshold treated the effect picture that curve graph shows in original image.
S205: paper slightly counts.According to Fuzzy Threshold treated drop shadow curve figure, according to the wave crest and trough found
The preferable one group of curve of matter finds out the quantity number of the wave crest or trough in the preferable one group of curve of the property, obtains paper
Quantity.Fig. 5 is that the effect picture of detection effect is counted and shown to this stacker Zhang Jinhang, and the billet line of black indicates the paper of detection
The position opened, i.e., by the position of the step S204 wave crest determined or trough, by carrying out statistical counting just to black billet line
The quantity of available paper.
S206: paper essence counts: with region-growing method to image binaryzation, obtaining paper width with statistical pixel method, together
When calculate drop shadow curve's trough point and drop shadow curve's mean value gray scale difference;Then it calculates drop shadow curve's average gray difference and paper is flat
Equal width constitutes two-dimensional feature vector with paper width and gray scale difference;Finally feature vector is divided with K-means clustering procedure
Class judges paper adhesion quantity.It completes to count the essence of paper.