A kind of image search method based on color characteristic
Technical field
The present invention relates to image retrieval technologies fields, and in particular to a kind of image search method based on color characteristic.
Background technology
With the rapid development of multimedia technology, generated image data amount is also growing day by day, how in magnanimity
Data in rapidly and effectively retrieve the images of needs, be current urgent problem to be solved.Because only that quickly, accurately
Image data is retrieved and is utilized on ground, could preferably utilize these image informations.
Color characteristic is a kind of basic visual signature that the mankind are used to perceive and distinguish different objects, in the mistake of analysis image
Cheng Zhong, color are a kind of important descriptors of simplified Objective extraction and classification.User gives the color characteristic to be retrieved to inspection
Cable system sends out request, and system is matched according to given colouring information with image data base, according to matching similarity size
Provide a user retrieval result.
Traditional judgement based on colouring information is mostly that the colouring information based on single pixel is handled, and to colour
It is found when image is analyzed, the color of image is usually gradual change, and a kind of color will not only there are one pixels, so as to cause inspection
Rope work is cumbersome and complicated, and working efficiency is low.
Invention content
The purpose of the present invention is to provide a kind of image search methods based on color characteristic, to substantially reduce operation
Amount, and improve processing speed.
To achieve the goals above, present invention employs following technical schemes:
A kind of image search method based on color characteristic, its step are as follows:
(1) Lab color modes sample set and colouring information to be checked are loaded;
(2) coloured image sample to be retrieved is obtained, and gamma correction is carried out to improve cromogram to coloured image sample
Decent contrast;
(3) super-pixel segmentation processing is carried out to the coloured image sample after gamma correction with SLIC super-pixel segmentations algorithm,
It is partitioned into multiple and different super-pixel regions;
(4) average value processing is carried out to each super-pixel region being partitioned into through step (3), made in each super-pixel region
All pixels value is identical, and mean value isIn formula:
Wherein:NkIndicate the number of pixels in k-th of region, Ln、an、bnExpression is corresponded to respectively three in Lab color mode samples
The pixel value in channel;
(5) by a pixel value in super-pixel region and each face in the Lab color mode sample sets of load in step (1)
It is compared using mahalanobis distance between color value, then the sample of color corresponding to the color value of mahalanobis distance minimum is exactly the super picture
The color in plain region, wherein mahalanobis distance calculation formula are:
In formula:LabiIndicate the color value of a pixel in i-th of super-pixel region, LabhjIndicate Lab color modes
The color value of h-th of sample, S in jth class sample in sample set-1For the inverse of covariance matrix S, the transposition of T representing matrixes;
(6) colouring information to be checked that will be loaded in the color in each super-pixel region in coloured image sample and step (1)
It is compared, if containing all information in colouring information to be checked in coloured image sample, which is
Target image.
Above-mentioned mentioned n, k, i, j, h are natural number.
Further scheme, gamma correction is to carry out non-linear tone editor to coloured image sample in the step (2),
Then the color in three channels of red, green, blue is handled as follows respectively in RGB:
Here r, g, b indicate that the pixel value of three Color Channels of red, green, blue, value range are [0,255] respectively.
Further scheme, in the step (3) with SLIC super-pixel segmentations algorithm to the coloured image after gamma correction
Sample is handled, and is as follows:
(a) coloured image sample to be retrieved is converted to Lab color spaces for follow-up super picture from RGB color first
Used in element segmentation;
(b) initialization of Color image pattern is divided into the categorical measure K and iterations in super-pixel region;For pixel
Size is the coloured image of N, with step-lengthCluster centre is initialized, i.e., is poly- to be divided into s capture vegetarian refreshments between wide, height
Class central point, cluster centre are expressed as C with five dimensional vectorsi=[li,ai,bi,xi,yi]T, wherein (li,ai,bi) indicate i-th to gather
The color value at class center, (xi,yi) be ith cluster center coordinate value, T indicate transposition;
Ith cluster center CiWith its surrounding pixel point distance d (i) in initialization to be infinitely great, i.e. d (i)=∞;
(c) with cluster centre CiCentered in the regions 3*3 put, compare the gradient magnitude between pixel two-by-two, and will
Cluster centre CiThe region for moving on to gradient minimum is Ck, it is marginal point and noise spot to avoid cluster centre, wherein pixel two-by-two
Between gradient G (x, y) be defined as follows:
V indicates five dimensional vectors of pixel, as V [L, a, b, x, y] in formula, wherein (L, a, b) indicates the color value of pixel,
(x, y) indicates the coordinate value of pixel;
(d) cluster centre C after movementk2s × 2s neighborhoods in more each pixel to the space of cluster centre away from
From wherein 2s × 2s neighborhoods are referred to cluster centre CkCentered on region 2s × 2s all pixels, s be step (b) in
Step sizes, that is, cluster centre peripheral region;Then cluster centre is updated, it is specific as follows shown:
In upper two formula:DsIth pixel is expressed as to cluster centre CkSpace length;CknFor updated new cluster
Five dimensional vectors at center;LabiIndicate the value of color of ith pixel:Labi=[Li,ai,bi];LabkIndicate cluster centre Ck's
Value of color:Labk=[Lk,ak,bk];SiIndicate the two-dimensional spatial location coordinate of ith pixel, Si=[xi,yi]T, SkIndicate poly-
Class center CkTwo-dimensional spatial location coordinate, Sk=[xk,yk]T;NlabAnd NsRespectively colored and space length normalization is normal
Number;GkIndicate cluster centre CkRepresented cluster areas, NkIndicate cluster centre CkInterior included pixel quantity;
(e) cluster centre C in comparison step (b)iWith pixel in surrounding pixel point distance d (i) and step (d) to cluster
Center CkSpace length DsBetween size, if Ds<D (i) then updates d (i)=Ds, and the position by label record at this time
It sets;
(f) step (d), (e) are executed repeatedly, until reaching the iterations set by step (b);
(g) luminance difference for comparing neighboring clusters central area two-by-two will be minimum when the difference is less than the threshold value of setting
Cluster centre region merging technique to its adjacent maximum cluster centre region in, otherwise, the min cluster central area continue
It finds nearest cluster centre region to merge, wherein luminance difference formula is as follows:
Dm=(μ-μm)2
In formula, μ and μmThe average brightness value of min cluster central area and the adjacent cluster centre nearest with it are indicated respectively
The average brightness value in region, DmIndicate minimum cluster centre region and nearest with its and maximum adjacent cluster centre regional luminance
Difference, m=1,2 ..., M.
Further scheme converts coloured image sample to be retrieved to from RGB color the step of Lab color spaces
It is rapid as follows:
(a) RGB color of coloured image is transformed into XYZ color space as the following formula first:
(b) XYZ color space is transformed into Lab space, conversion formula is as follows:
L*、a*、b*It is the value in final three channels in the color spaces LAB, Xn、Yn、ZnGeneral acquiescence is all 1.
The present invention changes traditional color search method based on single pixel, is to coloured image sample to be retrieved
Color of object judgement is carried out, to rapidly retrieve all images met the requirements from pile of colorful image.
The invention firstly uses super-pixel to divide the image into the identical super-pixel region of several pixel values, then to each
The color in a super-pixel region is judged, relative to traditional image processing method based on single pixel, to each region
It is handled, i.e., only needs to improve processing to color of each super-pixel region decision to substantially reduce operand
Speed.
Specific implementation mode
Content in order to better understand the present invention, with reference to specific embodiment, the present invention will be further described.Implement
Example 1:
A kind of image search method based on color characteristic, its step are as follows:
(1) Lab color modes sample set and colouring information to be checked are loaded;
(2) coloured image sample to be retrieved is obtained, and gamma correction is carried out to improve cromogram to coloured image sample
Decent contrast;Wherein gamma correction be to coloured image sample carry out non-linear tone editor, then in RGB it is red, green,
The color in blue three channels is handled as follows respectively:
Here r, g, b indicate that the pixel value of three Color Channels of red, green, blue, value range are [0,255] respectively;Its
Middle gamma functions are not unique, are mainly used to carry out non-linear tone editor to image;
(3) super-pixel segmentation processing is carried out to the coloured image sample after gamma correction with SLIC super-pixel segmentations algorithm,
It is partitioned into multiple and different super-pixel regions;
Wherein the coloured image sample after gamma correction is handled with SLIC super-pixel segmentations algorithm, it is specific to walk
It is rapid as follows:
(a) coloured image sample to be retrieved is converted to Lab color spaces for follow-up super picture from RGB color first
Used in element segmentation;
(b) initialization of Color image pattern is divided into the categorical measure K and iterations in super-pixel region;For pixel
Size is the coloured image of N, with step-lengthCluster centre is initialized, i.e., is poly- to be divided into s capture vegetarian refreshments between wide, height
Class central point, cluster centre are expressed as C with five dimensional vectorsi=[li,ai,bi,xi,yi]T, wherein (li,ai,bi) indicate i-th to gather
The color value at class center, (xi,yi) be ith cluster center coordinate value, T indicate transposition;
Ith cluster center CiWith its surrounding pixel point distance d (i) in initialization to be infinitely great, i.e. d (i)=∞;
(c) with cluster centre CiCentered in the regions 3*3 put, compare the gradient magnitude between pixel two-by-two, and will
Cluster centre CiThe region for moving on to gradient minimum is Ck, it is marginal point and noise spot to avoid cluster centre, wherein pixel two-by-two
Between gradient G (x, y) be defined as follows:
V indicates five dimensional vectors of pixel, as V [L, a, b, x, y] in formula, wherein (L, a, b) indicates the color value of pixel,
(x, y) indicates the coordinate value of pixel;
(d) cluster centre C after movementk2s × 2s neighborhoods in more each pixel to the space of cluster centre away from
From wherein 2s × 2s neighborhoods are referred to cluster centre CkCentered on region 2s × 2s all pixels, s be step (b) in
Step sizes, that is, cluster centre peripheral region;Then cluster centre is updated, it is specific as follows shown:
In upper two formula:DsIth pixel is expressed as to cluster centre CkSpace length;CknFor updated new cluster
Five dimensional vectors at center;LabiIndicate the value of color of ith pixel:Labi=[Li,ai,bi];LabkIndicate cluster centre Ck's
Value of color:Labk=[Lk,ak,bk];SiIndicate the two-dimensional spatial location coordinate of ith pixel, Si=[xi,yi]T, SkIndicate poly-
Class center CkTwo-dimensional spatial location coordinate, Sk=[xk,yk]T;NlabAnd NsRespectively colored and space length normalization is normal
Number;GkIndicate cluster centre CkRepresented cluster areas, NkIndicate cluster centre CkInterior included pixel quantity;
(e) cluster centre C in comparison step (b)iWith pixel in surrounding pixel point distance d (i) and step (d) to cluster
Center CkSpace length DsBetween size, if Ds<D (i) then updates d (i)=Ds, and the position by label record at this time
It sets;
(f) step (d), (e) are executed repeatedly, until reaching the iterations set by step (b);
(g) luminance difference for comparing neighboring clusters central area two-by-two will be minimum when the difference is less than the threshold value of setting
Cluster centre region merging technique to its adjacent maximum cluster centre region in, otherwise, the min cluster central area continue
It finds nearest cluster centre region to merge, wherein luminance difference formula is as follows:
Dm=(μ-μm)2
In formula, μ and μmThe average brightness value of min cluster central area and the adjacent cluster centre nearest with it are indicated respectively
The average brightness value in region, DmIndicate minimum cluster centre region and nearest with its and maximum adjacent cluster centre regional luminance
Difference, m=1,2 ..., M.
(4) average value processing is carried out to each super-pixel region being partitioned into through step (3), made in each super-pixel region
All pixels value is identical, and mean value isIn formula:
Wherein:NkIndicate the number of pixels in k-th of region, Ln、an、bnExpression is corresponded to respectively three in Lab color mode samples
The pixel value in channel;
(5) by a pixel value in super-pixel region and each face in the Lab color mode sample sets of load in step (1)
It is compared using mahalanobis distance between color value, then the sample of color corresponding to the color value of mahalanobis distance minimum is exactly the super picture
The color in plain region, wherein mahalanobis distance calculation formula are:
In formula:LabiIndicate the color value of a pixel in i-th of super-pixel region, LabhjIndicate Lab color modes
The color value of h-th of sample, S in jth class sample in sample set-1For the inverse of covariance matrix S, the transposition of T representing matrixes (on
It is natural number to state mentioned n, k, i, j, h);
(6) colouring information to be checked that will be loaded in the color in each super-pixel region in coloured image sample and step (1)
It is compared, if containing all information in colouring information to be checked in coloured image sample, which is
Target image.
Further scheme converts coloured image sample to be retrieved to from RGB color the step of Lab color spaces
It is rapid as follows:
(a) RGB color of coloured image is transformed into XYZ color space as the following formula first:
(b) XYZ color space is transformed into Lab space, conversion formula is as follows:
L*、a*、b*It is the value in final three channels in the color spaces LAB, Xn、Yn、ZnGeneral acquiescence is all 1.
Embodiment 2:
It is said so that the image that retrieval contains red, blue two kinds of colors in coloured image to be retrieved is target image as an example
Bright, search method is as follows:
(1) it loads Lab color modes sample set and colouring information to be checked is red and blue;
(2) coloured image sample to be retrieved is obtained, and gamma correction is carried out to coloured image sample, to improve colour
The contrast of image pattern;
(3) super-pixel segmentation processing is carried out to the coloured image sample after gamma correction with SLIC super-pixel segmentations algorithm,
It is partitioned into multiple and different super-pixel regions;Such as the coloured image of 612*563 sizes be divided into 500 it is different size of super
Pixel region, iterations are 20 times;
(4) average value processing is carried out to each super-pixel region being partitioned into through step (3), made in each super-pixel region
All pixels value is identical, and mean value is
(5) by a pixel value in super-pixel region and each face in the Lab color mode sample sets of load in step (1)
It is compared using mahalanobis distance between color value, then the sample of color corresponding to the color value of mahalanobis distance minimum is exactly the super picture
The color in plain region;Because after (4) are handled, the pixel value in each super-pixel region is identical, and region each so only needs
The color in the region can once be obtained by comparing.Such as the pixel value in the region for being 10 for classification number in a certain super-pixel regionPass through mahalanobis distance calculation formula(in formula
LabiIndicate the color value of a pixel in i-th of super-pixel region, LabhjIndicate the jth in Lab color mode sample sets
The color value of h-th of sample, S in class sample-1For the inverse of covariance matrix S, the transposition of T representing matrixes) calculate the pixel value
With the mahalanobis distance size between each color value in Lab color mode samples, finally obtain the pixel value and red geneva away from
From minimum, then the color in the super-pixel region is red;
(6) after step (5) processing, there is corresponding color in each super-pixel region in the coloured image sample, then
By these colors respectively with step (1) in load colouring information to be checked it is red and it is blue be compared judgement, if in these colors both
Have it is red have blue again, then illustrate that the coloured image sample is our target images to be retrieved, it is on the contrary then be not our institutes
The target image needed.
So all coloured image samples to be retrieved are handled respectively by above-mentioned steps (1)-(6), with quickly from
Our required target images are retrieved in thousands of image pattern.
Example discussed above is only that the preferred embodiment of the present invention is described, not to the scope of the present invention
It is defined, under the premise of not departing from design spirit of the present invention, those of ordinary skill in the art are to technical scheme of the present invention
The various modifications made and improvement should all be fallen into the protection domain of claims of the present invention determination.