Summary of the invention
To the problems referred to above, the purpose of this invention is to provide a kind of notion based on main body, through extracting the characteristic of traditional Chinese Painting image and handwriting image main body, realize method to traditional Chinese Painting image and handwriting image identification.
For realizing above-mentioned purpose; The present invention takes following technical scheme: a kind of based on the traditional Chinese Painting image of main body and the recognition methods of handwriting image; It comprises the steps: that (1) utilizes scanner scanning China traditional Chinese Painting works and calligraphy work that occurred in history before modern age, obtains the sample image of traditional Chinese Painting works and calligraphy work; (2) sample image is carried out the image pre-service based on Top-down, 1. it comprise the steps: sample image from the RGB color space conversion to the hsv color space; The sample image in the hsv color space that 2. 1. step is obtained is done the rim detection of Canny operator; The sample image of the rim detection that 3. 2. step is obtained is done the processing of edge swell; The sample image of the edge swell that 4. 3. step is obtained is done the processing that fill in the zone; The statistics of colouring information is carried out in background area beyond the fill area of the sample image that fill in the zone that 5. 4. step is obtained, comprises each component in the hsv color space is added up, and draws mean value Ave_H, Ave_S, the Ave_V of each component; 6. the sample image that preliminary sweep is obtained carries out the traversal of full figure individual element; The value of the H in the hsv color space of each pixel of sample image, S, each component of V respectively with the hsv color space in mean value Ave_H, Ave_S, the Ave_V of each component do the difference computing; Difference operation result and threshold value are compared; Pixel in threshold range thinks to stay white region, is set to be unified color; (3) picked at random training sample image and test sample image from the sample image that scanning obtains; (4) the body feature vector of extraction training sample image from training sample image, and training classifier, it comprises the steps: 1. to pass through the grey level histogram that step (2) image pre-service obtains training sample image, and gray scale is 256 rank; 2. count the number of times summation Total that in training sample image, occurs for bin between each chromatic zones in the training sample image grey level histogram; The last body feature vector that generates one 256 dimension of each training sample image; Accomplish the extraction of the body feature vector of training sample image; Consider the size of different training sample image, adopt following formula to calculate:
Wherein, Wide, High represent the wide and high of training sample image respectively;
(5) training sample image sorter; From test sample image, extract the body feature vector; The sample image sorter that utilization trains is discerned; 1. it comprise the steps: the body feature vector to the training sample image of extracting, and trains the sample image sorter that obtains training based on machine learning model; 2. extract the body feature vector of test sample image; 3. for the body feature vector of the test sample image of extracting, the sample image sorter that utilization trains is discerned, and draws the result of identification.
Said step (3) picked at random training sample image and test sample image from the sample image that scanning obtains comprise the steps 1. to define the sample image classification, are numbered 1 or 0,1 expression traditional Chinese Painting sample image, 0 expression calligraphy sample image; 2. being used for sample image to be identified is I, is labeled as { I
1, I
2, I wherein
1Expression calligraphy sample image is designated as I
1={ C
1, C
2... C
n, C
i(i=1 2...n) is expressed as the calligraphy sample image that scanning obtains, I
2Expression traditional Chinese Painting sample image is designated as I
2={ P
1, P
2... P
n, P
i(i=1 2...n) is expressed as the traditional Chinese Painting sample image that scanning obtains; 3. respectively from I
1, I
2The sample image that middle picked at random is set quantity is designated as { I as training sample image collection T
1', I
2', I
1' expression calligraphy training sample image, I
2' expression traditional Chinese Painting training sample image is with I
1, I
2Middle samples remaining image is as the test sample image collection
e
i(i=1 2...m) is test sample image.
In the said step (5) 1. to train the algorithm of employing based on machine learning model be decision Tree algorithms, artificial neural network, algorithm of support vector machine, a kind of in the Bayesian learning algorithm.
The present invention is owing to take above technical scheme, and it has the following advantages: 1, the present invention is based on the notion of main body, through extracting the characteristic of traditional Chinese Painting image and handwriting image main body, realized the identification to traditional Chinese Painting image and handwriting image.2, the present invention is through the pre-service to traditional Chinese Painting image and handwriting image; Realized the white region that stays of traditional Chinese Painting image and handwriting image background is handled; Make outstanding the manifesting of characteristic of traditional Chinese Painting image and each autonomous agent of handwriting image like this, help feature extraction traditional Chinese Painting image and handwriting image main body.3, the present invention can ignore the influence of the size of traditional Chinese Painting image and handwriting image to the body feature vector when traditional Chinese Painting image and handwriting image body feature are extracted.Therefore, the present invention can be widely used in the identification to traditional Chinese Painting image and handwriting image.
Embodiment
Below in conjunction with accompanying drawing and embodiment the present invention is carried out detailed description.
As shown in Figure 1, the recognition methods of traditional Chinese Painting image of the present invention and handwriting image comprises the steps:
1, scanning China's traditional Chinese Painting works and calligraphy work that occurred in history before modern age obtains the sample image of traditional Chinese Painting works and calligraphy work.
Like Fig. 2, shown in Figure 3, sample image of the present invention obtains through Epson Expression10000XL scanner scanning.
2, sample image is carried out the data pre-service, extract the characteristic of sample image main body.
Sample image mainly comprises and stays white region and main scene area; Characteristics to sample image self; It is after the unified color that white region is stayed in setting, and remaining main scene area more can be given prominence to the characteristic of sample image, the main body that therefore to define this main scene area be sample image.
Owing to reason of the remote past; Sample image stay white region variable color mostly; These information can be extracted the body feature of sample image and cause interference; The pretreated purpose of image is set at unified color to the white region that stays of sample image, reduces the interference that the sample image body feature is extracted.
As shown in Figure 4, the present invention carries out the image pre-service based on Top-down to sample image, and the process of its processing comprises the steps:
(1) at first the color space of sample image is transformed into HSV (hue, saturation, intensity color space) from RGB (red, green, blue color space).The RGB color space is not an even color space, and the distance on the RGB color space can not be represented the visual color similarity of human eye, though this representation is simple bigger with the sensory difference of human eye.Handling the appropriate to the occasion hsv color space of choosing of color characteristic, the hsv color space is by tone H, saturation degree S, and three components of brightness V are formed; More approaching with human vision property, wherein tone H representes different colours, as red, orange, green; Its strength component value scope is 0~360, and saturation degree S representes the depth of color, and its strength component value scope is 0~1; Brightness V representes the bright-dark degree of color, influenced by the light source power, measures with number percent usually; Its strength component value scope is 0% to 100%, and wherein black is 0%, is 100% in vain.The hsv color model is with Munsell (Meng Saier) three dimensions system representation; Variation that can feeling of independence fundamental color component; And this color space has linear extendible property; The Euclidean distance of the point of coordinate is proportional on appreciable colour-difference and the hsv color space, and the computing formula from the RGB color space conversion to the hsv color space is following:
In the formula, R, G, B represent the strength component value of the red, green, blue of each pixel in the sample image respectively.
(2) like Fig. 5, shown in Figure 6, make the rim detection of Canny operator on the V component of sample image in the hsv color space, comprise the steps:
1. utilize the level and smooth sample image of Gaussian filter, two-dimensional Gaussian function is:
In the formula, δ representes that variance is the parameter of Gaussian filter, and it is controlling level and smooth degree, and x, y are the coordinates that generates gaussian mask, calculate suitable mask with this formula, realizes that with the standard convolution Gauss is level and smooth, and the gaussian mask that calculates is shown in the following figure:
2 |
4 |
5 |
4 |
2 |
4 |
9 |
12 |
9 |
4 |
5 |
12 |
15 |
12 |
5 |
4 |
9 |
12 |
9 |
4 |
2 |
4 |
5 |
4 |
2 |
2. use the Sobel gradient operator to calculate the gradient estimated value of each pixel.
The Sobel gradient operator has two 3 * 3 convolution kernel: G
xGradient component for horizontal direction; G
yBe the gradient component of vertical direction, its computing formula is following:
Gradient magnitude or edge strength computing formula are:
|G|=|G
x|+|G
y|。
3. if the gradient component G of horizontal direction
xGradient component G with vertical direction
yKnown, the deflection computing formula is:
θ=arctan(G
y/G
x),
If the gradient component G of horizontal direction
xBe 0, deflection depends on the gradient component G of vertical direction
y:
4. each pixel has only 4 possible directions to link to each other with neighbor pixel in the sample image: 0 ° (horizontal direction), and 45 ° (over against angular direction), 90 ° (vertical direction), 135 ° (negative diagonal), deflection is arrived following 4 angles by standard:
0°∶0°~22.5°,157.5°~180°;45°∶22.5°~67.5°;
90°∶67.5°~112.5°;135°∶112.5°~157.5°。
If 5. the Grad on the deflection direction of the pixel in the sample image is maximum, then keep, otherwise this pixel is removed, the set that the maximum point of all pixels of sample image Grad on the deflection direction constitutes is the set of possible marginal point.
6. set two Grads threshold, a high threshold TH, a low threshold value TL, high threshold TH generally get 2~3 times of low threshold value TL.From the set of possible marginal point, remove the pixel of Grad earlier less than high threshold TH; Get marginal point set F; Handle the pixel set M of Grad between high and low threshold value again; Face a little if the point among the M is put to have among the set F on the edge of, then this point is added marginal point set F, the marginal point that finally obtains set F is exactly the marginal point set of sample image.
(3) like Fig. 7, shown in Figure 8, the sample image of the above-mentioned rim detection that obtains is carried out expansion process, comprise the steps:
Suppose that A is the edge of the above-mentioned sample image that obtains; B is that (why select this structural element for use, be because through experiment, draw under this situation to one 4 * 4 the structural element of stating; Recognition result is best), A is followed following formula as edge swell:
In the formula, A and B are z
2Set in (two-dimentional integer space), z is one of them element,
Be meant expansive working,
The reflection of expression B moves to a z=(z
1, z
2).
(4) like Fig. 9, shown in Figure 10, the above-mentioned sample image that obtains edge swell to be carried out the zone fill, the zone filling mainly is to be the basis with expansion, supplement and the common factor of gathering, the formula that fill in the zone is following:
In the formula, A
cThe supplementary set of expression A, X
K-1Be a bit in the fill area, k is the step number of algorithm iteration.
(5) like Figure 11, shown in Figure 12, handle the background area of the sample image that the above-mentioned zone that obtains is filled.White region is thought to stay in background area for beyond the fill area in the sample image, stays white region to be designated as I_B, and statistics is stayed the colouring information of white region, mainly adds up the mean value of each component in the hsv color space: Ave_H, Ave_S, Ave_V, and formula is following:
In the formula, h
k, s
k, v
kThe strength component value of representing tone, saturation degree and brightness respectively.
The sample image that preliminary sweep is obtained carries out the traversal of full figure individual element; The value of the H in the hsv color space of each pixel of sample image, S, each component of V respectively with the hsv color space in mean value Ave_H, Ave_S, the Ave_V of each component do the difference computing; Difference operation result and threshold value T_P are compared (this threshold value T_P draws through experiment, and threshold range is between 0.15~0.2), think to stay white region for the pixel within threshold value T_P scope; It is unified color that white region is stayed in setting; Be set at white (as example, being not limited thereto) here, its computing formula is:
Wherein, white is meant and is set to white that unchange is meant that the original sample image of maintenance is constant; I_pex representes each pixel in the sample image; I_pex_h, i_pex_s, i_pex_v represent it is H, the S on the hsv color space on each pixel of sample image, the value of each component of V.
Like Figure 13~shown in Figure 16, the present invention is from traditional Chinese Painting works and calligraphy work creative feature, and promptly calligraphy work is comparatively even with China ink, and the traditional Chinese Painting works want stereovision with China ink; Through after the above-mentioned data pre-service; Make that the main body of sample image is more outstanding, wherein, horizontal ordinate is represented the exponent number 0~255 of gray scale in grey level histogram; The gray scale exponent number is totally 256 rank, and ordinate is the number that the pixel in the statistical sample image occurs at certain gray scale exponent number.
3, from sample image, choose training sample image and test sample image at random.
Sample image is divided into training sample image and test sample image, and training sample image and test sample image labeling method comprise the steps: (1) definition sample image classification, are numbered 1 or 0,1 expression traditional Chinese Painting sample image, 0 expression calligraphy sample image; (2) supposing to be used for sample image to be identified is I, is labeled as { I
1, I
2, I wherein
1Expression calligraphy sample image is designated as I
1={ C
1, C
2... C
n, C
i(i=1 2...n) is expressed as the calligraphy sample image that scanning obtains, I
2Expression traditional Chinese Painting sample image is designated as I
2={ P
1, P
2... P
n, P
i(i=1 2...n) is expressed as the traditional Chinese Painting sample image that scanning obtains; (3) respectively from I
1, I
2The sample image that middle picked at random is set quantity is designated as { I as training sample image collection T
1', I
2', I
1' expression calligraphy training sample image, I
2' expression traditional Chinese Painting training sample image is with I
1, I
2Middle samples remaining image is as the test sample image collection
e
i(i=1 2...m) is test sample image.
4, accomplish on the pretreated basis of sample image, training sample image is carried out body feature extract, and training classifier.The process that the training sample image body feature is extracted is following: the grey level histogram that training sample image is obtained training sample image through above-mentioned image pre-service; Gray scale is 256 rank; Count the number of times summation Total that occurs at sample image for bin between each chromatic zones in the grey level histogram, the last body feature vector that generates one 256 dimension of each training sample image.Consider the size of different training sample image, adopt following formula to calculate among the present invention:
Wherein, Wide and High represent the wide and high of training sample image respectively.
The present invention adopts the recognition methods of SVMs (as example, being not limited thereto) that training sample image is trained, and after training, obtains the model model of a sample image sorter.The kit that this experiment adopts LIBSVM to provide makes an experiment, and following function model capable of using is represented:
model=svmtrain(T_F,label,options)
In the above-mentioned function call, svmtrain is the SVMs computing, the body feature vector of the training sample image that T_F representes to extract; Label representes the class label of corresponding training sample image, and value 0 or 1 is represented calligraphy sample image and traditional Chinese Painting sample image respectively here; Options is that parameter is selected; Parameter options='-t2-s0-b1-c1 ' for example, the implication of expression is that kernel function is intersection kernel, the SVM type is C-svc; The C-svc penalty coefficient is 1, and needs probability estimate.
5, from test sample image, extract the body feature vector of test sample image, and discern, accomplish the identification of test sample image, comprise the steps: with the sample image sorter that trains
(1) test sample image is carried out the data pre-service; (2) to through the pretreated test sample image of data, carry out body feature and extract, generate the body feature vector of test sample image; (3) the body feature vector of test sample image is imported the sample image sorter that trains, obtain recognition result.
The recognition methods that recognition result demonstration test of the present invention adopts is that SVMs is (as example; Be not limited thereto) in the MatlabR2008A software platform; Obtain the predict the outcome pre and the accuracy rate acc of test sample image, SVMs uses and handles with minor function:
[pre?acc]=svmpredict(label_1,H_F,model,‘-b?1’),
In the above-mentioned function call, svmpredict is an anticipation function, and label_1 is the class label of test sample image, and H_F is the body feature vector that test sample image generates, and model is the sample image sorter that trains.
The result of identification can adopt following formula:
In the formula, n_R is the number of the test sample image that identifies, and N_Total is the number of test sample image.
The present invention is through verifying explanation to the test findings of following traditional Chinese Painting image and handwriting image; Testing employed sample image obtains through scanning " Chinese painting complete or collected works " and " complete or collected works of Chinese calligraphy "; Make it as the sample image storehouse; Then therefrom at random choose training sample image and test sample image, as shown in the table:
The result who obtains through test is following:
The above results shows, utilizes image-recognizing method of the present invention to obtain very desirable recognition result, helps the mark and the retrieval of traditional Chinese Painting image and handwriting image.
Above-mentioned each embodiment only is used to explain the present invention; Each step all can change to some extent; On the basis of technical scheme of the present invention, all improvement and equivalents of individual steps and proportioning being carried out according to the principle of the invention all should not got rid of outside protection scope of the present invention.