A kind of characters on license plate cutting method based on projection
Technical field
The invention belongs to computer vision and technical field of intelligent traffic, and in particular to a kind of characters on license plate based on projection
Cutting method.
Background technology
With the continuous development of intelligent transportation field, at present in traffic monitoring, automatic fare collection system, district vehicles pipe
The aspect such as reason system and safety monitoring is required for carrying out car plate accurate to recognize.License plate recognition technology is usually each character point
Identification is opened, so to carry out the accurate cutting of characters on license plate before recognition.
Currently there is the method for many characters on license plate cuttings, wherein the technical scheme being closer to the present invention is:Patent (Xu Yi
It is outstanding.Application number:201310263494.8, title:A kind of registration number character dividing method based on grey level histogram binaryzation) propose
A kind of registration number character dividing method based on grey level histogram binaryzation, grey level histogram of the method first with license plate image
Be calculated suitable binary-state threshold with gray average carries out binaryzation to license plate image, then to the image after binaryzation
Carry out horizontal direction projection localization and obtain binary image mid portion, Vertical Square is carried out to the binary image after horizontal resection
Character is obtained to projection localization, adhesion situation process is carried out to the character for obtaining according to standard character width, this method does not have
Consider many complicated situations, such as the spot on car plate both sides is likely to by mistake as characters on license plate, and Chinese car plate
There is the relation of left and right radical in first middle word, it is also possible to by mistake as two characters;Patent (Yu Shengfeng, Wang Hui, Wu
More, Xu Zhijiang, Meng Limin, a mark mark, Du Kelin, Wang Yi.Application number:201110405227.0, title:A kind of characters on license plate point
Segmentation method) a kind of new registration number character dividing method is proposed, the method is first sentenced according to Gray Level Jump in horizontal direction less than 14
Lower cutting line on disconnected car plate, removes upper and lower side frame, then coarse segmentation is carried out to character using vertical projection method, finally according to character
The information such as center distance, character duration and actual license plate character the ratio of width to height first determine the region of the second character, then really
Fixed other character zones, car plate of the method mainly to there is adhesion situation is easy to cutting failure, and antijamming capability compares
It is weak;Patent (card, Ni Xiuming, He Jia, Fan Hao.Application number:201510658142.1, title:A kind of car based on exemplary position
Board character segmentation method) a kind of registration number character dividing method based on exemplary position is proposed, the method passes through first floor projection
Laying-out curve carries out horizontal resection to the lower edges position of characters on license plate, then to classifier training car plate 2-3 character positions
Region, using the grader 2-3 character positions are found in license plate image, other character right boundaries are derived, according to prediction
Boundary position find in upright projection curve near the position of curve mutation be defined as character left and right edges and enter line character
Cutting, the method needs repeatedly to predict characters on license plate 2-3 positions in license plate image, then carries out probability calculation, than relatively time-consuming,
And speculating that other character right boundaries have certain deviation according to 2-3 character positions, characters on license plate spacing inherently compares
Closely, so mutated site of the right boundary of adjacent character on curve is also close on upright projection curve, easily lead
Cause segmentation inaccurate;Document (Gu Lichao.License Plate and Character segmentation algorithm research [D] in vehicle image.Chongqing:Chongqing
University, 2012) proposes the character segmentation method that a kind of projection and connected region combine, and first binaryzation license plate image is carried out
Connected region detection, then carries out floor projection and upright projection, determines that character width is high, for the wide high phase high less than character width
Adjacent connected region is merged, and finally adds rectangular shaped rim to extract character in each connected region, and the method is simple, but anti-noise energy
Power is weak, easily is affected to cause segmentation errors by car plate spot;Document (white Jian Hua.License Plate Character Segmentation and recognizer are ground
Study carefully [D].Xi'an:Xian Electronics Science and Technology University, 2010) proposes a kind of Character Segmentation of License Plate, and the algorithm is also first to carry out
Floor projection carries out car plate horizontal resection, removes upper and lower side frame, then Character segmentation is carried out using upright projection, then to adhesion
Character is split according to two character center points or character the ratio of width to height, and finally the character that ruptures is processed, that is, cut
The two neighboring character duration sum for arriving is equal to standard character width, then two characters are considered that what is ruptured merges, the party
Method is not processed the stained region beyond character, easily assigns the spot of character the right and left as character, is caused correct
Character disappearance;Document (Chi Xiaojun, Meng Qingchun.Character Segmentation of License Plate [J] based on projection properties value.Computer application
Research, 2006,4:A kind of Character Segmentation of License Plate based on projection properties value 256-257) is proposed, the algorithm is first to two
Value car plate carries out upright projection, and according to each column pixel gray value sum a characteristic value is calculated, and by priori the is determined
One Character segmentation point between car plate second and the 3rd character as starting point, then to from left to right in vertical projection diagram
Scan respectively, scan the crest in perspective view more than characteristic value and be assured that a Character segmentation point, then to splitting
Character carry out horizontal segmentation, the algorithm calculates position between car plate second and the 3rd character as rising with priori
Point position, it is more likely that the position for calculating can with actually have deviation, this segmentation of other characters on after can all produce impact, and
And for there is adhesion situation or have the car plate of spot all can easy segmentation errors, anti-noise ability is weak, for there is left and right partially
Other middle word, then be easy to that two characters can be divided into.
In sum, the method for current car plate Character segmentation has following deficiency:(1) affected by spot on car plate
Cause Character segmentation mistake, antijamming capability is weak;(2) situation of characters on license plate adhesion is not accounted for, easy segmentation errors;
(3) for the middle word that there is left and right radical is easily divided into two or more characters;(4) calculate complicated, take;(5) by elder generation
Test knowledge and derive position inaccurately, cause Character segmentation to obtain inaccurately.
The content of the invention
For the insoluble deficiency of current car plate Character segmentation method, the present invention proposes a kind of car plate based on projection
Character segmentation method.
Described a kind of characters on license plate cutting method based on projection, it is characterised in that comprise the steps:
Step 1:Binaryzation is carried out to license plate image, the car plate for making binaryzation is white gravoply, with black engraved characters, then carries out Slant Rectify,
Picture size after correction is normalized, the height of binary image is height;
Step 2:Horizontal resection is carried out to the license plate image that step 1 is obtained, new image levelCutImage is formed;
Step 3:To step 2) the image levelCutImage that obtains carries out perpendicular cuts, comprises the following steps that:
Step 3.1:The set charList of a storage characters on license plate image is created, image levelCutImage is calculated
Black pixel point sum count1 on vertical sweep line at width1/2, if count1>0, execution step 3.2 is no
Then direct execution step 3.3, wherein width1 for image levelCutImage width;
Step 3.2:The character picture of centre is extracted from image levelCutImage, in being stored in charList, concrete step
It is rapid as follows:
Step 3.2.1:From the beginning of at the width1/2 of image levelCutImage, scan to the right by column, until in scanning
The black pixel point sum count1 of line epigraph levelCutImage<1, then stop scanning, now the position of scan line is designated as
The position of character right cut secant cL1;
Step 3.2.2:From the beginning of at the width1/2 of image levelCutImage, scan to the left by column, until in scanning
The black pixel point sum count1 of line epigraph levelCutImage<1, then stop scanning, now the position of scan line is designated as
The position of character left cut secant cL2;
Step 3.2.3:Rectangular area (cL2,0, cL1-cL2, height1) is extracted from image levelCutImage right
The part answered is used as character picture charImage, if black pixel point number total in charImage is more than set in advance
Threshold value, then be added to charImage in charList, does not otherwise process, and wherein height1 is image
The height of levelCutImage;
Step 3.3:Turn right from the centre of image levelCutImage and extract a character picture also not extracted,
In being stored in charList, comprise the following steps that:
Step 3.3.1:From the beginning of turning right at the width1/2 of image levelCutImage and also not scanning to where,
Turn right and scan by column, until the black pixel point sum count1 in scan line epigraph levelCutImage>0, then now
The position of scan line is designated as the position of character left cut secant cL2, and continuing to turn right scans by column, until in scan line epigraph
The black pixel point sum count1 of levelCutImage<1, then stop scanning, now the position of scan line is designated as character right cut
The position of secant cL1;
Step 3.3.2:Extract in rectangular area (cL2,0, cL1-cL2, height1) from image levelCutImage
Part as character picture charImage, if black pixel point number total in charImage be more than threshold set in advance
Value, then be added to charImage in charList, does not otherwise process;
Step 3.4:Turn left from the centre of image levelCutImage and extract a character picture also not extracted,
In being stored in charList, comprise the following steps that:
Step 3.4.1:From the beginning of turning left at the width1/2 of image levelCutImage and also not scanning to where,
Turn left and scan by column, until the black pixel point sum count1 in scan line epigraph levelCutImage>0, then now
The position of scan line is designated as the position of character right cut secant cL1, and continuing to turn left scans by column, until in scan line epigraph
The black pixel point sum count1 of levelCutImage<1, then stop scanning, now the position of scan line is designated as character left cut
The position of secant cL2;
Step 3.4.2:Extract in rectangular area (cL2,0, cL1-cL2, height1) from image levelCutImage
Part as character picture charImage, if black pixel point number total in charImage be more than threshold set in advance
Value, then be inserted into charList heads charImage, does not otherwise process, and step 3.3 is gone successively to, until charList
Middle element number then stops circulation not less than 7 or image levelCutImage the right and lefts all ends of scan;
Step 4:Image to there is Characters Stuck in charList splits, until can not find figure in charList
Till image of the image width degree more than widthAvg;
Step 5:Ensure that the total number of images in charList is 7, comprise the following steps that:
Step 5.1:If the total number of images in charList is less than 7, cutting failure is illustrated, if in charList
Total number of images is equal to 7, then be directly entered step 6, if the total number of images in charList is more than 7, into step 5.2;
Step 5.2:According to right boundary position of each character picture in charList in levelCutImage images
Put, a nearest character picture of the vertical curve in levelCutImage away from width1/2 is found in charList, with
Centered on this character picture, in charList respectively toward from left to right choose 3 character pictures, in charList except this
Other images beyond 7 character pictures are all deleted;
Step 6:First character image in charList is reprocessed, concrete process step is as follows:
Step 6.1:Calculate the average width of other 6 character pictures in charList in addition to first character image
Degree, is designated as avgWidth;
Step 6.2:Right cut secant cL1 of the note first character image in levelCutImage is equal in charList
The position of first character right margin in levelCutImage, left cut secant cL2=cL1-avgWidth;
Step 6.3:The part in rectangular area (cL2,0, cL1-cL2, height1) is chosen from levelCutImage
Image replaces the first character image in charList as first character image.
A kind of described characters on license plate cutting method based on projection, it is characterised in that license plate image is entered in step 2
Row horizontal resection is comprised the following steps that:
Step 2.1:From the beginning of at the height/2 of the license plate image obtained from step 1, scan up line by line, until in scanning
The black pixel point sum count of license plate image on line<Threshold, then stop scanning, and now the position of scan line is designated as
The position of line of cut cutLine1, wherein height are the height of the binary image that step 1 is obtained, and threshold is advance
The threshold value of setting;
Step 2.2:From the beginning of at the height/2 of the license plate image obtained from step 1, scan downwards line by line, until in scanning
The black pixel point sum count of license plate image on line<Threshold, then stop scanning, and now the position of scan line is designated as down
The position of line of cut cutLine2;
Step 2.3:The parts of images and below cutLine2 of more than cutLine1 in the license plate image that removal step 1 is obtained
Parts of images, leave license plate image mid portion and form new image levelCutImage.
Described a kind of characters on license plate cutting method based on projection, it is characterised in that to depositing in charList in step 4
In comprising the following steps that the image of Characters Stuck is split:
Step 4.1:Characters on license plate image averaging width widthAvg is calculated according to formula (1);
WidthAvg=width1/7 (1)
Step 4.2:The number of image of the picture traverse less than widthAvg is designated as num in statistics charList, calculates
The width sum of image of the picture traverse less than widthAvg is designated as widthSum in charList, is counted again according to formula (2)
Calculate the value of widthAvg;
Step 4.3:Image of the picture traverse more than widthAvg is found in charList and is designated as tempImg, remembered
Index value of the image in charList is i, and the image is removed in charList;
Step 4.4:TempImg is turned left from the right side and is split according to character duration widthAvg, be often partitioned into a word
Symbol image, then the character picture is inserted into charList at index value i, be divided into one character picture of Far Left when
Wait, if the picture traverse is not less than widthAvg/2, be inserted into charList at index value i, otherwise give up, Ran Houchong
Step 4.3 is newly entered, till the image of widthAvg is more than until can not find picture traverse in charList.
Characters on license plate is cut by using the method for the present invention, compared with prior art, its advantage is as follows:
1) present invention carries out again perpendicular cuts by advanced driving board horizontal resection, can avoid upper and lower spot for character
The impact of segmentation, and character perpendicular cuts cut from middle toward both sides, cut full 7 characters and then stop cutting, it is to avoid car plate or so
Frame is mistakenly considered character, and avoids left and right spot interference;
2) when the character to there is adhesion situation is split again, the Character segmentation width of selection is the present invention
The mean breadth of the character picture that there is no adhesion situation is determined in the cleaved character for obtaining, actual conditions are more conformed to,
Improve Character segmentation accuracy;
3) present invention is more than 7 to there is character picture after the process of adhesion situation, is extracted in license plate image and most leans on
7 characters in nearly centre position, because both sides may be disturbed by spot misdeeming as character, substantially increase Character segmentation correct
Rate;
4) present invention is entered again by reprocessing to the 1st Chinese character according to the mean breadth of other 6 characters
Row positioning obtains first Chinese character image, and Chinese character or so radical can be avoided to cause the situation of fracture in the middle of character.
Description of the drawings
Fig. 1 is the binaryzation license plate image for cutting that the embodiment of the present invention is chosen;
Fig. 2 is the binaryzation license plate image after horizontal resection of the present invention.
Fig. 3 is that the present invention finally cuts the characters on license plate image for obtaining.
Specific embodiment
The specific embodiment of the license plate sloped antidote of the present invention is elaborated with reference to embodiment.Should manage
Solution, specific embodiment described herein is used only for explaining the present invention, is not intended to limit the present invention.
A kind of characters on license plate cutting method based on projection of the present invention, comprises the following steps that:
Step 1:Binaryzation is carried out to license plate image, the car plate for making binaryzation is white gravoply, with black engraved characters, then carries out Slant Rectify,
Picture size after correction is normalized, in this example picture size is normalized to the pixel of length 204, and the pixel of width 54 is obtained
To result as shown in Figure 1;
Step 2:Horizontal resection is carried out to the license plate image that step 1 is obtained, the design sketch of horizontal resection such as Fig. 2 in this example
It is shown, comprise the following steps that:
Step 2.1:From the beginning of at the height/2 of the license plate image obtained from step 1, scan up line by line, until in scanning
The black pixel point sum count of license plate image on line<Threshold, then stop scanning, and now the position of scan line is designated as
The position of line of cut cutLine1, wherein height are the height of the binary image that step 1 is obtained, and threshold is advance
The threshold value of setting, this threshold value is mainly according to car plate picture size setting, and picture is bigger, is set to bigger, and picture is less, if
Surely it is less, in this example threshold is set as 20;
Step 2.2:From the beginning of at the height/2 of the license plate image obtained from step 1, scan downwards line by line, until in scanning
The black pixel point sum count of license plate image on line<Threshold, then stop scanning, and now the position of scan line is designated as down
The position of line of cut cutLine2;
Step 2.3:The parts of images and below cutLine2 of more than cutLine1 in the license plate image that removal step 1 is obtained
Parts of images, leave license plate image mid portion and form new image levelCutImage;
Step 3:Perpendicular cuts are carried out to image levelCutImage, is comprised the following steps that:
Step 3.1:The set charList of a storage characters on license plate image is created, image levelCutImage is calculated
Black pixel point sum count1 on vertical sweep line at width1/2, if count1>0, execution step 3.2 is no
Then direct execution step 3.3, wherein width1 for image levelCutImage width;
Step 3.2:The character picture of centre is extracted from image levelCutImage, in being stored in charList, concrete step
It is rapid as follows:
Step 3.2.1:From the beginning of at the width1/2 of image levelCutImage, scan to the right by column, until in scanning
The black pixel point sum count1 of line epigraph levelCutImage<1, then stop scanning, now the position of scan line is designated as
The position of character right cut secant cL1;
Step 3.2.2:From the beginning of at the width1/2 of image levelCutImage, scan to the left by column, until in scanning
The black pixel point sum count1 of line epigraph levelCutImage<1, then stop scanning, now the position of scan line is designated as
The position of character left cut secant cL2;
Step 3.2.3:Extract in rectangular area (cL2,0, cL1-cL2, height1) from image levelCutImage
Part as character picture charImage, if black pixel point number total in charImage be more than threshold set in advance
Value, then be added to charImage in charList, does not otherwise process, and this threshold value set in advance is mainly according to car plate
Picture size is setting, and picture is bigger, is set to bigger, and picture is less, is set to less, and in this example the threshold value is set as
50, wherein height1 are the height of image levelCutImage;
Step 3.3:Turn right from the centre of image levelCutImage and extract a character picture also not extracted,
In being stored in charList, comprise the following steps that:
Step 3.3.1:From the beginning of turning right at the width1/2 of image levelCutImage and also not scanning to where,
Turn right and scan by column, until the black pixel point sum count1 in scan line epigraph levelCutImage>0, then now
The position of scan line is designated as the position of character left cut secant cL2, and continuing to turn right scans by column, until in scan line epigraph
The black pixel point sum count1 of levelCutImage<1, then stop scanning, now the position of scan line is designated as character right cut
The position of secant cL1;
Step 3.3.2:Extract in rectangular area (cL2,0, cL1-cL2, height1) from image levelCutImage
Part as character picture charImage, if black pixel point number total in charImage be more than threshold set in advance
Value, then be added to charImage in charList, does not otherwise process, and this threshold value set in advance is with step 3.2.3
As, in this example the threshold value is set as 50;
Step 3.4:Turn left from the centre of image levelCutImage and extract a character picture also not extracted,
In being stored in charList, comprise the following steps that:
Step 3.4.1:From the beginning of turning left at the width1/2 of image levelCutImage and also not scanning to where,
Turn left and scan by column, until the black pixel point sum count1 in scan line epigraph levelCutImage>0, then now
The position of scan line is designated as the position of character right cut secant cL1, and continuing to turn left scans by column, until in scan line epigraph
The black pixel point sum count1 of levelCutImage<1, then stop scanning, now the position of scan line is designated as character left cut
The position of secant cL2;
Step 3.4.2:Extract in rectangular area (cL2,0, cL1-cL2, height1) from image levelCutImage
Part as character picture charImage, if black pixel point number total in charImage be more than threshold set in advance
Value, then be inserted into charList heads charImage, does not otherwise process, and this threshold value set in advance is with step 3.2.3
In as, in this example the threshold value is set as 50, goes successively to step 3.3, and element number is not little in charList
In 7 or image levelCutImage the right and lefts all ends of scan, then stop circulation;
Step 4:Image to there is Characters Stuck in charList splits, and comprises the following steps that:
Step 4.1:Characters on license plate image averaging width widthAvg is calculated according to formula (1);
WidthAvg=width1/7 (1)
Step 4.2:The number of image of the picture traverse less than widthAvg is designated as num in statistics charList, calculates
The width sum of image of the picture traverse less than widthAvg is designated as widthSum in charList, is counted again according to formula (2)
Calculate the value of widthAvg;
Step 4.3:Image of the picture traverse more than widthAvg is found in charList and is designated as tempImg, remembered
Index value of the image in charList is i, and the image is removed in charList;
Step 4.4:TempImg is turned left from the right side and is split according to character duration widthAvg, be often partitioned into a word
Symbol image, then the character picture is inserted into charList at index value i, be divided into one character picture of Far Left when
Wait, if the picture traverse is not less than widthAvg/2, be inserted into charList at index value i, otherwise give up, Ran Houchong
Step 4.3 is newly entered, till the image of widthAvg is more than until can not find picture traverse in charList;
Step 5:Ensure that the total number of images in charList is 7, comprise the following steps that:
Step 5.1:If the total number of images in charList is less than 7, cutting failure is illustrated, if in charList
Total number of images is equal to 7, then be directly entered step 6, if the total number of images in charList is more than 7, into step 5.2;
Step 5.2:According to right boundary position of each character picture in charList in levelCutImage images
Put, a nearest character picture of the vertical curve in levelCutImage away from width1/2 is found in charList, with
Centered on this character picture, in charList respectively toward from left to right choose 3 character pictures, in charList except this
Other images beyond 7 character pictures are all deleted;
Step 6:First character image in charList is reprocessed, concrete process step is as follows:
Step 6.1:Calculate the average width of other 6 character pictures in charList in addition to first character image
Degree, is designated as avgWidth;
Step 6.2:Right cut secant cL1 of the note first character image in levelCutImage is equal in charList
The position of first character right margin in levelCutImage, left cut secant cL2=cL1-avgWidth;
Step 6.3:The part in rectangular area (cL2,0, cL1-cL2, height1) is chosen from levelCutImage
Image replaces the first character image in charList as first character image, finally gives in this example such as Fig. 3 institutes
The character picture segmentation result for showing.