Background technology
Image binaryzation is exactly that the gray value of the pixel on image is set to 0 or 255, that is, by whole image is in
Reveal obvious black and white effect.The binaryzation of image is conducive to the further process of image, makes image become simple, and data
Amount reduces, and can highlight the profile of target interested.Traditional binarization method such as/kittler algorithms, are a kind of quick
Global thresholding, or average-histogram method, is characterized in that overall binaryzation.For the image of various gray levels is difficult to show not
With the profile of the target of grayscale image, the central idea of traditional binarization method is to calculate the gradient gray scale of entire image
Meansigma methodss, with this meansigma methods as threshold value, can apply in the pretty good environment of picture quality.But at the continuous image of batch
In reason, when there are the complex situations such as the image of polychrome level gray color level in the face of various images, using produced by single threshold value
Binaryzation can not completely reflect the feature of image.Though traditional binarization method has for global and local, they assess
The whether suitable standard of threshold value or foundation are the meansigma methodss of gray scale.And using single average gray as the evaluation criteria of threshold value
Have following defect and drawback:
1st, the meansigma methodss of gray scale only reflect the brightness of image or the average depth degree of color, but differ surely directly reflect for
User image object pixel interested and its contour feature for being constituted.
2nd, impact must be produced on the binary conversion treatment of the pixel of other gray values using the meansigma methodss of arbitrary gray scale, is made
The omission of imaging vegetarian refreshments characteristic information.
3rd, existing image binaryzation processing method, when the gray level for image occur is more, traditional image binaryzation
Processing method is difficult to find out by user image object pixel interested and its contour feature for constituting.
Such as patent CN105118067A, entitled:A kind of image partition method based on Gaussian smoothing filter, it is open following
Technical characteristic(Referring in full):Step 1, count histogrammic first trough average T0 of N number of infrared image;With gray level it is
Rectangular histogram abscissa, the number of times that each gray level occurs count the gray scale of each infrared image as histogrammic vertical coordinate
Rectangular histogram, finds the gray value Troughi of first trough of grey level histogram, and the gray value to all first troughs
It is averaged and is designated as T0;T0=ΣTroughi/N;Step 2, calculating adaptivenon-uniform sampling threshold θ;2-1 passes through first trough average T0
Calculate weighting function Fwtd=α (T1-T0);Wherein T1 is assembly average of the gray value higher than T0, specifically:, α is to finely tune the factor, 0.9 < α < 1.1;2-2 scans all gray levels, obtains and meets inter-class variance maximum
Segmentation threshold θ σ during change;2-3 calculates adaptivenon-uniform sampling threshold θ=θ σ+Fwtd;Step 3, use adapt to segmentation threshold θ pair
Image to be split carries out binary conversion treatment;3-1 scans all pixels point, if the gray level of pixel is more than θ, gray level is put
For 1, now pixel of the pixel for foreground target suspicious region;If the gray level of pixel is less than or equal to θ, gray scale
Level is set to 0, and now the pixel is background pixel point, and result now is designated as RSegmentation;It is step 4, right
RSegmentation carries out floor projection integration and upright projection integral analysis, filters the less focus interference of area.The patent
Only disclose the image binaryzation method based on single threshold value, it is impossible to solve the defect and drawback of single threshold value presence.
And for example patent CN104952060A, entitled:A kind of infrared pedestrian's area-of-interest adaptivenon-uniform sampling extracting method,
Including following technical characteristic(Referring in full):Step 4, to take be Global thresholding, only complete using one in binarization
The method of office's threshold value T, the gray value of each pixel of image is compared by it with T, if being more than T, is taken as foreground;It is no
Then, it is taken as background colour;Step 5, using the most center point Ps of respective pixel number in L grey level range as initial classes mean μ 1
(1),μ2(2), …,μl(l);Step 6, in ith iteration, investigate each pixel, calculate its average with each gray level
Between spacing, i.e., it with cluster centre apart from D, each pixel is assigned into the average class nearest away from which, i.e. D | xp- μ l (i) |=
Min D | xp- μ j (i) |, (j=1,2 ... l) }, D is that two pixel grey scale value differences are less than determining deviation;Xp (p=0,1 ..., 255)
For the gray value of pixel;Then for the collection of pixels of class j is assigned to after ith iteration;Step 7, for j=1,2 ... l, calculate it is new
Cluster centre, updates class average:μ j ( i + 1 ) = 1 / N j Σ x ∈Q j (i) x p, formula
In, Nj be in number of pixels;Step 8, all pixels are investigated one by one, if j=1,2 ... K have then algorithmic statement, knot
Beam;Otherwise return to step 6 continues next iteration;After step 9, above cluster process terminate, each pixel of segmentation result is with poly-
Class center gray value is used as such final gray scale.The patent cannot also solve the input picture of polychrome level to be carried out at image binaryzation
The omission problem of pixel characteristic information during reason.
Therefore, prior art has yet to be improved and developed.
The content of the invention
It is an object of the invention to provide the method and its system of a kind of dynamic calculation polychrome level binaryzation adaptive threshold,
When aiming to solve the problem that the input picture of polychrome level carries out image binaryzation process, it is difficult to overcome pixel feature using traditional method
The omission problem of information, when the gray level for image occur is more, traditional image binaryzation processing method is difficult to find out to make
The defect of user's image object pixel interested and its contour feature for being constituted.
Technical scheme is as follows:A kind of method of dynamic calculation polychrome level binaryzation adaptive threshold, wherein, institute
Polychrome level is stated for three or three with level of painting, following steps are specifically included:
Step S110:Extract the gray value of input image pixels point and obtain the center of each same or like color level of input picture
Gray value;
Step S120:According to the center gray value of acquired color level and press the ash of the border between the not homochromy level of preset formula dynamic calculation
Threshold value of the angle value as phase advancing coloud nearside level binarization segmentation, to obtain polychrome level binaryzation adaptive threshold.
The method of described dynamic calculation polychrome level binaryzation adaptive threshold, wherein, comprise the following steps:
Step S210:Extract the gray value of input image pixels point and the gray value that pixel in background colour level is most concentrated is carried out
Light color process, i.e., to pixel gray value in background colour level be not 255 or be not maximum input image pixels point gray value
Do inverse process;
Step S220:The gray value of analysis input image pixels point and the relation of pixel quantity, obtain input picture each identical
Or the center gray value of close color level;
Step S230:According to the center gray value of acquired color level and press the ash of the border between the not homochromy level of preset formula dynamic calculation
Threshold value of the angle value as phase advancing coloud nearside level binarization segmentation, to obtain polychrome level binaryzation adaptive threshold.
The method of described dynamic calculation polychrome level binaryzation adaptive threshold, wherein, described same or like color
Level refers to the same or like pixel point set of the attribute of the gray value of input image pixels point;Described same or like color level
Center gray value refer to gray value that pixel quantity in the same or like scope of the attribute of gray value at most or is most concentrated.
The method of described dynamic calculation polychrome level binaryzation adaptive threshold, wherein, described polychrome level binaryzation is
The gray value that the gray value of all pixels point on input picture is set to background colour level is set to 255 by finger, its allochromatic colour level
Gray value is set to the center gray value of the color level or the color level image segmentation is out set to 0 afterwards.
The method of described dynamic calculation polychrome level binaryzation adaptive threshold, wherein, it is described to obtain each phase of input picture
The center gray value of same or close color level, specifically includes following steps:
Step S221:Each gray value pixel number in the input image is counted, the pass of gray value and pixel quantity is analyzed
System;
Step S222:Find out crest gray value;
Step S223:Whether the crest gray value acquired in checking step S222 falls into the interval range of default gray scale length and is
The default trough pixel number of maximum crest gray value, will fall into crest gray value maximum in the range of default gray scale length of interval
And the pixel number of the crest gray value is considered as center gray value more than the crest gray value of default trough pixel number;
Step S224:Center gray value corresponding to per level number of the same colour is recorded into into data set.
The method of described dynamic calculation polychrome level binaryzation adaptive threshold, wherein, default gray scale length refers to basis
Application demand and the same or like interval range parameter of gray value that pre-sets, preset gray scale length interval comprising the color level
The gray value length of minimum gradation value to maximum gradation value;Default trough pixel number is referred to according to application demand and is pre-set
The range parameter of pixel number that should concentrate of same gray value.
The method of described dynamic calculation polychrome level binaryzation adaptive threshold, wherein, the default gray scale length takes
Value between 10 to 125, preset the value of trough pixel number between input image pixels point sum 0.1% to 10% it
Between.
The method of described dynamic calculation polychrome level binaryzation adaptive threshold, wherein, described dynamic calculation obtains many
The preset formula of color level binaryzation adaptive threshold includes:
Tn=An·core +(B n·core -A n·core )/2
Wherein, TnRepresent the self-adaption binaryzation threshold value of n-th color level in addition to background colour level, An·coreRepresent in addition to background colour level
The center gray value of n-th color level, B n·coreRepresent the upper level center gray value of n-th color level in addition to background colour level.
A kind of system of the method for the dynamic calculation polychrome level binaryzation adaptive threshold using as described in above-mentioned any one,
Wherein, including:
Gray value module is extracted, for extracting the gray value of input image pixels point;
Se Ji centers gray value module is obtained, for the relation by statistical analysiss input picture gray value and pixel quantity,
Obtain the center gray value of each same or like color level of input picture;
Calculate and obtain polychrome level binaryzation adaptive threshold module, polychrome level binaryzation is obtained for pressing preset formula dynamic calculation
Adaptive threshold.
The system of described dynamic calculation polychrome level binaryzation adaptive threshold, wherein, including:
Gray value module is extracted, for extracting the gray value of input image pixels point;
Inverse processing module, and be not the input image pixels of 255 or maximum to the gray value that pixel on sideline is most concentrated
Point gray value does inverse process;
Se Ji centers gray value module is obtained, for the relation by statistical analysiss input picture gray value and pixel quantity,
Obtain the center gray value of each same or like color level of input picture;
Calculate and obtain polychrome level binaryzation adaptive threshold module, polychrome level binaryzation is obtained for pressing preset formula dynamic calculation
Adaptive threshold.
Beneficial effects of the present invention:The present invention is by providing a kind of side of dynamic calculation polychrome level binaryzation adaptive threshold
Method and its system, by counting each gray value pixel number in the input image, analyze gray value with pixel quantity
Relation, finds out crest gray value, will fall into crest gray value maximum in the range of default gray scale length of interval and the crest gray scale
The pixel number of value is considered as center gray value more than the crest gray value of default trough pixel number, then by acquired color level
Heart gray value simultaneously presses the boundary gray value between the not homochromy level of preset formula dynamic calculation as the threshold of phase advancing coloud nearside level binarization segmentation
Value, so as to obtain the binaryzation adaptive threshold of polychrome level.Using the binaryzation adaptive threshold of polychrome level of the present invention,
Being capable of effective polychrome level(I.e. three or three with level of painting)Input picture carry out image binaryzation process when, using traditional
Method is difficult to the omission problem for overcoming pixel characteristic information, is difficult to overcome using the binarization method produced by single threshold value
The omission problem of pixel characteristic information, when the gray level for image occur is more, remain to effectively to find out for user it is interested
Image object pixel and its contour feature for being constituted, improve polychrome level input picture binary conversion treatment effect.
Specific embodiment
To make the objects, technical solutions and advantages of the present invention clearer, clear and definite, develop simultaneously embodiment pair referring to the drawings
The present invention is further described.
As shown in figure 1, a kind of method of dynamic calculation polychrome level binaryzation adaptive threshold, specifically includes following steps:
Step S110:Extract the gray value of input image pixels point and obtain the center of each same or like color level of input picture
Gray value;
Step S120:According to the center gray value of acquired color level and press the ash of the border between the not homochromy level of preset formula dynamic calculation
Threshold value of the angle value as phase advancing coloud nearside level binarization segmentation, to obtain polychrome level binaryzation adaptive threshold.
As shown in Fig. 2 for some need to do the image of inverse process, a kind of dynamic calculation polychrome level binaryzation self adaptation
The method of threshold value is comprised the following steps:
Step S210:Extract the gray value of input image pixels point and the gray value that pixel in background colour level is most concentrated is carried out
Light color process, i.e., to pixel gray value in background colour level be not 255 or be not maximum input image pixels point gray value
Do inverse process;
Step S220:The gray value of analysis input image pixels point and the relation of pixel quantity, obtain input picture each identical
Or the center gray value of close color level;
Step S230:According to the center gray value of acquired color level and press the ash of the border between the not homochromy level of preset formula dynamic calculation
Threshold value of the angle value as phase advancing coloud nearside level binarization segmentation, to obtain polychrome level binaryzation adaptive threshold.
Above steps is specifically described below based on specific embodiment:
The first step, extracts the gray value of input image pixels point.
In actual applications, by computer equipment, the mobile phone for having camera function, photographing unit, photographic head or other have shooting
Or the input picture that the equipment of storage image is obtained, can be used for the process object of the embodiment of the present invention.
Fig. 3 a and Fig. 3 b provides some images at random.The artwork of these images is with the different gray scales of three or more than three
Color level, can be used as the process object of the embodiment of the present invention, i.e. input picture.Each input picture all has the feature of gray scale, ash
The scope of angle value is 0~255, represents brightness from depth to shallow, and the color in correspondence image is that, from black to white, each pixel value is
One kind in 256 kinds of gray scales between black and white.The each pixel of input picture is extracted with known technology
Gray value.
Fig. 4 is the gray value statistical table of Fig. 3 a example images local pixel points.
Second step, carries out light process to the gray value that pixel in background colour level is most concentrated.
In actual applications, light color can be carried out to the gray value that pixel in background colour level is most concentrated according to application demand
Process, i.e., be not 255 to pixel gray value in background colour level or be not that the input image pixels point gray value of maximum does instead
Color process;To pixel gray value in background colour level can also not be 255 or be not maximum input image pixels point gray scale
Value does not do inverse process.In actual applications, in order to realize the standardization of background colour level, generally by the back of the body of input picture
Scenery unification is set as white or most light, naturally it is also possible to which background colour is set as black or most dark.
It is not 255 to pixel gray value in background colour level or is not that the input image pixels point gray value of maximum does instead
Color process method be:
The gray value of preimage vegetarian refreshments result of calculation as follows is entered into line replacement:
Gray value after inverse(Or the gray value being replaced into)=255- former ash angle value
Jing after inverse process, remain the background colour of input picture white or most light.
3rd step, analyzes the gray value of input image pixels point and the relation of pixel quantity, obtains each phase of input picture
The center gray value of same or close color level.
The most basic unit key element of composition image is pixel, and each pixel can be considered as a unit spot, also known as pixel
Point.There is between pixel and pixel line segment relation, the line of limited pixel is exactly pixel dotted line in particular directions
Section.The image that the set of pixel line segment is constituted.
Each pixel all has the attribute of gray value, and same or like color level is typically identical by gray scale value attribute
Or close pixel point set is constituted.The most gray value of pixel quantity in the same or like scope of attribute is claimed by we
For the center gray value of the same or like color level(Center gray value refers to the ash that the color level can be most represented in certain level of the same colour
The gray value of degree feature, in a certain specific region of the same or like scope of attribute for referring generally to gray value, pixel quantity is most
Or the gray value most concentrated), the same or like interval range of gray value is referred to as gray scale length(Gray scale length is referred to a certain
Se Jizhongyi centers gray value is basic point, does not change the depth excursion of the gray value of same or like attribute, including the phase
The gray-value variation length of the minimum gradation value to maximum gradation value of same or close color level).
By statistical analysiss input picture gray value and the relation of pixel quantity, Se Ji centers gray value can be obtained,
Comprise the following steps that:
Step S221, counts each gray value pixel number in the input image, analyzes the pass of gray value and pixel quantity
System.
The pixel number of each gray value of statistics input picture, produces the relation number of each gray value and pixel quantity
According to.Fig. 5 is the relation statistical table of Fig. 3 a example images gray values and pixel quantity.Fig. 6 is Fig. 3 a example images gray scales
The relation cartogram of value and pixel quantity.
Step S222, finds out crest gray value.
The pixel number of more each gray value and neighbor grayscale value is checked, the pixel number than neighbor grayscale value all many
Gray value be considered as crest gray value, otherwise, be not crest gray value.If the pixel number of left neighbor grayscale value is adjacent with the right side
The pixel number of gray value is equal and pixel number of than secondary neighbor grayscale value is all more, and this adjacent 2 points or multiple spot are collectively treated as
Crest gray value, otherwise, is not crest gray value.
Step S223, during the crest gray value for falling into the scope of default gray scale length and default trough pixel number is considered as
Heart gray value.
Default gray scale length refers to the same or like interval range ginseng of the gray value pre-set according to application demand
Number, comprising natural grade minimum gradation value to the gray value length between natural grade maximum gradation value, presets the value of gray scale length
Between 10 to 125;Or with natural grade center gray value as basic point, general natural grade minimum gradation value natural grade center ash
Angle value -5, value in the range of natural grade maximum gradation value+5(If natural grade center gray value is 70, then natural grade is minimum grey
Angle value 65, natural grade maximum gradation value 75).
Default trough pixel number refers to the pixel that the same gray value pre-set according to application demand should be concentrated
In advance the range parameter of points, preset the trough pixel number value typically in the range of 10% less than the total pixel number of image, i.e.,
If trough pixel number<The total pixel number * of image 10%.It is default whether the crest gray value acquired in checking step S222 falls into
The scope of gray scale length and default trough pixel number, by default gray scale length and more than the ripple of default trough pixel number
Peak gray value is considered as center gray value.
Center gray value corresponding to per level number of the same colour is recorded into data set by step S224.
To be numbered after size sequence of the acquired center gray value by gray value, each numbering represents a color
Level, the center gray value corresponding to per level number of the same colour is recorded as array.
It is ± 10 that table 1 lists Fig. 3 a example images and falls into default gray scale length and default trough pixel number scope is
Center gray value corresponding to 3% color level number:
Color level number |
Center gray value |
1 |
255 |
2 |
222 |
3 |
128 |
4 |
64 |
5 |
0 |
Table 1
4th step, according to the center gray value of acquired color level and presses the boundary intensity between the not homochromy level of preset formula dynamic calculation
It is worth the threshold value as phase advancing coloud nearside level binarization segmentation, to obtain polychrome level binaryzation adaptive threshold.
Specifically, traditional image binaryzation substantially just refers to the binaryzation of single image, will be all on input picture
The gray value of pixel is set to 0 or 255, that is, whole input picture is presented obvious black and white effect.Traditional figure
As binaryzation cannot be solved when input picture occur and there are the complex situations such as the image of multi-stage grey scale color level using single threshold
Binaryzation effect produced by value can not completely reflect a difficult problem for the feature of image.And adopt polychrome level binaryzation adaptive threshold
The binaryzation of assorted level is carried out respectively can, the whole figure of effectively solving can not be complete using the binaryzation effect produced by single threshold value
A difficult problem for the feature of reflection image.
The key for determining polychrome level binaryzation adaptive threshold is the segmentation for finding out background colour level respectively with other polychrome levels
Threshold value, i.e., when the gray value of the background colour level on input picture is set to 255, and its allochromatic colour level gray value is then set to the color
Level center gray value is 0 or the color level image segmentation is out set to 0 afterwards, that is, whole input picture is presented substantially
The distinct effect of color level segmentation.
Generally, center of maximum gray value(I.e.:255 gray value or closest to 255 gray value)For background colour
The center gray value of level.
Background colour level can be calculated using following preset formula with the segmentation threshold of other many color lumps or gray level respectively and be obtained
Take:
Tn=An·core +(B n·core -A n·core )/2
Wherein, TnRepresent the self-adaption binaryzation threshold value of n-th color level in addition to background colour level, An·coreRepresent in addition to background colour level
The center gray value of n-th color level, B n·coreRepresent the upper level center gray value of n-th color level in addition to background colour level.
By taking Fig. 3 a example images as an example, to according to each color lump number for having been obtained in step S220(Or color level number)Institute is right
The center gray value answered substitutes into formula 1 and is calculated, and obtains the self-adaption binaryzation threshold value in addition to background colour level:
Self-adaption binaryzation threshold calculations in Fig. 3 a example images in addition to background colour level are as follows:
The self-adaption binaryzation threshold value of the 1st color level:
T1=222+(255-222)/2=239;
The self-adaption binaryzation threshold value of the 2nd color level:
T2=128+(222-128)/2=175;
The self-adaption binaryzation threshold value of the 3rd color level:
T3=64+(128-64)/2=96;
The self-adaption binaryzation threshold value of the 4th color level:
T4=0+(64-0)/2=32.
Fig. 7 is the combination polychrome level binary picture of Fig. 3 a example images.
Fig. 8 a to Fig. 8 d are the segmentation polychrome level binary pictures of Fig. 3 a example images.
Fig. 9 is the combination polychrome level binary picture of Fig. 3 b example images.
Figure 10 a to Figure 10 b are the segmentation polychrome level binary pictures of Fig. 3 b example images.
In an embodiment of the present invention, according to acquired polychrome level adaptation binary-state threshold, outstanding level can be produced
The multistage color lump figure of the input picture of the distinct effect of segmentation, during for image outline line feature extraction, effectively increases profile special
What reference ceased puies forward quasi- rate.
A kind of system of the method using dynamic calculation polychrome level binaryzation adaptive threshold as described above, including:
Gray value module is extracted, for extracting the gray value of input image pixels point;
Se Ji centers gray value module is obtained, for the relation by statistical analysiss input picture gray value and pixel quantity,
Obtain the center gray value of each same or like color level of input picture;
Calculate and obtain polychrome level binaryzation adaptive threshold module, polychrome level binaryzation is obtained for pressing preset formula dynamic calculation
Adaptive threshold.
Figure 11 is a kind of system structure diagram one of dynamic calculation polychrome level binaryzation adaptive threshold.
When some images need inverse to process, a kind of system bag of dynamic calculation polychrome level binaryzation adaptive threshold
Include:
Gray value module is extracted, for extracting the gray value of input image pixels point;
Inverse processing module, and be not the input image pixels of 255 or maximum to the gray value that pixel on sideline is most concentrated
Point gray value does inverse process;
Se Ji centers gray value module is obtained, for the relation by statistical analysiss input picture gray value and pixel quantity,
Obtain the center gray value of each same or like color level of input picture;
Calculate and obtain polychrome level binaryzation adaptive threshold module, polychrome level binaryzation is obtained for pressing preset formula dynamic calculation
Adaptive threshold.
Figure 12 is a kind of system structure diagram two of dynamic calculation polychrome level binaryzation adaptive threshold.
Embodiment described above is illustrated by one by one to input picture gray value and the statistics of the relation of pixel quantity
Analysis, obtains the color level feature with center gray value as the form of expression for input picture, with the boundary intensity of not homochromy level
It is worth the threshold value as phase advancing coloud nearside level binarization segmentation, so as to obtain the binaryzation adaptive threshold of polychrome level.
Using the polychrome level binaryzation adaptive threshold method and its system of the present invention, can there is ash more to input picture
The complex situations such as the image of degree color level carry out the process of binaryzation, effectively improve the binary conversion treatment effect of polychrome level input picture
Really, and the color lump characteristic information of the not homochromy level of complete reflection input picture is obtained, overcomes the input picture of multi-grey level to carry out figure
During as binary conversion treatment, it is difficult to find out by user image object pixel interested and its constitute using traditional method
Not homochromy level color lump characteristic information defect.Using the present invention polychrome level binaryzation adaptive threshold method and its be
System, additionally it is possible to realize that image is carried out the partition of color lump by color level, the description of rich image feature is easy to broadly meet image point
The needs of analysis.
It should be appreciated that above example only expresses the several embodiments of the present invention, its description it is more concrete and
Therefore in detail, but the restriction to the scope of the claims of the present invention can not be interpreted as.It should be pointed out that to those of ordinary skill in the art
For, without departing from the inventive concept of the premise, some deformations, derivation can also be made, is improved or is converted, it is all these
The protection domain of claims of the present invention should all be belonged to.