图像篡改检测方法、系统、电子装置及可读存储介质Image tamper detecting method, system, electronic device and readable storage medium
本申请申明享有2017年8月4日递交的申请号为201710659580.9、名称为“图像篡改检测方法、电子装置及可读存储介质”的中国专利申请的优先权,该中国专利申请的整体内容以参考的方式结合在本申请中。The present application claims priority to Chinese Patent Application No. 201710659580.9, entitled "Image tampering detection method, electronic device and readable storage medium", which is filed on August 4, 2017, the entire contents of which are incorporated by reference. The way is combined in this application.
技术领域Technical field
本发明涉及计算机技术领域,尤其涉及一种图像篡改检测方法、系统、电子装置及可读存储介质。The present invention relates to the field of computer technologies, and in particular, to an image tamper detecting method, system, electronic device, and readable storage medium.
背景技术Background technique
目前,在理赔业务场景中需要对用户提供的理赔资料,比如车辆的损伤照片进行理赔金额的确定,由于损伤程度会影响最终的理赔金额,所以需要对车辆损伤照片进行PS鉴定即图像篡改检测。虽然,目前业界存在图像篡改检测算法实现对图像的自动PS检测,然而,现有的图像篡改检测算法需要依赖复杂的特征提取,并且提取的特征对篡改类型的变化不具鲁棒性,图像篡改检测的准确性得不到保障,检测错误率较高。At present, in the claims business scenario, the claim information provided by the user, such as the damage photograph of the vehicle, needs to be determined. The damage degree will affect the final claim amount, so it is necessary to perform PS identification, that is, image tampering detection on the vehicle damage photo. Although there are image tamper detection algorithms in the industry to achieve automatic PS detection of images, the existing image tamper detection algorithm relies on complex feature extraction, and the extracted features are not robust to tamper type changes, image tamper detection The accuracy is not guaranteed and the detection error rate is high.
发明内容Summary of the invention
本发明的目的在于提供一种图像篡改检测方法、电子装置、系统及可读存储介质,旨在提高图像篡改检测的准确性。An object of the present invention is to provide an image tamper detecting method, an electronic device, a system, and a readable storage medium, aiming at improving the accuracy of image tampering detection.
为实现上述目的,本发明提供一种电子装置,所述电子装置包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的图像篡改检测系统,所述图像篡改检测系统被所述处理器执行时实现如下步骤:To achieve the above object, the present invention provides an electronic device including: a memory, a processor, and an image tamper detecting system stored on the memory and operable on the processor, the image tamper detecting The system implements the following steps when executed by the processor:
A、对待检测图像进行预设的压缩和解压处理,得到所述待检测图像对应的多个图像块;A. performing preset compression and decompression processing on the detected image to obtain a plurality of image blocks corresponding to the image to be detected;
B、根据预先确定的分析算法,对各个图像块进行像素压缩次数分析,以分析出各个图像块是否存在篡改情况;B. Perform pixel analysis times on each image block according to a predetermined analysis algorithm to analyze whether there is tampering in each image block;
C、若有图像块存在篡改情况,则确定所述待检测图像为篡改图像。C. If there is a tampering condition of the image block, determine that the image to be detected is a tamper image.
此外,为实现上述目的,本发明还提供一种图像篡改检测方法,所述图像篡改检测方法包括:In addition, in order to achieve the above object, the present invention further provides an image tampering detecting method, where the image tampering detecting method includes:
A、对待检测图像进行预设的压缩和解压处理,得到所述待检测图像对应的多个图像块;A. performing preset compression and decompression processing on the detected image to obtain a plurality of image blocks corresponding to the image to be detected;
B、根据预先确定的分析算法,对各个图像块进行像素压缩次数分析,以分析出各个图像块是否存在篡改情况;B. Perform pixel analysis times on each image block according to a predetermined analysis algorithm to analyze whether there is tampering in each image block;
C、若有图像块存在篡改情况,则确定所述待检测图像为篡改图像。
C. If there is a tampering condition of the image block, determine that the image to be detected is a tamper image.
进一步地,为实现上述目的,本发明还提供一种计算机可读存储介质,所述计算机可读存储介质存储有图像篡改检测系统,所述图像篡改检测系统可被至少一个处理器执行,以实现如步骤:Further, in order to achieve the above object, the present invention also provides a computer readable storage medium storing an image tampering detection system, the image tamper detecting system being executable by at least one processor to implement As steps:
A、对待检测图像进行预设的压缩和解压处理,得到所述待检测图像对应的多个图像块;A. performing preset compression and decompression processing on the detected image to obtain a plurality of image blocks corresponding to the image to be detected;
B、根据预先确定的分析算法,对各个图像块进行像素压缩次数分析,以分析出各个图像块是否存在篡改情况;B. Perform pixel analysis times on each image block according to a predetermined analysis algorithm to analyze whether there is tampering in each image block;
C、若有图像块存在篡改情况,则确定所述待检测图像为篡改图像。C. If there is a tampering condition of the image block, determine that the image to be detected is a tamper image.
更进一步地,为实现上述目的,本发明还提供一种图像篡改检测系统,所述图像篡改检测系统存储于存储器中,可被至少一个处理器执行,以实现如步骤:Further, in order to achieve the above object, the present invention further provides an image tamper detecting system, which is stored in a memory and can be executed by at least one processor to implement steps as follows:
A、对待检测图像进行预设的压缩和解压处理,得到所述待检测图像对应的多个图像块;A. performing preset compression and decompression processing on the detected image to obtain a plurality of image blocks corresponding to the image to be detected;
B、根据预先确定的分析算法,对各个图像块进行像素压缩次数分析,以分析出各个图像块是否存在篡改情况;B. Perform pixel analysis times on each image block according to a predetermined analysis algorithm to analyze whether there is tampering in each image block;
C、若有图像块存在篡改情况,则确定所述待检测图像为篡改图像。C. If there is a tampering condition of the image block, determine that the image to be detected is a tamper image.
本发明提出的图像篡改检测方法、电子装置、系统及可读存储介质,通过对待检测图像进行压缩和解压得到对应的多个图像块;根据预先确定的分析算法对各个图像块进行像素压缩次数分析,以分析出各个图像块及所述待检测图像是否存在篡改情况。由于只需根据待检测图像的各个图像块的像素压缩次数来分析各个图像块是否存在篡改,进而确定待检测图像是否存在篡改,无需进行复杂的特征提取,且能对各种篡改类型进行检测,提高了图像篡改检测的准确性。The image tamper detecting method, the electronic device, the system and the readable storage medium provided by the invention obtain a corresponding plurality of image blocks by compressing and decompressing the image to be detected; and performing pixel compression times analysis on each image block according to a predetermined analysis algorithm To analyze whether each image block and the image to be detected have tampering conditions. Since it is only necessary to analyze whether each image block has tampering according to the number of pixel compressions of each image block of the image to be detected, thereby determining whether the image to be detected is falsified, no complicated feature extraction is required, and various tamper types can be detected. Improve the accuracy of image tamper detection.
附图说明DRAWINGS
图1为本发明各个实施例一可选的应用环境示意图;FIG. 1 is a schematic diagram of an optional application environment according to various embodiments of the present invention; FIG.
图2是图1中电子装置一实施例的硬件架构的示意图;2 is a schematic diagram of a hardware architecture of an embodiment of the electronic device of FIG. 1;
图3为本发明图像篡改检测方法一实施例的流程示意图。FIG. 3 is a schematic flow chart of an embodiment of an image tampering detecting method according to the present invention.
具体实施方式Detailed ways
为了使本发明的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本发明,并不用于限定本发明。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It is understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
需要说明的是,在本发明中涉及“第一”、“第二”等的描述仅用于描述目的,而不能理解为指示或暗示其相对重要性或者隐含指明所指示的技术特征
的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括至少一个该特征。另外,各个实施例之间的技术方案可以相互结合,但是必须是以本领域普通技术人员能够实现为基础,当技术方案的结合出现相互矛盾或无法实现时应当认为这种技术方案的结合不存在,也不在本发明要求的保护范围之内。It should be noted that the descriptions of "first", "second" and the like in the present invention are for the purpose of description only, and are not to be construed as indicating or implying their relative importance or implicitly indicating the indicated technical features.
quantity. Thus, features defining "first" and "second" may include at least one of the features, either explicitly or implicitly. In addition, the technical solutions between the various embodiments may be combined with each other, but must be based on the realization of those skilled in the art, and when the combination of the technical solutions is contradictory or impossible to implement, it should be considered that the combination of the technical solutions does not exist. It is also within the scope of protection required by the present invention.
参阅图1,是本发明各个实施例一可选的应用环境示意图。FIG. 1 is a schematic diagram of an optional application environment according to various embodiments of the present invention.
在本实施例中,本发明可应用于包括,但不仅限于,电子装置1、终端设备2、网络3的应用环境中。其中,电子装置1是一种能够按照事先设定或者存储的指令,自动进行数值计算和/或信息处理的设备。电子装置1可以是计算机、也可以是单个网络服务器、多个网络服务器组成的服务器组或者基于云计算的由大量主机或者网络服务器构成的云,其中云计算是分布式计算的一种,由一群松散耦合的计算机集组成的一个超级虚拟计算机。In the present embodiment, the present invention is applicable to an application environment including, but not limited to, an electronic device 1, a terminal device 2, and a network 3. The electronic device 1 is an apparatus capable of automatically performing numerical calculation and/or information processing in accordance with an instruction set or stored in advance. The electronic device 1 may be a computer, a single network server, a server group composed of a plurality of network servers, or a cloud-based cloud composed of a large number of hosts or network servers, wherein the cloud computing is a type of distributed computing, A super virtual computer consisting of a loosely coupled set of computers.
终端设备2包括,但不限于,任何一种可与用户通过键盘、鼠标、遥控器、触摸板或者声控设备等方式进行人机交互的电子产品,例如,个人计算机、平板电脑、智能手机、个人数字助理(Personal Digital Assistant,PDA),游戏机、交互式网络电视(Internet Protocol Television,IPTV)、智能式穿戴式设备等。The terminal device 2 includes, but is not limited to, any electronic product that can interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device, for example, a personal computer, a tablet computer, a smart phone, or an individual. Digital Assistant (PDA), game console, Internet Protocol Television (IPTV), smart wearable device, etc.
所述网络3可以是企业内部网(Intranet)、互联网(Internet)、全球移动通讯系统(Global S图像篡改检测stem of Mobile communication,GSM)、宽带码分多址(Wideband Code Division Multiple Access,WCDMA)、4G网络、5G网络、蓝牙(Bluetooth)、Wi-Fi等无线或有线网络。其中,所述电子装置1通过所述网络3分别与一个或多个所述终端设备2通信连接。The network 3 may be an intranet, an Internet, a global mobile communication system (Global S image tampering detection, GSM), and a Wideband Code Division Multiple Access (WCDMA). Wireless or wired networks such as 4G networks, 5G networks, Bluetooth, Wi-Fi, etc. The electronic device 1 is communicatively connected to one or more of the terminal devices 2 via the network 3 respectively.
参阅图2,是图1中电子装置1一可选的硬件架构的示意图,本实施例中,电子装置1可包括,但不仅限于,可通过系统总线相互通信连接的存储器11、处理器12、网络接口13。需要指出的是,图2仅示出了具有组件11-13的电子装置1,但是应理解的是,并不要求实施所有示出的组件,可以替代的实施更多或者更少的组件。FIG. 2 is a schematic diagram of an optional hardware architecture of the electronic device 1 of FIG. 1. In this embodiment, the electronic device 1 may include, but is not limited to, a memory 11 and a processor 12 that are communicably connected to each other through a system bus. Network interface 13. It is to be noted that FIG. 2 only shows the electronic device 1 having the components 11-13, but it should be understood that not all illustrated components may be implemented, and more or fewer components may be implemented instead.
其中,所述存储器11至少包括一种类型的可读存储介质,所述可读存储介质包括闪存、硬盘、多媒体卡、卡型存储器(例如,SD或DX存储器等)、随机访问存储器(RAM)、静态随机访问存储器(SRAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、可编程只读存储器(PROM)、磁性存储器、磁盘、光盘等。在一些实施例中,所述存储器11可以是所述电子装置1的内部存储单元,例如该电子装置1的硬盘或内存。在另一些实施例中,所述存储器11也可以是所述电子装置1的外部存储设备,例如该电子装置1上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。当然,所述存储器11还可以既包括所述电子装置1的内部存储单元也包括其外部存储设备。本实施例中,所述存储器11通常用于存储安装于所述电子装置1的操作系统和各类应用软件,例如所述图像篡改检测系统10的程序代码等。
此外,所述存储器11还可以用于暂时地存储已经输出或者将要输出的各类数据。The memory 11 includes at least one type of readable storage medium including a flash memory, a hard disk, a multimedia card, a card type memory (eg, SD or DX memory, etc.), and a random access memory (RAM). , static random access memory (SRAM), read only memory (ROM), electrically erasable programmable read only memory (EEPROM), programmable read only memory (PROM), magnetic memory, magnetic disk, optical disk, and the like. In some embodiments, the memory 11 may be an internal storage unit of the electronic device 1, such as a hard disk or a memory of the electronic device 1. In other embodiments, the memory 11 may also be an external storage device of the electronic device 1, such as a plug-in hard disk equipped on the electronic device 1, a smart memory card (SMC), and a secure digital device. (Secure Digital, SD) card, flash card, etc. Of course, the memory 11 can also include both the internal storage unit of the electronic device 1 and its external storage device. In this embodiment, the memory 11 is generally used to store an operating system installed in the electronic device 1 and various types of application software, such as program codes of the image tamper detecting system 10 and the like.
Further, the memory 11 can also be used to temporarily store various types of data that have been output or are to be output.
所述处理器12在一些实施例中可以是中央处理器(Central Processing Unit,CPU)、控制器、微控制器、微处理器、或其他数据处理芯片。该处理器12通常用于控制所述电子装置1的总体操作,例如执行与所述终端设备2进行数据交互或者通信相关的控制和处理等。本实施例中,所述处理器12用于运行所述存储器11中存储的程序代码或者处理数据,例如运行所述图像篡改检测系统10等。The processor 12 may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor, or other data processing chip in some embodiments. The processor 12 is typically used to control the overall operation of the electronic device 1, such as performing control and processing related to data interaction or communication with the terminal device 2. In this embodiment, the processor 12 is configured to run program code or process data stored in the memory 11, such as running the image tamper detecting system 10 and the like.
所述网络接口13可包括无线网络接口或有线网络接口,该网络接口13通常用于在所述电子装置1与其他电子设备之间建立通信连接。本实施例中,所述网络接口13主要用于通过所述网络3将所述电子装置1与一个或多个所述终端设备2相连,在所述电子装置1与一个或多个所述终端设备2之间建立数据传输通道和通信连接。The network interface 13 may comprise a wireless network interface or a wired network interface, which is typically used to establish a communication connection between the electronic device 1 and other electronic devices. In this embodiment, the network interface 13 is mainly used to connect the electronic device 1 to one or more of the terminal devices 2 through the network 3, in the electronic device 1 and one or more of the terminals. A data transmission channel and a communication connection are established between the devices 2.
图像篡改检测系统10包括至少一个存储在所述存储器11中的计算机可读指令,该至少一个计算机可读指令可被所述处理器12执行,以实现本申请各实施例。Image tampering detection system 10 includes at least one computer readable instruction stored in said memory 11 that is executable by said processor 12 to implement various embodiments of the present application.
其中,上述图像篡改检测系统10被所述处理器12执行时实现如下步骤:Wherein, when the image tampering detection system 10 is executed by the processor 12, the following steps are implemented:
步骤S1,对待检测图像进行预设的压缩和解压处理,得到所述待检测图像对应的多个图像块;Step S1, performing preset compression and decompression processing on the image to be detected, to obtain a plurality of image blocks corresponding to the image to be detected;
本实施例中,图像篡改检测系统接收用户发出的包含待检测图片的图像篡改检测请求,例如,接收用户通过手机、平板电脑、自助终端设备等终端发送的图像篡改检测请求,如接收用户在手机、平板电脑、自助终端设备等终端中预先安装的客户端上发送来的图像篡改检测请求,或接收用户在手机、平板电脑、自助终端设备等终端中的浏览器系统上发送来的图像篡改检测请求。In this embodiment, the image tampering detection system receives an image tampering detection request sent by the user including the image to be detected, for example, receiving an image tampering detection request sent by the user through a mobile phone, a tablet computer, a self-service terminal device, or the like, such as receiving the user in the mobile phone. Image tampering detection request sent by a pre-installed client in a terminal such as a tablet computer or a self-service terminal device, or receiving image tampering detection sent by a user on a browser system in a terminal such as a mobile phone, a tablet computer, or a self-service terminal device request.
接收到需进行图像篡改检测的待待检测图片后,对待检测图像进行预设的压缩和解压处理,如可对待检测图像进行网格分割形成若干图像小网格,并对图像小网格进行压缩和解压处理得到该待检测图像对应的多个图像块。After receiving the image to be detected that needs to be image tampering detection, the image to be detected is subjected to preset compression and decompression processing, for example, the image to be detected is mesh-divided to form a small image mesh, and the image small mesh is compressed. And decompressing the processing to obtain a plurality of image blocks corresponding to the image to be detected.
步骤S2,根据预先确定的分析算法,对各个图像块进行像素压缩次数分析,以分析出各个图像块是否存在篡改情况;Step S2, performing pixel compression times analysis on each image block according to a predetermined analysis algorithm, to analyze whether each image block has a tampering condition;
本实施例中,对待检测图像进行压缩和解压处理得到对应的多个图像块之后,利用预先确定的分析算法对各个图像块进行像素压缩次数分析,例如可计算出各个图像块经过一次压缩的条件概率和/或经过二次压缩的条件概率,并分析出各个图像块是经过一次压缩还是经过二次压缩,即分析出各个图像块对应的像素压缩次数。在图像被篡改过程中,一般是篡改方对图像进行分割、压缩和解压处理,然后根据篡改后的图像块在图像中的位置,将篡改后的图像块替换原始图像块,并对各个其他原始图像块及篡改后的图像块进行组合重建,得到重建图像,即为被篡改的图像。由此可知,图像在被篡改时已经进行过一次压缩处理,用于加入篡改的信息,因此,分析出待检测
图像对应的各个图像块对应的像素压缩次数之后,即可分析出各个图像块是否存在篡改情况。例如,本实施例中,在对待检测图像进行预设的压缩和解压处理得到对应的多个图像块之后,若分析出图像块对应的像素压缩次数为2,则说明在对图像块进行检测之前该图像块已经经过了1次压缩处理,因此,该图像块是被篡改过的图像块,即该图像块存在篡改情况;反之,若分析出图像块对应的像素压缩次数为2,则说明该图像块是没有被篡改过的图像块,即该图像块不存在篡改情况。In this embodiment, after the image to be detected is compressed and decompressed to obtain a corresponding plurality of image blocks, the number of times of pixel compression is analyzed for each image block by using a predetermined analysis algorithm, for example, a condition that each image block undergoes one compression can be calculated. Probability and/or conditional probability of secondary compression, and analyze whether each image block is compressed once or twice, that is, the number of pixel compressions corresponding to each image block is analyzed. In the process of image tampering, the tampering party generally divides, compresses and decompresses the image, and then replaces the falsified image block with the original image block according to the position of the falsified image block in the image, and each other original The image block and the falsified image block are combined and reconstructed to obtain a reconstructed image, that is, a falsified image. It can be seen that the image has been subjected to a compression process when it is tampered with, and is used to add tampering information, so that the analysis is to be detected.
After the number of pixel compressions corresponding to each image block corresponding to the image, it is possible to analyze whether there is tampering in each image block. For example, in this embodiment, after performing a predetermined compression and decompression process on the image to be detected to obtain a corresponding plurality of image blocks, if it is analyzed that the number of pixel compressions corresponding to the image block is 2, it is explained that before the image block is detected. The image block has undergone one compression process. Therefore, the image block is a tampered image block, that is, the image block has a tampering condition; on the contrary, if the pixel compression number corresponding to the image block is 2, the description is An image block is an image block that has not been tampered with, that is, there is no tampering in the image block.
步骤S3,若有图像块存在篡改情况,则确定所述待检测图像为篡改图像。In step S3, if there is a tampering condition of the image block, it is determined that the image to be detected is a tamper image.
本实施例中,在分析出各个图像块是否存在篡改情况后,即可进而确定出所述待检测图像是否为篡改图像。例如,若所述待检测图像对应的所有图像块的像素压缩次数均为1,即确定所有图像块均不存在篡改情况,则确定所述待检测图像不存在篡改情况,即所述待检测图像不是篡改图像。若所述待检测图像对应的所有图像块中有图像块的像素压缩次数为2,即确定有图像块存在篡改情况,则确定所述待检测图像存在篡改情况,即所述待检测图像是篡改图像。In this embodiment, after analyzing whether there is a tampering condition in each image block, it may be further determined whether the image to be detected is a tamper image. For example, if the number of pixel compressions of all the image blocks corresponding to the image to be detected is 1, that is, it is determined that there is no tampering condition in all the image blocks, it is determined that the image to be detected does not have a tampering condition, that is, the image to be detected Not tampering with the image. If the number of pixel compressions of the image block in the image block corresponding to the image to be detected is 2, that is, it is determined that there is a tampering condition of the image block, determining that the image to be detected has a tampering condition, that is, the image to be detected is tampering image.
本实施例通过对待检测图像进行压缩和解压得到对应的多个图像块;根据预先确定的分析算法对各个图像块进行像素压缩次数分析,以分析出各个图像块及所述待检测图像是否存在篡改情况。由于只需根据待检测图像的各个图像块的像素压缩次数来分析各个图像块是否存在篡改,进而确定待检测图像是否存在篡改,无需进行复杂的特征提取,且能对各种篡改类型进行检测,提高了图像篡改检测的准确性。In this embodiment, a plurality of image blocks are obtained by compressing and decompressing the image to be detected; and performing pixel compression times on each image block according to a predetermined analysis algorithm to analyze whether each image block and the image to be detected are falsified. Happening. Since it is only necessary to analyze whether each image block has tampering according to the number of pixel compressions of each image block of the image to be detected, thereby determining whether the image to be detected is falsified, no complicated feature extraction is required, and various tamper types can be detected. Improve the accuracy of image tamper detection.
在一可选的实施例中,在上述图2的实施例的基础上,所述图像篡改检测系统10被所述处理器12执行实现所述步骤S1时,具体包括:In an optional embodiment, on the basis of the foregoing embodiment of FIG. 2, when the image tampering detection system 10 is executed by the processor 12 to implement the step S1, the method specifically includes:
对待检测图像进行网格分割,将所述待检测图像分成多个N*M(例如,8*8)的图像小网格,N和M为正整数;Dividing the detected image into a mesh, dividing the image to be detected into a plurality of N*M (for example, 8*8) image small meshes, where N and M are positive integers;
对各个图像网格采用预设类型变换函数(例如,DCT(Discrete Cosine Transform,离散余弦变换)变换函数)进行变换,以得到对应的变换网格数据。例如,采用DCT变换函数按照预先确定的一次压缩的量化步长进行变换以得到对应的变换网格数据;Each image grid is transformed by a preset type transform function (for example, a DCT (Discrete Cosine Transform) transform function) to obtain corresponding transform grid data. For example, using a DCT transform function to perform a transform according to a predetermined one-time compressed quantization step to obtain corresponding transform grid data;
对各个图像网格对应的变换网格数据按照预先确定的压缩格式(例如,JPEG)进行一次压缩,以得到对应的网格压缩数据;Performing compression on the transformed mesh data corresponding to each image grid according to a predetermined compression format (for example, JPEG) to obtain corresponding mesh compressed data;
对各个图像网格对应的网格压缩数据进行解压缩,以得到对应的网格解压数据,并对各个图像网格对应的网格解压数据采用预设类型反变换函数(例如,DCT(Discrete Cosine Transform,离散余弦变换)反变换函数)进行反变换,以得到对应的图像块。Decompressing the grid compressed data corresponding to each image grid to obtain corresponding grid decompressed data, and adopting a preset type inverse transform function for the grid decompressed data corresponding to each image grid (for example, DCT (Discrete Cosine) Transform, discrete cosine transform) inverse transform function) performs inverse transform to obtain the corresponding image block.
本实施例中对待检测图像进行网格分割成若干图像小网格,并利用DCT
变换函数对图像小网格进行变换得到网格数据,进行压缩及解压处理后,再利用DCT反变换函数进行反变换得到待检测图像对应的多个图像块,便于后续更加精确地对各个图像块进行像素压缩次数分析,且通过将待检测图像分割成若干图像块,根据每一图像块是否存在篡改情况来确定待检测图像的篡改情况,能进一步地提高图像篡改检测的准确性。In this embodiment, the image to be detected is mesh-divided into a plurality of image small grids, and DCT is utilized.
The transformation function transforms the image small grid to obtain the grid data, and then performs compression and decompression processing, and then inversely transforms the DCT inverse transform function to obtain a plurality of image blocks corresponding to the image to be detected, so as to facilitate more accurate subsequent image blocks. The pixel compression number analysis is performed, and by dividing the image to be detected into a plurality of image blocks, determining the tampering condition of the image to be detected according to whether there is a tampering condition in each image block, the accuracy of the image tampering detection can be further improved.
在一可选的实施例中,所述图像篡改检测系统10被所述处理器12执行实现所述步骤S2时,所述预先确定的分析算法包括:In an optional embodiment, when the image tampering detection system 10 is executed by the processor 12 to implement the step S2, the predetermined analysis algorithm includes:
将图像块的每个像素x经过一次压缩的条件概率记为p(x|H0),经过二次压缩的条件概率记为p(x|H1),其中,p(x|H1)=pDQ(x;Q1,Q2),p(x|H0)=pNDQ(x;Q2),Q1为预设的一次压缩的量化步长,Q2为预设的二次压缩的量化步长;The conditional probability that each pixel x of the image block is compressed once is denoted as p(x|H 0 ), and the conditional probability of secondary compression is denoted as p(x|H 1 ), where p(x|H 1 ) =p DQ (x; Q 1 , Q 2 ), p(x|H 0 )=p NDQ (x; Q 2 ), Q 1 is the preset quantization step size of the first compression, and Q 2 is the preset two Secondary compression quantization step size;
计算每个像素x对应的两个条件概率p(x|H1)和p(x|H0),并根据计算的两个条件概率p(x|H1)和p(x|H0)的值,分析每个像素x对应的压缩次数;例如,可计算像素x的似然比率若L(x)>1,则确定该像素x对应的压缩次数为二;若L(x)≤1,则确定该像素x对应的压缩次数为一。Calculate two conditional probabilities p(x|H 1 ) and p(x|H 0 ) corresponding to each pixel x, and according to the calculated two conditional probabilities p(x|H 1 ) and p(x|H 0 ) Value, the number of compressions corresponding to each pixel x is analyzed; for example, the likelihood ratio of pixel x can be calculated If L(x)>1, it is determined that the number of compressions corresponding to the pixel x is two; if L(x)≤1, it is determined that the number of compressions corresponding to the pixel x is one.
若图像块中所有像素对应的压缩次数均为一,则确定该图像块不存在篡改情况,或者,若图像块中有像素对应的压缩次数为二,则确定该图像块存在篡改情况。If the number of compressions corresponding to all the pixels in the image block is one, it is determined that the image block does not have a tampering condition, or if the number of compressions corresponding to the pixel in the image block is two, it is determined that the image block has a tampering condition.
在一种可选的实施方式中,对待检测图像进行预设的压缩和解压处理过程中的预设类型变换函数可以为离散余弦变换DCT变换函数,预设类型反变换函数可以为DCT反变换函数。则图像块的每个像素x经过二次压缩的条件概率其中,x≠0,nDQ(x)为DCT系数的周期函数,图像块的每个像素x经过一次压缩的条件概率其中,pQ(v)=nQ(x)*pNQ(x),x≠0,nQ(x)=nQ,0(x)*gQ(x),Q为预设的量化步长,μe为对DCT系数分布的估计误差的均值,为DCT系数分布的估计误差的方差。估计误差的方差越小检测速度越慢但准确率较高,估计误差的均值μe是一个经验值,需要多次尝试才能确定,如可预先指定一个均值变动范围,然后在该范围内不断尝试,选取误差估计最小的那个。In an optional implementation manner, the preset type transform function in the preset compression and decompression process of the image to be detected may be a discrete cosine transform DCT transform function, and the preset type inverse transform function may be a DCT inverse transform function. . Conditional probability that each pixel x of the image block undergoes secondary compression Where x ≠ 0, n DQ (x) is a periodic function of the DCT coefficients, Conditional probability of one compression per pixel x of an image block Where p Q(v) = n Q (x) * p NQ (x), x ≠ 0, n Q (x) = n Q, 0 (x) * g Q (x), Q is the preset quantization step size, and μ e is the mean value of the estimation error of the DCT coefficient distribution. The variance of the estimated error for the DCT coefficient distribution. Estimation of the variance of the error The smaller the detection speed is, the slower the accuracy is. The average value of the estimated error μ e is an empirical value, which requires multiple attempts to determine. If a range of mean value can be specified in advance, then try to make an error estimate within the range. The smallest one.
本实施例中,计算出图像块的每个像素经过一次压缩的条件概率和经过二次压缩的条件概率,并根据每个像素的两个条件概率计算像素的似然比
率,根据该似然比率能最大概率地准确地分析出像素对应的压缩次数,以分析出图像块是否存在篡改情况,进而准确地分析出待检测图像是否为篡改图像。In this embodiment, a conditional probability of one compression of each pixel of the image block and a conditional probability of being subjected to secondary compression are calculated, and a likelihood ratio of the pixel is calculated according to two conditional probabilities of each pixel.
According to the likelihood ratio, the number of compressions corresponding to the pixel can be accurately and accurately analyzed according to the likelihood ratio, so as to analyze whether the image block has a tampering condition, and then accurately analyze whether the image to be detected is a tamper image.
如图3所示,图3为本发明图像篡改检测方法一实施例的流程示意图,该图像篡改检测方法包括以下步骤:As shown in FIG. 3, FIG. 3 is a schematic flowchart of an image tampering detection method according to an embodiment of the present invention. The image tampering detection method includes the following steps:
步骤S10,对待检测图像进行预设的压缩和解压处理,得到所述待检测图像对应的多个图像块;Step S10, performing preset compression and decompression processing on the image to be detected, to obtain a plurality of image blocks corresponding to the image to be detected;
本实施例中,图像篡改检测系统接收用户发出的包含待检测图片的图像篡改检测请求,例如,接收用户通过手机、平板电脑、自助终端设备等终端发送的图像篡改检测请求,如接收用户在手机、平板电脑、自助终端设备等终端中预先安装的客户端上发送来的图像篡改检测请求,或接收用户在手机、平板电脑、自助终端设备等终端中的浏览器系统上发送来的图像篡改检测请求。In this embodiment, the image tampering detection system receives an image tampering detection request sent by the user including the image to be detected, for example, receiving an image tampering detection request sent by the user through a mobile phone, a tablet computer, a self-service terminal device, or the like, such as receiving the user in the mobile phone. Image tampering detection request sent by a pre-installed client in a terminal such as a tablet computer or a self-service terminal device, or receiving image tampering detection sent by a user on a browser system in a terminal such as a mobile phone, a tablet computer, or a self-service terminal device request.
接收到需进行图像篡改检测的待待检测图片后,对待检测图像进行预设的压缩和解压处理,如可对待检测图像进行网格分割形成若干图像小网格,并对图像小网格进行压缩和解压处理得到该待检测图像对应的多个图像块。After receiving the image to be detected that needs to be image tampering detection, the image to be detected is subjected to preset compression and decompression processing, for example, the image to be detected is mesh-divided to form a small image mesh, and the image small mesh is compressed. And decompressing the processing to obtain a plurality of image blocks corresponding to the image to be detected.
步骤S20,根据预先确定的分析算法,对各个图像块进行像素压缩次数分析,以分析出各个图像块是否存在篡改情况;Step S20, performing pixel compression times analysis on each image block according to a predetermined analysis algorithm, to analyze whether each image block has a tampering condition;
本实施例中,对待检测图像进行压缩和解压处理得到对应的多个图像块之后,利用预先确定的分析算法对各个图像块进行像素压缩次数分析,例如可计算出各个图像块经过一次压缩的条件概率和/或经过二次压缩的条件概率,并分析出各个图像块是经过一次压缩还是经过二次压缩,即分析出各个图像块对应的像素压缩次数。在图像被篡改过程中,一般是篡改方对图像进行分割、压缩和解压处理,然后根据篡改后的图像块在图像中的位置,将篡改后的图像块替换原始图像块,并对各个其他原始图像块及篡改后的图像块进行组合重建,得到重建图像,即为被篡改的图像。由此可知,图像在被篡改时已经进行过一次压缩处理,用于加入篡改的信息,因此,分析出待检测图像对应的各个图像块对应的像素压缩次数之后,即可分析出各个图像块是否存在篡改情况。例如,本实施例中,在对待检测图像进行预设的压缩和解压处理得到对应的多个图像块之后,若分析出图像块对应的像素压缩次数为2,则说明在对图像块进行检测之前该图像块已经经过了1次压缩处理,因此,该图像块是被篡改过的图像块,即该图像块存在篡改情况;反之,若分析出图像块对应的像素压缩次数为2,则说明该图像块是没有被篡改过的图像块,即该图像块不存在篡改情况。In this embodiment, after the image to be detected is compressed and decompressed to obtain a corresponding plurality of image blocks, the number of times of pixel compression is analyzed for each image block by using a predetermined analysis algorithm, for example, a condition that each image block undergoes one compression can be calculated. Probability and/or conditional probability of secondary compression, and analyze whether each image block is compressed once or twice, that is, the number of pixel compressions corresponding to each image block is analyzed. In the process of image tampering, the tampering party generally divides, compresses and decompresses the image, and then replaces the falsified image block with the original image block according to the position of the falsified image block in the image, and each other original The image block and the falsified image block are combined and reconstructed to obtain a reconstructed image, that is, a falsified image. It can be seen that the image has been subjected to a compression process for tampering when it is falsified, and is used to add tampering information. Therefore, after analyzing the number of pixel compressions corresponding to each image block corresponding to the image to be detected, it is possible to analyze whether each image block is There is a tampering situation. For example, in this embodiment, after performing a predetermined compression and decompression process on the image to be detected to obtain a corresponding plurality of image blocks, if it is analyzed that the number of pixel compressions corresponding to the image block is 2, it is explained that before the image block is detected. The image block has undergone one compression process. Therefore, the image block is a tampered image block, that is, the image block has a tampering condition; on the contrary, if the pixel compression number corresponding to the image block is 2, the description is An image block is an image block that has not been tampered with, that is, there is no tampering in the image block.
步骤S30,若有图像块存在篡改情况,则确定所述待检测图像为篡改图像。In step S30, if there is a tampering condition of the image block, it is determined that the image to be detected is a tamper image.
本实施例中,在分析出各个图像块是否存在篡改情况后,即可进而确定出所述待检测图像是否为篡改图像。例如,若所述待检测图像对应的所有图
像块的像素压缩次数均为1,即确定所有图像块均不存在篡改情况,则确定所述待检测图像不存在篡改情况,即所述待检测图像不是篡改图像。若所述待检测图像对应的所有图像块中有图像块的像素压缩次数为2,即确定有图像块存在篡改情况,则确定所述待检测图像存在篡改情况,即所述待检测图像是篡改图像。In this embodiment, after analyzing whether there is a tampering condition in each image block, it may be further determined whether the image to be detected is a tamper image. For example, if all the maps corresponding to the image to be detected are
If the pixel compression number of the image block is 1, that is, it is determined that there is no tampering condition in all the image blocks, it is determined that the image to be detected does not have a tampering condition, that is, the image to be detected is not a tamper image. If the number of pixel compressions of the image block in the image block corresponding to the image to be detected is 2, that is, it is determined that there is a tampering condition of the image block, determining that the image to be detected has a tampering condition, that is, the image to be detected is tampering image.
本实施例通过对待检测图像进行压缩和解压得到对应的多个图像块;根据预先确定的分析算法对各个图像块进行像素压缩次数分析,以分析出各个图像块及所述待检测图像是否存在篡改情况。由于只需根据待检测图像的各个图像块的像素压缩次数来分析各个图像块是否存在篡改,进而确定待检测图像是否存在篡改,无需进行复杂的特征提取,且能对各种篡改类型进行检测,提高了图像篡改检测的准确性。In this embodiment, a plurality of image blocks are obtained by compressing and decompressing the image to be detected; and performing pixel compression times on each image block according to a predetermined analysis algorithm to analyze whether each image block and the image to be detected are falsified. Happening. Since it is only necessary to analyze whether each image block has tampering according to the number of pixel compressions of each image block of the image to be detected, thereby determining whether the image to be detected is falsified, no complicated feature extraction is required, and various tamper types can be detected. Improve the accuracy of image tamper detection.
在一可选的实施例中,在上述图3的实施例的基础上,所述步骤S10具体包括:In an optional embodiment, based on the foregoing embodiment of FIG. 3, the step S10 specifically includes:
对待检测图像进行网格分割,将所述待检测图像分成多个N*M(例如,8*8)的图像小网格,N和M为正整数;Dividing the detected image into a mesh, dividing the image to be detected into a plurality of N*M (for example, 8*8) image small meshes, where N and M are positive integers;
对各个图像网格采用预设类型变换函数(例如,DCT(Discrete Cosine Transform,离散余弦变换)变换函数)进行变换,以得到对应的变换网格数据。例如,采用DCT变换函数按照预先确定的一次压缩的量化步长进行变换以得到对应的变换网格数据;Each image grid is transformed by a preset type transform function (for example, a DCT (Discrete Cosine Transform) transform function) to obtain corresponding transform grid data. For example, using a DCT transform function to perform a transform according to a predetermined one-time compressed quantization step to obtain corresponding transform grid data;
对各个图像网格对应的变换网格数据按照预先确定的压缩格式(例如,JPEG)进行一次压缩,以得到对应的网格压缩数据;Performing compression on the transformed mesh data corresponding to each image grid according to a predetermined compression format (for example, JPEG) to obtain corresponding mesh compressed data;
对各个图像网格对应的网格压缩数据进行解压缩,以得到对应的网格解压数据,并对各个图像网格对应的网格解压数据采用预设类型反变换函数(例如,DCT(Discrete Cosine Transform,离散余弦变换)反变换函数)进行反变换,以得到对应的图像块。Decompressing the grid compressed data corresponding to each image grid to obtain corresponding grid decompressed data, and adopting a preset type inverse transform function for the grid decompressed data corresponding to each image grid (for example, DCT (Discrete Cosine) Transform, discrete cosine transform) inverse transform function) performs inverse transform to obtain the corresponding image block.
本实施例中对待检测图像进行网格分割成若干图像小网格,并利用DCT变换函数对图像小网格进行变换得到网格数据,进行压缩及解压处理后,再利用DCT反变换函数进行反变换得到待检测图像对应的多个图像块,便于后续更加精确地对各个图像块进行像素压缩次数分析,且通过将待检测图像分割成若干图像块,根据每一图像块是否存在篡改情况来确定待检测图像的篡改情况,能进一步地提高图像篡改检测的准确性。In this embodiment, the image to be detected is meshed into a plurality of image small meshes, and the image small mesh is transformed by the DCT transform function to obtain the mesh data, and then subjected to compression and decompression processing, and then inversed by the DCT inverse transform function. Transforming a plurality of image blocks corresponding to the image to be detected, so as to facilitate more accurate analysis of the number of times of pixel compression for each image block, and by dividing the image to be detected into several image blocks, determining whether there is tampering according to each image block. The tampering of the image to be detected can further improve the accuracy of image tampering detection.
在一可选的实施例中,所述步骤S20中预先确定的分析算法包括:In an optional embodiment, the predetermined analysis algorithm in the step S20 includes:
将图像块的每个像素x经过一次压缩的条件概率记为p(x|H0),经过二次压缩的条件概率记为p(x|H1),其中,p(x|H1)=pDQ(x;Q1,Q2),p(x|H0)=pNDQ(x;Q2),Q1为预设的一次压缩的量化步长,Q2为预设的二次压缩的量化步长;
The conditional probability that each pixel x of the image block is compressed once is denoted as p(x|H 0 ), and the conditional probability of secondary compression is denoted as p(x|H 1 ), where p(x|H 1 ) =p DQ (x; Q 1 , Q 2 ), p(x|H 0 )=p NDQ (x; Q 2 ), Q 1 is the preset quantization step size of the first compression, and Q 2 is the preset two Secondary compression quantization step size;
计算每个像素x对应的两个条件概率p(x|H1)和p(x|H0),并根据计算的两个条件概率p(x|H1)和p(x|H0)的值,分析每个像素x对应的压缩次数;例如,可计算像素x的似然比率若L(x)>1,则确定该像素x对应的压缩次数为二;若L(x)≤1,则确定该像素x对应的压缩次数为一。Calculate two conditional probabilities p(x|H 1 ) and p(x|H 0 ) corresponding to each pixel x, and according to the calculated two conditional probabilities p(x|H 1 ) and p(x|H 0 ) Value, the number of compressions corresponding to each pixel x is analyzed; for example, the likelihood ratio of pixel x can be calculated If L(x)>1, it is determined that the number of compressions corresponding to the pixel x is two; if L(x)≤1, it is determined that the number of compressions corresponding to the pixel x is one.
若图像块中所有像素对应的压缩次数均为一,则确定该图像块不存在篡改情况,或者,若图像块中有像素对应的压缩次数为二,则确定该图像块存在篡改情况。If the number of compressions corresponding to all the pixels in the image block is one, it is determined that the image block does not have a tampering condition, or if the number of compressions corresponding to the pixel in the image block is two, it is determined that the image block has a tampering condition.
在一种可选的实施方式中,对待检测图像进行预设的压缩和解压处理过程中的预设类型变换函数可以为离散余弦变换DCT变换函数,预设类型反变换函数可以为DCT反变换函数。则图像块的每个像素x经过二次压缩的条件概率其中,x≠0,nDQ(x)为DCT系数的周期函数,图像块的每个像素x经过一次压缩的条件概率其中,p0(v)=nQ(x)*pDQ(x),x≠0,nQ(x)=nQ,0(x)*gQ(x),Q为预设的量化步长,μe为对DCT系数分布的估计误差的均值,为DCT系数分布的估计误差的方差。估计误差的方差越小检测速度越慢但准确率较高,估计误差的均值μe是一个经验值,需要多次尝试才能确定,如可预先指定一个均值变动范围,然后在该范围内不断尝试,选取误差估计最小的那个。In an optional implementation manner, the preset type transform function in the preset compression and decompression process of the image to be detected may be a discrete cosine transform DCT transform function, and the preset type inverse transform function may be a DCT inverse transform function. . Conditional probability that each pixel x of the image block undergoes secondary compression Where x ≠ 0, n DQ (x) is a periodic function of the DCT coefficients, Conditional probability of one compression per pixel x of an image block Where p 0 (v)=n Q (x)*p DQ (x), x≠0, n Q (x)=n Q,0 (x)*g Q (x), Q is the preset quantization step size, and μ e is the mean value of the estimation error of the DCT coefficient distribution. The variance of the estimated error for the DCT coefficient distribution. Estimation of the variance of the error The smaller the detection speed is, the slower the accuracy is. The average value of the estimated error μ e is an empirical value, which requires multiple attempts to determine. If a range of mean value can be specified in advance, then try to make an error estimate within the range. The smallest one.
本实施例中,计算出图像块的每个像素经过一次压缩的条件概率和经过二次压缩的条件概率,并根据每个像素的两个条件概率计算像素的似然比率,根据该似然比率能最大概率地准确地分析出像素对应的压缩次数,以分析出图像块是否存在篡改情况,进而准确地分析出待检测图像是否为篡改图像。In this embodiment, a condition probability of one compression of each pixel of the image block and a conditional probability of secondary compression are calculated, and a likelihood ratio of the pixel is calculated according to two conditional probabilities of each pixel, according to the likelihood ratio. The number of compressions corresponding to the pixel can be accurately and accurately analyzed to analyze whether the image block has tampering condition, and then whether the image to be detected is a tamper image is accurately analyzed.
此外,本发明还提供一种计算机可读存储介质,所述计算机可读存储介质存储有图像篡改检测系统,所述图像篡改检测系统可被至少一个处理器执行,以使所述至少一个处理器执行如上述实施例中的图像篡改检测方法的步骤,该图像篡改检测方法的步骤S10、S20、S30等具体实施过程如上文所述,在此不再赘述。Moreover, the present invention also provides a computer readable storage medium storing an image tamper detecting system, the image tamper detecting system being executable by at least one processor to cause the at least one processor The specific implementation process of the image tampering detection method, such as the steps S10, S20, and S30, is as described above, and is not described here.
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者
装置不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者装置所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者装置中还存在另外的相同要素。It is to be understood that the term "comprises", "comprising", or any other variants thereof is intended to encompass a non-exclusive inclusion, such that a process, method, article, or
The device includes not only those elements, but also other elements not explicitly listed, or elements that are inherent to such a process, method, article, or device. An element that is defined by the phrase "comprising a ..." does not exclude the presence of additional equivalent elements in the process, method, item, or device that comprises the element.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件来实现,但很多情况下前者是更佳的实施方式。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本发明各个实施例所述的方法。Through the description of the above embodiments, those skilled in the art can clearly understand that the foregoing embodiment method can be implemented by means of software plus a necessary general hardware platform, and can also be implemented by hardware, but in many cases, the former is A better implementation. Based on such understanding, the technical solution of the present invention, which is essential or contributes to the prior art, may be embodied in the form of a software product stored in a storage medium (such as ROM/RAM, disk, The optical disc includes a number of instructions for causing a terminal device (which may be a cell phone, a computer, a server, an air conditioner, or a network device, etc.) to perform the methods described in various embodiments of the present invention.
以上参照附图说明了本发明的优选实施例,并非因此局限本发明的权利范围。上述本发明实施例序号仅仅为了描述,不代表实施例的优劣。另外,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。The preferred embodiments of the present invention have been described above with reference to the drawings, and are not intended to limit the scope of the invention. The serial numbers of the embodiments of the present invention are merely for the description, and do not represent the advantages and disadvantages of the embodiments. Additionally, although logical sequences are shown in the flowcharts, in some cases the steps shown or described may be performed in a different order than the ones described herein.
本领域技术人员不脱离本发明的范围和实质,可以有多种变型方案实现本发明,比如作为一个实施例的特征可用于另一实施例而得到又一实施例。凡在运用本发明的技术构思之内所作的任何修改、等同替换和改进,均应在本发明的权利范围之内。
A person skilled in the art can implement the invention in various variants without departing from the scope and spirit of the invention. For example, the features of one embodiment can be used in another embodiment to obtain a further embodiment. Any modifications, equivalent substitutions and improvements made within the technical concept of the invention are intended to be included within the scope of the invention.