Summary of the invention
At the problems referred to above, the purpose of this invention is to provide a kind of notion based on main body, by extracting the feature of traditional Chinese Painting image and handwriting image main body, realize method to traditional Chinese Painting image and handwriting image identification.
For achieving the above object, 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, its comprise the steps: (1) utilize scanner scanning China before modern age the traditional Chinese Painting works and the calligraphy work that occurred in history, obtain the sample image of traditional Chinese Painting works and calligraphy work; (2) sample image is carried out 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; 2. the sample image in the hsv color space that 1. step is obtained is done the rim detection of Canny operator; 3. the sample image of the rim detection that 2. step is obtained is done the processing of edge swell; 4. the sample image of the edge swell that 3. step is obtained is done the processing that fill in the zone; 5. the statistics of colouring information is carried out in the background area beyond the fill area of the zone that 4. step the is obtained sample image of filling, and 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, H, the S in the hsv color space of each pixel of sample image, the value of 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, finish 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, train 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.
Described 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 described 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, by extracting the feature 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 by 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 feature 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 drawings and Examples the present invention is described in detail.
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 before modern age the traditional Chinese Painting works and the calligraphy work that occurred in history, obtain the sample image of traditional Chinese Painting works and calligraphy work.
As Fig. 2, shown in Figure 3, sample image of the present invention obtains by Epson Expression10000XL scanner scanning.
2, sample image is carried out the data pre-service, extract the feature of sample image main body.
Sample image mainly comprises and stays white region and main scene area, characteristics at 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 feature 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 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, three components of brightness V are formed, more approaching with human vision property, wherein tone H represents different colours, and as red, orange, green, its strength component value scope is 0~360, saturation degree S represents the depth of color, its strength component value scope is 0~1, and brightness V represents the bright-dark degree of color, influenced by the light source power, usually measure with number percent, its strength component value scope is 0% to 100%, and wherein black is 0%, is 100% in vain.Hsv color model Munsell (Meng Saier) three dimensions system representation, variation that can feeling of independence fundamental color component, and this color space has linear extendible, 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 as follows:
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) as 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, δ represents 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 as shown below:
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 as follows:
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) to the angular direction, 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 the 5. Grad maximum on the deflection direction of the pixel in the sample image then keeps, otherwise this pixel is removed, the set that the point of all pixels of sample image Grad maximum 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, if having in marginal point set F, faces some the point among the M, 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) as 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 by experiment to one 4 * 4 the structural element of stating, draws under this situation, 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) as 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 expansion, supplement and the common factor based on set, the formula that fill in the zone is as follows:
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) as Figure 11, shown in Figure 12, handle the background area of the sample image that the above-mentioned zone that obtains is filled.Think to stay white region for the background area beyond the fill area in the sample image, stay white region to be designated as I_B, 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 as follows:
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 H in the hsv color space of each pixel of sample image, S, the value of each component of V respectively with the hsv color space in the mean value Ave_H of each component, Ave_S, Ave_V does the difference computing, difference operation result and threshold value T_P compared (this threshold value T_P draws by experiment, 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 herein (as example, be not limited thereto), 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 represents 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.
As 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, finish 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 as follows: 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 support vector machine (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 is tested, and can utilize following function model to represent:
model=svmtrain(T_F,label,options)
In the above-mentioned function call, svmtrain is the support vector machine computing, T_F represents the body feature vector of the training sample image extracted, label represents 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, finish 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 support vector machine 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, support vector machine is used and is handled 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 by verifying explanation to the test findings of following traditional Chinese Painting image and handwriting image, testing employed sample image obtains by 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 as follows:
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.
The various embodiments described above only are used to illustrate the present invention; each step all can change to some extent; on the basis of technical solution 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.