CN106203057B - Identifying code Picture Generation Method and device - Google Patents
Identifying code Picture Generation Method and device Download PDFInfo
- Publication number
- CN106203057B CN106203057B CN201610506523.2A CN201610506523A CN106203057B CN 106203057 B CN106203057 B CN 106203057B CN 201610506523 A CN201610506523 A CN 201610506523A CN 106203057 B CN106203057 B CN 106203057B
- Authority
- CN
- China
- Prior art keywords
- pixel
- gradient
- picture
- boundary
- verifying
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/30—Authentication, i.e. establishing the identity or authorisation of security principals
- G06F21/31—User authentication
- G06F21/36—User authentication by graphic or iconic representation
Landscapes
- Engineering & Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Character Input (AREA)
- Editing Of Facsimile Originals (AREA)
- Image Processing (AREA)
Abstract
This application provides a kind of generation methods of identifying code picture, this method obtains the background picture comprising abundant boundary content, the foreground picture comprising texture structure image and verifying character picture, it verifies in character picture comprising verifying code character, to verify code character as exposure mask, the gradient of background picture is replaced with to the gradient of foreground picture, to show verifying code character on background picture, which can be used as identifying code picture.Since background picture includes boundary abundant, rogue program needs to analyze picture material when distinguishing verifying code character, to improve the identified difficulty out of verifying code character, and then improves the safety of identifying code picture.In addition, present invention also provides the generating means of identifying code picture, to guarantee the application and realization of the above method in practice.
Description
Technical field
This application involves verification code technology fields, more particularly, to identifying code Picture Generation Method and device.
Background technique
Identifying code is applied in various public systems, is people or robot for judging to access the user of public system
Program.Robot program by executing automatically, malicious sabotage public system, and in ticketing system, robot program can malice
Brush ticket;In Forum System, robot program can be poured water with forum etc..And the application of identifying code, it can effectively identify machine
People's program, to protect normal access of the legitimate user to public system.
Currently, the identifying code color in identifying code picture is fixed color such as black.Such identifying code picture is easy quilt
Rogue program cracks, that is, is easy to extract identifying code from identifying code picture, the safety of identifying code picture is lower.
Summary of the invention
In view of this, this application provides a kind of identifying code Picture Generation Methods, to improve the safety of identifying code picture
Property.In addition, present invention also provides the generating means of identifying code picture, to guarantee the application and reality of the above method in practice
It is existing.
In order to achieve the object, technical solution provided by the present application is as follows:
The second aspect of the application provides a kind of identifying code Picture Generation Method, comprising:
Obtain verifying character picture, foreground picture and background picture;It wherein, include identifying code in the verifying character picture
Character, the image in the foreground picture are texture image, and the image in the background picture is natural image;
Using the verifying code character in the verifying character picture as exposure mask, by the verifying code character in the background picture
In gradient replace with the gradient of the verifying code character in the foreground picture, obtain identifying code picture.
Optionally, the verifying code character using in the verifying character picture exists the verifying code character as exposure mask
Gradient in the background picture replaces with gradient of the verifying code character in the foreground picture, comprising:
The boundary current according to the verifying code character, determines the gradient of the prospect boundary pixel in the foreground picture;
Wherein, the prospect boundary pixel is the boundary equitant picture current with the verifying code character in the foreground picture
Element;
The gradient of the background border pixel is replaced with to the gradient of the prospect boundary pixel;Wherein, the background side
Boundary's pixel is the boundary equitant pixel current with the verifying code character in the background picture;
It is inwardly indented the current boundary new with the determination verifying code character, is returned new according to the verifying code character
Current boundary, the gradient for determining the prospect boundary pixel in the foreground picture and the background border picture in the background picture
The gradient of element, until being inwardly indented to the last one pixel of the verifying code character.
Optionally, the boundary current according to the verifying code character, determines the prospect boundary in the foreground picture
The gradient of pixel, comprising:
By the verifying code character it is Chong Die with the foreground picture after, it is determining with the verifying in the foreground picture
The equitant prospect boundary pixel in the current boundary of code character;
Centered on the prospect boundary pixel, the neighborhood region comprising at least one pixel outside overlapping region is determined;
The pixel that overlapping region is not belonging in the neighborhood region is determined as pixel set G;
According to the pixel value of pixel in the pixel set G, the gradient of the prospect boundary pixel is determined.
Optionally, the pixel value according to pixel in the pixel set G, determines the ladder of the prospect boundary pixel
Degree, comprising:
Formula is determined according to gradientDetermine the gradient of the prospect boundary pixel;
Wherein, the grad (a) is the gradient of prospect boundary pixel, and a is the pixel value of prospect boundary pixel, described
B is the pixel value of pixel in pixel set G, and the num (G) is the sum of pixel in pixel set G.
Optionally, the gradient by the background border pixel replaces with the gradient of the prospect boundary pixel, comprising:
By the verifying code character it is Chong Die with the background picture after, it is determining with the verifying in the background picture
The equitant background border pixel in the current boundary of code character;
Centered on the background border pixel, the neighborhood region comprising at least one pixel outside overlapping region is determined;
The pixel that overlapping region is not belonging in the neighborhood region is determined as pixel set F;
The gradient grad (a) of the prospect boundary pixel is substituted into gradient replacement formulaIn, it obtains
Obtain the target pixel value x of the background border pixel;Wherein, the d is the pixel value of pixel in pixel set F, the num
It (F) is the sum of pixel in pixel set F.
The pixel value of the background border pixel is replaced with into the target pixel value x.
Optionally, the pixel value according to pixel in the pixel set G, determines the ladder of the prospect boundary pixel
Degree, comprising:
Formula is determined according to gradientDetermine the ladder of the prospect boundary pixel
Degree;
Wherein, the grad (a) is the gradient of prospect boundary pixel, and a is the pixel value of prospect boundary pixel, described
B is the pixel value of pixel in pixel set G, and the dist (a, b) is between the pixel in prospect boundary pixel and pixel set G
Distance, the σ be variance constant, the e be constant.
Optionally, the gradient by the background border pixel replaces with the gradient of the prospect boundary pixel, comprising:
By the verifying code character it is Chong Die with the background picture after, it is determining with the verifying in the background picture
The equitant background border pixel in the current boundary of code character;
Centered on the background border pixel, the neighborhood region comprising at least one pixel outside overlapping region is determined;
The pixel that overlapping region is not belonging in the neighborhood region is determined as pixel set F;
The gradient grad (a) of the prospect boundary pixel is substituted into gradient replacement formula
In, obtain the target pixel value x of the background border pixel;Wherein, the d is the pixel value of pixel in pixel set F, described
Dist (a, d) is the distance between the pixel in prospect boundary pixel and pixel set F.
The pixel value of the background border pixel is replaced with into the target pixel value x.
The second aspect of the application provides a kind of identifying code photograph creation device, comprising:
Picture obtains module, for obtaining verifying character picture, foreground picture and background picture;Wherein, the authenticator
According with the image comprising verifying code character in picture, in the foreground picture is texture image, and the image in the background picture is
Natural image;
Gradient replacement module, for using it is described verifying character picture in verifying code character as exposure mask, by the identifying code
Character replaces with gradient of the verifying code character in the foreground picture in the gradient in the background picture, is verified
Code picture.
Optionally, in the verifying code character using in the verifying character picture as exposure mask, by the verifying code character
The verifying code character is replaced in terms of the gradient in the foreground picture in the gradient in the background picture, the ladder
Degree replacement module is used for:
The boundary current according to the verifying code character, determines the gradient of the prospect boundary pixel in the foreground picture;
Wherein, the prospect boundary pixel is the boundary equitant picture current with the verifying code character in the foreground picture
Element;
The gradient of the background border pixel is replaced with to the gradient of the prospect boundary pixel;Wherein, the background side
Boundary's pixel is the boundary equitant pixel current with the verifying code character in the background picture;
It is inwardly indented the current boundary new with the determination verifying code character, is returned new according to the verifying code character
Current boundary, the gradient for determining the prospect boundary pixel in the foreground picture and the background border picture in the background picture
The gradient of element, until being inwardly indented to the last one pixel of the verifying code character.
Optionally, on the boundary current according to the verifying code character, the prospect side in the foreground picture is determined
The aspect of the gradient of boundary's pixel, the gradient replacement module are used for:
By the verifying code character it is Chong Die with the foreground picture after, it is determining with the verifying in the foreground picture
The equitant prospect boundary pixel in the current boundary of code character;
Centered on the prospect boundary pixel, the neighborhood region comprising at least one pixel outside overlapping region is determined;
The pixel that overlapping region is not belonging in the neighborhood region is determined as pixel set G;
According to the pixel value of pixel in the pixel set G, the gradient of the prospect boundary pixel is determined.
Optionally, in the pixel value according to pixel in the pixel set G, the ladder of the prospect boundary pixel is determined
The aspect of degree, the gradient replacement module are used for:
Formula is determined according to gradientDetermine the gradient of the prospect boundary pixel;
Wherein, the grad (a) is the gradient of prospect boundary pixel, and a is the pixel value of prospect boundary pixel, described
B is the pixel value of pixel in pixel set G, and the num (G) is the sum of pixel in pixel set G.
Optionally, the side of the gradient of the prospect boundary pixel is replaced in the gradient by the background border pixel
Face, the gradient replacement module are used for:
By the verifying code character it is Chong Die with the background picture after, it is determining with the verifying in the background picture
The equitant background border pixel in the current boundary of code character;
Centered on the background border pixel, the neighborhood region comprising at least one pixel outside overlapping region is determined;
The pixel that overlapping region is not belonging in the neighborhood region is determined as pixel set F;
The gradient grad (a) of the prospect boundary pixel is substituted into gradient replacement formulaIn, it obtains
Obtain the target pixel value x of the background border pixel;Wherein, the d is the pixel value of pixel in pixel set F, the num
It (F) is the sum of pixel in pixel set F.
The pixel value of the background border pixel is replaced with into the target pixel value x.
Optionally, in the pixel value according to pixel in the pixel set G, the ladder of the prospect boundary pixel is determined
The aspect of degree, the gradient replacement module are used for:
Formula is determined according to gradientDetermine the gradient of the prospect boundary pixel;
Wherein, the grad (a) is the gradient of prospect boundary pixel, and a is the pixel value of prospect boundary pixel, described
B is the pixel value of pixel in pixel set G, and the dist (a, b) is between the pixel in prospect boundary pixel and pixel set G
Distance, the σ be variance constant, the e be constant.
Optionally, the side of the gradient of the prospect boundary pixel is replaced in the gradient by the background border pixel
Face, the gradient replacement module are used for:
By the verifying code character it is Chong Die with the background picture after, it is determining with the verifying in the background picture
The equitant background border pixel in the current boundary of code character;
Centered on the background border pixel, the neighborhood region comprising at least one pixel outside overlapping region is determined;
The pixel that overlapping region is not belonging in the neighborhood region is determined as pixel set F;
The gradient grad (a) of the prospect boundary pixel is substituted into gradient replacement formula
In, obtain the target pixel value x of the background border pixel;Wherein, the d is the pixel value of pixel in pixel set F, described
Dist (a, d) is the distance between the pixel in prospect boundary pixel and pixel set F.
The pixel value of the background border pixel is replaced with into the target pixel value x.
From the above technical scheme, this application provides a kind of generation method of identifying code picture, this method obtains packet
Background picture containing abundant boundary content, the foreground picture comprising texture structure image and verifying character picture, verify character
The gradient of background picture is replaced with to the ladder of foreground picture to verify code character as exposure mask comprising verifying code character in picture
Degree, to can show verifying code character on background picture, which can be used as identifying code picture.Due to back
Scape picture includes boundary abundant, and rogue program is needed to analyze picture material, be tested to improve when distinguishing verifying code character
The identified difficulty out of code character is demonstrate,proved, and then improves the safety of identifying code picture.
Detailed description of the invention
In order to illustrate the technical solutions in the embodiments of the present application or in the prior art more clearly, to embodiment or will show below
There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this
The embodiment of application for those of ordinary skill in the art without creative efforts, can also basis
The attached drawing of offer obtains other attached drawings.
Fig. 1 is the flow chart of the generation method embodiment 1 of identifying code picture provided by the present application;
Fig. 2A~Fig. 2 D is followed successively by foreground picture, background picture, verifying character picture and identifying code figure provided by the present application
The exemplary diagram of piece;
Fig. 3 is the exemplary diagram provided by the present application for being inwardly indented verifying code character;
It is exemplary diagram that prospect boundary pixel determines neighborhood region that Fig. 4, which is provided by the present application,;
Fig. 5 is the structural schematic diagram of the generating means embodiment 1 of identifying code picture provided by the present application.
Specific embodiment
Below in conjunction with the attached drawing in the embodiment of the present application, technical solutions in the embodiments of the present application carries out clear, complete
Site preparation description, it is clear that described embodiments are only a part of embodiments of the present application, instead of all the embodiments.It is based on
Embodiment in the application, it is obtained by those of ordinary skill in the art without making creative efforts every other
Embodiment shall fall in the protection scope of this application.
Referring to Fig. 1, it illustrates the processes of identifying code Picture Generation Method embodiment 1 provided by the present application.Such as Fig. 1 institute
Show, the present embodiment can specifically include step S101~step S102.
Step S101: verifying character picture, foreground picture and background picture are obtained;Wherein, it verifies in character picture and includes
Code character is verified, the image in foreground picture is texture image, and the image in background picture is natural image.
Before implementation, foreground picture valut and Background valut are preset.Wherein, before including a large amount of in foreground picture valut
Scape picture, the image in foreground picture are the image of texture form.Texture image shown in A referring to fig. 2 includes in texture image
Various textures of different shapes.
It include a large amount of background picture in Background valut, background picture can be section of natural image or natural image
Figure, natural image are that the true picture come is shot using photographic device.Background picture shown in B referring to fig. 2, background picture packet
Containing boundary content abundant, in this way, identifying code can be improved in boundary property abundant on background picture after addition verifying code character
Character is by rogue program extraction or discernable difficulty.
In addition, background picture is also possible to the picture with texture structure, but know for the ease of verifying the human eye of code character
Not, the texture structure of background picture needs different from the form of the texture structure of foreground picture.
Verifying character picture library is preset, is verified in character picture comprising verifying code character.Verify the color of code character
Different from the verifying background color of character picture, optimal situation is that the two color is opposite.Character figure is verified as shown in fig. 2 c
Piece, the color for verifying code character is black, and the background of verifying character picture is white.Certainly, the color for verifying code character can also
To be white, then the background for verifying character picture is black.
Step S102: to verify the verifying code character in character picture as exposure mask, by verifying code character in background picture
Gradient replace with gradient of the verifying code character in foreground picture, obtain identifying code picture.
It is Chong Die with background picture that character picture will be verified, determine overlapping region.It will verifying character picture and foreground picture
Overlapping, to verify code character as exposure mask, replaces with the exposure mask institute area of coverage in foreground picture for the gradient of background picture overlapping region
The gradient in domain.To which as shown in Figure 2 D, verifying code character can be highlighted on background picture, verifying code character is on background picture
Gradient, that is, foreground picture in overlapping region gradient.
From the above technical scheme, a kind of generation method of identifying code picture is present embodiments provided, this method obtains
Background picture, the foreground picture comprising texture structure image and verifying character picture comprising enriching boundary content, authenticator
The gradient of background picture is replaced with into foreground picture to verify code character as exposure mask comprising verifying code character in symbol picture
Gradient, to can show verifying code character on background picture, which can be used as identifying code picture.Due to
Background picture includes boundary abundant, and rogue program needs to analyze picture material when distinguishing verifying code character, to improve
The identified difficulty out of code character is verified, and then improves the safety of identifying code picture.
It is understood that verifying code character was made of pixel, each lines for verifying code character occupy centainly
Therefore width when the gradient of background picture is replaced with the gradient of foreground picture by above-mentioned steps S102, it is thin every to can be gradually tune
The width of a lines, during adjusting thin, part that will successively verify code character peripheral boundary and covered on background picture
The gradient of pixel is replaced, that is, replaces with the part pixel that the verifying code character peripheral boundary is covered in foreground picture
Gradient.
As shown in figure 3, verifying code character is tapered.Before attenuating every time, the boundary of code character will be verified in Background
The gradient of the pixel of institute overlay area replaces with the gradient of the respective pixel in foreground picture in piece, so recycles, until verifying
Code character disappears.It is understood that be the ecto-entad to verify code character as profile in background picture, round and round by
Gradually change the gradient of itself pixel, until highlighting complete verifying code character.
Specifically, implementation above mode may comprise steps of A1~step A3.
Step A1: the boundary current according to verifying code character determines the gradient of the prospect boundary pixel in foreground picture;Its
In, prospect boundary pixel is the boundary equitant pixel current with verifying code character in foreground picture.
As shown in Figure 2 C, the color for verifying code character is different from the color of identifying code picture background, therefore, can obviously see
The boundary of code character is verified out.Boundary, that is, character the outermost one for verifying code character encloses pixel.
By after foreground picture and identifying code character overlap, in foreground picture with the equitant pixel in boundary of verifying code character
It is properly termed as prospect boundary pixel.After determining prospect boundary pixel, the gradient of the prospect boundary pixel is calculated.
Step A2: the gradient of background border pixel is replaced with to the gradient of prospect boundary pixel;Wherein, background border pixel
For the boundary equitant pixel current with verifying code character in background picture.
Definition with prospect boundary pixel similarly, by background picture and verifying character overlap after, in background picture with verifying
The equitant pixel in the boundary of code character is properly termed as background border pixel.After determining background border pixel, the background is calculated
The gradient of background border pixel is replaced with the gradient of prospect boundary pixel by the gradient of boundary pixel.Of course, background border picture
The plain gradient with corresponding prospect boundary pixel is replaced, it may be assumed that some pixel M on identifying code character boundary, in Background
On piece has overlaid pixel M1, also there is overlaid pixel M2 in foreground picture, is by the ladder of overlaid pixel M1 on background picture
Degree replaces with the gradient of overlaid pixel M2 in foreground picture.
Step A3: it is inwardly indented to determine the new current boundary of verifying code character, A1 is returned to step, until inwardly
It is retracted to the last one pixel of verifying code character.
In one example, the mode for being inwardly indented verifying code character can be, by pixel on identifying code character boundary
Pixel value becomes verifying the pixel value of character picture background pixel.As shown in Figure 2 C, by the picture of pixel on identifying code character boundary
Plain value is set as the pixel value of white background, that is, is set as 255, in this way, the lines of verifying code character can attenuate.
It is understood that being inwardly indented verifying code character, that is, the lines of thin verifying code character are adjusted, in this way, verifying code word
Symbol just has new boundary.Using the new boundary, continue to be replaced the gradient of the pixel on background picture.So follow
Ring, until being inwardly indented to the last lap or the last one pixel of verifying code character.For visually, tested in above-mentioned change
In the example for demonstrate,proving the pixel value of code character, until verifying code character disappears in verifying character picture.
Find out known to above technical solution, such implementation of step 102 is each picture determining round and round
The gradient of element, is then successively replaced.
Certainly, in practical applications, another implementation that step S102 replaces the gradient of background border pixel may be used also
To be:
Determine in the foreground area of foreground picture each picture in the gradient of each pixel and the background area of background picture
The gradient of element;Wherein, foreground area is the region verifying code character and occupying in foreground picture, and background area is verifying code character
The region occupied in background picture;The gradient of pixel each in background area is replaced with to the ladder of respective pixel in prospect character
Degree.
Such mode is to carry on the back the disposable gradient for determining verifying code character in foreground picture, and verifying code character
Gradient in scape picture, is integrally replaced, but the accuracy of gradient that such mode is determined is lower than the first realization side
Formula.The reason is that the gradient of pixel, is the difference of the pixel and the pixel value of other surrounding pixels.The first is achieved in that one
It determines the gradient of boundary pixel with enclosing, and determines gradient using the pixel and the nearest pixel of boundary peripheral distance, because
The gradient accuracy that this is determined is higher.
How detailed description below determines the gradient of prospect boundary pixel, and how to replace the gradient of background border pixel
It is changed to the gradient of foreground pixel.Specifically, there are following two different implementations.
The first implementation includes the following steps B1~step B6.
Step B1: will verifying code character it is Chong Die with foreground picture after, in foreground picture, determination and verify code character it is current
The equitant prospect boundary pixel in boundary.
Specifically, after verifying code character is Chong Die with foreground picture, a region can be determined in foreground picture, that is, is wrapped
The region of the code character containing verifying.It is understood that the boundary pixel i.e. foreground picture in the region and verifying code character
The pixel of border overlay.For ease of description, these pixels can be known as to prospect boundary pixel.
Step B2: centered on prospect boundary pixel, the neighborhood area comprising at least one pixel outside overlapping region is determined
Domain.
It is assumed that region 1 is to verify the code character partial region Chong Die with foreground picture, in foreground picture,
Centered on prospect boundary pixel A, a square neighborhood region is determined.
It should be noted that the shape in neighborhood region is not limited to the square in Fig. 4, it can be such as round with other,
The region of the regular shapes such as rectangle, sector.It is of course also possible to be the region of other irregular shapes.No matter the neighbour of which kind of shape
Domain region needs in the neighborhood region comprising the pixel except at least one overlapping region.As shown in figure 4, the neighborhood of square
Region not only includes overlapping region 1, also includes Non-overlapping Domain.
Step B3: the pixel that overlapping region is not belonging in neighborhood region is determined as pixel set G.
As shown in figure 4, the region of overlapping region is indicated in neighborhood region but is not belonging to using oblique line for the ease of identification,
Pixel in hatched example areas is determined as pixel set G.
Step B4: formula is determined according to gradientDetermine the gradient of prospect boundary pixel;Wherein,
Grad (a) is the gradient of prospect boundary pixel, and a is the pixel value of prospect boundary pixel, and b is the pixel of pixel in pixel set G
Value, num (G) are the sum of pixel in pixel set G.
Specifically, when determining formula using gradient, calculate the pixel value a of prospect boundary pixel respectively with it is each in pixel set
The difference of the pixel value b of a pixel by the sum after the summation of each difference divided by pixel in pixel set G, and then obtains prospect
The gradient grad (a) of boundary pixel.
Step B5: the gradient grad (a) of prospect boundary pixel is substituted into gradient replacement formula
In, obtain the target pixel value x of background border pixel;Wherein, d is the pixel value of pixel in pixel set F, and num (F) is pixel
The sum of pixel in set F.
Specifically, the boundary that above-mentioned steps B3 can be current according to verifying code character, determines pixel in foreground picture
Set G.In the same way, the boundary that this step can also be current according to verifying code character, determines set of pixels in background picture
Close F.
Specifically, will verifying code character it is Chong Die with background picture after, in background picture, determination and verify code character it is current
The equitant background border pixel in boundary determined centered on background border pixel comprising at least one outside overlapping region
The pixel that overlapping region is not belonging in neighborhood region will be determined as pixel set F by the neighborhood region of pixel.
After determining pixel set F, the pixel value d and pixel set F of each pixel in pixel set F can be obtained
The total num (F) of middle pixel.Therefore, step the B4 grad (a) determined and d and num (F) are substituted into above-mentioned gradient and replaces public affairs
After formula, the pixel value x of background border pixel counter can be released, for ease of description, which is known as target pixel value x.
Step B6: the pixel value of background border pixel is replaced with into target pixel value x.
It is understood that can determine background border pixel after verifying code character is Chong Die with background picture.Background side
Boundary's pixel itself has pixel value, i.e., the pixel value of its own is replaced with step B5 and obtained by the pixel value in background picture
Target pixel value x, to just realize the gradient that the gradient of background border pixel is replaced with to prospect boundary pixel.
It determines the gradient of prospect boundary pixel and the gradient of background border pixel is replaced with to the gradient of prospect boundary pixel
Second of implementation include the following steps C1~step C6.
It should be noted that the step B1 of step C1~step C3 of second of implementation and the first implementation~
Step B3 is identical, does not repeat herein, and only the part different from the first implementation to this implementation is illustrated.
Step C4: formula is determined according to gradientDetermine the ladder of prospect boundary pixel
Degree.
Wherein, grad (a) is the gradient of prospect boundary pixel, and a is the pixel value of prospect boundary pixel, and b is pixel set G
The pixel value of middle pixel, dist (a, b) are the distance between the pixel in prospect boundary pixel and pixel set G, and σ is that variance is normal
Amount, usual value are that 1, e is constant.
Specifically, the calculation of dist (a, b) can be, if the coordinate of prospect boundary pixel is (xa, ya), set of pixels
The coordinate for closing pixel in G is (xb, yb), then:
The gradient of this step determines that formula is, by the pixel of the pixel in the pixel value and pixel set of prospect boundary pixel
Value asks poor, then seeks the weighted average of the negative exponent of its distance.
Step C5: the gradient grad (a) of prospect boundary pixel is substituted into gradient replacement formulaIn, obtain the target pixel value x of background border pixel;Wherein, d is picture in pixel set F
The pixel value of element, dist (a, d) are the distance between the pixel in prospect boundary pixel and pixel set F.
It should be noted that determining the mode of pixel set F and the step B5 of the first above-mentioned implementation in this step
The mode of middle determining pixel set F is identical, does not repeat herein.In addition, with above-mentioned calculating prospect boundary pixel and pixel set G
The distance dist (a, b) of middle pixel is similar, this step can calculate background border pixel at a distance from pixel in pixel set F
dist(a,d)。
After each known quantity to be substituted into the gradient replacement formula of this step, the pixel value of background border pixel counter can be released
The pixel value can be known as target pixel value x for ease of description by x.
Step C6: the pixel value of background border pixel is replaced with into target pixel value x.
Can be seen that the above first way with the second way by comparison is only that gradient determines that formula is replaced with gradient
Formula difference is changed, other steps are identical.The gradient of background border pixel can be replaced with prospect picture by the two ways
The gradient of element, thus addition verifying code character on background picture, to generate identifying code picture.
Identifying code photograph creation device provided by the present application is introduced below, it should be noted that hereafter related to test
The explanation of card code photograph creation device may refer to identifying code Picture Generation Method provided above, not repeat below.
Corresponding with above-mentioned identifying code Picture Generation Method embodiment 1, this application provides a kind of generations of identifying code picture
Installation practice 1.As shown in figure 5, the present embodiment can specifically include: picture obtains module 501 and gradient replacement module 502.
Picture obtains module 501, for obtaining verifying character picture, foreground picture and background picture;Wherein, character is verified
Comprising verifying code character in picture, the image in foreground picture is texture image, and the image in background picture is natural image;
Gradient replacement module 502, for verify the verifying code character in character picture as exposure mask, verifying code character to be existed
Gradient in background picture replaces with gradient of the verifying code character in foreground picture, obtains identifying code picture.
Wherein, gradient replacement module 502 can be used for executing above-mentioned steps A1~step A3, step B1~step B6 or
Person's step C1~step C6.
It should be noted that all the embodiments in this specification are described in a progressive manner, each embodiment weight
Point explanation is the difference from other embodiments, and the same or similar parts between the embodiments can be referred to each other.
It should also be noted that, herein, relational terms such as first and second and the like are used merely to one
Entity or operation are distinguished with another entity or operation, without necessarily requiring or implying between these entities or operation
There are any actual relationship or orders.Moreover, the terms "include", "comprise" or its any other variant are intended to contain
Lid non-exclusive inclusion, so that the process, method, article or equipment including a series of elements is not only wanted including those
Element, but also including other elements that are not explicitly listed, or further include for this process, method, article or equipment
Intrinsic element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that
There is also other identical elements in process, method, article or equipment including above-mentioned element.
The foregoing description of the disclosed embodiments makes professional and technical personnel in the field can be realized or use the application.
Various modifications to these embodiments will be readily apparent to those skilled in the art, as defined herein
General Principle can be realized in other embodiments without departing from the spirit or scope of the application.Therefore, the application
It is not intended to be limited to the embodiments shown herein, and is to fit to and the principles and novel features disclosed herein phase one
The widest scope of cause.
Claims (14)
1. a kind of identifying code Picture Generation Method characterized by comprising
Obtain verifying character picture, foreground picture and background picture;Wherein, verifying code word is included in the verifying character picture
It accords with, the image in the foreground picture is texture image, and the image in the background picture is natural image;
Using the verifying code character in the verifying character picture as exposure mask, by the verifying code character in the background picture
Gradient replaces with gradient of the verifying code character in the foreground picture, obtains identifying code picture.
2. identifying code Picture Generation Method according to claim 1, which is characterized in that described with the verifying character picture
In verifying code character be exposure mask, the gradient of the verifying code character in the background picture is replaced with into the verifying code word
Accord with the gradient in the foreground picture, comprising:
The boundary current according to the verifying code character, determines the gradient of the prospect boundary pixel in the foreground picture;Wherein,
The prospect boundary pixel is the boundary equitant pixel current with the verifying code character in the foreground picture;
The gradient of background border pixel is replaced with to the gradient of the prospect boundary pixel;Wherein, the background border pixel is
The boundary equitant pixel current with the verifying code character in the background picture;
It is inwardly indented the current boundary new with the determination verifying code character, is returned according to new current of the verifying code character
Boundary, the gradient and background border pixel in the background picture for determining the prospect boundary pixel in the foreground picture
Gradient, until being inwardly indented to the last one pixel of the verifying code character.
3. identifying code Picture Generation Method according to claim 2, which is characterized in that described according to the verifying code character
Current boundary determines the gradient of the prospect boundary pixel in the foreground picture, comprising:
By the verifying code character it is Chong Die with the foreground picture after, it is determining with the verifying code word in the foreground picture
Accord with the equitant prospect boundary pixel in current boundary;
Centered on the prospect boundary pixel, the neighborhood region comprising at least one pixel outside overlapping region is determined;
The pixel that overlapping region is not belonging in the neighborhood region is determined as pixel set G;
According to the pixel value of pixel in the pixel set G, the gradient of the prospect boundary pixel is determined.
4. identifying code Picture Generation Method according to claim 3, which is characterized in that described according to the pixel set G
The pixel value of middle pixel determines the gradient of the prospect boundary pixel, comprising:
Formula is determined according to gradientDetermine the gradient of the prospect boundary pixel;
Wherein, the grad (a) is the gradient of prospect boundary pixel, and a is the pixel value of prospect boundary pixel, and the b is
The pixel value of pixel in pixel set G, the num (G) are the sum of pixel in pixel set G.
5. identifying code Picture Generation Method according to claim 4, which is characterized in that described by the background border pixel
Gradient replace with the gradient of the prospect boundary pixel, comprising:
By the verifying code character it is Chong Die with the background picture after, it is determining with the verifying code word in the background picture
Accord with the equitant background border pixel in current boundary;
Centered on the background border pixel, the neighborhood region comprising at least one pixel outside overlapping region is determined;
The pixel that overlapping region is not belonging in the neighborhood region is determined as pixel set F;
The gradient grad (a) of the prospect boundary pixel is substituted into gradient replacement formulaIn, obtain institute
State the target pixel value x of background border pixel;Wherein, the d is the pixel value of pixel in pixel set F, and the num (F) is
The sum of pixel in pixel set F;
The pixel value of the background border pixel is replaced with into the target pixel value x.
6. identifying code Picture Generation Method according to claim 3, which is characterized in that described according to the pixel set G
The pixel value of middle pixel determines the gradient of the prospect boundary pixel, comprising:
Formula is determined according to gradientDetermine the gradient of the prospect boundary pixel;
Wherein, the grad (a) is the gradient of prospect boundary pixel, and a is the pixel value of prospect boundary pixel, and the b is
The pixel value of pixel in pixel set G, the dist (a, b) are between the pixel in prospect boundary pixel and pixel set G
Distance, the σ are variance constant, and the e is constant.
7. identifying code Picture Generation Method according to claim 6, which is characterized in that described by the background border pixel
Gradient replace with the gradient of the prospect boundary pixel, comprising:
By the verifying code character it is Chong Die with the background picture after, it is determining with the verifying code word in the background picture
Accord with the equitant background border pixel in current boundary;
Centered on the background border pixel, the neighborhood region comprising at least one pixel outside overlapping region is determined;
The pixel that overlapping region is not belonging in the neighborhood region is determined as pixel set F;
The gradient grad (a) of the prospect boundary pixel is substituted into gradient replacement formula
In, obtain the target pixel value x of the background border pixel;Wherein, the d is the pixel value of pixel in pixel set F, described
Dist (a, d) is the distance between the pixel in prospect boundary pixel and pixel set F;
The pixel value of the background border pixel is replaced with into the target pixel value x.
8. a kind of identifying code photograph creation device characterized by comprising
Picture obtains module, for obtaining verifying character picture, foreground picture and background picture;Wherein, the verifying character figure
Comprising verifying code character in piece, the image in the foreground picture is texture image, and the image in the background picture is nature
Image;
Gradient replacement module, for using it is described verifying character picture in verifying code character as exposure mask, by the verifying code character
Gradient of the verifying code character in the foreground picture is replaced in the gradient in the background picture, obtains identifying code figure
Piece.
9. identifying code photograph creation device according to claim 8, which is characterized in that described with the verifying character figure
Verifying code character in piece is exposure mask, and gradient of the verifying code character in the background picture is replaced with the identifying code
In terms of the gradient in the foreground picture, the gradient replacement module is used for character:
The boundary current according to the verifying code character, determines the gradient of the prospect boundary pixel in the foreground picture;Wherein,
The prospect boundary pixel is the boundary equitant pixel current with the verifying code character in the foreground picture;
The gradient of background border pixel is replaced with to the gradient of the prospect boundary pixel;Wherein, the background border pixel is
The boundary equitant pixel current with the verifying code character in the background picture;
It is inwardly indented the current boundary new with the determination verifying code character, is returned according to new current of the verifying code character
Boundary, the gradient and background border pixel in the background picture for determining the prospect boundary pixel in the foreground picture
Gradient, until being inwardly indented to the last one pixel of the verifying code character.
10. identifying code photograph creation device according to claim 9, which is characterized in that described according to the identifying code
The current boundary of character determines the aspect of the gradient of the prospect boundary pixel in the foreground picture, the gradient replacement module
For:
By the verifying code character it is Chong Die with the foreground picture after, it is determining with the verifying code word in the foreground picture
Accord with the equitant prospect boundary pixel in current boundary;
Centered on the prospect boundary pixel, the neighborhood region comprising at least one pixel outside overlapping region is determined;
The pixel that overlapping region is not belonging in the neighborhood region is determined as pixel set G;
According to the pixel value of pixel in the pixel set G, the gradient of the prospect boundary pixel is determined.
11. identifying code photograph creation device according to claim 10, which is characterized in that described according to the set of pixels
The pixel value for closing pixel in G, determines the aspect of the gradient of the prospect boundary pixel, the gradient replacement module is used for:
Formula is determined according to gradientDetermine the gradient of the prospect boundary pixel;
Wherein, the grad (a) is the gradient of prospect boundary pixel, and a is the pixel value of prospect boundary pixel, and the b is
The pixel value of pixel in pixel set G, the num (G) are the sum of pixel in pixel set G.
12. identifying code photograph creation device according to claim 11, which is characterized in that described by the background border
The gradient of pixel replaces with the aspect of the gradient of the prospect boundary pixel, and the gradient replacement module is used for:
By the verifying code character it is Chong Die with the background picture after, it is determining with the verifying code word in the background picture
Accord with the equitant background border pixel in current boundary;
Centered on the background border pixel, the neighborhood region comprising at least one pixel outside overlapping region is determined;
The pixel that overlapping region is not belonging in the neighborhood region is determined as pixel set F;
The gradient grad (a) of the prospect boundary pixel is substituted into gradient replacement formulaIn, obtain institute
State the target pixel value x of background border pixel;Wherein, the d is the pixel value of pixel in pixel set F, and the num (F) is
The sum of pixel in pixel set F;
The pixel value of the background border pixel is replaced with into the target pixel value x.
13. identifying code photograph creation device according to claim 10, which is characterized in that described according to the set of pixels
The pixel value for closing pixel in G, determines the aspect of the gradient of the prospect boundary pixel, the gradient replacement module is used for:
Formula is determined according to gradientDetermine the gradient of the prospect boundary pixel;
Wherein, the grad (a) is the gradient of prospect boundary pixel, and a is the pixel value of prospect boundary pixel, and the b is
The pixel value of pixel in pixel set G, the dist (a, b) are between the pixel in prospect boundary pixel and pixel set G
Distance, the σ are variance constant, and the e is constant.
14. identifying code photograph creation device according to claim 13, which is characterized in that described by the background border
The gradient of pixel replaces with the aspect of the gradient of the prospect boundary pixel, and the gradient replacement module is used for:
By the verifying code character it is Chong Die with the background picture after, it is determining with the verifying code word in the background picture
Accord with the equitant background border pixel in current boundary;
Centered on the background border pixel, the neighborhood region comprising at least one pixel outside overlapping region is determined;
The pixel that overlapping region is not belonging in the neighborhood region is determined as pixel set F;
The gradient grad (a) of the prospect boundary pixel is substituted into gradient replacement formula
In, obtain the target pixel value x of the background border pixel;Wherein, the d is the pixel value of pixel in pixel set F, described
Dist (a, d) is the distance between the pixel in prospect boundary pixel and pixel set F;
The pixel value of the background border pixel is replaced with into the target pixel value x.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610506523.2A CN106203057B (en) | 2016-06-30 | 2016-06-30 | Identifying code Picture Generation Method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610506523.2A CN106203057B (en) | 2016-06-30 | 2016-06-30 | Identifying code Picture Generation Method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106203057A CN106203057A (en) | 2016-12-07 |
CN106203057B true CN106203057B (en) | 2019-03-12 |
Family
ID=57463791
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610506523.2A Active CN106203057B (en) | 2016-06-30 | 2016-06-30 | Identifying code Picture Generation Method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106203057B (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101201939A (en) * | 2007-12-20 | 2008-06-18 | 腾讯科技(深圳)有限公司 | Method and system for generating picture identifying code |
CN102737122A (en) * | 2012-06-08 | 2012-10-17 | 浙江大学 | Method for extracting verification code image from webpage |
CN102831568A (en) * | 2012-08-03 | 2012-12-19 | 网易(杭州)网络有限公司 | Method and device for generating verification code picture |
CN105404885A (en) * | 2015-10-28 | 2016-03-16 | 北京工业大学 | Two-dimensional character graphic verification code complex background noise interference removal method |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8103098B2 (en) * | 2008-09-03 | 2012-01-24 | Primax Electronics Ltd. | Method for generating a non-graphical digital image from an original digital image |
-
2016
- 2016-06-30 CN CN201610506523.2A patent/CN106203057B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101201939A (en) * | 2007-12-20 | 2008-06-18 | 腾讯科技(深圳)有限公司 | Method and system for generating picture identifying code |
CN102737122A (en) * | 2012-06-08 | 2012-10-17 | 浙江大学 | Method for extracting verification code image from webpage |
CN102831568A (en) * | 2012-08-03 | 2012-12-19 | 网易(杭州)网络有限公司 | Method and device for generating verification code picture |
CN105404885A (en) * | 2015-10-28 | 2016-03-16 | 北京工业大学 | Two-dimensional character graphic verification code complex background noise interference removal method |
Non-Patent Citations (1)
Title |
---|
"CAPTCHA技术的应用研究——从识别技术原理说起";毛远哲;《电子制作》;20140325;第75页 |
Also Published As
Publication number | Publication date |
---|---|
CN106203057A (en) | 2016-12-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN104463017B (en) | A kind of information processing method and electronic equipment | |
CN105117695A (en) | Living body detecting device and method | |
CN107240078A (en) | Lens articulation Method for Checking, device and electronic equipment | |
CN105224903B (en) | A kind of reading device of the method for anti-counterfeit and Quick Response Code of Quick Response Code | |
WO2017096814A1 (en) | Image processing method and apparatus | |
CN110378351B (en) | Seal identification method and device | |
CN109741232A (en) | A kind of image watermark detection method, device and electronic equipment | |
CN109948521A (en) | Image correcting error method and device, equipment and storage medium | |
CN108875556A (en) | Method, apparatus, system and the computer storage medium veritified for the testimony of a witness | |
CN109299634A (en) | Spot detection method, system, equipment and storage medium | |
CN107358609A (en) | A kind of image superimposing method and device for augmented reality | |
CN106910180B (en) | A kind of image quality measure method and device | |
CN109933971A (en) | A kind of verification method based on identifying code, device, electronic equipment and storage medium | |
CN113283271A (en) | Iris automatic capturing method, iris automatic capturing device, computer readable storage medium and computer readable storage equipment | |
CN105049710B (en) | A kind of big visual angle camera control method and user terminal | |
CN106203057B (en) | Identifying code Picture Generation Method and device | |
CN109840458A (en) | A kind of fingerprint identification method and fingerprint collecting equipment | |
CN108460319A (en) | Abnormal face detecting method and device | |
CN106713864B (en) | A kind of method for processing video frequency and device | |
CN107958236A (en) | The generation method and terminal of recognition of face sample image | |
CN105141904B (en) | Security monitoring and personal identification method and device | |
CN111767876A (en) | Method and device for generating face image with shielding | |
CN106875332A (en) | A kind of image processing method and terminal | |
CN110189350A (en) | A kind of the determination method, apparatus and storage medium of pupil edge | |
CN106203058B (en) | Verification code generation method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |