A kind of image search method based on color characteristic
Technical field
The present invention relates to image retrieval technologies field, be specifically related to a kind of image search method based on color characteristic.
Background technology
Along with developing rapidly of multimedia technology, image data amount produced by it is also growing with each passing day, and how rapidly and effectively to retrieve the image of needs in the data of magnanimity, has been current problem demanding prompt solution.Because only that retrieve quickly and accurately and utilize view data, could better utilize these image informations.
Color characteristic is the mankind's a kind of basic visual signatures for perception and differentiation different objects, and in the process analyzing image, color is a kind of important descriptor simplifying Objective extraction and classification.The given color characteristic to retrieve of user sends request to searching system, and system is mated with image data base according to given colouring information, provides a user with retrieval result according to matching similarity size.
Traditional judgement based on colouring information is mostly based on the colouring information of single pixel and processes, and find when coloured image is analyzed, the color of image is usually gradual change, and a kind of color will not only have a pixel, thus cause that retrieval work is cumbersome and complicated, and work efficiency is low.
Summary of the invention
It is an object of the invention to provide a kind of image search method based on color characteristic, thus substantially reducing operand, and improving processing speed.
To achieve these goals, present invention employs techniques below scheme:
A kind of image search method based on color characteristic, its step is as follows:
(1) Lab color mode sample set and colouring information to be checked are loaded;
(2) obtain coloured image sample to be retrieved, and coloured image sample is carried out gamma correction to improve the contrast of coloured image sample;
(3) with SLIC super-pixel partitioning algorithm, the coloured image sample after gamma correction is carried out super-pixel dividing processing, be partitioned into multiple different super-pixel region;
(4) each super-pixel region being partitioned into through step (3) being carried out average value processing, make all pixel values in each super-pixel region identical, its average isIn formula:
Wherein: NkRepresent the number of pixels in kth region, Ln、an、bnRepresent three-channel pixel value in the corresponding Lab color mode sample of difference;
(5) the Lab color mode sample set loaded in a pixel value in super-pixel region and step (1) will utilize mahalanobis distance to compare between each color value, the sample of color corresponding to color value that then mahalanobis distance is minimum is exactly the color in this super-pixel region, and wherein mahalanobis distance computing formula is:
In formula: LabiThe color value of a pixel in expression i-th super-pixel region, LabhjRepresent the color value of h sample, S in the jth class sample in Lab color mode sample set-1Inverse for covariance matrix S, the transposition of T representing matrix;
(6) color in each super-pixel region in coloured image sample is compared with the colouring information to be checked of loading in step (1), if all information contained in coloured image sample in colouring information to be checked, then this coloured image sample is target image.
Above-mentioned mentioned n, k, i, j, h are natural number.
Further scheme, in described step (2), gamma correction is that coloured image sample is carried out non-linear tone editor, then in RGB, the color of three passages of red, green, blue is handled as follows respectively:
Wherein:
Here r, g, b represent the pixel value of three Color Channels of red, green, blue respectively, and span is [0,255].
Further scheme, the coloured image sample after gamma correction being processed with SLIC super-pixel partitioning algorithm in described step (3), it specifically comprises the following steps that
A first coloured image sample to be retrieved is converted into Lab color space from RGB color and supplies used by the segmentation of follow-up super-pixel by ();
B () initialization of Color image pattern is divided into categorical measure K and the iterations in super-pixel region;It is the coloured image of N for pixel size, with step-lengthInitializing cluster centre, be namely spaced apart s capture vegetarian refreshments for cluster centre point with wide, height, cluster centre is expressed as C with five dimensional vectorsi=[li,ai,bi,xi,yi]T, wherein (li,ai,bi) represent ith cluster center color value, (xi,yi) for the coordinate figure at ith cluster center, T represents transposition;
Ith cluster center CiBe infinitely great when initializing with the distance d (i) of pixel about, i.e. d (i)=∞;
C () is with cluster centre CiCentered by point 3*3 region in, compare the gradient magnitude between two between pixel, and by cluster centre CiMoving on to the minimum region of gradient is Ck, thus avoiding cluster centre is marginal point and noise spot, wherein between two gradient G between pixel (x, y) definition is as follows:
In formula, V represents five dimensional vectors of pixel, is V [L, a, b, x, y], and wherein (L, a, b) represent the color value of pixel, and (x y) represents the coordinate figure of pixel;
(d) cluster centre C after movementk2s × 2s neighborhood in relatively each pixel is to the space length of cluster centre, wherein 2s × 2s neighborhood refers to cluster centre CkCentered by all pixels of 2s × 2s in region, s is the step sizes in step (b), namely the peripheral region of cluster centre;Then cluster centre is updated, shown in specific as follows:
In upper two formulas: DsIt is expressed as ith pixel to cluster centre CkSpace length;CknFive dimensional vectors for the new cluster centre after updating;LabiRepresent the value of color of ith pixel: Labi=[Li,ai,bi];LabkRepresent cluster centre CkValue of color: Labk=[Lk,ak,bk];SiRepresent the two-dimensional spatial location coordinate of ith pixel, Si=[xi,yi]T, SkRepresent cluster centre CkTwo-dimensional spatial location coordinate, Sk=[xk,yk]T;NlabAnd NsThe respectively colored normaliztion constant with space length;GkRepresent cluster centre CkRepresented cluster areas, NkRepresent cluster centre CkInterior comprised pixel quantity;
Cluster centre C in (e) comparison step (b)iWith pixel in the distance d (i) of surrounding pixel point and step (d) to cluster centre CkSpace length DsBetween size, if Ds < d (i), then update d (i)=Ds, and by label record position now;
F () performs step (d), (e) repeatedly, until reaching the iterations set by step (b);
G () compares the luminance difference of neighboring clusters central area between two, when this difference is less than the threshold value set, by in minimum cluster centre region merging technique to its adjacent maximum cluster centre region, otherwise, this min cluster central area continually looks for nearest cluster centre region and merges, and wherein luminance difference formula is as follows:
Dm=(μ-μm)2
In formula, μ and μmRepresent the average brightness value of min cluster central area and the average brightness value in the adjacent cluster centre region nearest with it, D respectivelymRepresent minimum cluster centre region and nearest with it and maximum adjacent cluster centre regional luminance difference, m=1,2 ..., M.
Further scheme, the step that from RGB color, coloured image sample to be retrieved is converted into Lab color space is as follows:
A first the RGB color of coloured image is transformed into XYZ color space by following formula by ():
In formula: R, G, B represent three passages of color space RGB respectively, three passages in X, Y, Z correspondence XYZ color space, M is the matrix of 3 × 3, and
B (), by XYZ color space transforming to Lab space, its conversion formula is as follows:
In formula:
L*、a*、b*It is the value of final three passages in LAB color space, Xn、Yn、ZnGeneral acquiescence is all 1.
The present invention changes traditional color search method based on single pixel, is that coloured image sample to be retrieved is carried out color of object judgement, thus retrieving all images meeting requirement rapidly from pile of colorful image.
The present invention divides the image into as the identical super-pixel region of several pixel values first with super-pixel, then the color in each super-pixel region is judged, it is relative to traditional image processing method based on single pixel, each region is processed, namely have only to color of each super-pixel region decision, thus substantially reducing operand, improve processing speed.
Detailed description of the invention
In order to be better understood from present invention, below in conjunction with specific embodiment, the present invention will be further described.Embodiment 1:
A kind of image search method based on color characteristic, its step is as follows:
(1) Lab color mode sample set and colouring information to be checked are loaded;
(2) obtain coloured image sample to be retrieved, and coloured image sample is carried out gamma correction to improve the contrast of coloured image sample;Wherein gamma correction is that coloured image sample is carried out non-linear tone editor, then in RGB, the color of three passages of red, green, blue is handled as follows respectively:
Wherein:
Here r, g, b represent the pixel value of three Color Channels of red, green, blue respectively, and span is [0,255];Wherein gamma function is not unique, is mainly used to image is carried out non-linear tone editor;
(3) with SLIC super-pixel partitioning algorithm, the coloured image sample after gamma correction is carried out super-pixel dividing processing, be partitioned into multiple different super-pixel region;
Wherein with SLIC super-pixel partitioning algorithm, the coloured image sample after gamma correction being processed, it specifically comprises the following steps that
A first coloured image sample to be retrieved is converted into Lab color space from RGB color and supplies used by the segmentation of follow-up super-pixel by ();
B () initialization of Color image pattern is divided into categorical measure K and the iterations in super-pixel region;It is the coloured image of N for pixel size, with step-lengthInitializing cluster centre, be namely spaced apart s capture vegetarian refreshments for cluster centre point with wide, height, cluster centre is expressed as C with five dimensional vectorsi=[li,ai,bi,xi,yi]T, wherein (li,ai,bi) represent ith cluster center color value, (xi,yi) for the coordinate figure at ith cluster center, T represents transposition;
Ith cluster center CiBe infinitely great when initializing with the distance d (i) of pixel about, i.e. d (i)=∞;
C () is with cluster centre CiCentered by point 3*3 region in, compare the gradient magnitude between two between pixel, and by cluster centre CiMoving on to the minimum region of gradient is Ck, thus avoiding cluster centre is marginal point and noise spot, wherein between two gradient G between pixel (x, y) definition is as follows:
In formula, V represents five dimensional vectors of pixel, is V [L, a, b, x, y], and wherein (L, a, b) represent the color value of pixel, and (x y) represents the coordinate figure of pixel;
(d) cluster centre C after movementk2s × 2s neighborhood in relatively each pixel is to the space length of cluster centre, wherein 2s × 2s neighborhood refers to cluster centre CkCentered by all pixels of 2s × 2s in region, s is the step sizes in step (b), namely the peripheral region of cluster centre;Then cluster centre is updated, shown in specific as follows:
In upper two formulas: DsIt is expressed as ith pixel to cluster centre CkSpace length;CknFive dimensional vectors for the new cluster centre after updating;LabiRepresent the value of color of ith pixel: Labi=[Li,ai,bi];LabkRepresent cluster centre CkValue of color: Labk=[Lk,ak,bk];SiRepresent the two-dimensional spatial location coordinate of ith pixel, Si=[xi,yi]T, SkRepresent cluster centre CkTwo-dimensional spatial location coordinate, Sk=[xk,yk]T;NlabAnd NsThe respectively colored normaliztion constant with space length;GkRepresent cluster centre CkRepresented cluster areas, NkRepresent cluster centre CkInterior comprised pixel quantity;
Cluster centre C in (e) comparison step (b)iWith pixel in the distance d (i) of surrounding pixel point and step (d) to cluster centre CkSpace length DsBetween size, if Ds < d (i), then update d (i)=Ds, and by label record position now;
F () performs step (d), (e) repeatedly, until reaching the iterations set by step (b);
G () compares the luminance difference of neighboring clusters central area between two, when this difference is less than the threshold value set, by in minimum cluster centre region merging technique to its adjacent maximum cluster centre region, otherwise, this min cluster central area continually looks for nearest cluster centre region and merges, and wherein luminance difference formula is as follows:
Dm=(μ-μm)2
In formula, μ and μmRepresent the average brightness value of min cluster central area and the average brightness value in the adjacent cluster centre region nearest with it, D respectivelymRepresent minimum cluster centre region and nearest with it and maximum adjacent cluster centre regional luminance difference, m=1,2 ..., M.
(4) each super-pixel region being partitioned into through step (3) being carried out average value processing, make all pixel values in each super-pixel region identical, its average isIn formula:
Wherein: NkRepresent the number of pixels in kth region, Ln、an、bnRepresent three-channel pixel value in the corresponding Lab color mode sample of difference;
(5) the Lab color mode sample set loaded in a pixel value in super-pixel region and step (1) will utilize mahalanobis distance to compare between each color value, the sample of color corresponding to color value that then mahalanobis distance is minimum is exactly the color in this super-pixel region, and wherein mahalanobis distance computing formula is:
In formula: LabiThe color value of a pixel in expression i-th super-pixel region, LabhjRepresent the color value of h sample, S in the jth class sample in Lab color mode sample set-1Inverse for covariance matrix S, the transposition (above-mentioned mentioned n, k, i, j, h are natural number) of T representing matrix;
(6) color in each super-pixel region in coloured image sample is compared with the colouring information to be checked of loading in step (1), if all information contained in coloured image sample in colouring information to be checked, then this coloured image sample is target image.
Further scheme, the step that from RGB color, coloured image sample to be retrieved is converted into Lab color space is as follows:
A first the RGB color of coloured image is transformed into XYZ color space by following formula by ():
In formula: R, G, B represent three passages of color space RGB respectively, three passages in X, Y, Z correspondence XYZ color space, M is the matrix of 3 × 3, and
B (), by XYZ color space transforming to Lab space, its conversion formula is as follows:
In formula:
L*、a*、b*It is the value of final three passages in LAB color space, Xn、Yn、ZnGeneral acquiescence is all 1.
Embodiment 2:
Illustrating for the retrieval image containing two kinds of colors red, blue in coloured image to be retrieved for target image, its search method is as follows:
(1) load Lab color mode sample set and colouring information to be checked is red and blue;
(2) obtain coloured image sample to be retrieved, and coloured image sample is carried out gamma correction, to improve the contrast of coloured image sample;
(3) with SLIC super-pixel partitioning algorithm, the coloured image sample after gamma correction is carried out super-pixel dividing processing, be partitioned into multiple different super-pixel region;As being divided into 500 different size of super-pixel regions for the coloured image of 612*563 size, iterations is 20 times;
(4) each super-pixel region being partitioned into through step (3) being carried out average value processing, make all pixel values in each super-pixel region identical, its average is
(5) mahalanobis distance will be utilized to compare between each color value in the Lab color mode sample set loaded in a pixel value in super-pixel region and step (1), then the sample of color corresponding to color value that mahalanobis distance is minimum is exactly the color in this super-pixel region;Because after (4) process, the pixel value in each super-pixel region is identical, so each region only needs to compare once just can the color in this region.It is such as the pixel value in the region of 10 for classification number in a certain super-pixel regionBy mahalanobis distance computing formula(Lab in formulaiThe color value of a pixel in expression i-th super-pixel region, LabhjRepresent the color value of h sample, S in the jth class sample in Lab color mode sample set-1Inverse for covariance matrix S, the transposition of T representing matrix) calculate the mahalanobis distance size between each color value in this pixel value and Lab color mode sample, finally show that this pixel value is minimum with red mahalanobis distance, then the color in this super-pixel region is redness;
(6) after step (5) processes, there is the color of correspondence in each super-pixel region in this coloured image sample, then these colors are compared judgement with the colouring information to be checked of loading is red and blue in step (1) respectively, if existing redness has again blueness in these colors, then illustrate that this coloured image sample is the target image that we to retrieve, otherwise be not then our required target image.
So respectively all of coloured image sample to be retrieved is processed by above-mentioned steps (1)-(6), quickly to retrieve the target image that we are required from thousands of image pattern.
Example discussed above is only that the preferred embodiment of the present invention is described; not the scope of the present invention is defined; under the premise designing spirit without departing from the present invention; various deformation that technical scheme is made by those of ordinary skill in the art and improvement, all should fall in the protection domain that claims of the present invention is determined.