CN110909791B - Similar image identification method and computing device - Google Patents

Similar image identification method and computing device Download PDF

Info

Publication number
CN110909791B
CN110909791B CN201911143303.8A CN201911143303A CN110909791B CN 110909791 B CN110909791 B CN 110909791B CN 201911143303 A CN201911143303 A CN 201911143303A CN 110909791 B CN110909791 B CN 110909791B
Authority
CN
China
Prior art keywords
images
image
gray
value
pixel
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201911143303.8A
Other languages
Chinese (zh)
Other versions
CN110909791A (en
Inventor
周俊
刘峰
黄中杰
刘翠翠
蒋毅
王朋恺
周晖
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chezhi Interconnection Beijing Technology Co ltd
Original Assignee
Chezhi Interconnection Beijing Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Chezhi Interconnection Beijing Technology Co ltd filed Critical Chezhi Interconnection Beijing Technology Co ltd
Priority to CN201911143303.8A priority Critical patent/CN110909791B/en
Publication of CN110909791A publication Critical patent/CN110909791A/en
Application granted granted Critical
Publication of CN110909791B publication Critical patent/CN110909791B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/22Matching criteria, e.g. proximity measures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/40Analysis of texture
    • G06T7/41Analysis of texture based on statistical description of texture
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/28Quantising the image, e.g. histogram thresholding for discrimination between background and foreground patterns
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20081Training; Learning

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Data Mining & Analysis (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Evolutionary Biology (AREA)
  • Evolutionary Computation (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • General Engineering & Computer Science (AREA)
  • Artificial Intelligence (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Multimedia (AREA)
  • Probability & Statistics with Applications (AREA)
  • Image Analysis (AREA)

Abstract

The invention discloses a similar image identification method, which is executed in computing equipment and comprises the following steps: acquiring two images to be identified; respectively determining texture feature vectors of the two images according to the gray level difference of adjacent pixels in the images; judging the texture similarity of the two images according to the texture feature vectors, and determining that the two images are not similar if the texture similarity is judged to be not similar; if judging that the textures are similar, the method comprises the following steps: respectively determining color distribution vectors of the two images according to the color value of each pixel in the images; respectively determining the information richness of the two images according to the gray value of each pixel in the images; and when the similarity of the color distribution vectors of the two images is greater than a first threshold value and the information richness of the two images is greater than a second threshold value, determining the two images as similar images. The invention also discloses corresponding computing equipment.

Description

Similar image identification method and computing device
Technical Field
The invention relates to the technical field of image processing, in particular to a similar image identification method and computing equipment.
Background
Images are widely used for storing and transmitting information due to intuition and richness of contained information. As information technology has developed, more and more images are accumulated on the internet, and the number of images local to a user has continuously increased, and accordingly, similar and repeated images have increased.
The identification of similar images is of great significance in the field of internet. For example, in the field of image retrieval, an image similar to an image input by a user is identified from an image library, and the identification result is returned to the user, so that a function of searching for images in an image manner is realized; in the field of recommendation systems, similar images are identified to perform de-duplication on the images, so that repeated recommendation is avoided; in the field of data compression, similar images are identified to remove the duplicate of the images, so that data redundancy is reduced, and storage space is saved; and so on.
The existing similar image identification method generally judges whether two images are similar or not by calculating and comparing hash values of the two images; or, extracting image features through a trained deep learning model, and calculating the distance between the two image features to judge whether the two images are similar. In the two methods, the algorithm of the former method is simple, but misjudgment is easy to generate, and the accuracy rate is not high; the latter training network model takes longer time, needs to occupy GPU resources in the training process, needs to occupy larger storage space for storing model parameters and training/testing data sets, has poor interpretability of characteristics, and is difficult to interpret and improve when misjudgment is generated.
The existing similar image identification method is difficult to meet the requirements of practical application in the aspects of identification accuracy and efficiency. Therefore, it is desirable to provide a method for accurately and efficiently identifying similar images.
Disclosure of Invention
To this end, the present invention provides a similar image recognition method and computing device in an attempt to solve or at least alleviate the above-identified problems.
According to a first aspect of the present invention, there is provided a similar image recognition method, executed in a computing device, comprising the steps of: acquiring two images to be identified; respectively determining texture feature vectors of the two images according to the gray level difference of adjacent pixels in the images; judging the texture similarity of the two images according to the texture feature vector, and if the texture similarity is judged to be dissimilar, determining that the two images are dissimilar; if judging that the textures are similar, the method comprises the following steps: respectively determining color distribution vectors of the two images according to the color value of each pixel in the images; respectively determining the information richness of the two images according to the gray value of each pixel in the images; and when the similarity of the color distribution vectors of the two images is greater than a first threshold value and the information richness of the two images is greater than a second threshold value, determining the two images as similar images.
Alternatively, in the similar image identification method according to the present invention, the texture feature vector is determined according to the following steps: reducing the image to a preset size, converting the image into a gray image, and recording the converted image as a thumbnail image; calculating gray differences of adjacent pixels of each line in the thumbnail images; binarizing the calculated gray level difference, wherein if the gray level difference is larger than 0, the gray level difference is binarized into 1, and if the gray level difference is smaller than or equal to 0, the gray level difference is binarized into 0; and taking a binary sequence consisting of the binarized gray level differences of each line as a texture feature vector of the image.
Optionally, in the similar image identifying method according to the present invention, the step of determining the similarity of the textures of the two images according to the texture feature vector includes: calculating the Hamming distance of the texture feature vectors of the two images, and if the Hamming distance is smaller than a third threshold value, judging that the textures of the two images are similar; and if the Hamming distance is larger than or equal to the third threshold value, judging that the textures of the two images are not similar.
Optionally, in the similar image identification method according to the present invention, if the number of consecutive 0 s or consecutive 1 s included in the texture feature vector of any one image is greater than a fourth threshold, it is determined that the two images are not similar.
Alternatively, in the similar image identifying method according to the present invention, the color distribution vector is determined according to the following steps: dividing the value range of the color value of each color channel into a plurality of sections, and generating a plurality of color intervals according to the sections, wherein each color interval comprises one section of each color channel; respectively counting the proportion of the number of pixels belonging to each color interval to the total number of image pixels; and taking a sequence formed by pixel proportions of each color interval as a color distribution vector of the image.
Alternatively, in the similar image identifying method according to the present invention, the similarity of the color distribution vectors is a cosine similarity.
Optionally, in the similar image identification method according to the present invention, the information richness is determined according to the following steps: converting the image into a grayscale image; calculating the gray characteristic value of each pixel in the gray image, wherein the gray characteristic value of a pixel comprises the gray value of the pixel and the average value of the gray values of the adjacent pixels of the pixel; and determining the information richness of the image according to the gray characteristic value of each pixel.
Alternatively, in the similar image identifying method according to the present invention, the information richness is calculated according to the following formula:
Figure BDA0002281522790000031
where H is the information richness, i represents the gray level of a pixel, j represents the gray level mean of the neighboring pixels of the pixel, and p i,j The number of pixels representing a gray feature value of (i, j) is a proportion of the total number of image pixels.
Optionally, in the similar image identifying method according to the present invention, the information richness is further calculated according to the following steps: storing a plurality of quick calculation numbers of base values in advance, wherein the base values are more than or equal to 0 and less than or equal to 1, and the quick calculation numbers of the base values are products of the base values and logarithms of the base values; calculating the proportion p of the number of pixels with the gray characteristic value of (i, j) to the total number of image pixels i,j And determining a target base value closest to the ratio; and acquiring a quick calculation number of the target base value, and calculating the information richness by adopting the quick calculation number.
According to a second aspect of the present invention, there is provided a computing device comprising: at least one processor; and a memory storing program instructions that, when read and executed by the processor, cause the computing device to perform a similar image recognition method as described above.
According to a third aspect of the present invention, there is provided a readable storage medium storing program instructions that, when read and executed by a computing device, cause the computing device to execute the similar image recognition method as described above.
According to the technical scheme of the invention, when similar images are identified, multiple characteristics of texture, color distribution and information richness are comprehensively considered, so that the identification result is more accurate, and the condition that dissimilar images are wrongly judged to be similar one by one due to less information contained in single characteristics of the images is avoided. In addition, the technical scheme of the invention has the advantages of high calculation speed, no need of model training, no need of occupying GPU resources, less occupied storage space, lower time and hardware cost and higher efficiency.
Further, after determining the texture feature vectors of the quantity images, if the number of consecutive 0 s or consecutive 1 s contained in the texture feature vector of any image is greater than a fourth threshold, it is determined that the two images are not similar, thereby avoiding the situation that the quantity images are mistakenly judged to be similar due to too little image texture information.
Furthermore, the technical scheme of the invention stores the quick calculation number in the memory in advance, and obtains the corresponding quick calculation number from the memory to calculate the information richness of the image, thereby avoiding the time consumption caused by logarithm operation and multiplication operation, and greatly accelerating the calculation speed of the information richness.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
To the accomplishment of the foregoing and related ends, certain illustrative aspects are described herein in connection with the following description and the annexed drawings, which are indicative of various ways in which the principles disclosed herein may be practiced, and all aspects and equivalents thereof are intended to be within the scope of the claimed subject matter. The above and other objects, features and advantages of the present disclosure will become more apparent from the following detailed description read in conjunction with the accompanying drawings. Throughout this disclosure, like reference numerals generally refer to like parts or elements.
FIG. 1 shows a schematic diagram of a computing device 100, according to one embodiment of the invention;
FIG. 2 illustrates a flow diagram of a similar image identification method 200 according to one embodiment of the invention;
FIG. 3 shows a schematic diagram of a similar image identification process according to one embodiment of the invention;
fig. 4 and 5 are schematic diagrams illustrating the recognition effect of the similar image recognition method of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
The invention provides a similar image identification method, which aims to solve the problem that the existing similar image identification method is difficult to meet the actual requirements in the aspects of identification accuracy and efficiency.
The similar image identification method of the present invention is executed in a computing device. The computing device may be any device with storage and computing capabilities, and may be implemented as, for example, a server, a workstation, or the like, or may be implemented as a personal computer such as a desktop computer or a notebook computer, or may be implemented as a terminal device such as a mobile phone, a tablet computer, a smart wearable device, or an internet of things device, but is not limited thereto.
FIG. 1 shows a schematic diagram of a computing device 100, according to one embodiment of the invention. It should be noted that the computing device 100 shown in fig. 1 is only an example, and in practice, the computing device for implementing the similar image recognition method of the present invention may be any type of device, and the hardware configuration thereof may be the same as the computing device 100 shown in fig. 1 or different from the computing device 100 shown in fig. 1. In practice, the computing device implementing the similar image recognition method of the present invention may add or delete hardware components of the computing device 100 shown in fig. 1, and the present invention does not limit the specific hardware configuration of the computing device.
As shown in FIG. 1, in a basic configuration 102, a computing device 100 typically includes system memory 106 and one or more processors 104. A memory bus 108 may be used for communication between the processor 104 and the system memory 106.
Depending on the desired configuration, the processor 104 may be any type of processing, including but not limited to: a microprocessor (μ P), a microcontroller (μ C), a digital information processor (DSP), or any combination thereof. The processor 104 may include one or more levels of cache, such as a level one cache 110 and a level two cache 112, a processor core 114, and registers 116. Example processor cores 114 may include Arithmetic Logic Units (ALUs), floating Point Units (FPUs), digital signal processing cores (DSP cores), or any combination thereof. The example memory controller 118 may be used with the processor 104, or in some implementations the memory controller 118 may be an internal part of the processor 104.
Depending on the desired configuration, system memory 106 may be any type of memory, including but not limited to: volatile memory (such as RAM), non-volatile memory (such as ROM, flash memory, etc.), or any combination thereof. The physical memory in the computing device is usually referred to as a volatile memory RAM, and data in the disk needs to be loaded into the physical memory to be read by the processor 104. System memory 106 may include an operating system 120, one or more applications 122, and program data 124. In some implementations, the application 122 can be arranged to execute instructions on an operating system with the program data 124 by the one or more processors 104. Operating system 120 may be, for example, linux, windows, etc., which includes program instructions for handling basic system services and performing hardware dependent tasks. The application 122 includes program instructions for implementing various user-desired functions, and the application 122 may be, for example, but not limited to, a browser, instant messenger, a software development tool (e.g., an integrated development environment IDE, a compiler, etc.), and the like. When the application 122 is installed into the computing device 100, a driver module may be added to the operating system 120.
When the computing device 100 is started, the processor 104 reads the program instructions of the operating system 120 from the memory 106 and executes them. The application 122 runs on top of the operating system 120, utilizing the operating system 120 and interfaces provided by the underlying hardware to implement various user-desired functions. When the user starts the application 122, the application 122 is loaded into the memory 106, and the processor 104 reads the program instructions of the application 122 from the memory 106 and executes the program instructions.
Computing device 100 may also include an interface bus 140 that facilitates communication from various interface devices (e.g., output devices 142, peripheral interfaces 144, and communication devices 146) to the basic configuration 102 via the bus/interface controller 130. The example output device 142 includes a graphics processing unit 148 and an audio processing unit 150. They may be configured to facilitate communication with various external devices, such as a display or speakers, via one or more a/V ports 152. Example peripheral interfaces 144 may include a serial interface controller 154 and a parallel interface controller 156, which may be configured to facilitate communication with external devices such as input devices (e.g., keyboard, mouse, pen, voice input device, touch input device) or other peripherals (e.g., printer, scanner, etc.) via one or more I/O ports 158. The example communication device 146 may include a network controller 160, which may be arranged to facilitate communications with one or more other computing devices 162 over a network communication link via one or more communication ports 164.
A network communication link may be one example of a communication medium. Communication media may typically be embodied by computer readable instructions, data structures, program modules, in a modulated data signal, such as a carrier wave or other transport mechanism, and may include any information delivery media. A "modulated data signal" may be a signal that has one or more of its data set or its changes in such a manner as to encode information in the signal. By way of non-limiting example, communication media may include wired media such as a wired network or private-wired network, and various wireless media such as acoustic, radio Frequency (RF), microwave, infrared (IR), or other wireless media. The term computer readable media as used herein may include both storage media and communication media.
In a computing device 100 according to the invention, the application 122 includes instructions for performing the similar image recognition method 200 of the invention, which may instruct the processor 104 to perform the similar image recognition method 200 of the invention to accurately and efficiently recognize similar images.
FIG. 2 shows a flow diagram of a similar image identification method 200 according to one embodiment of the invention. Method 200 is performed in a computing device, such as computing device 100 described above, for accurately and efficiently identifying similar images. As shown in fig. 2, the method 200 begins at step S210.
In step S210, two images to be recognized are acquired.
The image to be identified can be any image, and the source, the size, the content and the like of the image to be identified are not limited by the method. The image to be identified is typically a color image, which in some embodiments may also be a grayscale image or a black and white image.
Subsequently, in step S220, texture feature vectors of the two images are respectively determined according to the gray level difference of adjacent pixels in the images.
According to one embodiment, the texture feature vector may be determined according to the following steps S222 to S226:
first, in step S222, the image is reduced to a preset size and converted into a grayscale image, and the converted image is recorded as a thumbnail image for convenience of description.
It should be noted that the size of the preset dimension can be set by a person skilled in the art, and the present invention is not limited thereto. For example, the preset size may be 8 × 8, i.e., the reduced image includes 64 pixels. In addition, a person skilled in the art can use any image scaling algorithm to reduce the image, and the invention is not limited to the specific algorithm used to reduce the image to the preset size, for example, the algorithm may be an image down-sampling method such as nearest neighbor interpolation, mean value interpolation, bilinear interpolation, etc.
By reducing the image to a preset size, the details in the original image can be removed, only basic information such as texture structure, brightness and darkness is kept, and image differences caused by different sizes and proportions (aspect ratios) are abandoned.
And after the image is reduced to a preset size, converting the reduced image into a gray image. It should be noted that, the present invention does not limit the specific algorithm used for graying the image. For example, the original image is an RGB color image, and the image may be grayed by using an average value method, that is, the grayscale value of a pixel is an average value of the R channel value, the G channel value, and the B channel value of the pixel; the image may also be grayed by a weighted average method, that is, the grayscale value of the pixel is w1 × R + w2 × G + w3 × B, where w1, w2, and w3 are the weights of the R, G, and B channel values of the pixel, respectively.
By converting the reduced image into a gray image, the calculation amount in the subsequent steps S224 and S226 can be reduced, and the calculation speed of the texture feature vector can be increased.
Subsequently, in step S224, the gray scale difference of the adjacent pixels in each line in the thumbnail image is calculated, and the calculated gray scale difference is binarized, and if the gray scale difference is greater than 0, the gray scale difference is binarized into 1, and if the gray scale difference is equal to or less than 0, the gray scale difference is binarized into 0.
For example, the thumbnail image obtained through the processing in step S222 is a 8 × 8 grayscale image. Each line in the thumbnail image includes 8 pixels. Taking the first row of pixels as an example, the first pixel p is calculated 11 And a second pixel p 12 If the gray scale difference is greater than 0, the gray scale difference is binarized to 1, i.e., binarizedGray scale difference Δ of 11 =1; if the gray scale difference is less than or equal to 0, the binary value is changed into 0, namely the gray scale difference delta after the binary value is changed into 11 And =0. Similarly, the second pixel p of the first row is calculated 12 And the third pixel p 13 If the gray scale difference is greater than 0, the binary value is 1, i.e. Δ 12 =1; if the gray difference is less than or equal to 0, the gray difference is binarized into 0, namely delta 12 =0; and by analogy, calculating the gray difference of each pair of adjacent pixels in the first row and binarizing the gray difference to obtain the delta 13 、△ 14 、…、△ 17
Calculating the gray difference of each pair of adjacent pixels in the pixels of the second row to the eighth row and carrying out binarization to obtain delta in a similar way to the first row 21 、△ 22 、…、△ 27 ,△ 31 、△ 32 、…、△ 37 ,…,△ 81 、△ 82 、…、△ 87
Subsequently, in step S226, a binary sequence composed of the binarized gray-scale differences of the respective lines is taken as a texture feature vector of the image.
Referring to the embodiment in step S224, the texture feature vector of the image is [ Δ [ 11 ,△ 12 ,△ 13 ,…,△ 85 ,△ 86 ,△ 87 ]。
According to an embodiment, after calculating the texture feature vectors of the two images respectively according to step S220, the images are further filtered according to the number of consecutive 0S or consecutive 1S included in the texture feature vectors. That is, if the number of consecutive 0 s or consecutive 1 s included in the texture feature vector of any one image is greater than the fourth threshold, it is determined that texture information included in a certain image is too small, and it is determined that the two images are not similar, thereby avoiding erroneous determination of similar images due to too small texture information included in the images.
It should be noted that the fourth threshold may be set by a person skilled in the art, and the present invention is not limited thereto. According to an embodiment, the value of the fourth threshold may be determined according to the size of the thumbnail image. For example, the size of the thumbnail image is 8 × 8, accordingly, 7 × 8=56 elements are included in the texture feature vector, and the first threshold value may be set to 16 as appropriate.
If the number of consecutive 0S or consecutive 1S contained in the texture feature vectors of the two images is not greater than the fourth threshold, it indicates that the texture information contained in the two images is rich, and the subsequent step S230 needs to be performed to determine the texture similarity of the two images, so as to determine whether the two images are potentially similar images.
In step S230, the similarity of the textures of the two images is determined according to the texture feature vector. If the texture is judged to be dissimilar, step S240 is executed to determine that the two images are dissimilar; if the texture is similar, the steps S250 to S270 are executed to further determine whether the two images are similar.
According to an embodiment, the texture similarity may be determined by calculating the hamming distance between two texture feature vectors, that is, calculating the hamming distance between two texture feature vectors, if the hamming distance is less than a third threshold, determining that the textures of the two images are similar, and performing the subsequent step S250; and if the hamming distance is larger than or equal to the third threshold value, judging that the textures of the two images are not similar, and determining that the two images are not similar.
Hamming distance refers to the number of positions in the two sequences where the data is different. For example, the sequence 1 is 01010, the sequence 2 is 11100, the first, third and fourth bits of data of the two sequences are different, the number of positions where the data are different is 3, that is, the hamming distance between the two is 3.
It should be noted that the value of the third threshold may be set by a person skilled in the art, and the present invention is not limited thereto. In addition, the present invention does not limit the specific method for determining the texture similarity according to the texture feature vector. For example, in addition to the method of determining the texture similarity by the hamming distance of the texture feature vector, the texture similarity between two images may be determined by calculating the euclidean distance, the cosine distance, and the like of the texture feature vector.
If the texture of the two images is similar in step S230, it indicates that the two images may be similar images, but a determination cannot be made. Since the image is reduced and grayed out in step S230 when the texture feature vector is calculated (step S222), the original image information is lost to some extent, and the details and color information in the original image are lost. Therefore, in order to accurately determine whether the two images are similar, after the step S230 determines that the two images have similar textures, the following steps S250 to S270 are also required to be performed, so as to further determine from the aspects of color information and information richness.
In step S250, color distribution vectors of the two images are determined according to color values of pixels in the images.
According to one embodiment, the color distribution vector may be determined according to the following steps S252 to S256:
in step S252, the value range of the color value of each color channel is divided into a plurality of segments, and a plurality of color intervals are generated according to the segments, where each color interval includes a segment of each color channel.
For example, the original image is an RGB color image, which includes three color channels of RGB. The color value of each color channel ranges from 0 to 255, and 0 to 255 are divided into four sections, namely, 0 to 63 are the first section, 64 to 127 are the second section, 128 to 191 are the third section, and 192 to 255 are the fourth section. Each RGB color channel is divided into four segments, one segment is arbitrarily taken out from each color channel, and combined to form one color interval, where the number of the color intervals is the product of the number of the segments included in each color channel, that is, 4 × 4=64. The color zones are divided as shown in the following table.
Color interval R channel segment G channel segment B channel segment Pixel scale
1 0~63 0~63 0~63 ratio_1
2 0~63 0~63 64~127 ratio_2
3 0~63 0~63 128~191 ratio_3
64 128~191 128~191 128~191 ratio_64
It should be noted that, although each color channel is divided into four segments in the above embodiment, a person skilled in the art may understand that, in other embodiments, each color channel may also be divided into other number of segments, and the number of segments included in each color channel may be the same or different. The present invention does not limit the division manner of the segments of each color channel.
Subsequently, in step S254, the ratio of the number of pixels belonging to each color section to the total number of image pixels is counted, respectively.
For example, the color value of the first pixel in the image is (52, 33, 116), and the R value thereof is 52, belonging to the sections 0 to 63; the G value is 33, and the strain belongs to a section from 0 to 63; the value of B is 116, belonging to segments 64 to 127, so that the pixel belongs to color interval 2, and accordingly, the number of pixels in color interval 2 is increased by one. The color value of the second pixel in the image is (22, 44, 135) which belongs to color interval 3, and accordingly the number of pixels in color interval 3 is increased by one. By analogy, each pixel in the image is determined to belong to which color interval in a traversing manner, so that the number of pixels in each color interval is counted. Then, the number of pixels in each color interval is divided by the total number of image pixels to obtain the ratio of the number of pixels in each color interval to the total number of image pixels, i.e., the pixel ratios ratio _1, ratio_2, \8230;, ratio _64 in each color interval.
Subsequently, in step S256, a sequence composed of the pixel ratios of the respective color sections is taken as a color distribution vector of the image.
Referring to the example in step S254, the color distribution vector is [ ratio _1, ratio _2, \8230, ratio _64].
In step S260, the information richness of the two images is determined according to the gray scale value of each pixel in the image.
According to one embodiment, the information richness is determined according to the following steps S262 to S266:
in step S262, the image is converted into a grayscale image.
It should be noted that the present invention does not limit the specific algorithm used for graying the image. For example, the original image is an RGB color image, and the image may be grayed by using an average value method, that is, the grayscale value of a pixel is an average value of the R channel value, the G channel value, and the B channel value of the pixel; the image may also be grayed by a weighted average method, that is, the grayscale value of the pixel is w1 × R + w2 × G + w3 × B, where w1, w2, and w3 are the weights of the R, G, and B channel values of the pixel, respectively.
Subsequently, in step S264, a gray characteristic value of each pixel in the gray image is calculated, wherein the gray characteristic value of a pixel comprises the gray value of the pixel and the average value of the gray values of the adjacent pixels of the pixel.
The neighboring pixels of the image may be four-neighborhood pixels or eight-neighborhood pixels of the image. If the adjacent pixels of the image are defined as four-adjacent-domain pixels, the adjacent pixels of the pixel are four pixels of the pixel, namely, the upper pixel, the lower pixel, the left pixel and the right pixel, and correspondingly, the gray level average value of the adjacent pixels of the pixel is the average value of the gray level values of the four pixels of the pixel, namely, the upper pixel, the lower pixel, the left pixel and the right pixel. If the adjacent pixels of the image are defined as eight neighborhood pixels, the adjacent pixels of the pixel are eight pixels of the pixel, namely, upper, lower, left, right, upper left, upper right, lower left and lower right, and accordingly, the gray level mean value of the adjacent pixels of the pixel is the mean value of the gray level values of the eight pixels of the pixel, namely, the upper, lower, left, right, upper left, upper right, lower left and lower right.
Subsequently, in step S266, the information richness of the image is determined from the gradation feature value of each pixel.
According to one embodiment, the information richness is calculated according to the following formula:
Figure BDA0002281522790000111
where H is the information richness, i represents the gray level of a pixel, j represents the gray level mean of the neighboring pixels of the pixel, and p i,j The proportion of the number of pixels with the gray characteristic value of (i, j) to the total number of image pixels, namely the proportion of the number of pixels with the gray value of i and the average value of the gray values of the adjacent pixels of j to the total number of image pixels, is more than or equal to 0 and less than or equal to p i,j Less than or equal to 1. Note that the base of log is usuallyIs 2, which in some embodiments may also be 10, a natural constant e, etc.
The information richness calculated according to the above formula is also called two-dimensional entropy of the image, which can represent the spatial distribution characteristics of the image gray.
Considering that the logarithm and multiplication operations take longer to calculate the information richness H using the above formula, according to one embodiment, the calculation process of the information richness H can be accelerated by calculating and storing a fast arithmetic number in advance, i.e. the following steps S1 to S3:
in step S1, a plurality of base value arithmetic numbers are stored in advance, wherein a base value is greater than or equal to 0 and less than or equal to 1, and a base value arithmetic number is a product of the base value and a logarithm of the base value. For example, p i,j Is in the range of [0,1 ]]According to the value range, 100 base values, namely 0.01,0.02,0.03, \ 8230, 0.99,1 are arranged at the same interval, the rapid calculation numbers of the base values, namely 0.01, log0.02, log0.03, log 8230, and log0.99, log1 are calculated, and the calculated rapid calculation numbers are stored in an internal memory so as to be rapidly obtained when needed.
Subsequently, in step S2, the ratio p of the number of pixels having a gradation characteristic value of (i, j) to the total number of image pixels is calculated i,j And the target base value closest to the ratio is determined. For example, the ratio of the number of pixels with a gray scale feature value of (55, 66) to the total number of image pixels is p i,j =0.256, the base value closest to 0.256 is 0.26, i.e. the target base value is 0.26.
Subsequently, in step S3, the quick calculation number of the target base value is acquired, and the information richness is calculated using the quick calculation number. Referring to the embodiment in step S2, the target base value is 0.26, the quick calculation number 0.26 × log0.26 of 0.26 is obtained from the memory, and the quick calculation number is introduced into the above formula to calculate the information richness H.
The method according to steps S1 to S3, for each p i,j Not calculating p in real time i,j *logp i,j Instead, p is i,j Mapping the data to a target base value, and acquiring a quick calculation number of the target base value from a memory as p i,j *logp i,j . The method can preventThe logarithm and multiplication operation which consumes a large amount of time is avoided, the information richness is converted into the simple addition operation, and the calculation speed of the information richness is greatly accelerated.
It should be noted that, although in fig. 2, step S250 and step S260 are executed successively, those skilled in the art can understand that there is no strict execution sequence between step S250 and step S260, and step S250 may be executed first and step S260 may be executed later as in fig. 2; step S260 may be executed first, and then step S250 may be executed. In some embodiments, steps S250, S260 may also be performed in parallel.
After the color distribution vector and the information richness of the image are calculated in steps S250 and S260, step S270 is performed.
In step S270, when the similarity of the color distribution vectors of the two images is greater than a first threshold and the information richness of both the two images is greater than a second threshold, the two images are determined as similar images. Otherwise, the two images are determined to be dissimilar images.
The similarity of the color distribution vectors of the two images is greater than a first threshold value, indicating that the two images have similarity in color distribution. The information richness of the two images is larger than the second threshold value, which indicates that the information content of the two images is rich, and the misjudgment of the similar images caused by too little information content can be avoided. It should be noted that the values of the first threshold and the second threshold may be set by a person skilled in the art, and the values of the first threshold and the second threshold are not limited in the present invention.
According to one embodiment, the similarity of the color distribution vectors is a cosine similarity. In other embodiments, the similarity of the color distribution vectors may also be calculated by euclidean distance or the like, and the specific calculation method of the similarity of the color subdivision vectors is not limited in the present invention.
FIG. 3 shows a schematic diagram of a similar image identification process according to one embodiment of the invention.
As shown in fig. 3, the image 1 and the image 2 are two images to be recognized. The two images are respectively reduced to a preset size of 8 × 8, and then the reduced 8 × 8 images are grayed to obtain thumbnail images. Then, the gray difference of the adjacent pixels in the thumbnail image is calculated to obtain the texture feature vectors of the image 1 and the image 2.
And then, judging whether the texture feature vectors of the two images contain continuous 160 s, and if any texture feature vector contains continuous 160 s, determining that the two images are not similar. If the two texture feature vectors do not contain 16 continuous 0 s, the hamming distance between the two texture feature vectors is further calculated. If the hamming distance is greater than or equal to a third threshold value, determining that the two images are not similar; if the hamming distance is less than the third threshold, the color distribution vectors of the two images, the similarity a of the two color distribution vectors, and the information richness b1, b2 of the two images are further calculated.
If the similarity a is larger than a first threshold value, and the information richness b1 of the image 1 and the information richness b2 of the image 2 are both larger than a second threshold value, determining that the images are similar; otherwise, it is determined that the two images are not similar.
The similar image identification method comprehensively considers the characteristics of texture, color distribution and information richness when identifying similar images, so that the identification result is more accurate. Ten thousand groups of images in the image library are randomly selected, the identification accuracy of the method is as high as 99.1%, and the accuracy of the existing hash value identification method is 95.5, so that the identification accuracy of the method is higher. Especially when the image texture information is less, the existing method for judging the image similarity by using the hash value is easy to judge two originally dissimilar images to be similar by mistake, and the original images can be correctly judged to be dissimilar by using the method.
For example, the conventional method for determining image similarity by using hash values may falsely determine two images (a) and (b) in fig. 4 and two images (a) and (b) in fig. 5 as similar images, whereas the method of the present invention may correctly determine the two images as dissimilar images.
In addition, compared with a method for extracting image features based on a deep learning model, the method has the advantages of higher speed, simple implementation and less consumed resources (no GPU, no large-capacity storage space and no training process).
Therefore, the similar image identification scheme of the invention is close to the time efficiency of the hash value identification scheme, and the accuracy is higher. Compared with an identification scheme for extracting image features based on a deep learning model, the identification scheme provided by the invention is more time-efficient and consumes less resources. The similar image identification scheme of the invention can give consideration to both accuracy and cost, achieves the balance of identification accuracy and identification speed, and has higher practical value.
A11, a readable storage medium storing program instructions that, when read and executed by a computing device, cause the computing device to perform the similar image identifying method according to any one of claims 1 to 9.
The various techniques described herein may be implemented in connection with hardware or software or, alternatively, with a combination of both. Thus, the methods and apparatus of the present invention, or certain aspects or portions thereof, may take the form of program code (i.e., instructions) embodied in tangible media, such as removable hard drives, U.S. disks, floppy disks, CD-ROMs, or any other machine-readable storage medium, wherein, when the program is loaded into and executed by a machine, such as a computer, the machine becomes an apparatus for practicing the invention.
In the case of program code execution on programmable computers, the computing device will generally include a processor, a storage medium readable by the processor (including volatile and non-volatile memory and/or storage elements), at least one input device, and at least one output device. Wherein the memory is configured to store program code; the processor is configured to perform the similar image recognition method of the present invention according to instructions in the program code stored in the memory.
By way of example, and not limitation, readable media may comprise readable storage media and communication media. Readable storage media store information such as computer readable instructions, data structures, program modules or other data. Communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media. Combinations of any of the above are also included within the scope of readable media.
In the description provided herein, algorithms and displays are not inherently related to any particular computer, virtual system, or other apparatus. Various general purpose systems may also be used with examples of this invention. The required structure for constructing such a system will be apparent from the description above. Moreover, the present invention is not directed to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the teachings of the present invention as described herein, and any descriptions of specific languages are provided above to disclose the best mode of the invention.
In the description provided herein, numerous specific details are set forth. However, it is understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be construed to reflect the intent: that the invention as claimed requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this invention.
Those skilled in the art will appreciate that the modules or units or components of the devices in the examples disclosed herein may be arranged in a device as described in this embodiment or alternatively may be located in one or more devices different from the devices in this example. The modules in the foregoing examples may be combined into one module or may be further divided into multiple sub-modules.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Moreover, those skilled in the art will appreciate that although some embodiments described herein include some features included in other embodiments, not others, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.
Furthermore, some of the described embodiments are described herein as a method or combination of method elements that can be performed by a processor of a computer system or by other means of performing the described functions. A processor with the necessary instructions for carrying out the method or the method elements thus forms a device for carrying out the method or the method elements. Further, the elements of the apparatus embodiments described herein are examples of the following apparatus: the means for performing the functions performed by the elements for the purpose of carrying out the invention.
As used herein, unless otherwise specified the use of the ordinal adjectives "first", "second", "third", etc., to describe a common object, merely indicate that different instances of like objects are being referred to, and are not intended to imply that the objects so described must be in a given sequence, either temporally, spatially, in ranking, or in any other manner.
While the invention has been described with respect to a limited number of embodiments, those skilled in the art, having benefit of this description, will appreciate that other embodiments can be devised which do not depart from the scope of the invention as described herein. Furthermore, it should be noted that the language used in the specification has been principally selected for readability and instructional purposes, and may not have been selected to delineate or circumscribe the inventive subject matter. Accordingly, many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the appended claims. The present invention has been disclosed by way of illustration and not limitation with respect to the scope of the invention, which is defined by the appended claims.

Claims (6)

1. A similar image recognition method, executed in a computing device, comprising the steps of:
acquiring two images to be identified;
respectively determining texture feature vectors of the two images according to the gray level difference of adjacent pixels in the images;
judging the texture similarity of the two images according to the texture feature vector, and if the texture similarity is judged, determining that the two images are dissimilar; if judging that the textures are similar, the method comprises the following steps:
respectively determining color distribution vectors of the two images according to the color value of each pixel in the images;
respectively determining the information richness of the two images according to the gray value of each pixel in the images;
when the similarity of the color distribution vectors of the two images is greater than a first threshold value and the information richness of the two images is greater than a second threshold value, determining the two images as similar images;
wherein the texture feature vector is determined according to the following steps:
reducing the image to a preset size, converting the image into a gray image, and recording the converted image as a thumbnail image;
calculating gray differences of adjacent pixels of each line in the thumbnail images;
binarizing the calculated gray level difference, wherein if the gray level difference is larger than 0, the gray level difference is binarized into 1, and if the gray level difference is smaller than or equal to 0, the gray level difference is binarized into 0;
taking a binary sequence consisting of the binarized gray level differences of each row as a texture feature vector of the image;
the color distribution vector is determined according to the following steps:
dividing the value range of the color value of each color channel into a plurality of sections, and generating a plurality of color intervals according to the sections, wherein each color interval comprises one section of each color channel, and each color channel comprises an R color channel, a G color channel and a B color channel;
respectively counting the proportion of the number of pixels belonging to each color interval to the total number of image pixels;
taking a sequence formed by pixel proportions of all color intervals as a color distribution vector of the image;
the information richness is determined according to the following steps:
converting the image into a grayscale image;
calculating the gray characteristic value of each pixel in the gray image, wherein the gray characteristic value of a pixel comprises the gray value of the pixel and the average value of the gray values of the adjacent pixels of the pixel;
determining the information richness of the image according to the gray characteristic value of each pixel;
the information richness is calculated according to the following formula:
Figure FDA0003856507220000021
h is the information richness, i represents the gray value of the pixel, j represents the average value of the gray values of the adjacent pixels of the pixel, and p i,j Representing a characteristic value of the gray scale as(ii) the number of pixels of (i, j) as a proportion of the total number of image pixels;
the information richness is further calculated according to the following steps:
storing a plurality of quick calculation numbers of base values in advance, wherein the base values are more than or equal to 0 and less than or equal to 1, and the quick calculation numbers of the base values are products of the base values and logarithms of the base values;
calculating the proportion p of the number of pixels with the gray characteristic value of (i, j) to the total number of image pixels i,j And determining a target base value closest to the ratio;
and acquiring a quick calculation number of the target base value, and calculating the information richness by adopting the quick calculation number.
2. The method of claim 1, wherein the determining the similarity of the textures of the two images according to the texture feature vector comprises:
calculating the Hamming distance of the texture feature vectors of the two images, and if the Hamming distance is smaller than a third threshold value, judging that the textures of the two images are similar; and if the Hamming distance is larger than or equal to the third threshold value, judging that the textures of the two images are not similar.
3. The method of claim 2, wherein the two images are determined to be dissimilar if the number of consecutive 0 s or consecutive 1 s contained in the texture feature vector of any one of the images is greater than a fourth threshold.
4. The method of claim 1, wherein the similarity of the color distribution vectors is a cosine similarity.
5. A computing device, comprising:
at least one processor and a memory storing program instructions;
the program instructions, when read and executed by the processor, cause the computing device to perform a similar image recognition method as in any of claims 1-4.
6. A readable storage medium storing program instructions which, when read and executed by a computing device, cause the computing device to perform a similar image recognition method as claimed in any one of claims 1 to 4.
CN201911143303.8A 2019-11-20 2019-11-20 Similar image identification method and computing device Active CN110909791B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911143303.8A CN110909791B (en) 2019-11-20 2019-11-20 Similar image identification method and computing device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911143303.8A CN110909791B (en) 2019-11-20 2019-11-20 Similar image identification method and computing device

Publications (2)

Publication Number Publication Date
CN110909791A CN110909791A (en) 2020-03-24
CN110909791B true CN110909791B (en) 2023-02-28

Family

ID=69816728

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911143303.8A Active CN110909791B (en) 2019-11-20 2019-11-20 Similar image identification method and computing device

Country Status (1)

Country Link
CN (1) CN110909791B (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111598794A (en) * 2020-04-24 2020-08-28 山东易华录信息技术有限公司 Image imaging method and device for removing underwater overlapping condition
CN111881994B (en) * 2020-08-03 2024-04-05 杭州睿琪软件有限公司 Identification processing method and apparatus, and non-transitory computer readable storage medium
CN112702514B (en) * 2020-12-23 2023-02-17 北京小米移动软件有限公司 Image acquisition method, device, equipment and storage medium
CN112669290A (en) * 2020-12-30 2021-04-16 稿定(厦门)科技有限公司 Image comparison method and device
CN113435515B (en) * 2021-06-29 2023-12-19 青岛海尔科技有限公司 Picture identification method and device, storage medium and electronic equipment
CN113837181B (en) * 2021-09-24 2024-04-19 深圳须弥云图空间科技有限公司 Screening method, screening device, computer equipment and computer readable storage medium
CN114820841B (en) * 2022-03-31 2023-03-24 广东东唯新材料有限公司 Image processing method and device for random continuous lines of tile and rock plate product layout
CN114953306B (en) * 2022-04-19 2023-01-20 舒氏集团有限公司 Color composite rubber belt calendering process quality control system

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102622366A (en) * 2011-01-28 2012-08-01 阿里巴巴集团控股有限公司 Similar picture identification method and similar picture identification device
CN103440646A (en) * 2013-08-19 2013-12-11 成都品果科技有限公司 Similarity obtaining method for color distribution and texture distribution image retrieval
CN104572971A (en) * 2014-12-31 2015-04-29 安科智慧城市技术(中国)有限公司 Image retrieval method and device

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101989302B (en) * 2010-10-22 2012-11-28 西安交通大学 Multilayer bitmap color feature-based image retrieval method
WO2016075096A1 (en) * 2014-11-10 2016-05-19 Ventana Medical Systems, Inc. Classifying nuclei in histology images

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102622366A (en) * 2011-01-28 2012-08-01 阿里巴巴集团控股有限公司 Similar picture identification method and similar picture identification device
CN103440646A (en) * 2013-08-19 2013-12-11 成都品果科技有限公司 Similarity obtaining method for color distribution and texture distribution image retrieval
CN104572971A (en) * 2014-12-31 2015-04-29 安科智慧城市技术(中国)有限公司 Image retrieval method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
机器视觉在网片缺陷检测与分类中的应用;顾寄南等;《机械设计与制造》;20190608;第47-53页 *

Also Published As

Publication number Publication date
CN110909791A (en) 2020-03-24

Similar Documents

Publication Publication Date Title
CN110909791B (en) Similar image identification method and computing device
CN109977943B (en) Image target recognition method, system and storage medium based on YOLO
US9235758B1 (en) Robust method to find layout similarity between two documents
WO2022033095A1 (en) Text region positioning method and apparatus
CN109241861B (en) Mathematical formula identification method, device, equipment and storage medium
US20180253852A1 (en) Method and device for locating image edge in natural background
WO2023284608A1 (en) Character recognition model generating method and apparatus, computer device, and storage medium
EP3846076A1 (en) Method, device, chip circuit and computer program product for recognizing mixed typeset texts
CN111223128A (en) Target tracking method, device, equipment and storage medium
CN110427946A (en) A kind of file and picture binary coding method, device and calculate equipment
CN108960012B (en) Feature point detection method and device and electronic equipment
CN114581646A (en) Text recognition method and device, electronic equipment and storage medium
CN111492407B (en) System and method for map beautification
CN109712075B (en) Method and device for identifying original image of digital image data
CN113516739B (en) Animation processing method and device, storage medium and electronic equipment
CN115620321B (en) Table identification method and device, electronic equipment and storage medium
CN110717405B (en) Face feature point positioning method, device, medium and electronic equipment
CN112037174A (en) Chromosome abnormality detection method, device, equipment and computer readable storage medium
CN111382760A (en) Image category identification method and device and computer readable storage medium
CN113516738B (en) Animation processing method and device, storage medium and electronic equipment
Yin et al. Scaling resilient adversarial patch
CN113128496B (en) Method, device and equipment for extracting structured data from image
JP5083162B2 (en) Image data determination apparatus, image data determination system, and program
CN111783787A (en) Method and device for identifying image characters and electronic equipment
CN111563181A (en) Digital image file query method and device and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant