[go: up one dir, main page]

CN111986277A - Image local comparison method, device, equipment and medium based on gray value - Google Patents

Image local comparison method, device, equipment and medium based on gray value Download PDF

Info

Publication number
CN111986277A
CN111986277A CN202010886190.7A CN202010886190A CN111986277A CN 111986277 A CN111986277 A CN 111986277A CN 202010886190 A CN202010886190 A CN 202010886190A CN 111986277 A CN111986277 A CN 111986277A
Authority
CN
China
Prior art keywords
gray value
value
image
same
integer
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.)
Granted
Application number
CN202010886190.7A
Other languages
Chinese (zh)
Other versions
CN111986277B (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.)
Jiyi Data Technology Shanghai Co ltd
Original Assignee
Jiyi Data Technology Shanghai 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 Jiyi Data Technology Shanghai Co ltd filed Critical Jiyi Data Technology Shanghai Co ltd
Priority to CN202010886190.7A priority Critical patent/CN111986277B/en
Publication of CN111986277A publication Critical patent/CN111986277A/en
Application granted granted Critical
Publication of CN111986277B publication Critical patent/CN111986277B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/40Scaling of whole images or parts thereof, e.g. expanding or contracting
    • G06T3/4084Scaling of whole images or parts thereof, e.g. expanding or contracting in the transform domain, e.g. fast Fourier transform [FFT] domain scaling
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/187Segmentation; Edge detection involving region growing; involving region merging; involving connected component labelling
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/40Extraction of image or video features
    • G06V10/44Local feature extraction by analysis of parts of the pattern, e.g. by detecting edges, contours, loops, corners, strokes or intersections; Connectivity analysis, e.g. of connected components
    • G06V10/443Local feature extraction by analysis of parts of the pattern, e.g. by detecting edges, contours, loops, corners, strokes or intersections; Connectivity analysis, e.g. of connected components by matching or filtering

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Multimedia (AREA)
  • Image Analysis (AREA)

Abstract

本申请提供了一种基于灰度值的图像局部比对方法、装置、设备和介质,通过将获取的原始图像进行高斯模糊处理、及灰度值处理;令每个像素点的灰度值等比例缩小至预设范围内,并依据各像素点缩小后的灰度值,划分为多个对应不同整数灰度值的同阶灰度值图像;对各同阶灰度值图像进行二值化处理,并将灰度值相同的像素点组合以构成一或多个连通域;针对各连通域分别构建最小矩形框;对各最小矩形框内的像素点利用P希哈算法进行二值化处理以得到二值整数串,以供在图像数据库中通过二值整数串的比对判断是否存在至少局部相似的图像。本申请便于存储和比对,大大节省了对比处理速度和存储所需内存,更提升了图像局部的比对精准度和效率。

Figure 202010886190

The present application provides a method, device, device and medium for local image comparison based on gray value. By performing Gaussian blur processing and gray value processing on the obtained original image; The scale is reduced to a preset range, and according to the reduced gray value of each pixel point, it is divided into multiple gray value images of the same order corresponding to different integer gray values; binarize each gray value image of the same order process, and combine the pixels with the same gray value to form one or more connected domains; build a minimum rectangular frame for each connected domain; binarize the pixels in each minimum rectangular frame using the P-Hash algorithm to obtain a binary integer string for judging whether there are at least partially similar images in the image database by comparing the binary integer strings. The present application is convenient for storage and comparison, greatly saves the comparison processing speed and the memory required for storage, and further improves the accuracy and efficiency of local image comparison.

Figure 202010886190

Description

基于灰度值的图像局部比对方法、装置、设备和介质Method, Apparatus, Equipment and Medium for Local Image Comparison Based on Gray Value

技术领域technical field

本发明涉及图像处理技术领域,特别是涉及一种基于灰度值的图像局部比对方法、装置、设备和介质。The present invention relates to the technical field of image processing, in particular to a method, device, device and medium for local comparison of images based on gray values.

背景技术Background technique

当前越来越多的场景中需要图片的对比,如常见的针对盗用或抄袭图案的鉴定。随着图片或图案的抄袭越来越隐蔽,往往还需要对图片中的图案的颜色、形状等进行局部的比对。At present, more and more scenes require the comparison of pictures, such as the common identification of embezzled or plagiarized patterns. As the plagiarism of pictures or patterns becomes more and more concealed, it is often necessary to locally compare the colors and shapes of the patterns in the pictures.

而传统的图片比对过程,需要将待比对图像与数据库中的图片进行逐一比对,如常见的利用图片提取出的特征向量进行比对,但是一个图片中所包含的特征向量或像素内存也非常多,这就造成需比对的速度非常多,比对速度非常缓慢,另外,图片数据库中存储图片的数据占用也非常庞大,而且对于局部或细微的抄袭图案往往不能发现。In the traditional image comparison process, it is necessary to compare the images to be compared with the images in the database one by one. There are also many, which results in a lot of comparison speed, and the comparison speed is very slow. In addition, the data storage of pictures in the picture database is also very large, and local or subtle plagiarism patterns are often not found.

发明内容SUMMARY OF THE INVENTION

鉴于以上所述现有技术的缺点,本申请的目的在于提供一种基于灰度值的图像局部比对方法、装置、设备和介质,以解决现有技术中存在的至少一个问题。In view of the above-mentioned shortcomings of the prior art, the purpose of the present application is to provide a method, apparatus, device and medium for local comparison of images based on gray values, so as to solve at least one problem existing in the prior art.

为实现上述目的及其他相关目的,本申请提供一种基于灰度值的图像局部比对方法,所述方法包括:将获取的原始图像进行高斯模糊处理、及灰度值处理;令每个像素点的灰度值等比例缩小至预设范围内,并依据各像素点缩小后的灰度值,划分为多个对应不同整数灰度值的同阶灰度值图像;对各同阶灰度值图像进行二值化处理,并将灰度值相同的像素点组合以构成一或多个连通域;依据筛选条件选取一或多个包含独立完整图案的连通域,并针对各所述连通域分别构建用于覆盖全部所述独立完整图案的最小矩形框;对各所述最小矩形框内的像素点利用P希哈算法进行二值化处理以得到二值整数串,以供在图像数据库中通过二值整数串的比对判断是否存在至少局部相似的图像。In order to achieve the above purpose and other related purposes, the present application provides a gray value-based local image comparison method, the method includes: performing Gaussian blurring and gray value processing on the acquired original image; The gray value of the point is proportionally reduced to the preset range, and according to the reduced gray value of each pixel point, it is divided into multiple gray value images of the same level corresponding to different integer gray values; The value image is binarized, and the pixels with the same gray value are combined to form one or more connected domains; one or more connected domains containing independent complete patterns are selected according to the screening conditions, and for each connected domain Constructing the minimum rectangular frames used to cover all the independent complete patterns respectively; using the P-hash algorithm to binarize the pixels in each of the minimum rectangular frames to obtain a binary integer string for use in the image database It is judged whether there are at least partially similar images through the comparison of binary integer strings.

于本申请的一实施例中,所述令每个像素点的灰度值等比例缩小至预设范围内,并依据各像素点缩小后的灰度值,划分为多个对应不同整数灰度值的同阶灰度值图像,包括:令每个像素点的灰度值由范围0-255×255等比例缩小至范围0-N;针对缩小后的灰度值,将非整数的灰度值四舍五入为整数灰度值;按0-N中属于相同整数的灰度值分别选取对应的像素点,以得到N+1个仅包含相同整数灰度值的像素点的同阶灰度值图像。In an embodiment of the present application, the grayscale value of each pixel is proportionally reduced to a predetermined range, and is divided into a plurality of corresponding different integer grayscales according to the reduced grayscale value of each pixel. The same-level gray value image of the value, including: reducing the gray value of each pixel from the range 0-255×255 to the range 0-N in equal proportion; for the reduced gray value, the non-integer gray value The value is rounded to an integer gray value; corresponding pixels are selected according to the gray values belonging to the same integer in 0-N, so as to obtain the same-level gray value image of N+1 pixels only containing the same integer gray value .

于本申请的一实施例中,所述对各同阶灰度值图像进行二值化处理,并将灰度值相同的像素点组合以构成一或多个连通域,包括:令各所述同阶灰度值图像中属于被选取的相同整数的灰度值为1,令不属于被选取的相同整数的灰度值为0,以使各所述同阶灰度值图像的灰度值仅为0或1;分别将灰度值为0的像素点组合以构成一或多个连通域;和/或,将灰度值为1的像素点组合以构成一或多个连通域。In an embodiment of the present application, performing binarization processing on each gray value image of the same level, and combining pixel points with the same gray value to form one or more connected domains, includes: making each of the In the same-level gray-value image, the gray value of the selected same integer is 1, and the gray value of the gray value that does not belong to the selected same integer is 0, so that the gray value of each of the same-level gray value images is It is only 0 or 1; the pixel points with the gray value of 0 are respectively combined to form one or more connected domains; and/or the pixel points with the gray value of 1 are combined to form one or more connected domains.

于本申请的一实施例中,所述筛选条件包括以下任意一种或多种组合:1)所述连通域中的像素点个数大于121;2)所述连通域面积至多占整个所述同阶灰度值图像的三分之一;3)所述连通域中最长的长度与最长的宽度的比例0.2至5之间。In an embodiment of the present application, the screening conditions include any one or more of the following combinations: 1) the number of pixels in the connected domain is greater than 121; 2) the area of the connected domain accounts for at most the entire 3) The ratio of the longest length to the longest width in the connected domain is between 0.2 and 5.

于本申请的一实施例中,所述对各所述最小矩形框内的像素点利用P希哈算法进行二值化处理以得到二值整数串,包括:将所述最小矩形框按n×n宫格平均分割为n×n个小块;计算各小块内所有像素点的灰度值总和;将所有小块中非0的灰度值总和求平均值,并令各非0小块的灰度值总和与所述平均值进行对比;若小于所述平均值,则将非0小块所对应的值记为0;若大于等于所述平均值,则将非0小块的所对应的值记为1;按照由所述最小矩形框的中心位置逐步向外圈扩散的方式,依次统计中心位置的小块所对应的值、及由内向外各层外圈上各小块所对应的值,以得到对应一同阶灰度值图像的二值整数串。In an embodiment of the present application, performing binarization processing on the pixels in each of the minimum rectangular frames by using the P-hash algorithm to obtain a binary integer string includes: dividing the minimum rectangular frame by n× The n grid is divided into n×n small blocks on average; calculate the sum of the gray values of all pixels in each small block; average the sum of the non-0 gray values in all the small blocks, and make each non-0 small block The sum of the gray value of , is compared with the average value; if it is less than the average value, the value corresponding to the non-0 small block is recorded as 0; if it is greater than or equal to the average value, the non-0 small block is recorded as 0. The corresponding value is denoted as 1; according to the method of gradually diffusing from the center position of the minimum rectangular frame to the outer ring, the values corresponding to the small blocks at the center position and the values corresponding to the small blocks on the outer ring of each layer from the inside to the outside are counted in turn. corresponding value to obtain a binary integer string corresponding to the same-level gray value image.

于本申请的一实施例中,所述二值整数串的书写格式包括:分别对应所述中心位置、及由内向外的各层外圈所统计的二值整数串的区段,对应由内向外的顺序,依次从高位向低位排列各二值整数串的区段;所述高位向低位对应为从右向左或从左向右;和/或,各层外圈中由左上角的小块所对应的值为起始,按顺时针方向依次统计外圈上各小块所对应的值,并按从低位向高位的排列顺序书写。In an embodiment of the present application, the writing format of the binary integer string includes: respectively corresponding to the center position and sections of the binary integer string counted by the outer circle of each layer from the inside to the outside, corresponding to the In the outer order, the segments of the binary integer strings are sequentially arranged from the high order to the low order; the high order to the low order corresponds to right to left or left to right; The value corresponding to the block starts from the beginning, counts the values corresponding to each small block on the outer ring in a clockwise direction, and writes it in the order from low to high.

于本申请的一实施例中,所述在图像数据库中通过二值整数串的比对判断是否存在局部相似的图像,包括:针对所述二值整数串设置比对线,以令所述二值整数串中在所述比对线右边或左边的二值整数串的高位区段与图像数据库中各整数对应的二值整数区段的数值进行比对;其中,所述比对线可根据比对情况或场景需求进行调节,以供调整比对精确度;若二值整数串的高位区段的比对相同,则判定对应的二值整数串相近;若m个对应同阶灰度值图像的二值整数串的比对分别相近,则判定所述图像数据库中存在与所述原始图像为局部相似的图像。In an embodiment of the present application, determining whether there are locally similar images by comparing binary integer strings in the image database includes: setting a comparison line for the binary integer strings, so that the two The high-order segment of the binary integer string on the right or left side of the comparison line in the value integer string is compared with the value of the binary integer segment corresponding to each integer in the image database; wherein, the comparison line can be based on The comparison situation or scene needs are adjusted to adjust the comparison accuracy; if the comparison of the high-order segment of the binary integer string is the same, it is determined that the corresponding binary integer string is similar; if m corresponding grayscale values of the same level If the comparisons of the binary integer strings of the images are respectively similar, it is determined that there is an image in the image database that is partially similar to the original image.

为实现上述目的及其他相关目的,本申请提供一种基于灰度值的图像局部比对装置,所述装置包括:第一处理模块,用于将获取的原始图像进行高斯模糊处理、及灰度值处理;令每个像素点的灰度值等比例缩小至预设范围内,并依据各像素点缩小后的灰度值,划分为多个对应不同整数灰度值的同阶灰度值图像;第二处理模块,用于对各同阶灰度值图像进行二值化处理,并将灰度值相同的像素点组合以构成一或多个连通域;依据筛选条件选取一或多个包含独立完整图案的连通域,并针对各所述连通域分别构建用于覆盖全部所述独立完整图案的最小矩形框;对各所述最小矩形框内的像素点利用P希哈算法进行二值化处理以得到二值整数串,以供在图像数据库中通过二值整数串的比对判断是否存在至少局部相似的图像。In order to achieve the above purpose and other related purposes, the present application provides a gray value-based image local comparison device, the device includes: a first processing module for performing Gaussian blurring on the acquired original image, and grayscale Value processing; reduce the gray value of each pixel to the preset range in equal proportion, and divide it into multiple gray value images of the same level corresponding to different integer gray values according to the reduced gray value of each pixel ; The second processing module is used to binarize the gray value images of the same order, and combine the pixels with the same gray value to form one or more connected domains; Connected domains of independent complete patterns, and for each of the connected domains, respectively construct a minimum rectangular frame for covering all the independent complete patterns; binarize the pixels in each of the minimum rectangular frames using the P-Hash algorithm Processing to obtain a binary integer string for determining whether there are at least partially similar images in the image database by comparing the binary integer strings.

为实现上述目的及其他相关目的,本申请提供一种计算机设备,所述设备包括:存储器、及处理器;所述存储器用于存储计算机指令;所述处理器运行计算机指令实现如上所述的方法。In order to achieve the above purpose and other related purposes, the present application provides a computer device, the device includes: a memory and a processor; the memory is used to store computer instructions; the processor executes the computer instructions to implement the above method. .

为实现上述目的及其他相关目的,本申请提供一种计算机可读存储介质,存储有计算机指令,所述计算机指令被运行时执行如上所述的方法。In order to achieve the above object and other related objects, the present application provides a computer-readable storage medium storing computer instructions, and when the computer instructions are executed, the above-mentioned method is executed.

综上所述,本申请提供的一种基于灰度值的图像局部比对方法、装置、设备和介质,通过将获取的原始图像进行高斯模糊处理、及灰度值处理;令每个像素点的灰度值等比例缩小至预设范围内,并依据各像素点缩小后的灰度值,划分为多个对应不同整数灰度值的同阶灰度值图像;对各同阶灰度值图像进行二值化处理,并将灰度值相同的像素点组合以构成一或多个连通域;依据筛选条件选取一或多个包含独立完整图案的连通域,并针对各所述连通域分别构建用于覆盖全部所述独立完整图案的最小矩形框;对各所述最小矩形框内的像素点利用P希哈算法进行二值化处理以得到二值整数串,以供在图像数据库中通过二值整数串的比对判断是否存在至少局部相似的图像。To sum up, a method, device, device and medium for local image comparison based on gray value provided by the present application, by subjecting the acquired original image to Gaussian blurring and gray value processing; The gray value of the pixel is reduced to the preset range in equal proportion, and according to the reduced gray value of each pixel, it is divided into multiple gray value images of the same level corresponding to different integer gray values; The image is binarized, and the pixels with the same gray value are combined to form one or more connected domains; one or more connected domains containing independent complete patterns are selected according to the screening conditions, and for each connected domain, one or more connected domains are selected. Constructing a minimum rectangular frame for covering all the independent complete patterns; binarizing the pixels in each of the minimum rectangular frames using the P-Hash algorithm to obtain a binary integer string for passing in the image database The comparison of binary integer strings determines whether there are at least partially similar images.

具有以下有益效果:Has the following beneficial effects:

本申请基于灰度值将图像特征二值化,并通过连通域的分割,将图像局部细节的特征转换为二值数值串,便于存储和比对,大大节省了对比处理速度和存储所需内存,更提升了图像局部的比对精准度和效率。The present application binarizes the image features based on the gray value, and converts the features of the local details of the image into binary value strings through the segmentation of the connected domain, which is convenient for storage and comparison, and greatly saves the comparison processing speed and the memory required for storage. , which improves the accuracy and efficiency of local image comparison.

附图说明Description of drawings

图1显示为本申请于一实施例中基于灰度值的图像局部比对方法的流程示意图。FIG. 1 is a schematic flowchart of a method for local image comparison based on gray value in an embodiment of the present application.

图2A-2C显示为本申请于一实施例中对各所述最小矩形框内的像素点利用P希哈算法进行二值化处理以得到二值整数串的场景示意图。2A-2C are schematic diagrams of scenarios in which the pixel points in each of the smallest rectangular frames are binarized by the P-hash algorithm to obtain a binary integer string according to an embodiment of the present application.

图3显示为本申请于一实施例中基于灰度值的图像局部比对装置的模块示意图。FIG. 3 is a schematic block diagram of a local image comparison apparatus based on gray value in an embodiment of the present application.

图4显示为本申请于一实施例中计算机设备的结构示意图。FIG. 4 is a schematic structural diagram of a computer device in an embodiment of the present application.

具体实施方式Detailed ways

以下通过特定的具体实例说明本申请的实施方式,本领域技术人员可由本说明书所揭露的内容轻易地了解本申请的其他优点与功效。本申请还可以通过另外不同的具体实施方式加以实施或应用,本说明书中的各项细节也可以基于不同观点与应用,在没有背离本申请的精神下进行各种修饰或改变。需说明的是,在不冲突的情况下,以下实施例及实施例中的特征可以相互组合。The embodiments of the present application are described below through specific specific examples, and those skilled in the art can easily understand other advantages and effects of the present application from the contents disclosed in this specification. The present application can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present application. It should be noted that the following embodiments and features in the embodiments may be combined with each other under the condition of no conflict.

需要说明的是,以下实施例中所提供的图示仅以示意方式说明本申请的基本构想,虽然图式中仅显示与本申请中有关的组件而非按照实际实施时的组件数目、形状及尺寸绘制,但其实际实施时各组件的型态、数量及比例可为一种随意的改变,且其组件布局型态也可能更为复杂。It should be noted that the drawings provided in the following embodiments are only used to illustrate the basic concept of the present application in a schematic way, although the drawings only show the components related to the present application rather than the number, shape and number of components in actual implementation. The dimensions are drawn, but the type, quantity and proportion of each component can be arbitrarily changed in actual implementation, and the component layout may also be more complicated.

在通篇说明书中,当说某部分与另一部分“连接”时,这不仅包括“直接连接”的情形,也包括在其中间把其它元件置于其间而“间接连接”的情形。另外,当说某种部分“包括”某种构成要素时,只要没有特别相反的记载,则并非将其它构成要素,排除在外,而是意味着可以还包括其它构成要素。Throughout the specification, when a part is said to be "connected" to another part, this includes not only the case of "direct connection" but also the case of "indirect connection" with other elements interposed therebetween. In addition, when it says that a certain part "includes" a certain constituent element, unless there is particularly no description to the contrary, it does not exclude other constituent elements, but means that other constituent elements may also be included.

其中提到的第一、第二及第三等术语是为了说明多样的部分、成分、区域、层及/或段而使用的,但并非限定于此。这些术语只用于把某部分、成分、区域、层或段区别于其它部分、成分、区域、层或段。因此,以下叙述的第一部分、成分、区域、层或段在不超出本申请范围的范围内,可以言及到第二部分、成分、区域、层或段。The terms first, second, and third mentioned herein are used for the purpose of describing various parts, components, regions, layers and/or sections and are not intended to be limiting. These terms are only used to distinguish one part, component, region, layer or section from another part, component, region, layer or section. Thus, recitation of a first part, component, region, layer or section below may refer to a second part, component, region, layer or section without departing from the scope of the present application.

再者,如同在本文中所使用的,单数形式“一”、“一个”和“该”旨在也包括复数形式,除非上下文中有相反的指示。应当进一步理解,术语“包含”、“包括”表明存在所述的特征、操作、元件、组件、项目、种类、和/或组,但不排除一个或多个其他特征、操作、元件、组件、项目、种类、和/或组的存在、出现或添加。此处使用的术语“或”和“和/或”被解释为包括性的,或意味着任一个或任何组合。因此,“A、B或C”或者“A、B和/或C”意味着“以下任一个:A;B;C;A和B;A和C;B和C;A、B和C”。仅当元件、功能或操作的组合在某些方式下内在地互相排斥时,才会出现该定义的例外。Also, as used herein, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context dictates otherwise. It should be further understood that the terms "comprising", "comprising" indicate the presence of a stated feature, operation, element, component, item, kind, and/or group, but do not exclude one or more other features, operations, elements, components, The existence, appearance or addition of items, categories, and/or groups. The terms "or" and "and/or" as used herein are to be construed to be inclusive or to mean any one or any combination. Thus, "A, B or C" or "A, B and/or C" means "any of the following: A; B; C; A and B; A and C; B and C; A, B and C" . Exceptions to this definition arise only when combinations of elements, functions, or operations are inherently mutually exclusive in some way.

传统的图片比对过程,需要将待比对图像与数据库中的图片进行逐一比对,如常见的利用图片提取出的特征向量进行比对,但是一个图片中所包含的特征向量或像素内存也非常多,这就造成需比对的速度非常多,比对速度非常缓慢,而且对于局部或细微的抄袭图案往往不能发现;另外,图片数据库中存储图片的数据占用也非常庞大。In the traditional image comparison process, it is necessary to compare the images to be compared with the images in the database one by one. For example, the common feature vector extracted from the image is compared, but the feature vector or pixel memory contained in a There are a lot of them, which results in a lot of comparison speeds. The comparison speed is very slow, and local or subtle plagiarism patterns are often not found. In addition, the data storage of pictures in the picture database is also very large.

为解决上述问题,本申请提出一种基于灰度值的图像局部比对方法、装置、设备和介质,将图片的特征值转化为整数形式,以便于存储和比对,大大节省了对比速度和存储所需内存。In order to solve the above-mentioned problems, the present application proposes a method, device, equipment and medium for local image comparison based on gray value, which converts the feature value of the picture into an integer form, which is convenient for storage and comparison, and greatly saves the comparison speed and speed. memory required for storage.

如图1所示,展示为本申请于一实施例中的基于灰度值的图像局部比对方法的流程示意图。如图所示,所述方法包括:As shown in FIG. 1 , a schematic flowchart of a method for local image comparison based on gray value in an embodiment of the present application is shown. As shown, the method includes:

步骤S101:将获取的原始图像进行高斯模糊处理、及灰度值处理。Step S101: Perform Gaussian blur processing and gray value processing on the acquired original image.

于本实施例中,对获取的原始图像进行高斯模糊处理主要用于去噪。In this embodiment, Gaussian blurring is performed on the acquired original image mainly for denoising.

所述高斯模糊(Gaussian Blur),也叫高斯平滑,是在Adobe Photoshop、GIMP以及Paint.NET等图像处理软件中广泛使用的处理效果,通常用它来减少图像噪声以及降低细节层次。高斯平滑也用于计算机视觉算法中的预先处理阶段,以增强图像在不同比例大小下的图像效果(参见尺度空间表示以及尺度空间实现)。从数学的角度来看,图像的高斯模糊过程就是图像与正态分布做卷积。由于正态分布又叫作高斯分布,所以这项技术就叫作高斯模糊。The Gaussian Blur, also called Gaussian smoothing, is a processing effect widely used in image processing software such as Adobe Photoshop, GIMP, and Paint.NET, and is usually used to reduce image noise and reduce the level of detail. Gaussian smoothing is also used in the preprocessing stage in computer vision algorithms to enhance images at different scales (see Scale Space Representation and Scale Space Implementation). From a mathematical point of view, the Gaussian blurring process of an image is the convolution of the image with the normal distribution. Since the normal distribution is also known as the Gaussian distribution, this technique is called Gaussian blur.

优选地,本步骤还包括:将所述原始图像的RGBA四通道删减为RGB三通道。Preferably, this step further includes: pruning four RGBA channels of the original image into three RGB channels.

通常一张原始图像均具有RGBA四个通道,它们分别代表Red(红色)Green(绿色)Blue(蓝色)和Alpha的色彩空间,但是它其实仅仅是RGB模型的附加了额外的信息。采用的颜色通常是RGB,而Alpha通道一般用作不透明度参数,因此,本申请将在图像比对过程中产生影响较小或不产生影响的Alpha通道去掉,以减少通道数,从而减少比对用到的数据。Usually, an original image has four RGBA channels, which represent the color space of Red (red) Green (green) Blue (blue) and Alpha respectively, but it is actually just additional information of the RGB model. The color used is usually RGB, and the Alpha channel is generally used as an opacity parameter. Therefore, this application removes the Alpha channel that has little or no impact in the image comparison process to reduce the number of channels, thereby reducing the comparison. data used.

于本实施例中,本步骤中的灰度值处理主要是将每个像素点的RGB三通道像素转换为灰度值,如由某一像素点像素坐标(x,y,rgb)转换为灰度值坐标(x,y,g)。In this embodiment, the gray value processing in this step is mainly to convert the RGB three-channel pixels of each pixel into gray values, such as converting the pixel coordinates (x, y, rgb) of a certain pixel into gray. Degree coordinates (x,y,g).

步骤S102:令每个像素点的灰度值等比例缩小至预设范围内,并依据各像素点缩小后的灰度值,划分为多个对应不同整数灰度值的同阶灰度值图像。Step S102: Reduce the gray value of each pixel to a preset range in equal proportions, and divide it into a plurality of gray value images of the same level corresponding to different integer gray values according to the reduced gray value of each pixel .

于本申请一实施例中,In an embodiment of the present application,

A、令每个像素点的灰度值由范围0-255×255等比例缩小至范围0-N。A. Reduce the gray value of each pixel from the range 0-255×255 to the range 0-N in equal proportions.

举例来说,通常将像素点RGB三个颜色通道转换为灰度值至后,灰度值范围在(0-255×255)内。假设N取15,这里设置一系数G,G=255×255÷15=4335。因此,可通过将原始图像中每个像素点的灰度值除以系数G,以使每个像素点的灰度值等比例缩小至0-15的范围内。For example, after converting the three color channels of RGB to grayscale values, the grayscale value range is (0-255×255). Assuming that N is 15, a coefficient G is set here, G=255×255÷15=4335. Therefore, by dividing the gray value of each pixel in the original image by the coefficient G, the gray value of each pixel can be scaled down to a range of 0-15.

B、针对缩小后的灰度值,将非整数的灰度值四舍五入为整数灰度值。B. For the reduced grayscale value, round the non-integer grayscale value to an integer grayscale value.

承上举例来说,每个像素点的灰度值除以系数G后,得到的灰度值或为带小数的非整数或为整数,故本申请通过采用四舍五入的方式,将非整数统一转为整数。For example, after dividing the gray value of each pixel by the coefficient G, the obtained gray value is either a non-integer with a decimal or an integer. Therefore, the present application converts the non-integer into a uniform by rounding. is an integer.

C、按0-N中属于相同整数的灰度值分别选取对应的像素点,以得到N+1个仅包含相同整数灰度值的像素点的同阶灰度值图像。C. Select corresponding pixel points according to the gray value of the same integer in 0-N, so as to obtain N+1 gray value images of the same level that only contain the same integer gray value of the pixel points.

举例来说,将灰度值调整后为0的像素点选取出来,对应其他未被选取的像素点设为空,则可得到一个灰度值仅包含0的同阶灰度值图像,以此类推,假设N取15,则可得到16个这样的同阶灰度值图像。但须知的是,这里的N并非仅限于15,N也可以取10以下,100以下的数。例如,当原始图像的像素尺寸不大时,可以取1位数,当原始图像的像素尺寸非常大时,也可取100以下的任意两位数。For example, by selecting the pixels whose gray value is adjusted to 0, and setting the corresponding other unselected pixels to be empty, an image of the same gray value whose gray value only contains 0 can be obtained. By analogy, assuming that N is 15, 16 such grayscale images of the same order can be obtained. But it should be noted that N here is not limited to 15, and N can also take a number below 10 and below 100. For example, when the pixel size of the original image is not large, it can take 1 digit, and when the pixel size of the original image is very large, it can also take any two digits below 100.

再举例来说,假设原始图像为一幅人脸图像,划分为多个对应不同整数灰度值的同阶灰度值图像所呈现的情况可能为:一个同阶灰度值图像中的像素点呈现为脸部轮廓、另一个同阶灰度值图像中的像素点呈现为眼部、还有一个同阶灰度值图像中的像素点呈现为头发等,即通过灰度值将原始图像分层,将每个同阶灰度值图像则构成不同角度的子图,从而大大细化图像局部特征,对于存在盗用或抄袭细小图像元素的情况,也能够得到很好的比对效果。For another example, assuming that the original image is a face image, the situation presented by dividing it into multiple grayscale images of the same level corresponding to different integer grayscale values may be: pixel points in a grayscale image of the same level It is presented as the outline of the face, the pixels in another grayscale image of the same level are presented as eyes, and the pixels in another grayscale image of the same level are presented as hair, etc. Each gray value image of the same level is formed into sub-images of different angles, so as to greatly refine the local characteristics of the image, and even in the case of misappropriation or plagiarism of small image elements, a good comparison effect can be obtained.

步骤S103:对各同阶灰度值图像进行二值化处理,并将灰度值相同的像素点组合以构成一或多个连通域。Step S103 : Binarize each gray value image of the same level, and combine pixel points with the same gray value to form one or more connected domains.

该步骤具体包括:This step specifically includes:

A、令各所述同阶灰度值图像中属于被选取的相同整数的灰度值为1,令不属于被选取的相同整数的灰度值为0,以使各所述同阶灰度值图像的灰度值仅为0或1;A. Let the grayscale value of each of the same-level grayscale value images belonging to the selected same integer be 1, and let the grayscale value of the grayscale value not belonging to the selected same integer be 0, so that each of the same-level grayscale values The grayscale value of the value image is only 0 or 1;

B、分别将灰度值为0的像素点组合以及将灰度值为1的像素点组合,以构成一或多个连通域。B. Respectively combine pixel points with a grayscale value of 0 and pixels with a grayscale value of 1 to form one or more connected domains.

承上举例的同阶灰度值图像,假设其仅包含的相同整数的灰度值的为N,则可通过下面公式进行二值化处理,以使得图像中全部像素点的值为1或0。Taking the same-level gray value image from the above example, assuming that it only contains the same integer gray value of N, the following formula can be used to perform binarization processing, so that the value of all pixels in the image is 1 or 0 .

Figure BDA0002655639800000061
Figure BDA0002655639800000061

其中,g'表示等比例缩小后的灰度值。Among them, g' represents the gray value after proportional reduction.

在所述同阶灰度值图像的灰度值变为仅为0或1后,可将灰度值为0的像素点连接,以及将灰度值为1的像素点连接,从而得到一或多个包含独立完整图案的连通域。After the gray value of the gray value image of the same level becomes only 0 or 1, the pixels with the gray value of 0 can be connected, and the pixels with the gray value of 1 can be connected, so as to obtain an or Multiple connected domains that contain independent complete patterns.

需要说明的是,本步骤通过相同灰度值构成的连通域,实际上是将任意一个可描述的具有意义的细小图案或完整图案都显示凸显出来,因此,每个连通域理论都具有一定的比对价值。It should be noted that in this step, the connected domain formed by the same gray value actually displays and highlights any descriptive and meaningful small pattern or complete pattern. Therefore, each connected domain theory has certain characteristics. Compare value.

通常来说,一个同阶灰度值图像可得到几十个甚至几百个包含独立完整图案的连通域,而每个连通域可表示为有价值的子图。Generally speaking, a gray value image of the same level can obtain dozens or even hundreds of connected domains containing independent complete patterns, and each connected domain can be represented as a valuable subgraph.

步骤S104:依据筛选条件选取一或多个包含独立完整图案的连通域,并针对各所述连通域分别构建用于覆盖全部所述独立完整图案的最小矩形框。Step S104 : Select one or more connected domains including independent complete patterns according to the screening conditions, and construct a minimum rectangular frame for covering all the independent complete patterns for each connected domain.

需要说明的是,在所述同阶灰度值图像得到的一或多个连通域的图案,或大或小,或高矮胖瘦,或趋于饱满,形状各种各样。所以,并非任意一个连通域满足本申请所述方法后续计算的要求。因此,本申请通过预设筛选条件来挑选合适的包含独立完整图案的连通域。It should be noted that the patterns of one or more connected domains obtained from the same-level gray value image may be large or small, tall, short, fat and thin, or tend to be plump, and have various shapes. Therefore, not any connected domain satisfies the requirements of the subsequent calculation of the method described in this application. Therefore, the present application selects suitable connected domains containing independent complete patterns through preset screening conditions.

于本申请一实施例中,所述筛选条件包括以下任意一种或多种组合:In an embodiment of the present application, the screening conditions include any one or more of the following combinations:

1)所述连通域中的像素点个数大于121。优先地,长和宽最好大于11。1) The number of pixels in the connected domain is greater than 121. Preferably, the length and width are preferably greater than 11.

需要说明的是,这里需要像素点个数大于121的目的在于,在步骤S105中,需要通过n×n的宫格来划分所述同阶灰度值图像,而本申请中,11×11是比较优选的分割宫格,因此,这里希望连通域的像素点个数不小于121个。另外,原始图像的尺寸本申请并未进行缩放,因此原始图像的尺寸理论上是比较大的,而这里将连通域的像素点个数限制在121个,也实际上限制了所筛选出的独立完整图案的最小尺寸。因为,在实际操作中,过小的像素点个数所包含具有价值的图像元素较少,而且还会增加比对数量,延长处理时间。It should be noted that the purpose of requiring the number of pixels to be greater than 121 is that in step S105, the same-level gray value image needs to be divided by an n×n grid, and in this application, 11×11 is It is more preferable to divide the grid, so it is hoped that the number of pixels in the connected domain is not less than 121. In addition, the size of the original image is not scaled in this application, so the size of the original image is theoretically relatively large, and the number of pixels in the connected domain is limited to 121 here, which actually limits the selected independent pixels. Minimum size of a complete pattern. Because, in practice, the number of pixels that are too small contains fewer valuable image elements, and it also increases the number of comparisons and prolongs the processing time.

2)所述连通域面积至多占整个所述同阶灰度值图像的三分之一。2) The area of the connected domain accounts for at most one third of the entire gray value image of the same level.

本条筛选条件的目的是尽量将图像局部更细节化,以提高对复杂图像寻找相似元素的精准度。而且过大的区域大概率是背景,不适合本申请找局部相似图案。优选地,将整张图片降到11x11尺寸后再做P哈希(Phash)运算,更容易找到整体相似。但比对区域过大,对找到不相同的图片,反而造成干扰。The purpose of this filter condition is to try to make the image more detailed in order to improve the accuracy of finding similar elements in complex images. Moreover, an area that is too large is likely to be the background, which is not suitable for finding local similar patterns in this application. Preferably, the P hash (Phash) operation is performed after the entire image is reduced to 11x11 size, which makes it easier to find the overall similarity. However, if the comparison area is too large, it will interfere with finding different pictures.

3)所述连通域中最长的长度与最长的宽度的比例0.2至5之间。3) The ratio of the longest length to the longest width in the connected domain is between 0.2 and 5.

需说明的是,这里所述的最长的长度与最长的宽度的比例即为对应连通域的长宽比,因为后续需要构建覆盖连通域的矩形框,因此,所述连通域的形状越饱和越好,如呈圆形或趋近于方形。因此,本申请中希望所述连通域的长宽比限制在0.2至5之间,即长不大于宽的5倍,或小于宽的1/5。It should be noted that the ratio of the longest length to the longest width described here is the aspect ratio of the corresponding connected domain, because a rectangular frame covering the connected domain needs to be constructed later, so the more the shape of the connected domain is. The better the saturation, i.e. round or square. Therefore, in the present application, it is expected that the aspect ratio of the connected domain is limited between 0.2 and 5, that is, the length is not greater than 5 times the width, or less than 1/5 of the width.

步骤S105:对各所述最小矩形框内的像素点利用P希哈算法进行二值化处理以得到二值整数串,以供在图像数据库中通过二值整数串的比对判断是否存在至少局部相似的图像。Step S105: Perform binarization processing on the pixels in each of the minimum rectangular frames using the P-Hash algorithm to obtain a binary integer string, which is used to judge whether there is an at least partial integer string in the image database by comparing the binary integer string. similar images.

于本申请一实施例中,所述对各所述最小矩形框内的像素点利用P希哈算法进行二值化处理以得到二值整数串,包括:In an embodiment of the present application, performing binarization processing on the pixels in each of the smallest rectangular frames by using the P hash algorithm to obtain a binary integer string includes:

A、将所述最小矩形框按n×n宫格平均分割为n×n个小块。A. Divide the smallest rectangular frame into n×n small blocks on average according to n×n grids.

优选地,所述n优选为单数,如1、3、5、7、9、11、13等等。其原因在于,n为单数构成的n×n宫格,可使分割出的小块形成由中心向外扩展的一层层的外圈。例如,5×5宫格分割出25个小块,其可形成一中心位置小块,以及一个临近中心位置的内圈,和一个最外层的外圈。Preferably, the n is preferably singular, such as 1, 3, 5, 7, 9, 11, 13 and the like. The reason is that, n is an n×n grid formed by a singular number, so that the divided small blocks can form a layer-by-layer outer ring extending outward from the center. For example, a 5×5 grid is divided into 25 blocks, which can form a center block, an inner circle near the center, and an outermost outer circle.

需要说明的是,在实际运行操作中,最小矩形框按n×n宫格优选为不低于11×11。在本申请中采用低于11×11的宫格仅用于举例说明,这里也对应连通域筛选条件中的,所述连通域中的像素点个数大于121。优先地,长和宽最好大于11。It should be noted that, in actual operation, the minimum rectangular frame is preferably not less than 11×11 in an n×n grid. In the present application, the grid less than 11×11 is used for illustration only, and it also corresponds to the connected domain filtering condition, where the number of pixels in the connected domain is greater than 121. Preferably, the length and width are preferably greater than 11.

B、计算各小块内所有像素点的灰度值总和。B. Calculate the sum of the gray values of all pixels in each small block.

由于原始图像的尺寸并没有限制,所以由对应的各同阶灰度值图像上得到连通域的尺寸也并不小,因此,虽然分割成了一个个小块,但每个小块可能包含多个像素点,而该小块内的各个像素点可能为1或为0,因此,统计各小块内所有像素点的灰度值总和,就是将各像素点对应的0或1的值相加。Since the size of the original image is not limited, the size of the connected domain obtained from the corresponding gray value images of the same level is not small. Therefore, although it is divided into small blocks, each small block may contain multiple Each pixel in the small block may be 1 or 0. Therefore, to count the sum of the gray values of all pixels in each small block is to add the values of 0 or 1 corresponding to each pixel. .

如图2A所示,假设最小矩形框按5×5格平均分割为25块,其中,图中一连通域内的小块的灰度值总和为2,该小块内对应有2×2个像素点,分别为0、1、0、1,因此,该小块的灰度值总和为2。As shown in Figure 2A, it is assumed that the minimum rectangular frame is divided into 25 blocks according to 5 × 5 grids. The sum of the gray values of the small blocks in a connected domain in the figure is 2, and there are 2 × 2 pixels in this small block. Points are 0, 1, 0, 1, respectively, so the sum of the grayscale values of this small block is 2.

需要说明的是,虽然图2A中显示的连通域的边线仅占灰度值总和为2的小块的一半,但须知的是,连通域构建时,是在各同阶灰度值图像进行二值化处理后,将灰度值为1的像素点进行连接,因此,若将连通域放大至能够显示每个像素点大小时,所述连通域的边线均是由像素点单元构成,因此实际上所述连通域不会出现仅占像素点一半的情况,而是将整个像素点作为边线的组成部分,而图2A只是将尺寸显示到小块的大小,所以呈现出占据小块一半的情况。It should be noted that although the edge of the connected domain shown in Figure 2A only accounts for half of the small block whose gray value sum is 2, it should be noted that when the connected domain is constructed, two gray value images of the same level are used for After the value processing, the pixels whose gray value is 1 are connected. Therefore, if the connected domain is enlarged to display the size of each pixel, the edges of the connected domain are all composed of pixel units, so the actual The above-mentioned connected domain will not only occupy half of the pixels, but the entire pixel will be used as a component of the edge, and Figure 2A only displays the size to the size of the small block, so it appears to occupy half of the small block. .

C、将所有小块中非0的灰度值总和求平均值,并令各非0小块的灰度值总和与所述平均值进行对比。C. Average the sum of the non-0 grayscale values in all the small blocks, and compare the sum of the grayscale values of each non-0 small block with the average value.

统计小块内所有像素点的灰度值总和,若一小块内所有像素点的灰度值为0,那么该灰度值总和也为0,例如,所述矩形框中远离连通域的边线的区域,便经常会出现灰度值总和为0的情况。然后计算这些非0小块的灰度值总和的平均值,再将灰度值总和非0的值与求得的平均值进行比较。Count the sum of the gray values of all the pixels in the small block. If the gray value of all the pixels in the small block is 0, then the sum of the gray values is also 0. For example, the edge of the rectangle is far from the connected domain. In the area of it often occurs that the sum of the gray values is 0. Then calculate the average value of the sum of the gray value of these non-zero small blocks, and then compare the value of the sum of the gray value that is not 0 with the obtained average value.

D、若小于所述平均值,则将非0小块所对应的值记为0;若大于等于所述平均值,则将非0小块的所对应的值记为1;D. If it is less than the average value, the value corresponding to the non-zero block is recorded as 0; if it is greater than or equal to the average value, the value corresponding to the non-0 small block is recorded as 1;

举例来说,如图2B所示,图中显示为3×3的矩形块,各小块的灰度值总和如图所示,其中,灰度值总和为非0的小块有7个,而这7个小块的灰度值总和的总数为14,求得平均数为2。然后将这7个小块的灰度值总和与2相比,小于2的小块所对应的值记为0,大于等于2的小块所对应的值记为1。For example, as shown in Figure 2B, the figure is a 3×3 rectangular block, the sum of the gray value of each small block is shown in the figure, wherein, there are 7 small blocks whose gray value sum is non-0, The total sum of the gray value of these 7 small blocks is 14, and the average is 2. Then compare the sum of the grayscale values of these 7 small blocks with 2, the value corresponding to the small block smaller than 2 is recorded as 0, and the value corresponding to the small block greater than or equal to 2 is recorded as 1.

E、按照由所述最小矩形框的中心位置逐步向外圈扩散的方式,依次统计中心位置的小块所对应的值、及由内向外各层外圈上各小块所对应的值,以得到对应一同阶灰度值图像的二值整数串。E. According to the method of gradually diffusing from the center position of the minimum rectangular frame to the outer circle, count the values corresponding to the small blocks at the center position and the values corresponding to the small blocks on the outer circles of each layer from the inside to the outside in turn, so that Obtain the binary integer string corresponding to the same-level gray value image.

需说明的是,对应本实施例,这里的步骤A-E则近似于本领域中的P哈希算法。It should be noted that, corresponding to this embodiment, steps A-E here are similar to the P hash algorithm in the art.

于本申请一实施例中,所述二值整数串的书写格式包括:In an embodiment of the present application, the writing format of the binary integer string includes:

1)分别对应所述中心位置、及由内向外的各层外圈所统计的二值整数串的区段,对应由内向外的顺序,依次从高位向低位排列各二值整数串的区段;所述高位向低位对应为从右向左或从左向右;1) Corresponding to the central position and the sections of the binary integer string counted by the outer circles of each layer from the inside to the outside, corresponding to the order from the inside to the outside, arranging the sections of each binary integer string from the high order to the low order. ; The high-to-low corresponds to right-to-left or left-to-right;

和/或,and / or,

2)各层外圈中由左上角的小块所对应的值为起始,按顺时针方向依次统计外圈上各小块所对应的值,并按从低位向高位的排列顺序书写。2) The value corresponding to the small block in the upper left corner of the outer ring of each layer starts from the value corresponding to the small block in the upper left corner, counts the values corresponding to each small block on the outer ring in a clockwise direction, and writes in the order from low to high.

于本实施例中,越靠近中心点的值,其对应的权重越高,放置在高位。所述高位向低位可对应为从右向左或从左向右。In this embodiment, the value closer to the center point has a higher corresponding weight and is placed at a high position. The high-to-low may correspond to right-to-left or left-to-right.

举例来说,如图2C所示,所述中心位置所统计的二值整数为1,设其对应的区段为A;与中心位置相邻的外圈所统计的二值整数则为00100101,设其对应的区段为B;最外层的外圈所统计的二值整数则为01110011011101110,设其对应的区段为C。假设,高位向低位可对应为从右向左,则对应图2C所示的经步骤A-E处理后,所得到对应一同阶灰度值图像的二值整数串为:For example, as shown in FIG. 2C , the binary integer counted by the center position is 1, and the corresponding segment is set as A; the binary integer counted by the outer ring adjacent to the center position is 00100101, Let its corresponding section be B; the binary integer counted by the outermost outer ring is 01110011011101110, and let its corresponding section be C. Assuming that the high-order to low-order can correspond to from right to left, then the obtained binary integer string corresponding to the same-level gray value image after the processing of steps A-E shown in FIG. 2C is:

01110011011101110/00100101/1;01110011011101110/00100101/1;

其中,“/”仅用于区分不同区段,并不属于二值整数串中的数值或字符。Among them, "/" is only used to distinguish different sections, and does not belong to the value or character in the binary integer string.

于本申请一实施例中,所述在图像数据库中通过二值整数串的比对判断是否存在局部相似的图像,包括:In an embodiment of the present application, the judging whether there are locally similar images in the image database through the comparison of binary integer strings includes:

A、针对所述二值整数串设置比对线,以令所述二值整数串中在所述比对线右边或左边的二值整数串的高位区段与图像数据库中各整数对应的二值整数区段的数值进行比对;其中,所述比对线可根据比对情况或场景需求进行调节,以供调整比对精确度;A. Set an alignment line for the binary integer string, so that the high-order segment of the binary integer string on the right or left side of the alignment line in the binary integer string corresponds to the binary integer corresponding to each integer in the image database. The value of the integer value segment is compared; wherein, the comparison line can be adjusted according to the comparison situation or scene requirements, so as to adjust the comparison accuracy;

需说明的是,如上所举例的二值整数串的书写格式,其中不难看出,高位的值对应同阶灰度值图像的中心位置,二值整数串越靠低位的值则越对应同阶灰度值图像的边缘位置。因此,对中心位置对应的值进行比对,意义更高,准确度也相应更高。It should be noted that, in the writing format of the binary integer string as exemplified above, it is not difficult to see that the high-order value corresponds to the center position of the gray value image of the same level, and the lower the value of the binary integer string is, the more it corresponds to the same level. The edge position of the grayscale image. Therefore, the comparison of the values corresponding to the center position is more meaningful and the accuracy is correspondingly higher.

B、若二值整数串的高位区段的比对相同,则判定对应的二值整数串相近。B. If the comparisons of the high-order segments of the binary integer strings are the same, it is determined that the corresponding binary integer strings are similar.

C、若m个对应同阶灰度值图像的二值整数串的比对分别相近,则判定所述图像数据库中存在与所述原始图像为局部相似的图像。C. If the comparisons of m binary integer strings corresponding to the same-level gray value images are respectively similar, it is determined that there is an image that is partially similar to the original image in the image database.

需说明的是,这里二值整数串的高位区段的比对可以存在相同或不同,但相同的二值整数区段,其对应的整个二值整数串则很难相同,因此只能判定相近。但是又由于图案中有价值的更多的集中在中心位置,因此,达到二值整数串的高位区段的比对相同,便可判断出比对的两者的二值整数串相近。基于此,若m个对应同阶灰度值图像的二值整数串的高位区段的比对相同,则可以判定所述图像数据库中存在与所述原始图像为局部相似的图像。在一些可实现的实施例中,所述m为3或4个,便可准确判断出所述图像数据库中存在与所述原始图像为局部相似的图像。It should be noted that the comparison of the high-order segments of the binary integer strings here can be the same or different, but the same binary integer segment, the entire binary integer string corresponding to it is difficult to be the same, so it can only be determined that they are similar. . However, since the valuables in the pattern are more concentrated in the center position, it can be judged that the two compared binary integer strings are similar if the alignment of the high-order segment of the binary integer string is the same. Based on this, if the comparisons of the high-order segments of the m binary integer strings corresponding to the same-level gray value images are the same, it can be determined that there is an image in the image database that is partially similar to the original image. In some achievable embodiments, if the m is 3 or 4, it can be accurately determined that there is an image that is partially similar to the original image in the image database.

通常来说,本申请目的是实现同阶灰度值图像按照连通域切图,将一张图片切图上百张有价值的子图,每个子图转化成一个Hash整数,将子图查找转化为数据库整数范围对比。对应一个同阶灰度值图像便可形成几十几百个二值整数串,对一个原始图像便有成百上千个个二值整数串,因此,在图像局部的比对上,细化的更为精细。Generally speaking, the purpose of this application is to cut the same-level gray value image according to the connected domain, cut a picture into hundreds of valuable subgraphs, convert each subgraph into a Hash integer, and convert the subgraph search into Integer range comparison for the database. Corresponding to a gray value image of the same level, dozens and hundreds of binary integer strings can be formed, and for an original image, there are hundreds of binary integer strings. Therefore, in the local comparison of the image, refinement more precise.

综上所述,本申请提出的一种基于灰度值的图像局部比对方法、装置、设备和介质,基于灰度值将图像特征二值化,并通过连通域的分割,将图像局部细节的特征转换为二值数值串,便于存储和比对,大大节省了对比处理速度和存储所需内存,更提升了图像局部的比对精准度和效率。To sum up, a method, device, device and medium for local image comparison based on gray value proposed in this application binarize image features based on gray value, and divide the image local details through the segmentation of connected domains. The features are converted into binary value strings, which are convenient for storage and comparison, which greatly saves the comparison processing speed and memory required for storage, and also improves the accuracy and efficiency of local image comparison.

如图3所示,展示为本申请于一实施例中的基于灰度值的图像局部比对装置的模块示意图。如图所示,所述装置300包括:As shown in FIG. 3 , it is a schematic block diagram of an apparatus for local image comparison based on gray value in an embodiment of the present application. As shown, the apparatus 300 includes:

第一处理模块301,用于将获取的原始图像进行高斯模糊处理、及灰度值处理;令每个像素点的灰度值等比例缩小至预设范围内,并依据各像素点缩小后的灰度值,划分为多个对应不同整数灰度值的同阶灰度值图像;The first processing module 301 is used to perform Gaussian blur processing and gray value processing on the obtained original image; the gray value of each pixel is proportionally reduced to within a preset range, and according to the reduced size of each pixel. Gray value, divided into multiple gray value images of the same order corresponding to different integer gray values;

第二处理模块302,用于对各同阶灰度值图像进行二值化处理,并将灰度值相同的像素点组合以构成一或多个连通域;依据筛选条件选取一或多个包含独立完整图案的连通域,并针对各所述连通域分别构建用于覆盖全部所述独立完整图案的最小矩形框;对各所述最小矩形框内的像素点利用P希哈算法进行二值化处理以得到二值整数串,以供在图像数据库中通过二值整数串的比对判断是否存在至少局部相似的图像。The second processing module 302 is configured to perform binarization processing on each gray value image of the same level, and combine the pixels with the same gray value to form one or more connected domains; according to the screening conditions, select one or more including Connected domains of independent complete patterns, and for each of the connected domains, respectively construct a minimum rectangular frame for covering all the independent complete patterns; binarize the pixels in each of the minimum rectangular frames using the P-Hash algorithm Processing to obtain a binary integer string for determining whether there are at least partially similar images in the image database by comparing the binary integer strings.

需要说明的是,上述装置各模块/单元之间的信息交互、执行过程等内容,由于与本申请所述方法实施例基于同一构思,其带来的技术效果与本申请方法实施例相同,具体内容可参见本申请前述所示的方法实施例中的叙述,此处不再赘述。It should be noted that the information exchange, execution process, etc. among the modules/units of the above-mentioned device are based on the same concept as the method embodiments described in the present application, and the technical effects brought by them are the same as those of the method embodiments of the present application. For the content, reference may be made to the descriptions in the method embodiments shown in the foregoing application, and details are not repeated here.

还需要说明的是,应理解以上装置的各个模块的划分仅仅是一种逻辑功能的划分,实际实现时可以全部或部分集成到一个物理实体上,也可以物理上分开。且这些单元可以全部以软件通过处理元件调用的形式实现;也可以全部以硬件的形式实现;还可以部分模块通过处理元件调用软件的形式实现,部分模块通过硬件的形式实现。例如,第二处理模块302可以为单独设立的处理元件,也可以集成在上述系统的某一个芯片中实现,此外,也可以以程序代码的形式存储于上述系统的存储器中,由上述装置的某一个处理元件调用并执行以上第二处理模块302的功能。其它模块的实现与之类似。此外这些模块全部或部分可以集成在一起,也可以独立实现。这里所述的处理元件可以是一种集成电路,具有信号的处理能力。在实现过程中,上述方法的各步骤或以上各个模块可以通过处理器元件中的硬件的集成逻辑电路或者软件形式的指令完成。It should also be noted that it should be understood that the division of each module of the above apparatus is only a division of logical functions, and may be fully or partially integrated into a physical entity during actual implementation, or may be physically separated. And these units can all be implemented in the form of software calling through processing elements; they can also all be implemented in hardware; some modules can also be implemented in the form of calling software through processing elements, and some modules can be implemented in hardware. For example, the second processing module 302 may be a separately established processing element, or may be integrated into a certain chip of the above-mentioned system to be implemented, in addition, it may also be stored in the memory of the above-mentioned system in the form of program code, and the above-mentioned device is executed by a certain chip. A processing element invokes and executes the functions of the second processing module 302 above. The implementation of other modules is similar. In addition, all or part of these modules can be integrated together, and can also be implemented independently. The processing element described here may be an integrated circuit with signal processing capability. In the implementation process, each step of the above-mentioned method or each of the above-mentioned modules can be completed by an integrated logic circuit of hardware in the processor element or an instruction in the form of software.

例如,以上这些模块可以是被配置成实施以上方法的一个或多个集成电路,例如:一个或多个特定集成电路(Application Specific Integrated Circuit,简称ASIC),或,一个或多个微处理器(digital signal processor,简称DSP),或,一个或者多个现场可编程门阵列(Field Programmable Gate Array,简称FPGA)等。再如,当以上某个模块通过处理元件调度程序代码的形式实现时,该处理元件可以是通用处理器,例如中央处理器(Central Processing Unit,简称CPU)或其它可以调用程序代码的处理器。再如,这些模块可以集成在一起,以片上系统(system-on-a-chip,简称SOC)的形式实现。For example, the above modules may be one or more integrated circuits configured to implement the above methods, such as: one or more specific integrated circuits (Application Specific Integrated Circuit, ASIC for short), or one or more microprocessors ( digital signal processor, referred to as DSP), or, one or more Field Programmable Gate Array (Field Programmable Gate Array, referred to as FPGA) and the like. For another example, when one of the above modules is implemented in the form of processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit (Central Processing Unit, CPU for short) or other processors that can call program codes. For another example, these modules can be integrated together and implemented in the form of a system-on-a-chip (SOC for short).

如图4所示,展示为本申请于一实施例中的计算机设备的结构示意图。如图所示,所述计算机设备400包括:存储器401、及处理器402;所述存储器401用于存储计算机指令;所述处理器402运行计算机指令实现如图1所述的方法。As shown in FIG. 4 , a schematic structural diagram of a computer device in an embodiment of the present application is shown. As shown in the figure, the computer device 400 includes: a memory 401 and a processor 402; the memory 401 is used to store computer instructions; the processor 402 executes the computer instructions to implement the method described in FIG. 1 .

在一些实施例中,所述计算机设备400中的所述存储器401的数量均可以是一或多个,所述处理器402的数量均可以是一或多个,而图4中均以一个为例。In some embodiments, the number of the memory 401 in the computer device 400 may be one or more, the number of the processor 402 may be one or more, and in FIG. example.

于本申请一实施例中,所述计算机设备400中的处理器402会按照如图1所述的步骤,将一个或多个以应用程序的进程对应的指令加载到存储器401中,并由处理器402来运行存储在存储器401中的应用程序,从而实现如图1所述的方法。In an embodiment of the present application, the processor 402 in the computer device 400 loads one or more instructions corresponding to the process of the application program into the memory 401 according to the steps shown in FIG. The controller 402 is used to run the application program stored in the memory 401, thereby implementing the method described in FIG. 1 .

所述存储器401可以包括随机存取存储器(Random Access Memory,简称RAM),也可以包括非易失性存储器(non-volatile memory),例如至少一个磁盘存储器。所述存储器401存储有操作系统和操作指令、可执行模块或者数据结构,或者它们的子集,或者它们的扩展集,其中,操作指令可包括各种操作指令,用于实现各种操作。操作系统可包括各种系统程序,用于实现各种基础业务以及处理基于硬件的任务。The memory 401 may include random access memory (Random Access Memory, RAM for short), and may also include non-volatile memory (non-volatile memory), such as at least one disk memory. The memory 401 stores operating systems and operation instructions, executable modules or data structures, or their subsets, or their extended sets, wherein the operation instructions may include various operation instructions for implementing various operations. The operating system may include various system programs for implementing various basic services and handling hardware-based tasks.

所述处理器402可以是通用处理器,包括中央处理器(Central Processing Unit,简称CPU)、网络处理器(Network Processor,简称NP)等;还可以是数字信号处理器(Digital Signal Processing,简称DSP)、专用集成电路(Application SpecificIntegrated Circuit,简称ASIC)、现场可编程门阵列(Field-Programmable Gate Array,简称FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。The processor 402 may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU for short), a network processor (Network Processor, NP for short), etc.; it may also be a digital signal processor (Digital Signal Processing, DSP for short) ), Application Specific Integrated Circuit (ASIC for short), Field-Programmable Gate Array (FPGA for short) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.

在一些具体的应用中,所述计算机设备400的各个组件通过总线系统耦合在一起,其中总线系统除包括数据总线之外,还可以包括电源总线、控制总线和状态信号总线等。但是为了清除说明起见,在图4中将各种总线都成为总线系统。In some specific applications, various components of the computer device 400 are coupled together through a bus system, where the bus system may include a power bus, a control bus, a status signal bus, and the like in addition to a data bus. However, for the sake of clarity of illustration, the various buses are referred to as bus systems in FIG. 4 .

于本申请的一实施例中,本申请提供一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现如图1所述的方法。In an embodiment of the present application, the present application provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, implements the method described in FIG. 1 .

在任何可能的技术细节结合层面,本申请可以是系统、方法和/或计算机程序产品。计算机程序产品可以包括计算机可读存储介质,其上载有用于使处理器实现本申请的各个方面的计算机可读程序指令。At any possible level of incorporation of technical details, the present application may be a system, method and/or computer program product. The computer program product may include a computer-readable storage medium having computer-readable program instructions loaded thereon for causing a processor to implement various aspects of the present application.

计算机可读存储介质可以是可以保持和存储由指令执行设备使用的指令的有形设备。计算机可读存储介质例如可以是(但不限于)电存储设备、磁存储设备、光存储设备、电磁存储设备、半导体存储设备或者上述的任意合适的组合。计算机可读存储介质的更具体的例子(非穷举的列表)包括:便携式计算机盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、静态随机存取存储器(SRAM)、便携式压缩盘只读存储器(CD-ROM)、数字多功能盘(DVD)、记忆棒、软盘、机械编码设备、例如其上存储有指令的打孔卡或凹槽内凸起结构、以及上述的任意合适的组合。这里所使用的计算机可读存储介质不被解释为瞬时信号本身,诸如无线电波或者其他自由传播的电磁波、通过波导或其他传输媒介传播的电磁波(例如,通过光纤电缆的光脉冲)、或者通过电线传输的电信号。A computer-readable storage medium may be a tangible device that can hold and store instructions for use by the instruction execution device. The computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples (non-exhaustive list) of computer readable storage media include: portable computer disks, hard disks, random access memory (RAM), read only memory (ROM), erasable programmable read only memory (EPROM) or flash memory), static random access memory (SRAM), portable compact disk read only memory (CD-ROM), digital versatile disk (DVD), memory sticks, floppy disks, mechanically coded devices, such as printers with instructions stored thereon Hole cards or raised structures in grooves, and any suitable combination of the above. Computer-readable storage media, as used herein, are not to be construed as transient signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides or other transmission media (eg, light pulses through fiber optic cables), or through electrical wires transmitted electrical signals.

这里所描述的计算机可读程序可以从计算机可读存储介质下载到各个计算/处理设备,或者通过网络、例如因特网、局域网、广域网和/或无线网下载到外部计算机或外部存储设备。网络可以包括铜传输电缆、光纤传输、无线传输、路由器、防火墙、交换机、网关计算机和/或边缘服务器。每个计算/处理设备中的网络适配卡或者网络接口从网络接收计算机可读程序指令,并转发该计算机可读程序指令,以供存储在各个计算/处理设备中的计算机可读存储介质中。The computer-readable programs described herein can be downloaded to various computing/processing devices from computer-readable storage media, or to external computers or external storage devices over a network such as the Internet, a local area network, a wide area network, and/or a wireless network. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and/or edge servers. A network adapter card or network interface in each computing/processing device receives computer-readable program instructions from a network and forwards the computer-readable program instructions for storage in a computer-readable storage medium in each computing/processing device .

用于执行本申请操作的计算机程序指令可以是汇编指令、指令集架构(ISA)指令、机器指令、机器相关指令、微代码、固件指令、状态设置数据、集成电路配置数据或者以一种或多种编程语言的任意组合编写的源代码或目标代码,所述编程语言包括面向对象的编程语言—诸如Smalltalk、C++等,以及过程式编程语言—诸如“C”语言或类似的编程语言。计算机可读程序指令可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络—包括局域网(LAN)或广域网(WAN)—连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。在一些实施例中,通过利用计算机可读程序指令的状态信息来个性化定制电子电路,例如可编程逻辑电路、现场可编程门阵列(FPGA)或可编程逻辑阵列(PLA),该电子电路可以执行计算机可读程序指令,从而实现本申请的各个方面。Computer program instructions for carrying out the operations of the present application may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, integrated circuit configuration data, or in one or more source or object code written in any combination of programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and procedural programming languages, such as the "C" language or similar programming languages. The computer readable program instructions may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer, or entirely on the remote computer or server implement. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (eg, using an Internet service provider through the Internet connect). In some embodiments, custom electronic circuits, such as programmable logic circuits, field programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), can be personalized by utilizing state information of computer readable program instructions. Computer readable program instructions are executed to implement various aspects of the present application.

综上所述,本申请提供的一种基于灰度值的图像局部比对方法、装置、设备和介质,通过将获取的原始图像进行高斯模糊处理、及灰度值处理;令每个像素点的灰度值等比例缩小至预设范围内,并依据各像素点缩小后的灰度值,划分为多个对应不同整数灰度值的同阶灰度值图像;对各同阶灰度值图像进行二值化处理,并将灰度值相同的像素点组合以构成一或多个连通域;依据筛选条件选取一或多个包含独立完整图案的连通域,并针对各所述连通域分别构建用于覆盖全部所述独立完整图案的最小矩形框;对各所述最小矩形框内的像素点利用P希哈算法进行二值化处理以得到二值整数串,以供在图像数据库中通过二值整数串的比对判断是否存在至少局部相似的图像。To sum up, a method, device, device and medium for local image comparison based on gray value provided by the present application, by subjecting the acquired original image to Gaussian blurring and gray value processing; The gray value of the pixel is reduced to the preset range in equal proportion, and according to the reduced gray value of each pixel, it is divided into multiple gray value images of the same level corresponding to different integer gray values; The image is binarized, and the pixels with the same gray value are combined to form one or more connected domains; one or more connected domains containing independent complete patterns are selected according to the screening conditions, and for each connected domain, one or more connected domains are selected. Constructing a minimum rectangular frame for covering all the independent complete patterns; binarizing the pixels in each of the minimum rectangular frames using the P-Hash algorithm to obtain a binary integer string for passing in the image database The comparison of binary integer strings determines whether there are at least partially similar images.

本申请有效克服了现有技术中的种种缺点而具高度产业利用价值。The present application effectively overcomes various shortcomings in the prior art and has high industrial application value.

上述实施例仅例示性说明本申请的原理及其功效,而非用于限制本发明。任何熟悉此技术的人士皆可在不违背本申请的精神及范畴下,对上述实施例进行修饰或改变。因此,举凡所属技术领域中包含通常知识者在未脱离本发明所揭示的精神与技术思想下所完成的一切等效修饰或改变,仍应由本申请的权利要求所涵盖。The above-mentioned embodiments merely illustrate the principles and effects of the present application, but are not intended to limit the present invention. Anyone skilled in the art can make modifications or changes to the above embodiments without departing from the spirit and scope of the present application. Therefore, all equivalent modifications or changes made by those skilled in the art without departing from the spirit and technical idea disclosed in the present invention should still be covered by the claims of the present application.

Claims (10)

1.一种基于灰度值的图像局部比对方法,其特征在于,所述方法包括:1. an image local comparison method based on gray value, is characterized in that, described method comprises: 将获取的原始图像进行高斯模糊处理、及灰度值处理;Perform Gaussian blur processing and gray value processing on the acquired original image; 令每个像素点的灰度值等比例缩小至预设范围内,并依据各像素点缩小后的灰度值,划分为多个对应不同整数灰度值的同阶灰度值图像;The gray value of each pixel is reduced proportionally to a preset range, and according to the reduced gray value of each pixel, it is divided into a plurality of gray value images of the same level corresponding to different integer gray values; 对各同阶灰度值图像进行二值化处理,并将灰度值相同的像素点组合以构成一或多个连通域;Binarize each gray value image of the same level, and combine the pixels with the same gray value to form one or more connected domains; 依据筛选条件选取一或多个包含独立完整图案的连通域,并针对各所述连通域分别构建用于覆盖全部所述独立完整图案的最小矩形框;Selecting one or more connected domains containing independent complete patterns according to the screening conditions, and constructing a minimum rectangular frame for covering all the independent complete patterns for each of the connected domains; 对各所述最小矩形框内的像素点利用P希哈算法进行二值化处理以得到二值整数串,以供在图像数据库中通过二值整数串的比对判断是否存在至少局部相似的图像。Binarization is performed on the pixels in each of the minimum rectangular frames by using the P-Hash algorithm to obtain a binary integer string, which is used to judge whether there are at least partially similar images in the image database through the comparison of the binary integer strings . 2.根据权利要求1所述的方法,其特征在于,所述令每个像素点的灰度值等比例缩小至预设范围内,并依据各像素点缩小后的灰度值,划分为多个对应不同整数灰度值的同阶灰度值图像,包括:2. The method according to claim 1, wherein the gray value of each pixel is proportionally reduced to within a preset range, and is divided into multiple groups according to the reduced gray value of each pixel. A gray value image of the same order corresponding to different integer gray values, including: 令每个像素点的灰度值由范围0-255×255等比例缩小至范围0-N;Reduce the gray value of each pixel from the range 0-255×255 to the range 0-N in equal proportions; 针对缩小后的灰度值,将非整数的灰度值四舍五入为整数灰度值;For the reduced grayscale value, round the non-integer grayscale value to an integer grayscale value; 按0-N中属于相同整数的灰度值分别选取对应的像素点,以得到N+1个仅包含相同整数灰度值的像素点的同阶灰度值图像。Corresponding pixel points are respectively selected according to the gray value of the same integer in 0-N, so as to obtain the same-level gray value image of N+1 pixel points only containing the same integer gray value. 3.根据权利要求2所述的方法,其特征在于,所述对各同阶灰度值图像进行二值化处理,并将灰度值相同的像素点组合以构成一或多个连通域,包括:3. The method according to claim 2, wherein the binarization processing is performed on each gray value image of the same level, and the pixel points with the same gray value are combined to form one or more connected domains, include: 令各所述同阶灰度值图像中属于被选取的相同整数的灰度值为1,令不属于被选取的相同整数的灰度值为0,以使各所述同阶灰度值图像的灰度值仅为0或1;Let the grayscale value of each of the same-level grayscale value images belonging to the selected same integer be 1, and let the grayscale value of not belonging to the selected same integer value be 0, so that each of the same-level grayscale value images The grayscale value is only 0 or 1; 分别将灰度值为0的像素点组合以构成一或多个连通域;和/或,将灰度值为1的像素点组合以构成一或多个连通域。The pixel points with the gray value of 0 are respectively combined to form one or more connected domains; and/or the pixel points with the gray value of 1 are combined to form one or more connected domains. 4.根据权利要求1所述的方法,其特征在于,所述筛选条件包括以下任意一种或多种组合:4. The method according to claim 1, wherein the screening condition comprises any one or more of the following combinations: 1)所述连通域中的像素点个数大于121;1) The number of pixels in the connected domain is greater than 121; 2)所述连通域面积至多占整个所述同阶灰度值图像的三分之一;2) the area of the connected domain accounts for at most one third of the entire gray value image of the same order; 3)所述连通域中最长的长度与最长的宽度的比例0.2至5之间。3) The ratio of the longest length to the longest width in the connected domain is between 0.2 and 5. 5.根据权利要求1所述的方法,其特征在于,对各所述最小矩形框内的像素点利用P希哈算法进行二值化处理以得到二值整数串,包括:5. The method according to claim 1, wherein the pixel points in each of the minimum rectangular frames are subjected to binarization processing using a P-Hash algorithm to obtain a binary integer string, comprising: 将所述最小矩形框按n×n宫格平均分割为n×n个小块;Divide the minimum rectangular frame into n×n small blocks on average according to n×n grids; 计算各小块内所有像素点的灰度值总和;Calculate the sum of the gray values of all pixels in each small block; 将所有小块中非0的灰度值总和求平均值,并令各非0小块的灰度值总和与所述平均值进行对比;Average the sum of the non-0 grayscale values in all the small blocks, and compare the sum of the grayscale values of each non-0 small block with the average value; 若小于所述平均值,则将非0小块所对应的值记为0;若大于等于所述平均值,则将非0小块的所对应的值记为1;If it is less than the average value, the value corresponding to the non-0 small block is recorded as 0; if it is greater than or equal to the average value, the value corresponding to the non-0 small block is recorded as 1; 按照由所述最小矩形框的中心位置逐步向外圈扩散的方式,依次统计中心位置的小块所对应的值、及由内向外各层外圈上各小块所对应的值,以得到对应一同阶灰度值图像的二值整数串。According to the method of gradually diffusing from the center position of the smallest rectangular frame to the outer circle, count the values corresponding to the small blocks at the center position and the values corresponding to the small blocks on the outer circle of each layer from the inside to the outside in turn, so as to obtain the corresponding A string of binary integers for a grayscale image of the same order. 6.根据权利要求5所述的方法,其特征在于,所述二值整数串的书写格式包括:6. The method according to claim 5, wherein the writing format of the binary integer string comprises: 分别对应所述中心位置、及由内向外的各层外圈所统计的二值整数串的区段,对应由内向外的顺序,依次从高位向低位排列各二值整数串的区段;所述高位向低位对应为从右向左或从左向右;Corresponding to the center position and the sections of the binary integer string counted by the outer circles of each layer from the inside to the outside, corresponding to the order from the inside to the outside, the sections of the binary integer strings are sequentially arranged from the high order to the low order; The above-mentioned high-to-low corresponds to right-to-left or left-to-right; 和/或,and / or, 各层外圈中由左上角的小块所对应的值为起始,按顺时针方向依次统计外圈上各小块所对应的值,并按从低位向高位的排列顺序书写。In the outer ring of each layer, the value corresponding to the small block in the upper left corner starts from the value corresponding to the small block in the upper left corner. The values corresponding to each small block on the outer ring are counted clockwise, and are written in the order from low to high. 7.根据权利要求1所述的方法,其特征在于,所述在图像数据库中通过二值整数串的比对判断是否存在局部相似的图像,包括:7. The method according to claim 1, wherein, determining whether there are locally similar images in the image database through the comparison of binary integer strings, comprising: 针对所述二值整数串设置比对线,以令所述二值整数串中在所述比对线右边或左边的二值整数串的高位区段与图像数据库中各整数对应的二值整数区段的数值进行比对;其中,所述比对线可根据比对情况或场景需求进行调节,以供调整比对精确度;An alignment line is set for the binary integer string, so that the high-order segment of the binary integer string on the right or left side of the alignment line in the binary integer string corresponds to the binary integer corresponding to each integer in the image database The values of the sections are compared; wherein, the comparison line can be adjusted according to the comparison situation or scene requirements, so as to adjust the comparison accuracy; 若二值整数串的高位区段的比对相同,则判定对应的二值整数串相近;If the comparisons of the high-order segments of the binary integer strings are the same, it is determined that the corresponding binary integer strings are similar; 若m个对应同阶灰度值图像的二值整数串的比对分别相近,则判定所述图像数据库中存在与所述原始图像为局部相似的图像。If the comparisons of the m binary integer strings corresponding to the same-level gray value images are respectively similar, it is determined that there is an image that is locally similar to the original image in the image database. 8.一种基于灰度值的图像局部比对装置,其特征在于,所述装置包括:8. A device for local comparison of images based on gray values, wherein the device comprises: 第一处理模块,用于将获取的原始图像进行高斯模糊处理、及灰度值处理;令每个像素点的灰度值等比例缩小至预设范围内,并依据各像素点缩小后的灰度值,划分为多个对应不同整数灰度值的同阶灰度值图像;The first processing module is used to perform Gaussian blur processing and gray value processing on the acquired original image; the gray value of each pixel is proportionally reduced to a preset range, and the gray value of each pixel is reduced according to the reduced gray value. The degree value is divided into multiple gray value images of the same order corresponding to different integer gray values; 第二处理模块,用于对各同阶灰度值图像进行二值化处理,并将灰度值相同的像素点组合以构成一或多个连通域;依据筛选条件选取一或多个包含独立完整图案的连通域,并针对各所述连通域分别构建用于覆盖全部所述独立完整图案的最小矩形框;对各所述最小矩形框内的像素点利用P希哈算法进行二值化处理以得到二值整数串,以供在图像数据库中通过二值整数串的比对判断是否存在至少局部相似的图像。The second processing module is used for binarizing each gray value image of the same level, and combining the pixels with the same gray value to form one or more connected domains; according to the screening conditions, select one or more including independent The connected domain of the complete pattern, and for each of the connected domains, a minimum rectangular frame for covering all the independent complete patterns is respectively constructed; the pixels in each of the minimum rectangular frames are binarized using the P-Hash algorithm. to obtain a binary integer string for judging whether there are at least partially similar images in the image database by comparing the binary integer strings. 9.一种计算机设备,其特征在于,所述设备包括:存储器、及处理器;所述存储器用于存储计算机指令;所述处理器运行计算机指令实现如权利要求1至7中任意一项所述的方法。9. A computer device, characterized in that, the device comprises: a memory and a processor; the memory is used to store computer instructions; the processor executes the computer instructions to implement any one of claims 1 to 7. method described. 10.一种计算机可读存储介质,其特征在于,存储有计算机指令,所述计算机指令被运行时执行如权利要求1至7中任一项所述的方法。10. A computer-readable storage medium, characterized by storing computer instructions that, when executed, perform the method of any one of claims 1 to 7.
CN202010886190.7A 2020-08-28 2020-08-28 Gray value-based image local comparison method, device, equipment and medium Active CN111986277B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010886190.7A CN111986277B (en) 2020-08-28 2020-08-28 Gray value-based image local comparison method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010886190.7A CN111986277B (en) 2020-08-28 2020-08-28 Gray value-based image local comparison method, device, equipment and medium

Publications (2)

Publication Number Publication Date
CN111986277A true CN111986277A (en) 2020-11-24
CN111986277B CN111986277B (en) 2025-04-01

Family

ID=73440861

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010886190.7A Active CN111986277B (en) 2020-08-28 2020-08-28 Gray value-based image local comparison method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN111986277B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115953473A (en) * 2022-09-30 2023-04-11 长城汽车股份有限公司 Joint calibration method of vehicle camera, electronic equipment, storage medium and vehicle

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030012438A1 (en) * 1998-04-08 2003-01-16 Radovan V. Krtolica Multiple size reductions for image segmentation
JP2005038415A (en) * 2003-06-23 2005-02-10 Fuji Xerox Co Ltd Image processor and method for processing image, image processing program, and storage medium
CN103714122A (en) * 2013-12-06 2014-04-09 安徽大学 Image retrieval method based on local block binary coding characteristics
CN106296578A (en) * 2015-05-29 2017-01-04 阿里巴巴集团控股有限公司 A kind of image processing method and device
CN109558878A (en) * 2017-09-27 2019-04-02 北京国双科技有限公司 Image-recognizing method and device
CN109754379A (en) * 2018-12-29 2019-05-14 北京金山安全软件有限公司 Image processing method and device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030012438A1 (en) * 1998-04-08 2003-01-16 Radovan V. Krtolica Multiple size reductions for image segmentation
JP2005038415A (en) * 2003-06-23 2005-02-10 Fuji Xerox Co Ltd Image processor and method for processing image, image processing program, and storage medium
CN103714122A (en) * 2013-12-06 2014-04-09 安徽大学 Image retrieval method based on local block binary coding characteristics
CN106296578A (en) * 2015-05-29 2017-01-04 阿里巴巴集团控股有限公司 A kind of image processing method and device
CN109558878A (en) * 2017-09-27 2019-04-02 北京国双科技有限公司 Image-recognizing method and device
CN109754379A (en) * 2018-12-29 2019-05-14 北京金山安全软件有限公司 Image processing method and device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115953473A (en) * 2022-09-30 2023-04-11 长城汽车股份有限公司 Joint calibration method of vehicle camera, electronic equipment, storage medium and vehicle
CN115953473B (en) * 2022-09-30 2026-02-13 长城汽车股份有限公司 Joint calibration method for vehicle cameras, electronic equipment, storage media and vehicle

Also Published As

Publication number Publication date
CN111986277B (en) 2025-04-01

Similar Documents

Publication Publication Date Title
CN111462086B (en) Image segmentation method and device, neural network model training method and device
US9886792B2 (en) Adaptive mesh refinement
US20210209459A1 (en) Processing method and system for convolutional neural network, and storage medium
US8237710B1 (en) Methods and apparatus for fill rule evaluation over a tessellation
CN107204034B (en) An image processing method and terminal
CN104574358B (en) From the method and apparatus for focusing heap image progress scene cut
CN110717953B (en) Coloring method and system for black and white pictures based on CNN-LSTM combined model
CN113506305B (en) Image enhancement method, semantic segmentation method and device for three-dimensional point cloud data
CN110675334A (en) Image enhancement method and device
CN111179276B (en) Image processing method and device
CN111681165A (en) Image processing method, apparatus, computer device, and computer-readable storage medium
CN114723636A (en) Model generation method, device, device and storage medium based on multi-feature fusion
US10936938B2 (en) Method for visualizing neural network models
US11200708B1 (en) Real-time color vector preview generation
CN110110829A (en) A kind of two dimensional code processing method and processing device
CN111383054A (en) Advertisement checking method and device
WO2019209751A1 (en) Superpixel merging
US20240104822A1 (en) Multicore system for neural rendering
CN113763496A (en) Image coloring method, device and computer readable storage medium
CN110942488B (en) Image processing device, image processing system, image processing method, and recording medium
CN111986277A (en) Image local comparison method, device, equipment and medium based on gray value
CN114648448B (en) Image enhancement method, device, equipment and storage medium
CN113487624A (en) Human body instance segmentation method, terminal device and storage medium
CN111986089B (en) Image storage and comparison method, device, equipment and medium for eigenvalue integerization
WO2023024660A1 (en) Image enhancement method and apparatus

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