WO2020155485A1 - 图片差异性判断方法、装置、计算机设备和存储介质 - Google Patents

图片差异性判断方法、装置、计算机设备和存储介质 Download PDF

Info

Publication number
WO2020155485A1
WO2020155485A1 PCT/CN2019/089058 CN2019089058W WO2020155485A1 WO 2020155485 A1 WO2020155485 A1 WO 2020155485A1 CN 2019089058 W CN2019089058 W CN 2019089058W WO 2020155485 A1 WO2020155485 A1 WO 2020155485A1
Authority
WO
WIPO (PCT)
Prior art keywords
pictures
pixels
gray
grayscale
picture
Prior art date
Application number
PCT/CN2019/089058
Other languages
English (en)
French (fr)
Inventor
唐可
Original Assignee
平安科技(深圳)有限公司
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 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2020155485A1 publication Critical patent/WO2020155485A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition

Definitions

  • This application relates to the computer field, and in particular to a method, device, computer equipment, and storage medium for judging picture difference.
  • Picture recognition is a widely used technology and has an important position in various fields. At present, the recognition of pictures is generally based on the comparison of pixels. If the pixels of two pictures are the same, it indicates that there is no difference between the two pictures.
  • this picture recognition method has technical defects, including at least: the amount of calculation is large, the three primary colors of the pixels of any picture that needs to be compared need to be compared one by one, which takes a long time and consumes more computing resources; for pictures processed by zooming Unrecognizable, easy to cause recognition errors; for larger files, too long recognition time and too much computing resources are required. Therefore, the image recognition method in the prior art has the above technical defects that need to be solved urgently.
  • the main purpose of this application is to provide a method, device, computer equipment, and storage medium for judging picture difference, which aims to reduce the time of picture recognition and judgment on the basis of ensuring the accuracy of picture difference judgment.
  • this application proposes a method for judging picture difference, which includes the following steps:
  • This application provides a device for judging picture difference, including:
  • the picture acquisition unit is used to acquire two pictures to be recognized
  • a gray-scale picture acquiring unit configured to perform gray-scale processing on the two pictures to obtain two gray-scale pictures
  • a gray-level average calculation unit for calculating the average value Am of the gray values of all pixels in the m-th column or m-th row of the gray-level picture, and calculating the gray levels of all the pixels in the gray-level picture Average value B;
  • the overall variance calculation unit is used according to the formula: Calculate the overall variance of the m-th column or m-th row of the grayscale image Where N is the total number of columns or rows in the grayscale picture;
  • the calculation unit of the difference of population variance used according to the formula: Obtain the difference between the overall variance of the m-th column or m-th row of the two grayscale images among them, Is the overall variance of the mth column or mth row of the first grayscale image, Is the overall variance of the mth column or mth row of the second grayscale image;
  • Variance error threshold judgment unit for judging Whether it is less than the preset variance error threshold
  • No difference determination unit used if If it is less than the preset variance error threshold, it is determined that there is no difference between the two pictures.
  • the present application provides a computer device including a memory and a processor, the memory stores a computer program, and the processor implements the steps of any one of the foregoing methods when the computer program is executed.
  • the present application provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps of any of the above methods are implemented.
  • the method, device, computer equipment, and storage medium for judging the difference of pictures of the present application obtain two gray-scale pictures by performing gray-scale processing on two pictures, and calculate the m-th column or m-th row of the gray-scale picture.
  • Population variance Obtain the difference between the overall variance of the m-th column or m-th row of the two grayscale images If If it is less than the preset variance error threshold, it is determined that there is no difference between the two pictures, thereby reducing the time for picture recognition and judgment on the basis of ensuring the accuracy of judgment of picture difference.
  • FIG. 1 is a schematic flowchart of a method for judging picture difference according to an embodiment of this application
  • FIG. 2 is a schematic block diagram of the structure of an apparatus for judging picture difference according to an embodiment of the application
  • FIG. 3 is a schematic block diagram of the structure of a computer device according to an embodiment of the application.
  • an embodiment of the present application provides a method for judging picture difference, including the following steps:
  • the two pictures to be recognized are acquired.
  • the two pictures to be recognized may be two unknown pictures, or a pre-stored reference picture and an unknown picture (to judge the difference between other pictures and the reference picture).
  • the parameters of the two pictures are preferably the same, for example, the resolutions are preferably the same.
  • grayscale refers to the color representing a grayscale color.
  • the color represents a grayscale color
  • the gray scale range is, for example, 0-255 (when the values of R, G, and B are all 0-255, of course, it will also change with the change of the value range of R, G, and B).
  • the gray-scale processing method can be any method, such as component method, maximum value method, average method, weighted average method, etc. Among them, since there are only 256 value ranges for gray values, image comparison on this basis can greatly reduce the amount of calculation.
  • step S3 calculate the average value Am of the gray values of all pixels in the m-th column or m-th row of the gray-scale image, and calculate the gray values of all pixels in the gray-scale image Average B.
  • the process of calculating the average value Am of the gray values of all pixels in the m-th column or m-th row of the gray-scale picture includes: collecting all the pixels in the m-th column or m-th row of the gray-scale picture Add the gray values of all pixels in the mth column or mth row, and divide the sum of the gray values obtained by the summation by the mth column or The number of all pixels in the m rows is the average value Am of the gray values of all the pixels in the mth column or mth row of the grayscale image.
  • the process of calculating the average value B of the gray values of all pixels in the gray image includes: calculating the sum of the gray values of all pixels in the gray image, and dividing the sum of the gray values by According to the number of pixels, the average value B of the gray values of all pixels in the gray image is obtained.
  • step S4 calculateate the overall variance of the m-th column or m-th row of the grayscale image
  • N is the total number of columns or rows in the grayscale picture.
  • the overall variance is used to measure the average of the gray values Am of the pixels in the m-th column or the m-th row of the gray-scale image and the average of the gray-scale values of all pixels in the gray-scale image. The difference between the value B.
  • step S5 As described in step S5 above, according to the formula: Obtain the difference between the overall variance of the m-th column or m-th row of the two grayscale images among them, Is the overall variance of the mth column or mth row of the first grayscale image, Is the overall variance of the mth column or mth row of the second grayscale image. Difference in population variance It reflects the difference of the gray value of the m-th column or m-th row of the two gray-scale pictures.
  • the gray value of the m-th column or m-th row of the first gray-scale image is the same or approximately the same as the gray value of the m-th column or m-th row of the second gray-scale image (approximate judgment to save computing power , And because the overall variances of the two different pictures are generally not equal, the accuracy of the judgment is very high), on the contrary, the gray value of the mth column or mth row of the first grayscale image is the same as the second grayscale value.
  • the gray value of the m-th column or m-th row of the picture is different.
  • step S6 it is determined Whether it is less than the preset variance error threshold.
  • the return value is The maximum value in Less than the preset variance error threshold, indicating that all Are less than the preset variance error threshold, it can be regarded as the gray value of all columns or all rows of the first grayscale image is the same or approximately the same as the gray values of all columns or all rows of the second grayscale image.
  • the gray values of all pixels of a grayscale picture are the same as the second grayscale picture.
  • step S7 if it is less than the preset variance error threshold, it is determined that there is no difference between the two pictures.
  • Less than the preset variance error threshold indicating that all Are less than the preset variance error threshold, which can be regarded as the gray value of all columns or all rows of the first grayscale image and the gray value of all columns or all rows of the second grayscale image are the same or approximately the same, that is, the first grayscale image
  • the gray values of all pixels of a gray-scale picture are the same as those of the second gray-scale picture, so it is determined that there is no difference between the two pictures (approximate judgment, because all the gray-scales of the gray-scale pictures converted from two different pictures are The values are generally not equal, and all the gray values of the gray images converted from the same image are generally equal, so the accuracy of this judgment is guaranteed).
  • the step S2 of performing grayscale processing on the two pictures to obtain two grayscale pictures includes:
  • the two pictures are grayed out to obtain two grayscale pictures.
  • the total number of pixels of the two pictures is not the same, it is determined that the two pictures are definitely not the same.
  • gray-scale processing is performed on the two pictures to obtain two gray-scale pictures.
  • the resolution is a parameter that measures the amount of data in an image, and is usually expressed as pixels per inch (ppi) and dots per inch (dpi).
  • the step S203 of performing grayscale processing on the two pictures to obtain two grayscale pictures includes:
  • the file size of the picture is reduced to reduce the amount of calculation under the premise that the information of the intercepted pictures is not lost.
  • the designated column or designated row may be any column or row, for example, a continuous column or continuous row, and preferably includes the designated column or designated row of the first column or the first row.
  • the intercepted picture is composed of designated columns or designated rows selected according to an arithmetic sequence or a geometric sequence.
  • the step S2 of performing grayscale processing on the two pictures to obtain two grayscale pictures includes:
  • S211 Collect a specified number of pixels of the two pictures by using a preset collection rule, and analyze the color value range of the specified number of pixels to obtain the number of bits of the color depth of the two pictures. ;
  • the color requirement of the picture can be judged by the number of digits of the color depth, and then the picture is grayed out when the color requirement is low.
  • the color depth indicates the number of bits used to store a pixel of color (for example, any one of the three primary colors RGB) in a bitmap or video frame buffer, and it is also called bit/pixel (bpp). The higher the color depth, the more colors are available. If the color depth is n bits, there are 2 n-th power options, and the number of bits used to store each pixel is n.
  • the preset collection rules include any feasible methods such as random collection and collection by arithmetic sequence.
  • the color value range of a pixel refers to the number of optional colors of the pixel (it is the n-th power of 2, that is, color depth). The color value range can be obtained by confirming the specific value of the collected pixel.
  • the picture difference judgment method in other embodiments is still used to judge the picture difference, wherein the gray value is replaced with Three primary color values (although the amount of calculation has been increased by about twice, the accuracy of the difference judgment can be guaranteed).
  • the calculation of the average value Am of the gray values of all pixels in the m-th column or the m-th row of the gray-scale picture, and the calculation of the gray-scale values of all the pixels in the gray-scale picture Step S3 of the average value B includes:
  • S301 Collect the gray values of all pixels in the gray image
  • the arithmetic mean value is used to calculate the average value Am of the gray values of all pixels in the m-th column or m-th row of the gray-scale picture, and to calculate the average value of all pixels in the gray-scale picture.
  • the average value of gray values B is the average value of the gray values of the pixels in the column or all rows in the gray image.
  • the method includes:
  • the overall variance reflects the difference between the average value (namely variable) of each column or row and the average value of the grayscale picture (the overall average). If the two pictures are the same, then the overall variance should be equal or approximately equal. Accordingly, if If it is not less than a preset variance error threshold, it is determined that the two pictures are different. After confirming that the two pictures are different, pass the confirmation If the value is not less than the preset variance error threshold, the difference column or the difference row can be obtained.
  • the mth column or mth row is the difference column or difference row, that is, the subscript of the value not less than the preset variance error threshold represents the difference column or difference row.
  • S621 Restore the pixel points of the difference column or the difference row to the color before the grayscale processing to obtain the restored column or the restored row;
  • S622 Compare the pixel points of the restored column or the restored row in the two grayscale pictures one by one to obtain a difference pixel point, and mark the difference pixel point specially.
  • the difference pixels are specifically marked. From the aforementioned known difference columns or difference rows, it is still not clear which pixels are different.
  • the pixel points of the difference column or the difference row are restored to the color before the grayscale processing, and the pixels are compared one by one to accurately determine the positions of the difference pixels.
  • restoring to the color before the gray-scale processing includes: replacing the pixels before the gray-scale processing with the pixels after the gray-scale processing.
  • the process of comparing the pixels of the restored column or the restored row in the two gray-scale pictures includes: extracting the three primary colors of the pixels of the restored column or the restored row in the first grayscale picture, and sequentially comparing the three primary colors Contrast with the three primary colors of the pixels in the restored column or row in the second grayscale picture that correspond to the pixels in the restored column or row in the first grayscale picture. If the three primary colors are compared sequentially, the results are not uniform , It is judged as a difference pixel.
  • the special mark can be any mark, for example, the difference pixels are circled in a picture.
  • two gray-scale pictures are obtained by performing gray-scale processing on two pictures, and the overall variance of the m-th column or m-th row of the gray-scale pictures is calculated Obtain the difference between the overall variance of the m-th column or m-th row of the two grayscale images If If it is less than the preset variance error threshold, it is determined that there is no difference between the two pictures, thereby reducing the time for picture recognition and judgment on the basis of ensuring the accuracy of judgment of picture difference.
  • an embodiment of the present application provides an apparatus for judging picture difference, including:
  • the picture obtaining unit 10 is used to obtain two pictures to be recognized;
  • the grayscale picture acquiring unit 20 is configured to perform grayscale processing on the two pictures to obtain two grayscale pictures;
  • the gray average value calculation unit 30 is used to calculate the average value Am of the gray values of all pixels in the m-th column or m-th row of the gray-scale picture, and calculate the gray values of all the pixels in the gray-scale picture.
  • the overall variance calculation unit 40 is used according to the formula: Calculate the overall variance of the m-th column or m-th row of the grayscale image Where N is the total number of columns or rows in the grayscale picture;
  • the calculation unit 50 for the difference of population variance is used according to the formula: Obtain the difference between the overall variance of the m-th column or m-th row of the two grayscale images among them, Is the overall variance of the mth column or mth row of the first grayscale image, Is the overall variance of the mth column or mth row of the second grayscale image;
  • the variance error threshold judgment unit 60 is used to judge Whether it is less than the preset variance error threshold
  • the indifference judging unit 70 is used if If it is less than the preset variance error threshold, it is determined that there is no difference between the two pictures.
  • the gray-scale image acquisition unit 20 includes:
  • the total number of pixels judging subunit is used to determine whether the total number of pixels of the two pictures is the same;
  • the first subunit for obtaining grayscale pictures is used to perform grayscale processing on the two pictures if the total number of pixels of the two pictures is the same to obtain two grayscale pictures.
  • the first subunit for acquiring the grayscale picture includes:
  • the file size judgment module is configured to obtain the file size of the two pictures if the total number of pixels of the two pictures is the same, and determine whether the difference between the file sizes of the two pictures is less than a preset file size Threshold
  • the intercepted picture acquisition module is used to if the difference in file size of the two pictures is not less than the preset file size threshold, respectively intercept the pixels of the specified column or specified row of the two pictures to form two intercepted pictures ;
  • the gray-scale picture acquisition module is used to perform gray-scale processing on the two intercepted pictures to obtain two gray-scale pictures.
  • the gray-scale image acquisition unit 20 includes:
  • the color depth bit acquisition subunit is used to collect a specified number of pixels of the two pictures using a preset collection rule, and analyze the color value range of the specified number of pixels to obtain the respective The number of bits of color depth of the two pictures;
  • the color depth threshold judging subunit is used for judging whether the color depth bits of the two pictures are both less than a preset color depth threshold
  • the second subunit for obtaining grayscale pictures is used to perform grayscale processing on the two pictures if the color depth bits of the two pictures are both less than the preset color depth threshold to obtain two grayscales image.
  • the gray average value calculation unit 30 includes:
  • a gray value collection subunit for collecting the gray values of all pixels in the gray image
  • the average value Am collecting subunit is used to add and process the gray values of all pixels in the mth column or mth row of the grayscale image to obtain the summation value of the mth column or mth row. Divide the sum value of the m-th column or m-th row by the number of all pixels in the m-th column or m-th row to obtain the gray values of all the pixels in the m-th column or m-th row of the grayscale image The average Am;
  • the average value B collection subunit is used to add the gray values of all pixels in the gray image to obtain the added value of the gray image, and divide the added value of the gray image Using the total number of all the pixels in the gray-scale picture, the average value B of the gray-scale values of all the pixels in the gray-scale picture is obtained.
  • the device includes:
  • Marking unit for obtaining A value that is not less than a preset variance error threshold value in, and the column or row corresponding to the value that is not less than the preset variance error threshold value is recorded as a difference column or a difference row.
  • the device includes:
  • a restored column or restored row obtaining unit configured to restore the pixel points of the difference column or the difference row to the color before the grayscale processing to obtain the restored column or the restored row;
  • the special marking unit is used to compare the pixels of the restored column or the restored row in the two grayscale pictures one by one to obtain different pixels, and perform special marking on the different pixels.
  • the picture difference judgment device of the present application obtains two gray-scale pictures by performing gray-scale processing on two pictures, and calculates the overall variance of the m-th column or m-th row of the gray-scale picture Obtain the difference between the overall variance of the m-th column or m-th row of the two grayscale images If If it is less than the preset variance error threshold, it is determined that there is no difference between the two pictures, thereby reducing the time for picture recognition and judgment on the basis of ensuring the accuracy of judgment of picture difference.
  • the embodiment of the present invention also provides a computer device.
  • the computer device may be a server, and its internal structure may be as shown in the figure.
  • the computer equipment includes a processor, a memory, a network interface and a database connected by a system bus. Among them, the computer designed processor is used to provide calculation and control capabilities.
  • the memory of the computer device includes a non-volatile storage medium and an internal memory.
  • the non-volatile storage medium stores an operating system, a computer program, and a database.
  • the memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium.
  • the database of the computer equipment is used to store the data used in the method for judging the difference of pictures.
  • the network interface of the computer device is used to communicate with an external terminal through a network connection.
  • the computer program is executed by the processor to realize a method for judging the difference of pictures.
  • the above-mentioned processor executes the above-mentioned method for judging picture difference, wherein the steps included in the method respectively correspond to the steps of executing the method for judging picture difference of the foregoing embodiment one-to-one, and will not be repeated here.
  • the computer device of the present application obtains two gray-scale pictures by performing gray-scale processing on two pictures, and calculates the overall variance of the m-th column or m-th row of the gray-scale pictures Obtain the difference between the overall variance of the m-th column or m-th row of the two grayscale images If If it is less than the preset variance error threshold, it is determined that there is no difference between the two pictures, thereby reducing the time for picture recognition and judgment on the basis of ensuring the accuracy of judgment of picture difference.
  • An embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored.
  • a computer program is stored on which a computer program is stored.
  • the computer program is executed by a processor, a method for judging picture difference is realized.
  • the steps of the method for judging the difference of pictures correspond one by one, so I won't repeat them here.
  • the computer-readable storage medium of the present application obtains two gray-scale pictures by performing gray-scale processing on two pictures, and calculates the overall variance of the m-th column or m-th row of the gray-scale pictures Obtain the difference between the overall variance of the m-th column or m-th row of the two grayscale images If If it is less than the preset variance error threshold, it is determined that there is no difference between the two pictures, thereby reducing the time for picture recognition and judgment on the basis of ensuring the accuracy of judgment of picture difference.
  • Non-volatile memory may include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
  • Volatile memory may include random access memory (RAM) or external cache memory.
  • RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual-rate data rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous Link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

Landscapes

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

Abstract

一种图片差异性判断方法、装置、计算机设备和存储介质,包括:获取待识别的两张图片;对所述两张图片进行灰度化处理,获得两张灰度图片;计算灰度图片的第m列或者第m行的所有像素点的灰度值的平均值Am,以及计算所述灰度图片中所有像素点的灰度值的平均值B;根据公式(1),计算灰度图片的第m列或者第m行的总体方差a1;根据公式(2),获得两张所述灰度图片的第m列或者第m行的总体方差之差a2,若式(3)的值小于预设的方差误差阈值,则判定所述两张图片无差异。从而在保证图片差异性判断准确性的基础上减少图片识别与判断时间。

Description

图片差异性判断方法、装置、计算机设备和存储介质
本申请要求于2019年1月31日提交中国专利局、申请号为201910101305.4,发明名称为“图片差异性判断方法、装置、计算机设备和存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及到计算机领域,特别是涉及到一种图片差异性判断方法、装置、计算机设备和存储介质。
背景技术
图片识别是应用广泛的技术,在各领域中均具有重要的地位。目前对于图片的识别,一般基于像素点的对比,若两张图片像素点都相同,表明这两张图片无差异。但是,这种图片的识别方式具有技术上的缺陷,至少包括:计算量大,需要对需要对比的任意图片的像素点的三原色进行逐一对比,耗时长消耗计算资源多;对于缩放等处理的图片无法识别,容易造成识别错误;对于文件较大的图片,需要过长的识别时间与过多的计算资源。因此,现有技术的图片识别方法存在上述亟待解决的技术缺陷。
技术问题
本申请的主要目的为提供一种图片差异性判断方法、装置、计算机设备和存储介质,旨在保证图片差异性判断准确性的基础上减少图片识别与判断时间。
技术解决方案
为了实现上述发明目的,本申请提出一种图片差异性判断方法,包括以下步骤:
获取待识别的两张图片;
对所述两张图片进行灰度化处理,获得两张灰度图片;
计算所述灰度图片的第m列或者第m行的所有像素点的灰度值的平均值Am,以及计算所述灰度图片中所有像素点的灰度值的平均值B;
根据公式:
Figure PCTCN2019089058-appb-000001
计算所述灰度图片的第m列或者第m行的总体方差
Figure PCTCN2019089058-appb-000002
其中N为所述灰度图片中的列或者行的总数量;
根据公式:
Figure PCTCN2019089058-appb-000003
获得两张所述灰度图片的第m列或者第m行的总体方差之差
Figure PCTCN2019089058-appb-000004
其中,
Figure PCTCN2019089058-appb-000005
为第一张灰度图片的第m列或者第m行的总体方差,
Figure PCTCN2019089058-appb-000006
为第二张灰度图片的第m列或者第m行的总体方差;
判断
Figure PCTCN2019089058-appb-000007
是否小于预设的方差误差阈值;
Figure PCTCN2019089058-appb-000008
小于预设的方差误差阈值,则判定所述两张图片无差异。
本申请提供一种图片差异性判断装置,包括:
图片获取单元,用于获取待识别的两张图片;
灰度图片获取单元,用于对所述两张图片进行灰度化处理,获得两张灰度图片;
灰度平均值计算单元,用于计算所述灰度图片的第m列或者第m行的所有像素点的灰度值的平均值Am,以及计算所述灰度图片中所有像素点的灰度值的平均值B;
总体方差计算单元,用于根据公式:
Figure PCTCN2019089058-appb-000009
计算所述灰度图片的第m列或者第m行的总体方差
Figure PCTCN2019089058-appb-000010
其中N为所述灰度图片中的列或者行的总数量;
总体方差之差计算单元,用于根据公式:
Figure PCTCN2019089058-appb-000011
获得两张所述灰度图片的第m列或者第m行的总体方差之差
Figure PCTCN2019089058-appb-000012
其中,
Figure PCTCN2019089058-appb-000013
为第一张灰度图片的第m列或者第m行的总体方差,
Figure PCTCN2019089058-appb-000014
为第二张灰度图片的第m列或者第m行的总体方差;
方差误差阈值判断单元,用于判断
Figure PCTCN2019089058-appb-000015
是否小于预设的方差误差阈值;
无差异判定单元,用于若
Figure PCTCN2019089058-appb-000016
小于预设的方差误差阈值,则判定所述两张图片无差异。
本申请提供一种计算机设备,包括存储器和处理器,所述存储器存储有计算机程序,所述处理器执行所述计算机程序时实现上述任一项所述方法的步骤。
本申请提供一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现上述任一项所述的方法的步骤。
有益效果
本申请的图片差异性判断方法、装置、计算机设备和存储介质,通过对两张图片进行灰度化处理,获得两张灰度图片,计算所述灰度图片的第m列或者第m行的总体方差
Figure PCTCN2019089058-appb-000017
获得两张所述灰度图片的第m列或者第m行的总体方差之差
Figure PCTCN2019089058-appb-000018
Figure PCTCN2019089058-appb-000019
小于预设的方差误差阈值,则判定所述两张图片无差异,从而实现了在保证图片差异性判断准确性的基础上减少图片识别与判断时间。
附图说明
图1为本申请一实施例的图片差异性判断方法的流程示意图;
图2为本申请一实施例的图片差异性判断装置的结构示意框图;
图3为本申请一实施例的计算机设备的结构示意框图。
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。
本发明的最佳实施方式
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。
参照图1,本申请实施例提供一种图片差异性判断方法,包括以下步骤:
S1、获取待识别的两张图片;
S2、对所述两张图片进行灰度化处理,获得两张灰度图片;
S3、计算所述灰度图片的第m列或者第m行的所有像素点的灰度值的平均值Am,以及计算所述灰度图片中所有像素点的灰度值的平均值B;
S4、根据公式:
Figure PCTCN2019089058-appb-000020
计算所述灰度图片的第m列或者第m行的总体方差
Figure PCTCN2019089058-appb-000021
其中N为所述灰度图片中的列或者行的总数量;
S5、根据公式:
Figure PCTCN2019089058-appb-000022
获得两张所述灰度图片的第m列或者第m行的总体方差之差
Figure PCTCN2019089058-appb-000023
其中,
Figure PCTCN2019089058-appb-000024
为第一张灰度图片的第m列或者第m行的总体方差,
Figure PCTCN2019089058-appb-000025
为第二张灰度图片的第m列或者第m行的总体方差;
S6、判断
Figure PCTCN2019089058-appb-000026
是否小于预设的方差误差阈值;
S7、若
Figure PCTCN2019089058-appb-000027
小于预设的方差误差阈值,则判定所述两张图片无差异。
如上述步骤S1所述,获取待识别的两张图片。其中,待识别的两张图片,可以为两张未知图片,也可以为一张预存的基准图片与一张未知图片(用以判断其他图片与基准图片的差异性)。其中,所述两张图片的各参数优选均相同,例如优选分辨率相同。
如上述步骤S2所述,对所述两张图片进行灰度化处理,获得两张灰度图片。其中,灰度化指将彩色表示一种灰度颜色,例如在在RGB模型中,如果R=G=B时,则彩色表示一种灰度颜色,其中R=G=B的值叫灰度值,因此,灰度图像每个像素只需一个字节存放灰度值(又称强度值、亮度值),从而减少存储量。灰度范围例如为0-255(当R,G,B的取值均为0-255时,当然也会随R,G,B的取值范围的变化而变化)。采用灰度化处理的方法可以为任意方法,例如分量法、最大值法、平均值法、加权平均法等。其中,由于灰度值的取值范围只有256种,在此基础上进行图片对比能够大大减轻计算量。
如上述步骤S3所述,计算所述灰度图片的第m列或者第m行的所有像素点的灰度值的平均值Am,以及计算所述灰度图片中所有像素点的灰度值的平均值B。其中,计算所述灰度图片的第m列或者第m行的所有像素点的灰度值的平均值Am的过程包括:采集所述灰度图片的第m列或者第m行的所有像素点的灰度值,对所述第m列或者第m行的所有像素点的灰度值进行加和处理,将进行过加和处理得到的灰度值之和除以所述第m列或者第m行的所有像素点的数量,得到所述灰度图片的第m列或者 第m行的所有像素点的灰度值的平均值Am。计算所述灰度图片中所有像素点的灰度值的平均值B的过程包括:计算所述灰度图片中所有像素点的灰度值之和,再以所述灰度值之和除以所述像素点的数量,得到所述灰度图片中所有像素点的灰度值的平均值B。
如上述步骤S4所述,根据公式:
Figure PCTCN2019089058-appb-000028
计算所述灰度图片的第m列或者第m行的总体方差
Figure PCTCN2019089058-appb-000029
其中N为所述灰度图片中的列或者行的总数量。在本申请中,采用总体方差来衡量所述灰度图片的第m列或者第m行的像素点的灰度值的平均值Am与所述灰度图片中所有像素点的灰度值的平均值B之间的差异。
如上述步骤S5所述,根据公式:
Figure PCTCN2019089058-appb-000030
获得两张所述灰度图片的第m列或者第m行的总体方差之差
Figure PCTCN2019089058-appb-000031
其中,
Figure PCTCN2019089058-appb-000032
为第一张灰度图片的第m列或者第m行的总体方差,
Figure PCTCN2019089058-appb-000033
为第二张灰度图片的第m列或者第m行的总体方差。总体方差之差
Figure PCTCN2019089058-appb-000034
反应了两张灰度图片的第m列或者第m行的灰度值的差异。当
Figure PCTCN2019089058-appb-000035
较小时,例如为0时,表明
Figure PCTCN2019089058-appb-000036
等于或者近似等于
Figure PCTCN2019089058-appb-000037
可视为第一张灰度图片第m列或者第m行的灰度值与第二张灰度图片第m列或者第m行的灰度值相同或者近似相同(近似判断,以节省算力,并且由于不同的两张图片的总体方差一般不相等,因此该判断的准确性很高),反之认为第一张灰度图片第m列或者第m行的灰度值与第二张灰度图片第m列或者第m行的灰度值不相同。
如上述步骤S6所述,判断
Figure PCTCN2019089058-appb-000038
是否小于预设的方差误差阈值。其中
Figure PCTCN2019089058-appb-000039
的返回值即为
Figure PCTCN2019089058-appb-000040
中的最大值,若
Figure PCTCN2019089058-appb-000041
小于预设的方差误差阈值,表明所有的
Figure PCTCN2019089058-appb-000042
均小于预设的方差误差阈值,可视为第一张灰度图片所有列或者所有行的灰度值与第二张灰度图片所有列或者所有行的灰度值相同或者近似相同,即第一张灰度图片的所有像素点的灰度值与第二张灰度图片相同。
如上述步骤S7所述,若
Figure PCTCN2019089058-appb-000043
小于预设的方差误差阈值,则判定所述两张图片无差异。如前所述,若
Figure PCTCN2019089058-appb-000044
小于预设的方差误差阈值,表明所有的
Figure PCTCN2019089058-appb-000045
均小于预设的方差误差阈值,可视为第一张灰度图片所有列或者所有行的灰度值与第二张灰度图片所有列或者所有行的灰度值相同或者近似相同,即第一张灰度图片的所有像素点的灰度值与第二张灰度图片相同,从而判定所述两张图片无差异(近似判断,由于两张不同图片转化为的灰度图片的所有灰度值一般不相等,而相同图片转化为的灰度图片的所有灰度值一般相等,所以此判断的准确性有所保证)。
在一个实施方式中,所述对所述两张图片进行灰度化处理,获得两张灰度图片的步骤S2,包括:
S201、获取所述两张图片的分辨率、图片长度与图片宽度,并根据公式:像素点总数量=分辨率×图片长度+分辨率×图片宽度,分别计算出所述两张图片的像素点总数量;
S202、判断所述两张图片的像素点总数量是否相同;
S203、若所述两张图片的像素点总数量相同,则对所述两张图片进行灰度化处理,获得两张灰度图片。
如上所述,实现了在所述两张图片的像素点总数量相同的前提下,对所述两张图片进行灰度化处理,获得两张灰度图片。一般而言,要判定两张图片相同很难,但是要判定两张图片不同较为简单。当两张图片的总像素点数量不相同时,判定这两张图片肯定不相同。据此,先计算出图片的像素点总数量。其中像素点总数量与图片的分辨率、图片长度与图片宽度直接相关,根据公式:像素点总数量=分辨率×图片长度+分辨率×图片宽度,即可分别计算出所述两张图片的像素点总数量。在确定所述两张图片的像素点总数量相同后,对所述两张图片进行灰度化处理,获得两张灰度图片。其中,分辨率是度量图像内数据量多少的一个参数,通常表示成每英寸像素(Pixel per inch,ppi)和每英寸点(Dot per inch,dpi)。
在一个实施方式中,所述若所述两张图片的像素点总数量相同,则对所述两张图片进行灰度化处理,获得两张灰度图片的步骤S203,包括:
S2031、若所述两张图片的像素点总数量相同,则获取所述两张图片的文件大小,并判断所述两张图片的文件大小之差是否小于预设的文件大小阈值;
S2032、若所述两张图片的文件大小之差不小于预设的文件大小阈值,则分别截取所述两张图片的指定列或者指定行的像素点以形成两张截取图片;
S2033、对所述两张截取图片进行灰度化处理,获得两张灰度图片。
如上所述,实现了通过截取图片以减小计算量。当图片的文件大小过大时,进行图片的对比消耗过多的计算量。本实施方式通过截取指定列或者指定行的像素点以形成两张截取图片的方式,在保证截取图片的信息不丢失的前提下,减少文件大小以减少计算量。其中指定列或者指定行可以为任意列或者行,例如为连续的列或者连续的行,优选包括第1列或者第1行的指定列或者指定行。进一步地,所述截取图片由按等差数列或等比数列选取的指定列或者指定行构成。
在一个实施方式中,所述对所述两张图片进行灰度化处理,获得两张灰度图片的步骤S2,包括:
S211、利用预设采集规则,分别采集所述两张图片的指定数量的像素点,并分析所述指定数量的像素点的颜色取值范围以分别获得所述两张图片的色彩深度的位数;
S212、判断所述两张图片的色彩深度的位数是否均小于预设的色彩深度阈值;
S213、若所述两张图片的色彩深度的位数均小于预设的色彩深度阈值,则对所述两张图片进行灰度化处理,获得两张灰度图片。
如上所述,实现了通过色彩深度的位数以判断图片的色彩要求,进而在色彩要求较低的情况下对图片进行灰度化处理。色彩深度表示在位图或者视频帧缓冲区中储存1像素的颜色(例如三原色RGB中的任一一种颜色)所用的位数,它也称为位/像素(bpp)。色彩深度越高,可用的颜色就越多,若色彩深度是n位,即有2的n次方种颜色选择,而储存每像素所用的位数就是n。即色彩深度的位数n越大,图片对色彩的要求越高,因此不应进行灰度化处理(色彩的要求越高,进行灰度化处理损失的信息越多,容易造成误判)。其中,预设采集规则包括随机采集、按等差数列采集等任意可行方式。像素点的颜色取值范围指像素点的可选颜色数量(为2的n次方种,即色彩深度),通过确认采集到的像素点的具体数值,即可得到颜色取值范围。具体地,分析所述指定数量的像素点的颜色取值范围以获得所述图片的色彩深度的位数的过程包括:获取所述指定数量的像素点的三原色各自的最大取值;以所述三原色各自的最大取值中的最大值+1(因为颜色取值初始为0)作为像素点的颜色取值范围的最大值;根据式子:2的n次方>=所述颜色取值范围的最大值,获取n的最小值,并将所述n的最小值作为图片的色彩深度的位数。进一步地,若所述两张图片的色彩深度的位数不小于预设的色彩深度阈值,则仍采用其他实施方式中的图片差异性判断手段进行图片差异性判断,其中将灰度值替换为三原色值(虽然增加了大约两倍的计算量,但是能够保证差异性判断的准确性)。
在一个实施方式中,所述计算所述灰度图片的第m列或者第m行的所有像素点的灰度值的平均值Am,以及计算所述灰度图片中所有像素点的灰度值的平均值B的步骤S3,包括:
S301、采集所述灰度图片中的所有像素点的灰度值;
S302、将所述灰度图片的第m列或者第m行的所有像素点的灰度值进行加和处理得到第m列或者第m行加和值,将所述第m列或者第m行加和值除以所述第m列或者第m行的所有像素点的数量,得到所述灰度图片的第m列或者第m行的所有像素点的灰度值的平均值Am;
S303、将所述灰度图片中的所有像素点的灰度值进行加和处理得到所述灰度图片的加和值,将所述灰度图片的加和值除以所述灰度图片中的所有像素点的总数量,得到所述灰度图片中所有像素点的灰度值的平均值B。
如上所述,实现了采用算术平均值进行计算所述灰度图片的第m列或者第m行的所有像素点的灰度值的平均值Am,以及计算所述灰度图片中所有像素点的灰度值的平均值B。其中,所述灰度图片中所有像素点的灰度值的平均值B即为灰度图片中所述列或者所有行的像素点的灰度值的平均值。先采集所述灰度图片中的所有像素点的灰度值,再进行加和以及除法处理,分别计算得到所述灰度图片的第 m列或者第m行的所有像素点的灰度值的平均值Am,以及所述灰度图片中所有像素点的灰度值的平均值B。
在一个实施方式中,所述判断
Figure PCTCN2019089058-appb-000046
是否小于预设的方差误差阈值的步骤S6之后,包括:
S61、若
Figure PCTCN2019089058-appb-000047
不小于预设的方差误差阈值,则判定所述两张图片有差异;
S62、获取
Figure PCTCN2019089058-appb-000048
中不小于预设的方差误差阈值的值,并将所述不小于预设的方差误差阈值的值对应的列或者行记为差异列或者差异行。
如上所述,实现了判定图片有差异并标出差异列或者差异行。其中总体方差反应了各列或者各行的平均值(即变量)与灰度图片的平均值(总体均数)的差异。若两张图片相同,那么总体方差应是相等或是近似相等的。据此,若
Figure PCTCN2019089058-appb-000049
不小于预设的方差误差阈值,则判定所述两张图片有差异。在确定两张图片有差异之后,通过确定
Figure PCTCN2019089058-appb-000050
中不小于预设的方差误差阈值的值,即可得到差异列或者差异行。具体地,若
Figure PCTCN2019089058-appb-000051
不小于预设的方差误差阈值的值,那么第m列或者第m行即为差异列或者差异行,即不小于预设的方差误差阈值的值的下标,代表了差异列或者差异行。
在一个实施方式中,所述获取
Figure PCTCN2019089058-appb-000052
中不小于预设的方差误差阈值的值,并将所述不小于预设的方差误差阈值的值对应的列或者行记为差异列或者差异行的步骤S62之后,包括:
S621、将所述差异列或者所述差异行的像素点还原为所述灰度化处理之前的颜色,获得还原列或者还原行;
S622、逐一比对两张灰度图片中所述还原列或者所述还原行的像素点,获得差异像素点,并对所述差异像素点进行特殊标记。
如上所述,实现了具体标出差异像素点。由前述已知差异列或者差异行,但还不能明确哪些像素点有差异。在本实施方式中,采用将所述差异列或者所述差异行的像素点还原为所述灰度化处理之前的颜色,再逐一对比像素点的方式,以精准确定差异像素点的位置。其中,还原为所述灰度化处理之前的颜色包括:将所述灰度化处理之前的像素点替换所述灰烬度化处理之后的像素点。其中,比对两张灰度图片中所述还原列或者所述还原行的像素点过程包括:提取第一张灰度图片中的还原列或者还原行的像素点的三原色,将所述三原色依次与第二张灰度图片中的还原列或者还原行的与所述第一张灰度图片中的还原列或者还原行的像素点对应的像素点的三原色对比,若三原色依次对比结果不均相同,则判定为差异像素点。其中,特殊标记可以为任意标记,例如在图片中用圆圈圈出所述差异像素点。
本申请的图片差异性判断方法,通过对两张图片进行灰度化处理,获得两张灰度图片,计算所述灰度图片的第m列或者第m行的总体方差
Figure PCTCN2019089058-appb-000053
获得两张所述灰度图片的第m列或者第m行的总体方差之差
Figure PCTCN2019089058-appb-000054
Figure PCTCN2019089058-appb-000055
小于预设的方差误差阈值,则判定所述两张图片无差异,从而实现了在保证图片差异性判断准确性的基础上减少图片识别与判断时间。
参照图2,本申请实施例提供一种图片差异性判断装置,包括:
图片获取单元10,用于获取待识别的两张图片;
灰度图片获取单元20,用于对所述两张图片进行灰度化处理,获得两张灰度图片;
灰度平均值计算单元30,用于计算所述灰度图片的第m列或者第m行的所有像素点的灰度值的平均值Am,以及计算所述灰度图片中所有像素点的灰度值的平均值B;
总体方差计算单元40,用于根据公式:
Figure PCTCN2019089058-appb-000056
计算所述灰度图片的第m列或者第m行的总体方差
Figure PCTCN2019089058-appb-000057
其中N为所述灰度图片中的列或者行的总数量;
总体方差之差计算单元50,用于根据公式:
Figure PCTCN2019089058-appb-000058
获得两张所述灰度图片的第m列或者第m行的总体方差之差
Figure PCTCN2019089058-appb-000059
其中,
Figure PCTCN2019089058-appb-000060
为第一张灰度图片的第m列或者第m行的总体方差,
Figure PCTCN2019089058-appb-000061
为第二张灰度图片的第m列或者第m行的总体方差;
方差误差阈值判断单元60,用于判断
Figure PCTCN2019089058-appb-000062
是否小于预设的方差误差阈值;
无差异判定单元70,用于若
Figure PCTCN2019089058-appb-000063
小于预设的方差误差阈值,则判定所述两张图片无差异。
其中上述单元分别用于执行的操作与前述实施方式的图片差异性判断方法的步骤一一对应,在此不再赘述。
在一个实施方式中,所述灰度图片获取单元20,包括:
像素点总数量计算子单元,用于获取所述两张图片的分辨率、图片长度与图片宽度,并根据公式:像素点总数量=分辨率×图片长度+分辨率×图片宽度,分别计算出所述两张图片的像素点总数量;
像素点总数量判断子单元,用于判断所述两张图片的像素点总数量是否相同;
灰度图片获取第一子单元,用于若所述两张图片的像素点总数量相同,则对所述两张图片进行灰度化处理,获得两张灰度图片。
其中上述子单元分别用于执行的操作与前述实施方式的图片差异性判断方法的步骤一一对应,在此不再赘述。
在一个实施方式中,所述灰度图片获取第一子单元,包括:
文件大小判断模块,用于若所述两张图片的像素点总数量相同,则获取所述两张图片的文件大小,并判断所述两张图片的文件大小之差是否小于预设的文件大小阈值;
截取图片获取模块,用于若所述两张图片的文件大小之差不小于预设的文件大小阈值,则分别截取所述两张图片的指定列或者指定行的像素点以形成两张截取图片;
灰度图片获取模块,用于对所述两张截取图片进行灰度化处理,获得两张灰度图片。
其中上述模块分别用于执行的操作与前述实施方式的图片差异性判断方法的步骤一一对应,在此不再赘述。
在一个实施方式中,所述灰度图片获取单元20,包括:
色彩深度的位数获取子单元,用于利用预设采集规则,分别采集所述两张图片的指定数量的像素点,并分析所述指定数量的像素点的颜色取值范围以分别获得所述两张图片的色彩深度的位数;
色彩深度阈值判断子单元,用于判断所述两张图片的色彩深度的位数是否均小于预设的色彩深度阈值;
灰度图片获取第二子单元,用于若所述两张图片的色彩深度的位数均小于预设的色彩深度阈值,则对所述两张图片进行灰度化处理,获得两张灰度图片。
其中上述子单元分别用于执行的操作与前述实施方式的图片差异性判断方法的步骤一一对应,在此不再赘述。
在一个实施方式中,所述灰度平均值计算单元30,包括:
灰度值采集子单元,用于采集所述灰度图片中的所有像素点的灰度值;
平均值Am采集子单元,用于将所述灰度图片的第m列或者第m行的所有像素点的灰度值进行加和处理得到第m列或者第m行加和值,将所述第m列或者第m行加和值除以所述第m列或者第m行的所有像素点的数量,得到所述灰度图片的第m列或者第m行的所有像素点的灰度值的平均值Am;
平均值B采集子单元,用于将所述灰度图片中的所有像素点的灰度值进行加和处理得到所述灰度图片的加和值,将所述灰度图片的加和值除以所述灰度图片中的所有像素点的总数量,得到所述灰度图片中所有像素点的灰度值的平均值B。
其中上述子单元分别用于执行的操作与前述实施方式的图片差异性判断方法的步骤一一对应,在此不再赘述。
在一个实施方式中,所述装置,包括:
有差异判定单元,用于若
Figure PCTCN2019089058-appb-000064
不小于预设的方差误差阈值,则判定所述两张图片有差异;
标记单元,用于获取
Figure PCTCN2019089058-appb-000065
中不小于预设的方差误差阈值的值,并将所述不小于预设的方差误差阈值的值对应的列或者行记为差异列或者差异行。
其中上述单元分别用于执行的操作与前述实施方式的图片差异性判断方法的步骤一一对应,在此不再赘述。
在一个实施方式中,所述装置,包括:
还原列或者还原行获取单元,用于将所述差异列或者所述差异行的像素点还原为所述灰度化处理之前的颜色,获得还原列或者还原行;
特殊标记单元,用于逐一比对两张灰度图片中所述还原列或者所述还原行的像素点,获得差异像素点,并对所述差异像素点进行特殊标记。
其中上述单元分别用于执行的操作与前述实施方式的图片差异性判断方法的步骤一一对应,在此不再赘述。
本申请的图片差异性判断装置,通过对两张图片进行灰度化处理,获得两张灰度图片,计算所述灰度图片的第m列或者第m行的总体方差
Figure PCTCN2019089058-appb-000066
获得两张所述灰度图片的第m列或者第m行的总体方差之差
Figure PCTCN2019089058-appb-000067
Figure PCTCN2019089058-appb-000068
小于预设的方差误差阈值,则判定所述两张图片无差异,从而实现了在保证图片差异性判断准确性的基础上减少图片识别与判断时间。
参照图3,本发明实施例中还提供一种计算机设备,该计算机设备可以是服务器,其内部结构可以如图所示。该计算机设备包括通过系统总线连接的处理器、存储器、网络接口和数据库。其中,该计算机设计的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统、计算机程序和数据库。该内存器为非易失性存储介质中的操作系统和计算机程序的运行提供环境。该计算机设备的数据库用于存储图片差异性判断方法所用数据。该计算机设备的网络接口用于与外部的终端通过网络连接通信。该计算机程序被处理器执行时以实现一种图 片差异性判断方法。
上述处理器执行上述图片差异性判断方法,其中所述方法包括的步骤分别与执行前述实施方式的图片差异性判断方法的步骤一一对应,在此不再赘述。
本领域技术人员可以理解,图中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定。
本申请的计算机设备,通过对两张图片进行灰度化处理,获得两张灰度图片,计算所述灰度图片的第m列或者第m行的总体方差
Figure PCTCN2019089058-appb-000069
获得两张所述灰度图片的第m列或者第m行的总体方差之差
Figure PCTCN2019089058-appb-000070
Figure PCTCN2019089058-appb-000071
小于预设的方差误差阈值,则判定所述两张图片无差异,从而实现了在保证图片差异性判断准确性的基础上减少图片识别与判断时间。
本申请一实施例还提供一种计算机可读存储介质,其上存储有计算机程序,计算机程序被处理器执行时实现图片差异性判断方法,其中所述方法包括的步骤分别与执行前述实施方式的图片差异性判断方法的步骤一一对应,在此不再赘述。
本申请的计算机可读存储介质,通过对两张图片进行灰度化处理,获得两张灰度图片,计算所述灰度图片的第m列或者第m行的总体方差
Figure PCTCN2019089058-appb-000072
获得两张所述灰度图片的第m列或者第m行的总体方差之差
Figure PCTCN2019089058-appb-000073
Figure PCTCN2019089058-appb-000074
小于预设的方差误差阈值,则判定所述两张图片无差异,从而实现了在保证图片差异性判断准确性的基础上减少图片识别与判断时间。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一非易失性计算机可读取存储介质中,该计算机程序在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的和实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可以包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双速据率SDRAM(SSRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从 而使得包括一系列要素的过程、装置、物品或者方法不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、装置、物品或者方法所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、装置、物品或者方法中还存在另外的相同要素。
以上所述仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。

Claims (20)

  1. 一种图片差异性判断方法,其特征在于,包括:
    获取待识别的两张图片;
    对所述两张图片进行灰度化处理,获得两张灰度图片;
    计算所述灰度图片的第m列或者第m行的所有像素点的灰度值的平均值Am,以及计算所述灰度图片中所有像素点的灰度值的平均值B;
    根据公式:
    Figure PCTCN2019089058-appb-100001
    计算所述灰度图片的第m列或者第m行的总体方差
    Figure PCTCN2019089058-appb-100002
    其中N为所述灰度图片中的列或者行的总数量;
    根据公式:
    Figure PCTCN2019089058-appb-100003
    获得两张所述灰度图片的第m列或者第m行的总体方差之差
    Figure PCTCN2019089058-appb-100004
    其中,
    Figure PCTCN2019089058-appb-100005
    为第一张灰度图片的第m列或者第m行的总体方差,
    Figure PCTCN2019089058-appb-100006
    为第二张灰度图片的第m列或者第m行的总体方差;
    判断
    Figure PCTCN2019089058-appb-100007
    是否小于预设的方差误差阈值;
    Figure PCTCN2019089058-appb-100008
    小于预设的方差误差阈值,则判定所述两张图片无差异。
  2. 根据权利要求1所述的图片差异性判断方法,其特征在于,所述对所述两张图片进行灰度化处理,获得两张灰度图片的步骤,包括:
    获取所述两张图片的分辨率、图片长度与图片宽度,并根据公式:像素点总数量=分辨率×图片长度+分辨率×图片宽度,分别计算出所述两张图片的像素点总数量;
    判断所述两张图片的像素点总数量是否相同;
    若所述两张图片的像素点总数量相同,则对所述两张图片进行灰度化处理,获得两张灰度图片。
  3. 根据权利要求2所述的图片差异性判断方法,其特征在于,所述若所述两张图片的像素点总数量相同,则对所述两张图片进行灰度化处理,获得两张灰度图片的步骤,包括:
    若所述两张图片的像素点总数量相同,则获取所述两张图片的文件大小,并判断所述两张图片的文件大小之差是否小于预设的文件大小阈值;
    若所述两张图片的文件大小之差不小于预设的文件大小阈值,则分别截取所述两张图片的指定列或者指定行的像素点以形成两张截取图片;
    对所述两张截取图片进行灰度化处理,获得两张灰度图片。
  4. 根据权利要求1所述的图片差异性判断方法,其特征在于,所述对所述两张图片进行灰度化处理,获得两张灰度图片的步骤,包括:
    利用预设采集规则,分别采集所述两张图片的指定数量的像素点,并分析所述指定数量的像素点的 颜色取值范围以分别获得所述两张图片的色彩深度的位数;
    判断所述两张图片的色彩深度的位数是否均小于预设的色彩深度阈值;
    若所述两张图片的色彩深度的位数均小于预设的色彩深度阈值,则对所述两张图片进行灰度化处理,获得两张灰度图片。
  5. 根据权利要求1所述的图片差异性判断方法,其特征在于,所述计算所述灰度图片的第m列或者第m行的所有像素点的灰度值的平均值Am,以及计算所述灰度图片中所有像素点的灰度值的平均值B的步骤,包括:
    采集所述灰度图片中的所有像素点的灰度值;
    将所述灰度图片的第m列或者第m行的所有像素点的灰度值进行加和处理得到第m列或者第m行加和值,将所述第m列或者第m行加和值除以所述第m列或者第m行的所有像素点的数量,得到所述灰度图片的第m列或者第m行的所有像素点的灰度值的平均值Am;
    将所述灰度图片中的所有像素点的灰度值进行加和处理得到所述灰度图片的加和值,将所述灰度图片的加和值除以所述灰度图片中的所有像素点的总数量,得到所述灰度图片中所有像素点的灰度值的平均值B。
  6. 根据权利要求1所述的图片差异性判断方法,其特征在于,所述判断
    Figure PCTCN2019089058-appb-100009
    是否小于预设的方差误差阈值的步骤之后,包括:
    Figure PCTCN2019089058-appb-100010
    不小于预设的方差误差阈值,则判定所述两张图片有差异;
    获取
    Figure PCTCN2019089058-appb-100011
    中不小于预设的方差误差阈值的值,并将所述不小于预设的方差误差阈值的值对应的列或者行记为差异列或者差异行。
  7. 一种图片差异性判断装置,其特征在于,包括:
    图片获取单元,用于获取待识别的两张图片;
    灰度图片获取单元,用于对所述两张图片进行灰度化处理,获得两张灰度图片;
    灰度平均值计算单元,用于计算所述灰度图片的第m列或者第m行的所有像素点的灰度值的平均值Am,以及计算所述灰度图片中所有像素点的灰度值的平均值B;
    总体方差计算单元,用于根据公式:
    Figure PCTCN2019089058-appb-100012
    计算所述灰度图片的第m列或者第m行的总体方差
    Figure PCTCN2019089058-appb-100013
    其中N为所述灰度图片中的列或者行的总数量;
    总体方差之差计算单元,用于根据公式:
    Figure PCTCN2019089058-appb-100014
    获得两张所述灰度图片的第m列或者第m行的总体方差之差
    Figure PCTCN2019089058-appb-100015
    其中,
    Figure PCTCN2019089058-appb-100016
    为第一张灰度图片的第m列或者第m行的总体方差,
    Figure PCTCN2019089058-appb-100017
    为第二张灰度图片的第m列或者第m行的总体方差;
    方差误差阈值判断单元,用于判断
    Figure PCTCN2019089058-appb-100018
    是否小于预设的方差误差阈值;
    无差异判定单元,用于若
    Figure PCTCN2019089058-appb-100019
    小于预设的方差误差阈值,则判定所述两张图片无差异。
  8. 根据权利要求7所述的图片差异性判断装置,其特征在于,所述灰度图片获取单元,包括:
    像素点总数量计算子单元,用于获取所述两张图片的分辨率、图片长度与图片宽度,并根据公式:像素点总数量=分辨率×图片长度+分辨率×图片宽度,分别计算出所述两张图片的像素点总数量;
    像素点总数量判断子单元,用于判断所述两张图片的像素点总数量是否相同;
    灰度图片获取第一子单元,用于若所述两张图片的像素点总数量相同,则对所述两张图片进行灰度化处理,获得两张灰度图片。
  9. 根据权利要求8所述的图片差异性判断装置,其特征在于,所述灰度图片获取第一子单元,包括:
    文件大小判断模块,用于若所述两张图片的像素点总数量相同,则获取所述两张图片的文件大小,并判断所述两张图片的文件大小之差是否小于预设的文件大小阈值;
    截取图片获取模块,用于若所述两张图片的文件大小之差不小于预设的文件大小阈值,则分别截取所述两张图片的指定列或者指定行的像素点以形成两张截取图片;
    灰度图片获取模块,用于对所述两张截取图片进行灰度化处理,获得两张灰度图片。
  10. 根据权利要求7所述的图片差异性判断装置,其特征在于,所述灰度图片获取单元,包括:
    色彩深度的位数获取子单元,用于利用预设采集规则,分别采集所述两张图片的指定数量的像素点,并分析所述指定数量的像素点的颜色取值范围以分别获得所述两张图片的色彩深度的位数;
    色彩深度阈值判断子单元,用于判断所述两张图片的色彩深度的位数是否均小于预设的色彩深度阈值;
    灰度图片获取第二子单元,用于若所述两张图片的色彩深度的位数均小于预设的色彩深度阈值,则对所述两张图片进行灰度化处理,获得两张灰度图片。
  11. 根据权利要求7所述的图片差异性判断装置,其特征在于,所述灰度平均值计算单元,包括:
    灰度值采集子单元,用于采集所述灰度图片中的所有像素点的灰度值;
    平均值Am采集子单元,用于将所述灰度图片的第m列或者第m行的所有像素点的灰度值进行加和处理得到第m列或者第m行加和值,将所述第m列或者第m行加和值除以所述第m列或者第m行的所有像素点的数量,得到所述灰度图片的第m列或者第m行的所有像素点的灰度值的平均值Am;
    平均值B采集子单元,用于将所述灰度图片中的所有像素点的灰度值进行加和处理得到所述灰度图片的加和值,将所述灰度图片的加和值除以所述灰度图片中的所有像素点的总数量,得到所述灰度图片中所有像素点的灰度值的平均值B。
  12. 根据权利要求7所述的图片差异性判断装置,其特征在于,所述装置,包括:
    有差异判定单元,用于若
    Figure PCTCN2019089058-appb-100020
    不小于预设的方差误差阈值,则判定所述两张图片有差异;
    标记单元,用于获取
    Figure PCTCN2019089058-appb-100021
    中不小于预设的方差误差阈值的值,并将所述不小于预设的方差误差阈值的值对应的列或者行记为差异列或者差异行。
  13. 一种计算机设备,包括存储器和处理器,所述存储器存储有计算机可读指令,其特征在于,所述处理器执行所述计算机可读指令时实现图片差异性判断方法,该图片差异性判断方法,包括:
    获取待识别的两张图片;
    对所述两张图片进行灰度化处理,获得两张灰度图片;
    计算所述灰度图片的第m列或者第m行的所有像素点的灰度值的平均值Am,以及计算所述灰度图片中所有像素点的灰度值的平均值B;
    根据公式:
    Figure PCTCN2019089058-appb-100022
    计算所述灰度图片的第m列或者第m行的总体方差
    Figure PCTCN2019089058-appb-100023
    其中N为所述灰度图片中的列或者行的总数量;
    根据公式:
    Figure PCTCN2019089058-appb-100024
    获得两张所述灰度图片的第m列或者第m行的总体方差之差
    Figure PCTCN2019089058-appb-100025
    其中,
    Figure PCTCN2019089058-appb-100026
    为第一张灰度图片的第m列或者第m行的总体方差,
    Figure PCTCN2019089058-appb-100027
    为第二张灰度图片的第m列或者第m行的总体方差;
    判断
    Figure PCTCN2019089058-appb-100028
    是否小于预设的方差误差阈值;
    Figure PCTCN2019089058-appb-100029
    小于预设的方差误差阈值,则判定所述两张图片无差异。
  14. 根据权利要求13所述的计算机设备,其特征在于,所述对所述两张图片进行灰度化处理,获得两张灰度图片的步骤,包括:
    获取所述两张图片的分辨率、图片长度与图片宽度,并根据公式:像素点总数量=分辨率×图片长度+分辨率×图片宽度,分别计算出所述两张图片的像素点总数量;
    判断所述两张图片的像素点总数量是否相同;
    若所述两张图片的像素点总数量相同,则对所述两张图片进行灰度化处理,获得两张灰度图片。
  15. 根据权利要求14所述的计算机设备,其特征在于,所述若所述两张图片的像素点总数量相同,则对所述两张图片进行灰度化处理,获得两张灰度图片的步骤,包括:
    若所述两张图片的像素点总数量相同,则获取所述两张图片的文件大小,并判断所述两张图片的文件大小之差是否小于预设的文件大小阈值;
    若所述两张图片的文件大小之差不小于预设的文件大小阈值,则分别截取所述两张图片的指定列或 者指定行的像素点以形成两张截取图片;
    对所述两张截取图片进行灰度化处理,获得两张灰度图片。
  16. 根据权利要求13所述的计算机设备,其特征在于,所述对所述两张图片进行灰度化处理,获得两张灰度图片的步骤,包括:
    利用预设采集规则,分别采集所述两张图片的指定数量的像素点,并分析所述指定数量的像素点的颜色取值范围以分别获得所述两张图片的色彩深度的位数;
    判断所述两张图片的色彩深度的位数是否均小于预设的色彩深度阈值;
    若所述两张图片的色彩深度的位数均小于预设的色彩深度阈值,则对所述两张图片进行灰度化处理,获得两张灰度图片。
  17. 一种计算机非易失性可读存储介质,其上存储有计算机可读指令,其特征在于,所述计算机可读指令被处理器执行时实现图片差异性判断方法,该图片差异性判断方法,包括:
    获取待识别的两张图片;
    对所述两张图片进行灰度化处理,获得两张灰度图片;
    计算所述灰度图片的第m列或者第m行的所有像素点的灰度值的平均值Am,以及计算所述灰度图片中所有像素点的灰度值的平均值B;
    根据公式:
    Figure PCTCN2019089058-appb-100030
    计算所述灰度图片的第m列或者第m行的总体方差
    Figure PCTCN2019089058-appb-100031
    其中N为所述灰度图片中的列或者行的总数量;
    根据公式:
    Figure PCTCN2019089058-appb-100032
    获得两张所述灰度图片的第m列或者第m行的总体方差之差
    Figure PCTCN2019089058-appb-100033
    其中,
    Figure PCTCN2019089058-appb-100034
    为第一张灰度图片的第m列或者第m行的总体方差,
    Figure PCTCN2019089058-appb-100035
    为第二张灰度图片的第m列或者第m行的总体方差;
    判断
    Figure PCTCN2019089058-appb-100036
    是否小于预设的方差误差阈值;
    Figure PCTCN2019089058-appb-100037
    小于预设的方差误差阈值,则判定所述两张图片无差异。
  18. 根据权利要求17所述的计算机非易失性可读存储介质,其特征在于,所述对所述两张图片进行灰度化处理,获得两张灰度图片的步骤,包括:
    获取所述两张图片的分辨率、图片长度与图片宽度,并根据公式:像素点总数量=分辨率×图片长度+分辨率×图片宽度,分别计算出所述两张图片的像素点总数量;
    判断所述两张图片的像素点总数量是否相同;
    若所述两张图片的像素点总数量相同,则对所述两张图片进行灰度化处理,获得两张灰度图片。
  19. 根据权利要求18所述的计算机非易失性可读存储介质,其特征在于,所述若所述两张图片的 像素点总数量相同,则对所述两张图片进行灰度化处理,获得两张灰度图片的步骤,包括:
    若所述两张图片的像素点总数量相同,则获取所述两张图片的文件大小,并判断所述两张图片的文件大小之差是否小于预设的文件大小阈值;
    若所述两张图片的文件大小之差不小于预设的文件大小阈值,则分别截取所述两张图片的指定列或者指定行的像素点以形成两张截取图片;
    对所述两张截取图片进行灰度化处理,获得两张灰度图片。
  20. 根据权利要求17所述的计算机非易失性可读存储介质,其特征在于,所述对所述两张图片进行灰度化处理,获得两张灰度图片的步骤,包括:
    利用预设采集规则,分别采集所述两张图片的指定数量的像素点,并分析所述指定数量的像素点的颜色取值范围以分别获得所述两张图片的色彩深度的位数;
    判断所述两张图片的色彩深度的位数是否均小于预设的色彩深度阈值;
    若所述两张图片的色彩深度的位数均小于预设的色彩深度阈值,则对所述两张图片进行灰度化处理,获得两张灰度图片。
PCT/CN2019/089058 2019-01-31 2019-05-29 图片差异性判断方法、装置、计算机设备和存储介质 WO2020155485A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910101305.4 2019-01-31
CN201910101305.4A CN109934262B (zh) 2019-01-31 2019-01-31 图片差异性判断方法、装置、计算机设备和存储介质

Publications (1)

Publication Number Publication Date
WO2020155485A1 true WO2020155485A1 (zh) 2020-08-06

Family

ID=66985474

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/089058 WO2020155485A1 (zh) 2019-01-31 2019-05-29 图片差异性判断方法、装置、计算机设备和存储介质

Country Status (2)

Country Link
CN (1) CN109934262B (zh)
WO (1) WO2020155485A1 (zh)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112539843A (zh) * 2020-12-11 2021-03-23 平安科技(深圳)有限公司 检测温度的方法、装置和计算机设备
CN112927277A (zh) * 2021-02-05 2021-06-08 广东博智林机器人有限公司 激光条纹列中心线的提取方法、装置、设备及存储介质
CN114693650A (zh) * 2022-03-31 2022-07-01 南通俊朗智能科技有限公司 一种基于机器视觉的混合机智能控制方法
CN117635610B (zh) * 2024-01-25 2024-04-09 青岛正大正电力环保设备有限公司 一种液压张紧机构油管漏油视觉检测方法

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110619274A (zh) * 2019-08-14 2019-12-27 深圳壹账通智能科技有限公司 基于印章和签名的身份验证方法、装置和计算机设备
CN111177430B (zh) * 2019-12-16 2023-06-20 中国平安财产保险股份有限公司 综合图像的存储方法、装置、计算机设备和存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101360184A (zh) * 2008-09-22 2009-02-04 腾讯科技(深圳)有限公司 提取视频关键帧的系统及方法
WO2012000191A1 (en) * 2010-06-30 2012-01-05 France Telecom Research & Development Beijing Company Limited Pixel interpolation method and system
CN102360503A (zh) * 2011-10-09 2012-02-22 西安电子科技大学 基于空间贴近度和像素相似性的sar图像变化检测方法
CN105637852A (zh) * 2014-08-29 2016-06-01 华为技术有限公司 一种图像处理方法、装置及电子设备

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4776308B2 (ja) * 2005-09-05 2011-09-21 株式会社東京精密 画像欠陥検査装置、画像欠陥検査システム、欠陥分類装置及び画像欠陥検査方法
CN104217416B (zh) * 2013-05-31 2017-09-15 富士通株式会社 灰度图像处理方法及其装置
CN106650829B (zh) * 2017-01-04 2019-07-16 华南理工大学 一种图片相似度计算方法
CN107679568A (zh) * 2017-09-25 2018-02-09 曾传德 基于像素差异分析的对比系统

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101360184A (zh) * 2008-09-22 2009-02-04 腾讯科技(深圳)有限公司 提取视频关键帧的系统及方法
WO2012000191A1 (en) * 2010-06-30 2012-01-05 France Telecom Research & Development Beijing Company Limited Pixel interpolation method and system
CN102360503A (zh) * 2011-10-09 2012-02-22 西安电子科技大学 基于空间贴近度和像素相似性的sar图像变化检测方法
CN105637852A (zh) * 2014-08-29 2016-06-01 华为技术有限公司 一种图像处理方法、装置及电子设备

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112539843A (zh) * 2020-12-11 2021-03-23 平安科技(深圳)有限公司 检测温度的方法、装置和计算机设备
CN112539843B (zh) * 2020-12-11 2023-06-02 平安科技(深圳)有限公司 检测温度的方法、装置和计算机设备
CN112927277A (zh) * 2021-02-05 2021-06-08 广东博智林机器人有限公司 激光条纹列中心线的提取方法、装置、设备及存储介质
CN114693650A (zh) * 2022-03-31 2022-07-01 南通俊朗智能科技有限公司 一种基于机器视觉的混合机智能控制方法
CN114693650B (zh) * 2022-03-31 2024-05-24 无锡市慧航智能科技有限公司 一种基于机器视觉的混合机智能控制方法
CN117635610B (zh) * 2024-01-25 2024-04-09 青岛正大正电力环保设备有限公司 一种液压张紧机构油管漏油视觉检测方法

Also Published As

Publication number Publication date
CN109934262B (zh) 2023-08-22
CN109934262A (zh) 2019-06-25

Similar Documents

Publication Publication Date Title
WO2020155485A1 (zh) 图片差异性判断方法、装置、计算机设备和存储介质
CN109389030B (zh) 人脸特征点检测方法、装置、计算机设备及存储介质
CN108968991B (zh) 手骨x光片骨龄评估方法、装置、计算机设备和存储介质
EP2806374A1 (en) Method and system for automatic selection of one or more image processing algorithm
CN110889457B (zh) 样本图像分类训练方法、装置、计算机设备和存储介质
CN109840524B (zh) 文字的类型识别方法、装置、设备及存储介质
US10832032B2 (en) Facial recognition method, facial recognition system, and non-transitory recording medium
US7539351B2 (en) Model-based line width control
CN111368638A (zh) 电子表格的创建方法、装置、计算机设备和存储介质
US10839253B2 (en) Systems and methods for optimized computer vision using deep neural networks and Litpschitz analysis
WO2020238556A1 (zh) 基于配置平台的数据传输方法、装置和计算机设备
CN111091146B (zh) 图片相似度获取方法、装置、计算机设备及存储介质
CN111199186A (zh) 图像质量评分模型训练方法、装置、设备及存储介质
CN113034514A (zh) 天空区域分割方法、装置、计算机设备和存储介质
CN109996063B (zh) 视频图像花屏检测方法、装置、计算机设备和存储介质
CN113240042B (zh) 图像分类预处理、图像分类方法、装置、设备及存储介质
CN110942067A (zh) 文本识别方法、装置、计算机设备和存储介质
CN112330671A (zh) 细胞分布状态的分析方法、装置、计算机设备和存储介质
CN109993067B (zh) 面部关键点提取方法、装置、计算机设备和存储介质
WO2021072883A1 (zh) 基于面部特征点检测的图片纠正方法、装置和计算机设备
CN111145152A (zh) 图像检测方法、计算机设备和存储介质
CN113283388B (zh) 活体人脸检测模型的训练方法、装置、设备及存储介质
WO2021073150A1 (zh) 数据检测方法、装置、计算机设备和存储介质
CN114218574A (zh) 一种数据检测方法、装置、电子设备以及存储介质
CN111402121A (zh) 图像风格的转换方法、装置、计算机设备和存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19913109

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19913109

Country of ref document: EP

Kind code of ref document: A1