Disclosure of Invention
The invention provides a self-adaptive threshold segmentation signature image binary processing method based on PDE (differential equation), aiming at solving the problems that the traditional signature image segmentation method is low in calculation efficiency, poor in image segmentation effect on noise and required to manually adjust parameters in the processing process.
The invention is realized by the following technical scheme:
a binary processing method for self-adaptive threshold segmentation of a signature image based on PDE (partial differential equation), wherein the specific steps of the segmentation process of the signature image are as follows:
step 1: denoising the given signature image to obtain a smooth image;
step 2: processing the denoised image by using Gamma correction to increase the image contrast;
and step 3: changing the image with the increased contrast in the step 2 into a binary image by using a self-adaptive threshold fast segmentation algorithm again;
and 4, step 4: and (3) dividing the binary image in the step (3) into a signature font and a background, wherein the signature font corresponds to a black area, and the background corresponds to a white area.
Further, in the step 1, specifically,
step 1.1: discrete noise image fi,jF (I, J), where I ═ 1, ·, I, J ═ 1, ·, J, N ═ I × J ═ size (f (x)); constructing a semi-implicit numerical format of a diffusion equation corresponding to PDE filtering;
step 1.2: setting a boundary condition f according to the value format in step 1.1i,0=fi,1,fi,J+1=fi,J,f0,j=f1,j,fI+1,j=fi,j;
Step 1.3: according to the semi-hidden format in step 1.1, Gaussian convolution is applied to the noise image to obtain a smooth image f
σAnd calculate f
σGradient mode of
Step 1.4: calculating the gradient modulus of the noisy image according to the semi-hidden format in step 1.1
Step 1.5: using the results of the calculations in steps 1.3 and 1.4
And
calculating diffusion coefficient of diffusion equation
Step 1.6: calculating a diffusion coefficient matrix C by using the semi-hidden format in the step 1.1;
step 1.7: and (3) solving the semi-hidden format in the step 1.1 by utilizing a Gauss-Seidel iterative process to obtain a smooth image.
Further, the diffusion equation corresponding to the PDE filtering in step 1.1 is
u(x,0)=f(x),x∈Ω
Wherein
T > 0, f is a noise image, K is an adjustment parameter, G
σAs a gaussian function:
the semi-implicit numerical format of the diffusion equation is:
wherein tau is the time step, p ∈ { (i +1, j), (i-1, j), (i, j +1), (i, j-1) },
the above numerical format can be rewritten into matrix form U
n+1=(E-τA
n)
-1U
nWherein
A
nTo represent the symmetric sparse matrix of the diffusion portion, E is the identity matrix.
Further, in step 1.3 fσ=GσF, wherein denotes a convolution operator, an
Further, in step 1.6, when the number of iteration steps is 1, the value format in step one can be represented as U1=(E-τA0)-1F, where F is a vector representation of the noisy image. Definition C ═ E- τ A0=(cm,n)IJ×IJThe concrete form is as follows:
wherein
α(j-1)*I+i=1+2τgi,j+τ(gi-1,j+gi+1,j+gi,j-1+gi,j+1)/2
β(j-1)*I+i=-τ(gi,j+gi+1,j)/2
γ(j-1)*I+i=-τ(gi,j+gi,j+1)/2
Further, the gaussian-seidel iteration process in step 1.7 is: u. ofi,j=fi,jWhen error < 0.001, the following cycle is performed: for I is more than or equal to 1 and less than or equal to I and J is more than or equal to 1 and less than or equal to J, calculating
And then calculate error ═ U
1-U|
∞Wherein U ═ U (U)
1u
2…u
N)
T,
U is the numerical solution sought.
Further, the step 2 is specifically that,
step 2.1: processing the image by using Gamma correction; namely, it is
Said gamma usually has a value in the range of [0.5,1.5 ]];
Step 2.2: calculate the gray value range [ K ] of the smooth image um,KM]Traversing the smooth image u and recording the gray level KmCorresponding pixel ui,j;
Step 2.3: corresponding to a gray level of K
mThe pixel point of (2) calculating the two divided sub-regions
And
corresponding parameter c
1And c
2Wherein K is K
m;
Step 2.4: functional of energy calculation
Step 2.5: repeating steps 2.2 to 2.4, K for K ═ Km+1,…,KMCalculate KM-KmThe value of +1 corresponding energy functional e (K) is found, K ═ K at which e (K) reaches a maximum valuemax;
Step 2.6: determination of K
maxAfter, image u
0Is divided into two sub-regions, i.e.
Further, parameter c in step 2.2
1And c
2Are respectively as
Further, as described in step 2.3
Respectively represent D
1,D
2The number of pixel points in; if the energy e (k) reaches a maximum, the area will be divided into two sub-areas, i.e. a black area representing the font and a white area representing the background.
The invention has the beneficial effects that:
1. the self-adaptive threshold segmentation signature image binary processing technology based on the PDE can change an image into a binary image, namely a signature font corresponds to a black area, and a background corresponds to a white area; the boundary line of the new model is closer to the real boundary of the image from the gray level set, so that the complete information of the signature image is effectively segmented.
2. Compared with other image segmentation methods, the self-adaptive threshold segmentation signature image binary processing technology based on the PDE does not need to initialize parameters again, the complexity of the algorithm is deduced to be O (N), N is the number of pixel points, and therefore the algorithm can remarkably improve the calculation efficiency when processing large-scale images.
3. The self-adaptive threshold segmentation signature image binary processing technology based on the PDE is easy to realize. The first step of the new algorithm is mainly to obtain smooth images without obtaining the optimal denoising result, so that the corresponding filtering processing is carried out for several times; the new algorithm step 2 only needs to traverse the image once, then calculates 256 situations, and finally finds the best gray level to achieve the segmentation purpose. Therefore, the method is simple in processing flow and easy to implement.
4. The image segmentation method based on the diffusion equation and the gray level set is different from the traditional level set method in that the level set function needs to be solved, but the image is restored firstly, and then the level set of the image is used for segmentation, so that the defect that the variational level set needs to be solved in the original level set method is overcome, and the calculation efficiency is greatly improved.
Detailed Description
The technical solutions in the embodiments of the present invention will be described clearly and completely with reference to the accompanying drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Example 1
As shown in fig. 1, a method for adaptive threshold segmentation of a signature image binary processing based on PDE includes the following specific steps:
step 1: denoising the given signature image to obtain a smooth image;
step 2: processing the denoised image by using Gamma correction to increase the image contrast;
and step 3: changing the image with the increased contrast in the step 2 into a binary image by using a self-adaptive threshold fast segmentation algorithm again;
and 4, step 4: and (3) dividing the binary image in the step (3) into a signature font and a background, wherein the signature font corresponds to a black area, and the background corresponds to a white area.
Further, in the step 1, specifically,
step 1.1: discrete noise image fi,jF (I, J), where I ═ 1, ·, I, J ═ 1, ·, J, N ═ I × J ═ size (f (x)); constructing a semi-implicit numerical format of a diffusion equation corresponding to PDE filtering;
step 1.2: setting a boundary condition f according to the value format in step 1.1i,0=fi,1,fi,J+1=fi,J,f0,j=f1,j,fI+1,j=fi,j;
Step 1.3: according to the semi-hidden format in step 1.1, Gaussian convolution is applied to the noise image to obtain a smooth image f
σAnd calculate f
σGradient mode of
Step 1.4: calculating the gradient modulus of the noisy image according to the semi-hidden format in step 1.1
Step 1.5: using the results of the calculations in steps 1.3 and 1.4
And
calculating diffusion coefficient of diffusion equation
Step 1.6: calculating a diffusion coefficient matrix C by using the semi-hidden format in the step 1.1;
step 1.7: and (3) solving the semi-hidden format in the step 1.1 by utilizing a Gauss-Seidel iterative process to obtain a smooth image.
Further, the diffusion equation corresponding to the PDE filtering in step 1.1 is
Wherein
T > 0, f is a noise image, K is an adjustment parameter, G
σAs a gaussian function:
the semi-implicit numerical format of the diffusion equation is:
wherein τ is the time stepLong, p ∈ { (i +1, j), (i-1, j), (i, j +1), (i, j-1) },
the above numerical format can be rewritten into matrix form U
n+1=(E-τA
n)
-1U
nWherein
A
nTo represent the symmetric sparse matrix of the diffusion portion, E is the identity matrix.
Further, in step 1.3 fσ=GσF, wherein denotes a convolution operator, an
Further, in step 1.6, when the number of iteration steps is 1, the value format in step one can be represented as U1=(E-τA0)-1F, where F is a vector representation of the noisy image. Definition C ═ E- τ A0=(cm,n)IJ×IJThe concrete form is as follows:
wherein
α(j-1)*I+i=1+2τgi,j+τ(gi-1,j+gi+1,j+gi,j-1+gi,j+1)/2
β(j-1)*I+i=-τ(gi,j+gi+1,j)/2
γ(j-1)*I+i=-τ(gi,j+gi,j+1)/2
Further, the gaussian-seidel iteration process in step 1.7 is: u. ofi,j=fi,jWhen error < 0.001, the following cycle is performed: for I is more than or equal to 1 and less than or equal to I and J is more than or equal to 1 and less than or equal to J, calculating
And then calculate error ═ U
1-U|
∞Wherein U ═ U (U)
1u
2…u
N)
T,
U is the numerical solution sought.
Further, the step 2 is specifically that,
step 2.1: processing the image by using Gamma correction; namely, it is
Said gamma usually has a value in the range of [0.5,1.5 ]](ii) a There is no optimum value for this value and the user needs to choose a smaller gamma when the processed image is dark and vice versa.
Step 2.2: calculate the gray value range [ K ] of the smooth image um,KM]Traversing the smooth image u and recording the gray level KmCorresponding pixel ui,j;
Step 2.3: corresponding to a gray level of K
mThe pixel point of (2) calculating the two divided sub-regions
And
corresponding parameter c
1And c
2Wherein K is K
m;
Step (ii) of2.4: functional of energy calculation
Step 2.5: repeating steps 2.2 to 2.4, K for K ═ Km+1,…,KMCalculate KM-KmThe value of +1 corresponding energy functional e (K) is found, K ═ K at which e (K) reaches a maximum valuemax;
Step 2.6: determination of K
maxAfter, image u
0Is divided into two sub-regions, i.e.
Further, parameter c in step 2.2
1And c
2Are respectively as
Further, as described in step 2.3
Respectively represent D
1,D
2The number of pixel points in; if the energy e (k) reaches a maximum, the area will be divided into two sub-areas, i.e. a black area representing the font and a white area representing the background.