[go: up one dir, main page]

CN106604033B - Image coding and logical calculation method and device - Google Patents

Image coding and logical calculation method and device Download PDF

Info

Publication number
CN106604033B
CN106604033B CN201710103806.7A CN201710103806A CN106604033B CN 106604033 B CN106604033 B CN 106604033B CN 201710103806 A CN201710103806 A CN 201710103806A CN 106604033 B CN106604033 B CN 106604033B
Authority
CN
China
Prior art keywords
node
code
mono
color
pixel
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN201710103806.7A
Other languages
Chinese (zh)
Other versions
CN106604033A (en
Inventor
郭斯羽
宋鹏程
梁梦霞
温和
滕召胜
孟志强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hunan University
Original Assignee
Hunan University
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 Hunan University filed Critical Hunan University
Priority to CN201710103806.7A priority Critical patent/CN106604033B/en
Publication of CN106604033A publication Critical patent/CN106604033A/en
Application granted granted Critical
Publication of CN106604033B publication Critical patent/CN106604033B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/42Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by implementation details or hardware specially adapted for video compression or decompression, e.g. dedicated software implementation
    • H04N19/423Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by implementation details or hardware specially adapted for video compression or decompression, e.g. dedicated software implementation characterised by memory arrangements
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/42Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by implementation details or hardware specially adapted for video compression or decompression, e.g. dedicated software implementation
    • H04N19/436Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by implementation details or hardware specially adapted for video compression or decompression, e.g. dedicated software implementation using parallelised computational arrangements

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Computing Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

本发明涉及图像处理技术领域,提供一种图像编码与逻辑运算方法及装置,首先将多幅二值图像分别扩充为多幅正方形二值图像;其次根据每幅所述正方形二值图像中节点的节点编码q和像素编码r,生成每幅所述正方形二值图像的截断四叉树编码;然后对截断四叉树编码进行逻辑运算,得到结果编码序列;最后根据所述结果编码序列解码得到2N×2N的扩充后的二值图像,截取扩充后的二值图像所扩充的子图像,得到结果二值图像。这样便能够获得空间开销足够小的二值图像编码,同时在进行二值图像的逻辑运算时,速度也更快。

The present invention relates to the technical field of image processing, and provides an image encoding and logical operation method and device, firstly, multiple binary images are respectively expanded into multiple square binary images; secondly, according to the nodes in each of the square binary images, Node code q and pixel code r generate a truncated quadtree code for each square binary image; then perform logical operations on the truncated quadtree code to obtain a result code sequence; finally decode the result code sequence to obtain 2 An expanded binary image of N ×2 N , and the sub-image expanded by the expanded binary image is intercepted to obtain a resultant binary image. In this way, binary image encoding with sufficiently small space overhead can be obtained, and at the same time, the speed of logical operation of binary images is faster.

Description

图像编码与逻辑运算方法及装置Image coding and logical operation method and device

技术领域technical field

本发明涉及图像处理技术领域,具体而言,涉及一种图像编码与逻辑运算方法及装置。The present invention relates to the technical field of image processing, in particular to an image coding and logical operation method and device.

背景技术Background technique

二值图像的逻辑运算频繁出现在图像压缩和处理以及机器视觉检测中的对象识别和图像理解任务之中。二值图像的逻辑运算常可通过逐像素逻辑操作来便捷地完成,且运行效率和空间开销也可以接受。但是当大量大尺寸的二值图像进行多次逻辑运算时,这种逐像素运算的方法,在时间和空间性能上都存在问题。此外,在很多应用中,二值图像往往以某种压缩的形式被表达,如果采用逐像素逻辑操作方法,则需要将这些压缩形式的二值图像转换为原始像素形式,运算完成后再转换回压缩格式,不但不能充分利用压缩的二值图像数据量更少的优点,还额外增加了表达形式转换的负担。Logical operations on binary images are frequently found in image compression and processing, as well as object recognition and image understanding tasks in machine vision inspection. Logical operations on binary images can often be conveniently completed through pixel-by-pixel logical operations, and the operating efficiency and space overhead are also acceptable. However, when a large number of large-scale binary images are subjected to multiple logical operations, this method of pixel-by-pixel operation has problems in both time and space performance. In addition, in many applications, binary images are often expressed in a compressed form. If the pixel-by-pixel logical operation method is used, it is necessary to convert these compressed binary images into the original pixel form, and then convert back to the original pixel form after the operation is completed. The compressed format not only cannot take full advantage of the advantages of less compressed binary image data, but also increases the burden of expression form conversion.

发明内容Contents of the invention

本发明的目的在于提供一种图像编码与逻辑运算方法,用以改善上述问题。The object of the present invention is to provide an image coding and logical operation method to improve the above problems.

本发明的另一目的在于提供一种图像编码与逻辑运算装置,用以改善上述问题。Another object of the present invention is to provide an image coding and logical operation device to improve the above problems.

为了实现上述目的,本发明实施例采用的技术方案如下:In order to achieve the above object, the technical solution adopted in the embodiment of the present invention is as follows:

本发明提供了一种图像编码与逻辑运算方法,其包括:将多幅二值图像分别扩充为多幅正方形二值图像;根据每幅所述正方形二值图像中节点的节点编码q和像素编码r,生成每幅所述正方形二值图像的截断四叉树编码;对任意两幅大小相同的所述正方形二值图像的截断四叉树编码进行第一逻辑运算,得到结果编码序列;对任意一幅所述正方形二值图像的截断四叉树编码进行第二逻辑运算,得到结果编码序列;根据所述结果编码序列解码得到2N×2N的扩充后的二值图像,截取扩充后的二值图像所扩充的子图像,得到结果二值图像。The present invention provides an image coding and logical operation method, which includes: respectively expanding multiple binary images into multiple square binary images; r, generating the truncated quadtree encoding of each square binary image; performing the first logical operation on the truncated quadtree encoding of any two square binary images of the same size to obtain the resulting encoding sequence; for any A truncated quadtree encoding of the square binary image is subjected to a second logic operation to obtain a result encoding sequence; an expanded binary image of 2 N × 2 N is obtained by decoding the result encoding sequence, and the expanded binary image is intercepted The sub-image augmented by the binary image to obtain the resulting binary image.

本发明还提供了一种图像编码与逻辑运算装置,应用于电子设备,其包括:扩充模块,用于将多幅二值图像分别扩充为多幅正方形二值图像;编码模块,用于根据每幅所述正方形二值图像中节点的节点编码q和像素编码r,生成每幅所述正方形二值图像的截断四叉树编码;第一逻辑运算模块,用于对任意两幅大小相同的所述正方形二值图像的截断四叉树编码进行逻辑运算,得到结果编码序列;第二逻辑运算模块,用于对任意一幅所述正方形二值图像的截断四叉树编码进行第二逻辑运算,得到结果编码序列;解码模块,用于根据所述结果编码序列解码得到2N×2N的扩充后的二值图像,截取扩充后的二值图像所扩充的子图像,得到结果二值图像。The present invention also provides an image coding and logical operation device, which is applied to electronic equipment, and includes: an expansion module, which is used to respectively expand multiple binary images into multiple square binary images; a coding module, which is used for each The node code q and the pixel code r of the nodes in the said square binary image generate the truncated quadtree code of each said square binary image; the first logical operation module is used for any two of the same size all Perform logical operations on the truncated quadtree encoding of the square binary image to obtain a result encoding sequence; the second logical operation module is used to perform a second logical operation on any one of the truncated quadtree encodings of the square binary image, Obtain the resulting coded sequence; the decoding module is used to decode the resulting coded sequence to obtain an expanded binary image of 2 N × 2 N , intercept the expanded sub-image of the expanded binary image, and obtain the resulting binary image.

与现有技术相比,本发明提供的一种图像编码与逻辑运算方法及装置,首先,将多幅二值图像分别扩充为多幅正方形二值图像;其次,根据每幅所述正方形二值图像中节点的节点编码q和像素编码r,生成每幅所述正方形二值图像的截断四叉树编码;再次,对任意两幅大小相同的所述正方形二值图像的截断四叉树编码进行第一逻辑运算,得到结果编码序列;最后,根据所述结果编码序列解码得到2N×2N的扩充后的二值图像,截取扩充后的二值图像所扩充的子图像,得到结果二值图像。与现有技术的二值图像处理相比,本发明通过截断四叉树编码方法,能够获得空间开销足够小的二值图像编码,同时在进行二值图像的逻辑运算时,速度也更快。Compared with the prior art, the present invention provides an image coding and logical operation method and device. Firstly, a plurality of binary images are respectively expanded into a plurality of square binary images; secondly, according to each of the square binary images, The node code q and the pixel code r of the node in the image generate the truncated quadtree coding of each said square binary image; again, carry out the truncated quadtree coding of any two said square binary images of the same size The first logical operation is to obtain the result coding sequence; finally, according to the result coding sequence, the expanded binary image of 2 N × 2 N is obtained by decoding, and the sub-image expanded by the expanded binary image is intercepted to obtain the resulting binary image image. Compared with the binary image processing in the prior art, the present invention can obtain binary image coding with sufficiently small space overhead through the truncated quadtree coding method, and at the same time, the speed of logical operation of the binary image is also faster.

为使本发明的上述目的、特征和优点能更明显易懂,下文特举较佳实施例,并配合所附附图,作详细说明如下。In order to make the above-mentioned objects, features and advantages of the present invention more comprehensible, preferred embodiments will be described in detail below together with the accompanying drawings.

附图说明Description of drawings

为了更清楚地说明本发明实施例的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,应当理解,以下附图仅示出了本发明的某些实施例,因此不应被看作是对范围的限定,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他相关的附图。In order to illustrate the technical solutions of the embodiments of the present invention more clearly, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention, and thus It should be regarded as a limitation on the scope, and those skilled in the art can also obtain other related drawings based on these drawings without creative work.

图1示出了本发明较佳实施例提供的电子设备的方框示意图。Fig. 1 shows a schematic block diagram of an electronic device provided by a preferred embodiment of the present invention.

图2示出了本发明较佳实施例提供的图像编码与逻辑运算方法流程图。Fig. 2 shows a flow chart of an image coding and logical operation method provided by a preferred embodiment of the present invention.

图3为图2示出的步骤S102的子步骤流程图。FIG. 3 is a flow chart of sub-steps of step S102 shown in FIG. 2 .

图4为图2示出的步骤S103的一子步骤流程图。FIG. 4 is a flowchart of a sub-step of step S103 shown in FIG. 2 .

图5为图2示出的步骤S103的另一子步骤流程图。FIG. 5 is a flow chart of another sub-step of step S103 shown in FIG. 2 .

图6为图2示出的步骤S103的又一子步骤流程图。FIG. 6 is a flow chart of another sub-step of step S103 shown in FIG. 2 .

图7为图2示出的步骤S103的又一子步骤流程图。FIG. 7 is a flow chart of another sub-step of step S103 shown in FIG. 2 .

图8为图2示出的步骤S104的子步骤流程图。FIG. 8 is a flowchart of sub-steps of step S104 shown in FIG. 2 .

图9为图4至图7中子步骤S1036的子步骤流程图。FIG. 9 is a flowchart of sub-steps of sub-step S1036 in FIG. 4 to FIG. 7 .

图10为图8示出的子步骤S1042的子步骤流程图。FIG. 10 is a sub-step flowchart of sub-step S1042 shown in FIG. 8 .

图11示出了本发明较佳实施例提供的图像编码与逻辑运算装置的方框示意图。Fig. 11 shows a schematic block diagram of an image coding and logical operation device provided by a preferred embodiment of the present invention.

图标:100-电子设备;101-存储器;102-存储控制器;103-处理器;200-图像编码与逻辑运算装置;201-扩充模块;202-编码模块;203-第一逻辑运算模块;204-第二逻辑运算模块;205-解码模块。Icons: 100-electronic equipment; 101-memory; 102-storage controller; 103-processor; 200-image coding and logic operation device; 201-expansion module; 202-encoding module; 203-first logic operation module; 204 - second logic operation module; 205 - decoding module.

具体实施方式Detailed ways

下面将结合本发明实施例中附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。通常在此处附图中描述和示出的本发明实施例的组件可以以各种不同的配置来布置和设计。因此,以下对在附图中提供的本发明的实施例的详细描述并非旨在限制要求保护的本发明的范围,而是仅仅表示本发明的选定实施例。基于本发明的实施例,本领域技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本发明保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some, not all, embodiments of the present invention. The components of the embodiments of the invention generally described and illustrated in the figures herein may be arranged and designed in a variety of different configurations. Accordingly, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making creative efforts belong to the protection scope of the present invention.

应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步定义和解释。同时,在本发明的描述中,术语“第一”、“第二”等仅用于区分描述,而不能理解为指示或暗示相对重要性。It should be noted that like numerals and letters denote similar items in the following figures, therefore, once an item is defined in one figure, it does not require further definition and explanation in subsequent figures. Meanwhile, in the description of the present invention, the terms "first", "second", etc. are only used to distinguish descriptions, and cannot be understood as indicating or implying relative importance.

图1示出本发明较佳实施例提供的电子设备100的方框示意图。电子设备100优选为计算机,可以包括台式机和个人笔记本电脑。所述电子设备100包括图像编码与逻辑运算装置200、存储器101、存储控制器102、处理器103。Fig. 1 shows a schematic block diagram of an electronic device 100 provided by a preferred embodiment of the present invention. The electronic device 100 is preferably a computer, which may include a desktop computer and a personal notebook computer. The electronic device 100 includes an image coding and logical operation device 200 , a memory 101 , a storage controller 102 , and a processor 103 .

所述存储器101、存储控制器102、处理器103各元件相互之间直接或间接地电性连接,以实现数据的传输或交互。例如,这些元件相互之间可通过一条或多条信号线实现电性连接。所述图像编码与逻辑运算装置200包括至少一个可以软件或固件(firmware)的形式存储于所述存储器101中或固化在所述电子设备100的操作系统(operating system,OS)中的软件功能模块。所述处理器103用于执行存储器101中存储的可执行模块,例如所述图像编码与逻辑运算装置200包括的软件功能模块或计算机程序。The memory 101 , storage controller 102 , and processor 103 are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, these components can be electrically connected to each other through one or more signal lines. The image coding and logical operation device 200 includes at least one software function module that can be stored in the memory 101 in the form of software or firmware (firmware) or solidified in the operating system (operating system, OS) of the electronic device 100 . The processor 103 is configured to execute executable modules stored in the memory 101 , such as software function modules or computer programs included in the image coding and logical operation device 200 .

其中,存储器101可以是,但不限于,随机存取存储器(Random Access Memory,RAM),只读存储器(Read Only Memory,ROM),可编程只读存储器(Programmable Read-OnlyMemory,PROM),可擦除只读存储器(Erasable Programmable Read-Only Memory,EPROM),电可擦除只读存储器(Electric Erasable Programmable Read-Only Memory,EEPROM)等。其中,存储器101用于存储程序,所述处理器103在接收到执行指令后,执行所述程序,本发明任一实施例揭示的流程定义的服务器所执行的方法可以应用于处理器103中,或者由处理器103实现。Wherein, memory 101 can be, but not limited to, random access memory (Random Access Memory, RAM), read-only memory (Read Only Memory, ROM), programmable read-only memory (Programmable Read-OnlyMemory, PROM), erasable In addition to read-only memory (Erasable Programmable Read-Only Memory, EPROM), electrically erasable read-only memory (Electric Erasable Programmable Read-Only Memory, EEPROM), etc. Wherein, the memory 101 is used to store a program, and the processor 103 executes the program after receiving an execution instruction, and the method performed by the process definition server disclosed in any embodiment of the present invention can be applied to the processor 103, Or implemented by the processor 103 .

处理器103可以是一种集成电路芯片,具有信号处理能力。上述的处理器103可以是通用处理器,包括中央处理器(Central Processing Unit,CPU)、网络处理器(NetworkProcessor,NP)、语音处理器以及视频处理器等;还可以是数字信号处理器、专用集成电路、现场可编程门阵列或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。可以实现或者执行本发明实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器103也可以是任何常规的处理器等。The processor 103 may be an integrated circuit chip with signal processing capabilities. Above-mentioned processor 103 can be general-purpose processor, comprises central processing unit (Central Processing Unit, CPU), network processor (NetworkProcessor, NP), speech processor and video processor etc.; Integrated circuits, field programmable gate arrays or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. Various methods, steps and logic block diagrams disclosed in the embodiments of the present invention may be implemented or executed. The general-purpose processor may be a microprocessor, or the processor 103 may be any conventional processor or the like.

第一实施例first embodiment

请参考图2,图2示出了本发明较佳实施例提供的图像编码与逻辑运算方法流程图。图像编码与逻辑运算方法包括以下步骤:Please refer to FIG. 2 . FIG. 2 shows a flowchart of an image coding and logical operation method provided by a preferred embodiment of the present invention. The image coding and logical operation method comprises the following steps:

步骤S101,将多幅二值图像分别扩充为多幅正方形二值图像。Step S101, expand multiple binary images into multiple square binary images respectively.

在本发明实施例中,正方形二值图像的扩充部分用单色填充,黑色白色均可,优选为黑色。In the embodiment of the present invention, the expanded part of the square binary image is filled with a single color, either black or white, preferably black.

步骤S102,根据每幅正方形二值图像中节点的节点编码q和像素编码r,生成每幅正方形二值图像的截断四叉树编码。Step S102, according to the node code q and the pixel code r of the nodes in each square binary image, generate a truncated quadtree code for each square binary image.

请参考图3,步骤S102还包括以下子步骤:Please refer to FIG. 3, step S102 also includes the following sub-steps:

步骤S1021,构建正方形二值图像的四叉树。Step S1021, constructing a quadtree of a square binary image.

在本发明实施例中,四叉树的每个节点均具有深度q.depth,其中,根节点的深度为0,且四叉树中子节点的深度为该子节点对应的父节点的深度加1。In the embodiment of the present invention, each node of the quadtree has a depth of q.depth, wherein the depth of the root node is 0, and the depth of the child node in the quadtree is the depth of the parent node corresponding to the child node plus 1.

步骤S1022,从正方形二值图像的根节点开始,按深度优先的方式遍历四叉树。Step S1022, starting from the root node of the square binary image, traversing the quadtree in a depth-first manner.

步骤S1023,若当前遍历的节点的深度小于或等于第一标准时,则根据第一规则设置该节点的节点编码q的q.mono、q.color和q.depth,并将该节点对应的节点编码q加入预先设置的空的基础节点编码序列,其中,第一标准为正方形二值图像的图层N与截断图层NT之差,截断图层NT是预先设定的。Step S1023, if the depth of the currently traversed node is less than or equal to the first standard, set the q.mono, q.color and q.depth of the node code q of the node according to the first rule, and code the node corresponding to the node q adds a pre-set empty basic node coding sequence, wherein the first criterion is the difference between the layer N of the square binary image and the truncated layer NT , and the truncated layer NT is preset.

在本发明实施例中,第一规则为:对该节点使用1个字节进行编码,其中,字节的最高位表示q.mono、次高位表示q.color、低六位以整型值方式给出该节点的深度q.depth,当该节点对应的子区域为单色区域时,q.mono=TRUE,否则q.mono=FALSE,当q.mono=FALSE时,q.color的取值无作用,当单色区域内所有像素点均为白色时,q.mono=TRUE且q.color=TRUE,当单色区域内所有像素点均为黑色时,q.mono=TRUE且q.color=FALSE。In the embodiment of the present invention, the first rule is: use 1 byte to encode the node, wherein, the highest bit of the byte indicates q.mono, the second highest bit indicates q.color, and the lower six bits are integer values Given the depth q.depth of the node, when the sub-area corresponding to the node is a monochromatic area, q.mono=TRUE, otherwise q.mono=FALSE, when q.mono=FALSE, the value of q.color No effect, when all pixels in the monochrome area are white, q.mono=TRUE and q.color=TRUE, when all pixels in the monochrome area are black, q.mono=TRUE and q.color = FALSE.

步骤S1024,若当前遍历的节点的深度等于第二标准,且节点对应的子区域为单色区域时,则根据第二规则设置该节点的节点编码q的q.mono、q.color和q.depth,并将该节点对应的节点编码q加入基础节点编码序列,且设置该节点对应的子区域的像素编码r,将像素编码r加入预先设置的空的基础像素编码序列,并不再对节点的所有子节点进行遍历,其中,第二标准为N-NT+1。Step S1024, if the depth of the currently traversed node is equal to the second standard, and the sub-area corresponding to the node is a monochromatic area, set the q.mono, q.color and q. of the node code q of the node according to the second rule. depth, and add the node code q corresponding to the node to the basic node code sequence, and set the pixel code r of the sub-region corresponding to the node, add the pixel code r to the preset empty basic pixel code sequence, and no longer modify the node All child nodes of , where the second criterion is NN T +1.

在本发明实施例中,第二规则为:对该节点使用1个字节进行编码,字节的最高位表示q.mono、次高位表示q.color、低六位以整型值方式给出该节点的深度q.depth,置q.mono=TRUE,当单色区域内所有像素点均为白色时,q.color=TRUE,当单色区域内所有像素点均为黑色时,q.color=FALSE。In the embodiment of the present invention, the second rule is: use 1 byte to encode the node, the highest bit of the byte indicates q.mono, the second highest bit indicates q.color, and the lower six bits are given as integer values The depth q.depth of this node, set q.mono=TRUE, when all the pixels in the monochrome area are white, q.color=TRUE, when all the pixels in the monochrome area are black, q.color = FALSE.

在本发明实施例中,像素编码r中的一位对应于该节点对应的子区域的每个像素点,当像素点为白色时,像素编码r中的对应位为1。In the embodiment of the present invention, one bit in the pixel code r corresponds to each pixel in the sub-region corresponding to the node, and when the pixel is white, the corresponding bit in the pixel code r is 1.

步骤S1025,遍历完成后,根据基础节点编码序列和基础像素编码序列得到正方形二值图像的截断四叉树编码。Step S1025, after the traversal is completed, the truncated quadtree coding of the square binary image is obtained according to the basic node coding sequence and the basic pixel coding sequence.

步骤S103,对任意两幅大小相同的正方形二值图像的截断四叉树编码进行第一逻辑运算,得到结果编码序列。Step S103, performing a first logical operation on the truncated quadtree encoding of any two square binary images of the same size to obtain a resulting encoding sequence.

在本发明实施例中,第一逻辑运算包括逻辑与运算、逻辑或运算、逻辑异或运算及集合差运算。In the embodiment of the present invention, the first logical operation includes a logical AND operation, a logical OR operation, a logical exclusive OR operation, and a set difference operation.

请参考图4,当第一逻辑运算为逻辑与运算时,步骤S103还包括以下子步骤:Please refer to FIG. 4, when the first logical operation is a logical AND operation, step S103 also includes the following sub-steps:

步骤S1031,设置任意两幅大小相同的正方形二值图像的截断四叉树编码分别为(Q1,R1)和(Q2,R2),q1为Q1中的第一个节点编码,r1为R1中的第一个像素编码,q2为Q2中的第一个节点编码,r2为R2中的第一个像素编码。Step S1031, set the truncated quadtree codes of any two square binary images of the same size as (Q 1 , R 1 ) and (Q 2 , R 2 ), and q 1 is the first node code in Q 1 , r 1 codes the first pixel in R 1 , q 2 codes the first node in Q 2 , r 2 codes the first pixel in R 2 .

步骤S1032,若q1.mono=FALSE且q2.mono=FALSE,则将q1加入预先设置的空的节点编码序列QRStep S1032, if q 1 .mono=FALSE and q 2 .mono=FALSE, add q 1 to the preset empty node code sequence Q R .

步骤S1033,若q1.mono=TRUE且q1.color=TRUE,则将(Q2,R2)中的当前子树编码加入节点编码序列QR和预先设置的空的像素编码序列RR中,置q1为Q1中的下一个节点编码,否则将q1加入QR,并忽略Q2中的当前子树编码。Step S1033, if q 1 .mono=TRUE and q 1 .color=TRUE, code the current subtree in (Q 2 , R 2 ) into the node coding sequence Q R and the preset empty pixel coding sequence R R , set q 1 as the code of the next node in Q 1 , otherwise add q 1 to Q R , and ignore the code of the current subtree in Q 2 .

步骤S1034,若q2.mono=TRUE且q2.color=TRUE,则将(Q1,R1)中的当前子树编码加入QR和RR中,置q2为Q2中的下一个节点编码,否则将q2加入QR,并忽略Q1中的当前子树编码。Step S1034, if q 2 .mono=TRUE and q 2 .color=TRUE, then code the current subtree in (Q 1 , R 1 ) into Q R and R R , and set q 2 as the next subtree in Q 2 A node encoding, otherwise add q2 to QR and ignore the current subtree encoding in Q1.

步骤S1035,若q1.depth=N-NT+1,则计算r1和r2的位逻辑与,并将结果加入RR,然后设置r1为R1的下一个像素编码和设置r2为R2的下一个像素编码。Step S1035, if q 1 .depth=NN T +1, then calculate the logical AND of r 1 and r 2 , and add the result to R R , then set r 1 as the next pixel code of R 1 and set r 2 as R 2 's next pixel encoding.

步骤S1036,当(Q1,R1)和(Q2,R2)均被遍历完成,则运算结束,(QR,RR)即为逻辑运算得到的结果编码序列。In step S1036, when both (Q 1 , R 1 ) and (Q 2 , R 2 ) have been traversed, the operation ends, and (Q R , R R ) is the coded sequence obtained by the logic operation.

请参考图5,当第一逻辑运算为逻辑或运算时,步骤S103还包括以下子步骤:Please refer to FIG. 5, when the first logical operation is a logical OR operation, step S103 also includes the following sub-steps:

步骤S1031,设置任意两幅大小相同的正方形二值图像的截断四叉树编码分别为(Q1,R1)和(Q2,R2),q1为Q1中的第一个节点编码,r1为R1中的第一个像素编码,q2为Q2中的第一个节点编码,r2为R2中的第一个像素编码。Step S1031, set the truncated quadtree codes of any two square binary images of the same size as (Q 1 , R 1 ) and (Q 2 , R 2 ), and q 1 is the first node code in Q 1 , r 1 codes the first pixel in R 1 , q 2 codes the first node in Q 2 , r 2 codes the first pixel in R 2 .

步骤S1032,若q1.mono=FALSE且q2.mono=FALSE,则将q1加入预先设置的空的节点编码序列QRStep S1032, if q 1 .mono=FALSE and q 2 .mono=FALSE, add q 1 to the preset empty node code sequence Q R .

步骤S1033,若q1.mono=TRUE且q1.color=FALSE,则将(Q2,R2)中的当前子树编码加入所述节点编码序列QR和预先设置的空的像素编码序列RR中,置q1为Q1中的下一个节点编码,否则将q1加入QR,并忽略Q2中的当前子树编码。Step S1033, if q 1 .mono=TRUE and q 1 .color=FALSE, add the current subtree code in (Q 2 , R 2 ) to the node code sequence Q R and the preset empty pixel code sequence In R R , set q 1 as the code of the next node in Q 1 , otherwise add q 1 to Q R , and ignore the code of the current subtree in Q 2 .

步骤S1034,若q2.mono=TRUE且q2.color=FALSE,则将(Q1,R1)中的当前子树编码加入QR和RR中,置q2为Q2中的下一个节点编码,否则将q2加入QR,并忽略Q1中的当前子树编码。Step S1034, if q 2 .mono=TRUE and q 2 .color=FALSE, code the current subtree in (Q 1 , R 1 ) into Q R and R R , and set q 2 as the next subtree in Q 2 A node encoding, otherwise add q2 to QR and ignore the current subtree encoding in Q1.

步骤S1035,若q1.depth=N-NT+1,则计算r1和r2的位逻辑或,并将结果加入RR,然后设置r1为R1的下一个像素编码和设置r2为R2的下一个像素编码。Step S1035, if q 1 .depth=NN T +1, then calculate the logical OR of r 1 and r 2 , and add the result to R R , then set r 1 as the next pixel code of R 1 and set r 2 as R 2 's next pixel encoding.

步骤S1036,当(Q1,R1)和(Q2,R2)均被遍历完成,则运算结束,(QR,RR)即为逻辑运算得到的结果编码序列。In step S1036, when both (Q 1 , R 1 ) and (Q 2 , R 2 ) have been traversed, the operation ends, and (Q R , R R ) is the coded sequence obtained by the logic operation.

请参考图6,当第一逻辑运算为逻辑异或运算时,步骤S103还包括以下子步骤:Please refer to FIG. 6, when the first logical operation is a logical XOR operation, step S103 also includes the following sub-steps:

步骤S1031,设置任意两幅大小相同的正方形二值图像的截断四叉树编码分别为(Q1,R1)和(Q2,R2),q1为Q1中的第一个节点编码,r1为R1中的第一个像素编码,q2为Q2中的第一个节点编码,r2为R2中的第一个像素编码。Step S1031, set the truncated quadtree codes of any two square binary images of the same size as (Q 1 , R 1 ) and (Q 2 , R 2 ), and q 1 is the first node code in Q 1 , r 1 codes the first pixel in R 1 , q 2 codes the first node in Q 2 , r 2 codes the first pixel in R 2 .

步骤S1032,若q1.mono=FALSE且q2.mono=FALSE,则将q1加入预先设置的空的节点编码序列QRStep S1032, if q 1 .mono=FALSE and q 2 .mono=FALSE, add q 1 to the preset empty node code sequence Q R .

步骤S1033,若q1.mono=TRUE且q1.color=TRUE,则将(Q2,R2)中的当前子树的反色编码加入所述节点编码序列QR和预先设置的空的像素编码序列RR中,否则将Q2中的当前子树的编码加入QR和RR中,置q1为Q1中的下一个节点编码。Step S1033, if q 1 .mono=TRUE and q 1 .color=TRUE, add the inverse color coding of the current subtree in (Q 2 , R 2 ) to the node coding sequence Q R and the preset empty In the pixel coding sequence R R , otherwise, the coding of the current subtree in Q 2 is added to Q R and RR , and q 1 is set as the coding of the next node in Q 1 .

步骤S1034,若q2.mono=TRUE且q2.color=TRUE,则将(Q1,R1)中的当前子树的反色编码加入QR和RR中,否则将Q1中的当前子树的编码加入QR和RR中,置q2为Q2中的下一个节点编码。Step S1034, if q 2 .mono=TRUE and q 2 .color=TRUE, then add the inverse color coding of the current subtree in (Q 1 , R 1 ) to Q R and R R , otherwise add the inverse color coding of the current subtree in Q 1 The code of the current subtree is added to Q R and RR , and q 2 is set as the code of the next node in Q 2 .

步骤S1035,若q1.depth=N-NT+1,则计算r1和r2的位逻辑异或,并将结果加入RR,然后设置r1为R1的下一个像素编码和设置r2为R2的下一个像素编码。Step S1035, if q 1 .depth=NN T +1, calculate the logical exclusive OR of r 1 and r 2 , and add the result to R R , then set r 1 as the next pixel code of R 1 and set r 2 Encode the next pixel for R2.

步骤S1036,当(Q1,R1)和(Q2,R2)均被遍历完成,则运算结束,(QR,RR)即为逻辑运算得到的结果编码序列。In step S1036, when both (Q 1 , R 1 ) and (Q 2 , R 2 ) have been traversed, the operation ends, and (Q R , R R ) is the coded sequence obtained by the logic operation.

请参考图7,当第一逻辑运算为集合差运算时,步骤S103还包括以下子步骤:Please refer to FIG. 7, when the first logic operation is a set difference operation, step S103 also includes the following sub-steps:

步骤S1031,设置任意两幅大小相同的正方形二值图像的截断四叉树编码分别为(Q1,R1)和(Q2,R2),q1为Q1中的第一个节点编码,r1为R1中的第一个像素编码,q2为Q2中的第一个节点编码,r2为R2中的第一个像素编码。Step S1031, set the truncated quadtree codes of any two square binary images of the same size as (Q 1 , R 1 ) and (Q 2 , R 2 ), and q 1 is the first node code in Q 1 , r 1 codes the first pixel in R 1 , q 2 codes the first node in Q 2 , r 2 codes the first pixel in R 2 .

步骤S1032,若q1.mono=FALSE且q2.mono=FALSE,则将q1加入预先设置的空的节点编码序列QRStep S1032, if q 1 .mono=FALSE and q 2 .mono=FALSE, add q 1 to the preset empty node code sequence Q R .

步骤S1033,若q1.mono=TRUE且q1.color=TRUE,则将(Q2,R2)中的当前子树的反色编码加入所述节点编码序列QR和预先设置的空的像素编码序列RR中,置q1为Q1中的下一个像素编码,否则将q1加入QR中,并忽略Q2中的当前子树编码。Step S1033, if q 1 .mono=TRUE and q 1 .color=TRUE, add the inverse color coding of the current subtree in (Q 2 , R 2 ) to the node coding sequence Q R and the preset empty In the pixel code sequence R R , set q 1 as the next pixel code in Q 1 , otherwise add q 1 to Q R , and ignore the current subtree code in Q 2 .

步骤S1034,若q2.mono=TRUE且q2.color=TRUE,则忽略Q1中的当前子树编码,将q2.color取反后,将q2加入QR,否则将(Q1,R1)中的当前子树编码加入QR和RR中,置q2为Q2中的下一个像素编码。Step S1034, if q 2 .mono=TRUE and q 2 .color=TRUE, ignore the current subtree code in Q 1 , invert q 2 .color, add q 2 to Q R , otherwise add (Q 1 , R 1 ) the current subtree encoding is added to Q R and R R , and q 2 is set as the next pixel encoding in Q 2 .

步骤S1035,若q1.depth=N-NT+1,则计算r1和r2的集合差,即将r2逐位取反后与r1进行位逻辑与运算,并将结果加入RR,然后设置r1为R1的下一个像素编码和设置r2为R2的下一个像素编码。Step S1035, if q 1 .depth=NN T +1, then calculate the set difference between r 1 and r 2 , that is, perform a logical AND operation with r 1 after bit-by-bit inversion of r 2 , and add the result to R R , then Set r1 to the next pixel code of R1 and set r2 to the next pixel code of R2.

步骤S1036,当(Q1,R1)和(Q2,R2)均被遍历完成,则运算结束,(QR,RR)即为逻辑运算得到的结果编码序列。In step S1036, when both (Q 1 , R 1 ) and (Q 2 , R 2 ) have been traversed, the operation ends, and (Q R , R R ) is the coded sequence obtained by the logic operation.

步骤S104,对任意一幅所述正方形二值图像的截断四叉树编码进行第二逻辑运算,得到结果编码序列。Step S104, performing a second logical operation on the truncated quadtree encoding of any one of the square binary images to obtain a resulting encoding sequence.

请参考图8,步骤S104还包括以下子步骤:Please refer to FIG. 8, step S104 also includes the following sub-steps:

步骤S1041,设置任意一幅正方形二值图像的截断四叉树编码为(Q,R),q为Q中的第一个节点编码,r为R中的第一个像素编码。Step S1041, set the truncated quadtree code of any square binary image as (Q, R), where q is the code of the first node in Q, and r is the code of the first pixel in R.

步骤S1042,将(Q,R)中当前子树的反色编码加入预先设置的空的节点编码序列QR和预先设置的空的像素编码序列RR中。Step S1042, add the inverse color coding of the current subtree in (Q, R) to the preset empty node coding sequence Q R and the preset empty pixel coding sequence R R.

步骤S1043,当(Q,R)被遍历完成,则运算结束,(QR,RR)即为逻辑运算的结果编码序列。Step S1043, when (Q, R) has been traversed, the operation ends, and (Q R , R R ) is the coded sequence of the logical operation result.

请参考图9,图9为图4至图7中示出的通过逻辑运算得到结果编码序列的子步骤流程图中当前子树编码加入结果编码序列的子步骤流程图,以步骤S1036为例,步骤S1036还包括以下子步骤:Please refer to Fig. 9, Fig. 9 is the sub-step flowchart of obtaining the result coding sequence by logical operation shown in Fig. 4 to Fig. 7, and the sub-step flowchart of adding the result coding sequence to the current subtree code, taking step S1036 as an example, Step S1036 also includes the following sub-steps:

步骤S10361,设q为Q1或Q2中的当前节点编码,r为R1或R2中的当前像素编码,置l=q.depth。Step S10361 , set q as the current node code in Q1 or Q2 , r as the current pixel code in R1 or R2, and set l = q.depth .

步骤S10362,若q.depth>l,则将q加入QR,置q为Q中的下一个像素编码。Step S10362, if q.depth>1, then add q to Q R , and set q as the next pixel code in Q.

步骤S10363,若q.mono=FALSE且q.depth=N-NT+1,则将r加入RR,置r为R中的下一个像素编码。Step S10363, if q.mono=FALSE and q.depth=NN T +1, add r to R R and set r as the next pixel code in R.

步骤S10364,若q.depth<l,则遍历结束。Step S10364, if q.depth<1, the traversal ends.

请参考图10,图10为图8中示出的通过逻辑运算得到结果编码序列的子步骤流程图中当前子树的反色编码加入结果编码序列的子步骤流程图,步骤S1042还包括以下子步骤:Please refer to Fig. 10, Fig. 10 obtains the substep flow chart of the substep flow chart of obtaining the result coding sequence by logic operation shown in Fig. 8, and the reverse color code of current subtree adds the substep flow chart of the result coding sequence, step S1042 also includes the following substeps step:

步骤S10421,设q为Q1或Q2或Q中的当前节点编码,r为R1或R2或R中的当前像素编码,置l=q.depth。Step S10421, set q as Q 1 or Q 2 or the current node code in Q, r as R 1 or R 2 or the current pixel code in R, and set l=q.depth.

步骤S10422,若q.depth>l,则将q.color取反后,将q加入QR,置q为Q中的下一个像素编码。Step S10422, if q.depth>1, after inverting q.color, add q to Q R , and set q to be the next pixel code in Q.

步骤S10423,若q.mono=FALSE且q.depth=N-NT+1,则将r按位取反后加入RR,置r为R中的下一个像素编码。Step S10423, if q.mono=FALSE and q.depth=NN T +1, then invert r bit by bit and add R R , and set r as the next pixel code in R.

步骤S10424,若q.depth<l,则遍历结束。Step S10424, if q.depth<1, the traversal ends.

需要说明的是,图6和图7中通过逻辑运算得到结果编码序列的子步骤中将当前子树的反色编码加入结果编码序列,同样采用上述方法步骤,在此不再赘述。It should be noted that in the sub-steps of obtaining the result coded sequence through logical operations in Fig. 6 and Fig. 7 , adding the reverse color code of the current subtree to the result coded sequence also adopts the above-mentioned method steps, which will not be repeated here.

步骤S105,根据结果编码序列解码得到2N×2N的扩充后的二值图像,依据扩充前的多幅二值图像截取扩充后的二值图像所扩充的子图像,得到结果二值图像,其中,结果二值图像与多幅二值图像对应。Step S105, decode according to the resulting coding sequence to obtain an expanded binary image of 2 N × 2 N , intercept the expanded sub-image of the expanded binary image according to multiple binary images before expansion, and obtain the resulting binary image, Wherein, the resulting binary image corresponds to multiple binary images.

请结合参考表1和表2,表1示出了本发明提出的图像编码与逻辑运算方法(记为TQ)与现有的图像编码与逻辑运算方法(记为Q)的运行时间,表2示出了TQ与Q的空间开销,TQ与Q均在一个40幅自然场景图片构成的图像集上进行运算,且每幅图片的大小均为2048×1536,实验结果如下:Please refer to Table 1 and Table 2 in conjunction. Table 1 shows the running time of the image coding and logical operation method (marked as TQ) proposed by the present invention and the existing image coding and logical operation method (marked as Q). Table 2 The space overhead of TQ and Q is shown. Both TQ and Q are calculated on an image set composed of 40 natural scene pictures, and the size of each picture is 2048×1536. The experimental results are as follows:

表1.TQ与Q的运行时间Table 1. Running times of TQ and Q

操作operate TQ平均运行时间(ms)TQ average running time (ms) Q平均运行时间(ms)Q average running time (ms) 由二值图像获取编码Obtain encoding from binary image 17.717.7 13.813.8 逻辑与logic and 8.08.0 2.92.9 逻辑或logical or 9.49.4 3.23.2 逻辑异或XOR 10.810.8 3.53.5 集合差collection difference 9.09.0 3.13.1 逻辑非logical NOT 4.14.1 1.71.7 由编码重构二值图像Reconstruct binary image from encoding 24.624.6 9.69.6

表2.TQ与Q的空间开销Table 2. Space overhead of TQ and Q

TQ的平均编码空间开销(kB)TQ average encoding space overhead (kB) Q的平均编码空间开销(kB)The average encoding space overhead of Q (kB) 569.8569.8 187.2187.2

由表1和表2可知,本发明提出的图像编码与逻辑运算方法在运行速度和空间开销两方面均明显优于现有的图像编码与逻辑运算方法。It can be seen from Table 1 and Table 2 that the image coding and logical operation method proposed by the present invention is obviously superior to the existing image coding and logical operation method in terms of running speed and space overhead.

第二实施例second embodiment

请参考图11,图11示出了本发明较佳实施例提供的图像编码与逻辑运算装置200的方框示意图。图像编码与逻辑运算装置200应用于电子设备100,其包括:扩充模块201、编码模块202、第一逻辑运算模块203、第二逻辑运算模块204以及解码模块205。Please refer to FIG. 11 , which shows a schematic block diagram of an image coding and logical operation device 200 provided by a preferred embodiment of the present invention. The image encoding and logical operation device 200 is applied to the electronic device 100 , and includes: an expansion module 201 , an encoding module 202 , a first logical operation module 203 , a second logical operation module 204 and a decoding module 205 .

扩充模块201,用于将多幅二值图像分别扩充为多幅正方形二值图像。The expansion module 201 is used to expand multiple binary images into multiple square binary images respectively.

在本发明实施例中,扩充模块201可以用于执行步骤S101。In the embodiment of the present invention, the expansion module 201 may be used to execute step S101.

编码模块202,用于根据每幅正方形二值图像中节点的节点编码q和像素编码r,生成每幅正方形二值图像的截断四叉树编码。The encoding module 202 is configured to generate a truncated quadtree encoding of each square binary image according to node code q and pixel code r of nodes in each square binary image.

在本发明实施例中,编码模块202可以用于执行步骤S102。In the embodiment of the present invention, the coding module 202 may be used to execute step S102.

第一逻辑运算模块203,用于对任意两幅大小相同的正方形二值图像的截断四叉树编码进行逻辑运算,得到结果编码序列。The first logical operation module 203 is configured to perform logical operation on the truncated quadtree coding of any two square binary images of the same size to obtain the resulting coding sequence.

在本发明实施例中,第一逻辑运算模块203可以用于执行步骤S103,且可以用于对任意两幅大小相同的正方形二值图像进行逻辑与运算、逻辑或运算、逻辑异或运算以及集合差运算。In the embodiment of the present invention, the first logical operation module 203 can be used to execute step S103, and can be used to perform logical AND operation, logical OR operation, logical exclusive OR operation and set of any two square binary images of the same size difference operation.

第二逻辑运算模块204,用于对任意一幅正方形二值图像的截断四叉树编码进行第二逻辑运算,得到结果编码序列。The second logic operation module 204 is configured to perform a second logic operation on the truncated quadtree encoding of any square binary image to obtain a result encoding sequence.

在本发明实施例中,第二逻辑运算模块204可以用于执行步骤S104,且可以用于对任意一幅正方形二值图像的截断四叉树编码进行逻辑非运算。In the embodiment of the present invention, the second logical operation module 204 may be used to execute step S104, and may be used to perform a logical NOT operation on the truncated quadtree coding of any square binary image.

解码模块205,用于根据结果编码序列解码得到2N×2N的扩充后的二值图像,截取扩充后的二值图像所扩充的子图像,得到结果二值图像。The decoding module 205 is used to decode the resulting coding sequence to obtain a 2 N × 2 N expanded binary image, intercept the expanded sub-image of the expanded binary image, and obtain the resulting binary image.

在本发明实施例中,解码模块205可以用于执行步骤S105。In the embodiment of the present invention, the decoding module 205 may be used to execute step S105.

综上所述,本发明提供的一种图像编码与逻辑运算方法及装置,通过将多幅二值图像分别扩充为多幅正方形二值图像;其次根据每幅所述正方形二值图像中节点的节点编码q和像素编码r,生成每幅所述正方形二值图像的截断四叉树编码;然后对任意两幅大小相同的所述正方形二值图像的截断四叉树编码进行第一逻辑运算,得到结果编码序列;以及对任意一幅所述正方形二值图像的截断四叉树编码进行第二逻辑运算,得到结果编码序列;最后根据所述结果编码序列解码得到2N×2N的扩充后的二值图像,截取扩充后的二值图像所扩充的子图像,得到结果二值图像。这样便能够获得空间开销足够小的二值图像编码,同时在进行二值图像的逻辑运算时,速度也更快。To sum up, the present invention provides a method and device for image coding and logical operation, by respectively expanding multiple binary images into multiple square binary images; Node coding q and pixel coding r, generating the truncated quadtree coding of each square binary image; then performing the first logical operation on the truncated quadtree coding of any two square binary images of the same size, Obtain the result coding sequence; and perform a second logical operation on the truncated quadtree coding of any one of the square binary images to obtain the result coding sequence; finally obtain the expanded 2 N × 2 N according to the result coding sequence The binary image of the expanded binary image is intercepted to obtain the resulting binary image. In this way, binary image encoding with sufficiently small space overhead can be obtained, and at the same time, the speed of logical operation of binary images is faster.

在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,也可以通过其它的方式实现。以上所描述的装置实施例仅仅是示意性的,例如,附图中的流程图和框图显示了根据本发明的多个实施例的装置、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段或代码的一部分,所述模块、程序段或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现方式中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个连续的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或动作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。In the several embodiments provided in this application, it should be understood that the disclosed devices and methods may also be implemented in other ways. The device embodiments described above are only illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the architecture, functions and possible implementations of devices, methods and computer program products according to multiple embodiments of the present invention. operate. In this regard, each block in a flowchart or block diagram may represent a module, program segment, or part of code that includes one or more Executable instructions. It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks in succession may, in fact, be executed substantially concurrently, or they may sometimes be executed in the reverse order, depending upon the functionality involved. It should also be noted that each block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations, can be implemented by a dedicated hardware-based system that performs the specified function or action , or may be implemented by a combination of dedicated hardware and computer instructions.

另外,在本发明各个实施例中的各功能模块可以集成在一起形成一个独立的部分,也可以是各个模块单独存在,也可以两个或两个以上模块集成形成一个独立的部分。In addition, each functional module in each embodiment of the present invention can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

所述功能如果以软件功能模块的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the essence of the technical solution of the present invention or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including Several instructions are used to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program codes. .

需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。It should be noted that in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is a relationship between these entities or operations. There is no such actual relationship or order between them. Furthermore, the term "comprises", "comprises" or any other variation thereof is intended to cover a non-exclusive inclusion such that a process, method, article or apparatus comprising a set of elements includes not only those elements, but also includes elements not expressly listed. other elements of or also include elements inherent in such a process, method, article, or device. Without further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article or apparatus comprising said element.

以上所述仅为本发明的优选实施例而已,并不用于限制本发明,对于本领域的技术人员来说,本发明可以有各种更改和变化。凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步定义和解释。The above descriptions are only preferred embodiments of the present invention, and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and changes. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention shall be included within the protection scope of the present invention. It should be noted that like numerals and letters denote similar items in the following figures, therefore, once an item is defined in one figure, it does not require further definition and explanation in subsequent figures.

Claims (10)

1.一种图像编码与逻辑运算方法,其特征在于,所述方法包括:1. An image coding and logical operation method, characterized in that the method comprises: 将多幅二值图像分别扩充为多幅正方形二值图像;Expand multiple binary images into multiple square binary images respectively; 根据每幅所述正方形二值图像中节点的节点编码q和像素编码r,生成每幅所述正方形二值图像的截断四叉树编码;Generate a truncated quadtree code for each square binary image according to the node code q and the pixel code r of the nodes in each of the square binary images; 对任意两幅大小相同的所述正方形二值图像的截断四叉树编码进行第一逻辑运算,或者,对任意一幅所述正方形二值图像的截断四叉树编码进行第二逻辑运算,得到结果编码序列,其中,所述第一逻辑运算包括逻辑与运算、逻辑或运算、逻辑异或运算及集合差运算,所述第二逻辑运算包括逻辑非运算;Performing the first logical operation on the truncated quadtree encoding of any two square binary images of the same size, or performing the second logical operation on the truncated quadtree encoding of any one of the square binary images, to obtain Result coding sequence, wherein the first logical operation includes logical AND operation, logical OR operation, logical exclusive OR operation and set difference operation, and the second logical operation includes logical NOT operation; 根据所述结果编码序列解码得到2N×2N的扩充后的二值图像,依据扩充前的多幅二值图像截取扩充后的二值图像所扩充的子图像,得到结果二值图像,其中,结果二值图像与多幅二值图像对应;According to the coding sequence of the result, the expanded binary image of 2 N × 2 N is obtained by decoding, and the sub-image expanded by the expanded binary image is intercepted according to the multiple binary images before expansion, and the resulting binary image is obtained, wherein , the resulting binary image corresponds to multiple binary images; 所述根据每幅所述正方形二值图像中节点的节点编码q和像素编码r,生成每幅所述正方形二值图像的截断四叉树编码的步骤,包括:The step of generating the truncated quadtree code of each square binary image according to the node code q and pixel code r of the nodes in each square binary image includes: 构建所述正方形二值图像的四叉树;Construct the quadtree of the square binary image; 从所述正方形二值图像的根节点开始,按深度优先的方式遍历所述四叉树;Starting from the root node of the square binary image, traversing the quadtree in a depth-first manner; 若当前遍历的所述节点的深度小于或等于第一标准时,则根据第一规则设置该节点的节点编码q的q.mono、q.color和q.depth,并将该节点对应的节点编码q加入预先设置的空的基础节点编码序列,其中,所述第一标准为所述正方形二值图像的图层N与截断图层NT之差,所述截断图层NT是预先设定的,第一规则为:对该节点使用1个字节进行编码,其中,字节的最高位表示q.mono、次高位表示q.color、低六位以整型值方式给出该节点的深度q.depth,当该节点对应的子区域为单色区域时,q.mono=TRUE,否则q.mono=FALSE,当q.mono=FALSE时,q.color的取值无作用,当单色区域内所有像素点均为白色时,q.mono=TRUE且q.color=TRUE,当单色区域内所有像素点均为黑色时,q.mono=TRUE且q.color=FALSE;If the depth of the currently traversed node is less than or equal to the first standard, set the q.mono, q.color and q.depth of the node code q of the node according to the first rule, and set the node code q corresponding to the node Adding a preset empty basic node coding sequence, wherein the first standard is the difference between the layer N of the square binary image and the truncated layer N T , and the truncated layer N T is preset , the first rule is: use 1 byte to encode the node, where the highest bit of the byte indicates q.mono, the second highest bit indicates q.color, and the lower six bits give the depth of the node as an integer value q.depth, when the sub-area corresponding to this node is a monochrome area, q.mono=TRUE, otherwise q.mono=FALSE, when q.mono=FALSE, the value of q.color has no effect, when monochrome When all pixels in the area are white, q.mono=TRUE and q.color=TRUE; when all pixels in the monochrome area are black, q.mono=TRUE and q.color=FALSE; 若当前遍历的所述节点的深度等于第二标准时,且所述节点对应的子区域为单色区域,则根据第二规则设置该节点的节点编码q的q.mono、q.color和q.depth,并将该节点对应的节点编码q加入所述基础节点编码序列,且设置所述节点对应的所述子区域的像素编码r,将所述像素编码r加入预先设置的空的基础像素编码序列,并不再对所述节点的所有子节点进行遍历,其中,所述第二标准为N-NT+1,第二规则为:对该节点使用1个字节进行编码,字节的最高位表示q.mono、次高位表示q.color、低六位以整型值方式给出该节点的深度q.depth,置q.mono=TRUE,当单色区域内所有像素点均为白色时,q.color=TRUE,当单色区域内所有像素点均为黑色时,q.color=FALSE;If the depth of the currently traversed node is equal to the second standard, and the sub-area corresponding to the node is a monochrome area, set the q.mono, q.color and q.mono, q.color and q. depth, and add the node code q corresponding to the node to the basic node code sequence, and set the pixel code r of the sub-region corresponding to the node, and add the pixel code r to the preset empty basic pixel code sequence, and no longer traverse all child nodes of the node, wherein, the second standard is NNT +1, and the second rule is: use 1 byte to encode the node, and the highest bit of the byte Indicates q.mono, the second highest bit indicates q.color, and the lower six bits give the depth q.depth of the node in the form of an integer value, set q.mono=TRUE, when all pixels in the monochrome area are white, q.color=TRUE, when all pixels in the monochrome area are black, q.color=FALSE; 遍历完成后,根据所述基础节点编码序列和所述基础像素编码序列得到所述正方形二值图像的截断四叉树编码。After the traversal is completed, the truncated quadtree coding of the square binary image is obtained according to the basic node coding sequence and the basic pixel coding sequence. 2.如权利要求1所述的图像编码与逻辑运算方法,其特征在于,所述四叉树的每个所述节点编码q均包括:q.mono、q.color和q.depth,q.mono表示所述节点编码q所编码的所述节点所对应的所述正方形二值图像中的子区域是否为单色区域,q.color表示所述节点所对应的所述子区域的颜色,q.depth表示所述节点在所述正方形二值图像中的深度,当所述子区域为单色区域时,q.mono=TRUE,否则q.mono=FALSE,当q.mono=TRUE且q.color=TRUE时,所述单色区域内所有像素点均为白色,当q.mono=TRUE且q.color=FALSE时,所述单色区域内所有像素点均为黑色,当q.mono=FALSE时,q.color的取值无作用,所述四叉树的根节点的q.depth=0,且所述四叉树中子节点的深度=其父节点的深度+1;所述四叉树的每个所述像素编码r中的一位对应于所述子区域的每个像素点,当所述像素点为白色时,所述像素编码r中的对应位为1。2. The image coding and logical operation method according to claim 1, wherein each node code q of the quadtree includes: q.mono, q.color and q.depth, q. mono indicates whether the sub-area in the square binary image corresponding to the node coded by the node code q is a monochrome area, q.color indicates the color of the sub-area corresponding to the node, q .depth represents the depth of the node in the square binary image, when the sub-area is a monochromatic area, q.mono=TRUE, otherwise q.mono=FALSE, when q.mono=TRUE and q. When color=TRUE, all pixels in the monochrome area are white; when q.mono=TRUE and q.color=FALSE, all pixels in the monochrome area are black; when q.mono= When FALSE, the value of q.color has no effect, q.depth=0 of the root node of the quadtree, and the depth of the child node in the quadtree=the depth of its parent node+1; One bit in each pixel code r of the fork tree corresponds to each pixel point in the sub-region, and when the pixel point is white, the corresponding bit in the pixel code r is 1. 3.如权利要求2所述的图像编码与逻辑运算方法,其特征在于,所述对任意两幅大小相同的所述正方形二值图像的截断四叉树编码进行第一逻辑运算,得到结果编码序列的步骤,包括:3. The image coding and logical operation method according to claim 2, wherein the first logical operation is carried out to the truncated quadtree coding of any two identically sized square binary images to obtain the resulting code sequence of steps, including: 设置任意两幅大小相同的所述正方形二值图像的截断四叉树编码分别为(Q1,R1)和(Q2,R2),q1为Q1中的第一个节点编码,r1为R1中的第一个像素编码,q2为Q2中的第一个节点编码,r2为R2中的第一个像素编码;Set the truncated quadtree codes of any two square binary images of the same size as (Q 1 , R 1 ) and (Q 2 , R 2 ), respectively, q 1 is the first node code in Q 1 , r 1 codes the first pixel in R 1 , q 2 codes the first node in Q 2 , r 2 codes the first pixel in R 2 ; 若q1.mono=FALSE且q2.mono=FALSE,则将q1加入预先设置的空的节点编码序列QRIf q 1 .mono=FALSE and q 2 .mono=FALSE, then add q 1 to the preset empty node code sequence Q R ; 若q1.mono=TRUE且q1.color=TRUE,则将(Q2,R2)中的当前子树编码加入所述节点编码序列QR和预先设置的空的像素编码序列RR中,置q1为Q1中的下一个节点编码,否则将q1加入QR,并忽略Q2中的当前子树编码;If q 1 .mono=TRUE and q 1 .color=TRUE, add the current subtree code in (Q 2 , R 2 ) into the node code sequence Q R and the preset empty pixel code sequence R R , set q 1 as the next node code in Q 1 , otherwise add q 1 to Q R , and ignore the current subtree code in Q 2 ; 若q2.mono=TRUE且q2.color=TRUE,则将(Q1,R1)中的当前子树编码加入QR和RR中,置q2为Q2中的下一个节点编码,否则将q2加入QR,并忽略Q1中的当前子树编码;If q 2 .mono=TRUE and q 2 .color=TRUE, add the current subtree code in (Q 1 , R 1 ) to Q R and R R , and set q 2 to be the code of the next node in Q 2 , otherwise add q 2 to Q R , and ignore the current subtree encoding in Q 1 ; 若q1.depth=N-NT+1,则计算r1和r2的位逻辑与,并将结果加入RR,然后设置r1为R1的下一个像素编码和设置r2为R2的下一个像素编码;If q 1 .depth=NN T +1, calculate the bit logic AND of r 1 and r 2 and add the result to R R , then set r 1 to the next pixel code of R 1 and set r 2 to the value of R 2 next pixel encoding; 当(Q1,R1)和(Q2,R2)均被遍历完成,则运算结束,(QR,RR)即为逻辑运算得到的结果编码序列。When both (Q 1 , R 1 ) and (Q 2 , R 2 ) have been traversed, the operation ends, and (Q R , R R ) is the result coded sequence obtained by the logical operation. 4.如权利要求2所述的图像编码与逻辑运算方法,其特征在于,所述对任意两幅大小相同的所述正方形二值图像的截断四叉树编码进行第一逻辑运算,得到结果编码序列的步骤,包括:4. The image coding and logical operation method according to claim 2, wherein the first logical operation is carried out to the truncated quadtree coding of any two identically sized square binary images to obtain the resulting code sequence of steps, including: 设置任意两幅大小相同的所述正方形二值图像的截断四叉树编码分别为(Q1,R1)和(Q2,R2),q1为Q1中的第一个节点编码,r1为R1中的第一个像素编码,q2为Q2中的第一个节点编码,r2为R2中的第一个像素编码;Set the truncated quadtree codes of any two square binary images of the same size as (Q 1 , R 1 ) and (Q 2 , R 2 ), respectively, q 1 is the first node code in Q 1 , r 1 codes the first pixel in R 1 , q 2 codes the first node in Q 2 , r 2 codes the first pixel in R 2 ; 若q1.mono=FALSE且q2.mono=FALSE,则将q1加入预先设置的空的节点编码序列QRIf q 1 .mono=FALSE and q 2 .mono=FALSE, then add q 1 to the preset empty node code sequence Q R ; 若q1.mono=TRUE且q1.color=FALSE,则将(Q2,R2)中的当前子树编码加入所述节点编码序列QR和预先设置的空的像素编码序列RR中,置q1为Q1中的下一个节点编码,否则将q1加入QR,并忽略Q2中的当前子树编码;If q 1 .mono=TRUE and q 1 .color=FALSE, add the current subtree code in (Q 2 , R 2 ) into the node code sequence Q R and the preset empty pixel code sequence R R , set q 1 as the next node code in Q 1 , otherwise add q 1 to Q R , and ignore the current subtree code in Q 2 ; 若q2.mono=TRUE且q2.color=FALSE,则将(Q1,R1)中的当前子树编码加入QR和RR中,置q2为Q2中的下一个节点编码,否则将q2加入QR,并忽略Q1中的当前子树编码;If q 2 .mono=TRUE and q 2 .color=FALSE, add the current subtree code in (Q 1 , R 1 ) to Q R and R R , and set q 2 to be the code of the next node in Q 2 , otherwise add q 2 to Q R , and ignore the current subtree encoding in Q 1 ; 若q1.depth=N-NT+1,则计算r1和r2的位逻辑或,并将结果加入RR,然后设置r1为R1的下一个像素编码和设置r2为R2的下一个像素编码;If q 1 .depth=NN T +1, calculate the logical OR of r 1 and r 2 , and add the result to R R , then set r 1 to the next pixel code of R 1 and set r 2 to the value of R 2 next pixel encoding; 当(Q1,R1)和(Q2,R2)均被遍历完成,则运算结束,(QR,RR)即为逻辑运算的结果编码序列。When both (Q 1 , R 1 ) and (Q 2 , R 2 ) are traversed, the operation ends, and (Q R , R R ) is the code sequence of the result of the logic operation. 5.如权利要求2所述的图像编码与逻辑运算方法,其特征在于,所述对任意两幅大小相同的所述正方形二值图像的截断四叉树编码进行第一逻辑运算,得到结果编码序列的步骤,包括:5. The image coding and logical operation method according to claim 2, wherein the first logical operation is carried out to any two truncated quadtree codings of the square binary images having the same size to obtain the resulting code sequence of steps, including: 设置任意两幅大小相同的所述正方形二值图像的截断四叉树编码分别为(Q1,R1)和(Q2,R2),q1为Q1中的第一个节点编码,r1为R1中的第一个像素编码,q2为Q2中的第一个节点编码,r2为R2中的第一个像素编码;Set the truncated quadtree codes of any two square binary images of the same size as (Q 1 , R 1 ) and (Q 2 , R 2 ), respectively, q 1 is the first node code in Q 1 , r 1 codes the first pixel in R 1 , q 2 codes the first node in Q 2 , r 2 codes the first pixel in R 2 ; 若q1.mono=FALSE且q2.mono=FALSE,则将q1加入预先设置的空的节点编码序列QRIf q 1 .mono=FALSE and q 2 .mono=FALSE, then add q 1 to the preset empty node code sequence Q R ; 若q1.mono=TRUE且q1.color=TRUE,则将(Q2,R2)中的当前子树的反色编码加入所述节点编码序列QR和预先设置的空的像素编码序列RR中,否则将Q2中的当前子树的编码加入QR和RR中,置q1为Q1中的下一个节点编码;If q 1 .mono=TRUE and q 1 .color=TRUE, add the inverse color coding of the current subtree in (Q 2 , R 2 ) to the node coding sequence Q R and the preset empty pixel coding sequence In R R , otherwise add the encoding of the current subtree in Q 2 to Q R and R R , and set q 1 to be the next node encoding in Q 1 ; 若q2.mono=TRUE且q2.color=TRUE,则将(Q1,R1)中的当前子树的反色编码加入QR和RR中,否则将Q1中的当前子树的编码加入QR和RR中,置q2为Q2中的下一个节点编码;If q 2 .mono=TRUE and q 2 .color=TRUE, add the inverse color coding of the current subtree in (Q 1 , R 1 ) to Q R and R R , otherwise add the current subtree in Q 1 Add the code of Q R and R R , set q 2 as the code of the next node in Q 2 ; 若q1.depth=N-NT+1,则计算r1和r2的位逻辑异或,并将结果加入RR,然后设置r1为R1的下一个像素编码和设置r2为R2的下一个像素编码;If q 1 .depth=NN T +1, calculate the logical exclusive OR of r 1 and r 2 , and add the result to R R , then set r 1 to the next pixel code of R 1 and set r 2 to R 2 The next pixel encoding of ; 当(Q1,R1)和(Q2,R2)均被遍历完成,则运算结束,(QR,RR)即为逻辑运算的结果编码序列。When both (Q 1 , R 1 ) and (Q 2 , R 2 ) are traversed, the operation ends, and (Q R , R R ) is the code sequence of the result of the logic operation. 6.如权利要求2所述的图像编码与逻辑运算方法,其特征在于,所述对任意两幅大小相同的所述正方形二值图像的截断四叉树编码进行第一逻辑运算,得到结果编码序列的步骤,包括:6. The image coding and logical operation method according to claim 2, wherein the first logical operation is carried out to the truncated quadtree coding of any two square binary images of the same size to obtain the resulting code sequence of steps, including: 设置任意两幅大小相同的所述正方形二值图像的截断四叉树编码分别为(Q1,R1)和(Q2,R2),q1为Q1中的第一个节点编码,r1为R1中的第一个像素编码,q2为Q2中的第一个节点编码,r2为R2中的第一个像素编码;Set the truncated quadtree codes of any two square binary images of the same size as (Q 1 , R 1 ) and (Q 2 , R 2 ), respectively, q 1 is the first node code in Q 1 , r 1 codes the first pixel in R 1 , q 2 codes the first node in Q 2 , r 2 codes the first pixel in R 2 ; 若q1.mono=FALSE且q2.mono=FALSE,则将q1加入预先设置的空的节点编码序列QRIf q 1 .mono=FALSE and q 2 .mono=FALSE, then add q 1 to the preset empty node code sequence Q R ; 若q1.mono=TRUE且q1.color=TRUE,则将(Q2,R2)中的当前子树的反色编码加入所述节点编码序列QR和预先设置的空的像素编码序列RR中,置q1为Q1中的下一个像素编码,否则将q1加入QR中,并忽略Q2中的当前子树编码;If q 1 .mono=TRUE and q 1 .color=TRUE, add the inverse color coding of the current subtree in (Q 2 , R 2 ) to the node coding sequence Q R and the preset empty pixel coding sequence In R R , set q 1 as the next pixel code in Q 1 , otherwise add q 1 to Q R , and ignore the current subtree code in Q 2 ; 若q2.mono=TRUE且q2.color=TRUE,则忽略Q1中的当前子树编码,将q2.color取反后,将q2加入QR,否则将(Q1,R1)中的当前子树编码加入QR和RR中,置q2为Q2中的下一个像素编码;If q 2 .mono=TRUE and q 2 .color=TRUE, then ignore the current subtree code in Q 1 , after inverting q 2 .color, add q 2 to Q R , otherwise add (Q 1 , R 1 ) in the current subtree coding into Q R and RR , set q 2 as the next pixel coding in Q 2 ; 若q1.depth=N-NT+1,则计算r1和r2的集合差,即将r2逐位取反后与r1进行位逻辑与运算,并将结果加入RR,然后设置r1为R1的下一个像素编码和设置r2为R2的下一个像素编码;If q 1 .depth=NN T +1, then calculate the set difference between r 1 and r 2 , that is, perform a logical AND operation with r 1 after bit-by-bit inversion of r 2 , add the result to R R , and then set r 1 Encode the next pixel for R 1 and set r 2 to encode the next pixel for R 2 ; 当(Q1,R1)和(Q2,R2)均被遍历完成,则运算结束,(QR,RR)即为逻辑运算的结果编码序列。When both (Q 1 , R 1 ) and (Q 2 , R 2 ) are traversed, the operation ends, and (Q R , R R ) is the code sequence of the result of the logic operation. 7.如权利要求2所述的图像编码与逻辑运算方法,其特征在于,所述对任意一幅所述正方形二值图像的截断四叉树编码进行第二逻辑运算,得到结果编码序列的步骤,包括:7. image coding and logical operation method as claimed in claim 2, is characterized in that, described carries out the second logical operation to the truncated quadtree coding of any one described square binary image, obtains the step of result coding sequence ,include: 设置任意一幅所述正方形二值图像的截断四叉树编码为(Q,R),q为Q中的第一个节点编码,r为R中的第一个像素编码;The truncated quadtree encoding of any one of the square binary images is set as (Q, R), q is the first node encoding in Q, and r is the first pixel encoding in R; 将(Q,R)中当前子树的反色编码加入预先设置的空的节点编码序列QR和预先设置的空的像素编码序列RR中;Add the reverse color coding of the current subtree in (Q, R) to the preset empty node coding sequence Q R and the preset empty pixel coding sequence R R ; 当(Q,R)被遍历完成,则运算结束,(Q,R)即为逻辑运算的结果编码序列。When (Q, R) is traversed, the operation ends, and (Q, R) is the coded sequence of the result of the logic operation. 8.如权利要求3-6任一项所述的图像编码与逻辑运算方法,其特征在于,所述将(Q1,R1)或(Q2,R2)中的当前子树编码加入QR和RR中的步骤,包括:8. The image coding and logical operation method according to any one of claims 3-6, characterized in that, adding the current subtree coding in (Q 1 , R 1 ) or (Q 2 , R 2 ) Steps in Q R and R R , including: 设q为Q1或Q2中的当前所述节点编码,r为R1或R2中的当前所述像素编码,置l=q.depth;Let q be the current described node code in Q 1 or Q 2 , r be the current described pixel code in R 1 or R 2 , put l=q.depth; 若q.depth>l,则将q加入QR,置q为Q中的下一个像素编码;If q.depth>l, then add q to Q R , and set q to be the next pixel code in Q; 若q.mono=FALSE且q.depth=N-NT+1,则将r加入RR,置r为R中的下一个像素编码;If q.mono=FALSE and q.depth=NN T +1, then add r to R R , and set r to be the next pixel code in R; 若q.depth<l,则遍历结束。If q.depth<l, the traversal ends. 9.如权利要求5-7任一项所述的图像编码与逻辑运算方法,其特征在于,所述将(Q1,R1)或(Q2,R2)或(Q,R)中的当前子树的反色编码加入QR和RR中的步骤,包括:9. The image coding and logical operation method according to any one of claims 5-7, characterized in that, among (Q 1 , R 1 ) or (Q 2 , R 2 ) or (Q, R) The inverse color coding of the current subtree joins the steps in Q R and R R , including: 设q为Q1或Q2或Q中的当前所述节点编码,r为R1或R2或R中的当前所述像素编码,置l=q.depth;Let q be Q 1 or Q 2 or the current described node code in Q, r be R 1 or R 2 or the current described pixel code in R, set l=q.depth; 若q.depth>l,则将q.color取反后,将q加入QR,置q为Q中的下一个像素编码;If q.depth>l, after inverting q.color, add q to Q R , and set q to be the next pixel code in Q; 若q.mono=FALSE且q.depth=N-NT+1,则将r按位取反后加入RR,置r为R中的下一个像素编码;If q.mono=FALSE and q.depth=NN T +1, then invert r bit by bit and add R R , set r as the next pixel code in R; 若q.depth<l,则遍历结束。If q.depth<l, the traversal ends. 10.一种图像编码与逻辑运算装置,其特征在于,应用于电子设备,所述装置包括:10. An image coding and logical operation device, characterized in that it is applied to electronic equipment, and the device includes: 扩充模块,用于将多幅二值图像分别扩充为多幅正方形二值图像;The expansion module is used to expand multiple binary images into multiple square binary images respectively; 编码模块,用于根据每幅所述正方形二值图像中节点的节点编码q和像素编码r,生成每幅所述正方形二值图像的截断四叉树编码;An encoding module, configured to generate a truncated quadtree encoding of each of the square binary images according to the node code q and the pixel code r of the nodes in each of the square binary images; 逻辑运算模块,用于对任意两幅大小相同的所述正方形二值图像的截断四叉树编码进行第一逻辑运算,或者,对任意一幅所述正方形二值图像的截断四叉树编码进行第二逻辑运算,得到结果编码序列,其中,所述第一逻辑运算包括逻辑与运算、逻辑或运算、逻辑异或运算及集合差运算,所述第二逻辑运算包括逻辑非运算;A logical operation module, configured to perform a first logical operation on the truncated quadtree encoding of any two square binary images of the same size, or perform a first logical operation on the truncated quadtree encoding of any one of the square binary images The second logical operation is to obtain the result coded sequence, wherein the first logical operation includes a logical AND operation, a logical OR operation, a logical XOR operation, and a set difference operation, and the second logical operation includes a logical NOT operation; 解码模块,用于根据所述结果编码序列解码得到2N×2N的扩充后的二值图像,依据扩充前的多幅二值图像截取扩充后的二值图像所扩充的子图像,得到结果二值图像,其中,结果二值图像与多幅二值图像对应;The decoding module is used to decode and obtain the expanded binary image of 2 N × 2 N according to the result encoding sequence, intercept the expanded sub-image of the expanded binary image according to the multiple binary images before the expansion, and obtain the result A binary image, wherein the resulting binary image corresponds to multiple binary images; 编码模块执行所述根据每幅所述正方形二值图像中节点的节点编码q和像素编码r,生成每幅所述正方形二值图像的截断四叉树编码的方式,包括:The coding module executes the method of generating the truncated quadtree coding of each square binary image according to the node code q and the pixel code r of the nodes in each square binary image, including: 构建所述正方形二值图像的四叉树;Construct the quadtree of the square binary image; 从所述正方形二值图像的根节点开始,按深度优先的方式遍历所述四叉树;Starting from the root node of the square binary image, traversing the quadtree in a depth-first manner; 若当前遍历的所述节点的深度小于或等于第一标准时,则根据第一规则设置该节点的节点编码q的q.mono、q.color和q.depth,并将该节点对应的节点编码q加入预先设置的空的基础节点编码序列,其中,所述第一标准为所述正方形二值图像的图层N与截断图层NT之差,所述截断图层NT是预先设定的,第一规则为:对该节点使用1个字节进行编码,其中,字节的最高位表示q.mono、次高位表示q.color、低六位以整型值方式给出该节点的深度q.depth,当该节点对应的子区域为单色区域时,q.mono=TRUE,否则q.mono=FALSE,当q.mono=FALSE时,q.color的取值无作用,当单色区域内所有像素点均为白色时,q.mono=TRUE且q.color=TRUE,当单色区域内所有像素点均为黑色时,q.mono=TRUE且q.color=FALSE;If the depth of the currently traversed node is less than or equal to the first standard, set the q.mono, q.color and q.depth of the node code q of the node according to the first rule, and set the node code q corresponding to the node Adding a preset empty basic node coding sequence, wherein the first standard is the difference between the layer N of the square binary image and the truncated layer N T , and the truncated layer N T is preset , the first rule is: use 1 byte to encode the node, where the highest bit of the byte indicates q.mono, the second highest bit indicates q.color, and the lower six bits give the depth of the node as an integer value q.depth, when the sub-area corresponding to this node is a monochrome area, q.mono=TRUE, otherwise q.mono=FALSE, when q.mono=FALSE, the value of q.color has no effect, when monochrome When all pixels in the area are white, q.mono=TRUE and q.color=TRUE; when all pixels in the monochrome area are black, q.mono=TRUE and q.color=FALSE; 若当前遍历的所述节点的深度等于第二标准时,且所述节点对应的子区域为单色区域,则根据第二规则设置该节点的节点编码q的q.mono、q.color和q.depth,并将该节点对应的节点编码q加入所述基础节点编码序列,且设置所述节点对应的所述子区域的像素编码r,将所述像素编码r加入预先设置的空的基础像素编码序列,并不再对所述节点的所有子节点进行遍历,其中,所述第二标准为N-NT+1,第二规则为:对该节点使用1个字节进行编码,字节的最高位表示q.mono、次高位表示q.color、低六位以整型值方式给出该节点的深度q.depth,置q.mono=TRUE,当单色区域内所有像素点均为白色时,q.color=TRUE,当单色区域内所有像素点均为黑色时,q.color=FALSE;If the depth of the currently traversed node is equal to the second standard, and the sub-area corresponding to the node is a monochrome area, set the q.mono, q.color and q.mono, q.color and q. depth, and add the node code q corresponding to the node to the basic node code sequence, and set the pixel code r of the sub-region corresponding to the node, and add the pixel code r to the preset empty basic pixel code sequence, and no longer traverse all child nodes of the node, wherein, the second standard is NNT +1, and the second rule is: use 1 byte to encode the node, and the highest bit of the byte Indicates q.mono, the second highest bit indicates q.color, and the lower six bits give the depth q.depth of the node in the form of an integer value, set q.mono=TRUE, when all pixels in the monochrome area are white, q.color=TRUE, when all pixels in the monochrome area are black, q.color=FALSE; 遍历完成后,根据所述基础节点编码序列和所述基础像素编码序列得到所述正方形二值图像的截断四叉树编码。After the traversal is completed, the truncated quadtree coding of the square binary image is obtained according to the basic node coding sequence and the basic pixel coding sequence.
CN201710103806.7A 2017-02-24 2017-02-24 Image coding and logical calculation method and device Expired - Fee Related CN106604033B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710103806.7A CN106604033B (en) 2017-02-24 2017-02-24 Image coding and logical calculation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710103806.7A CN106604033B (en) 2017-02-24 2017-02-24 Image coding and logical calculation method and device

Publications (2)

Publication Number Publication Date
CN106604033A CN106604033A (en) 2017-04-26
CN106604033B true CN106604033B (en) 2019-09-17

Family

ID=58587970

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710103806.7A Expired - Fee Related CN106604033B (en) 2017-02-24 2017-02-24 Image coding and logical calculation method and device

Country Status (1)

Country Link
CN (1) CN106604033B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110929741A (en) * 2019-11-22 2020-03-27 腾讯科技(深圳)有限公司 Image feature descriptor extraction method, device, equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1256043A (en) * 1997-05-13 2000-06-07 艾利森电话股份有限公司 Lossless image compression with tree coding
CN105046632A (en) * 2015-06-29 2015-11-11 湖南大学 Space-time efficient binary image binary logic operation method
CN105608713A (en) * 2016-01-04 2016-05-25 湖南大学 Quadtree-based binary image coding and high-efficiency logical operation method
WO2016090568A1 (en) * 2014-12-10 2016-06-16 Mediatek Singapore Pte. Ltd. Binary tree block partitioning structure

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1256043A (en) * 1997-05-13 2000-06-07 艾利森电话股份有限公司 Lossless image compression with tree coding
WO2016090568A1 (en) * 2014-12-10 2016-06-16 Mediatek Singapore Pte. Ltd. Binary tree block partitioning structure
CN105046632A (en) * 2015-06-29 2015-11-11 湖南大学 Space-time efficient binary image binary logic operation method
CN105608713A (en) * 2016-01-04 2016-05-25 湖南大学 Quadtree-based binary image coding and high-efficiency logical operation method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
利用四叉树编码的快速二值图像逻辑运算方法;郭斯羽等;《电子测量与仪器学报》;20160615;全文

Also Published As

Publication number Publication date
CN106604033A (en) 2017-04-26

Similar Documents

Publication Publication Date Title
US11711545B2 (en) Arithmetic coding information for parallel octree coding
CN109064399B (en) Image super-resolution reconstruction method and system, computer device and storage medium thereof
KR102512507B1 (en) Techniques for upscaling images generated with undetermined downscaling kernels
CN106604033B (en) Image coding and logical calculation method and device
US20240314293A1 (en) Lossless image compression using block based prediction and optimized context adaptive entropy coding
CN116668691A (en) A picture compression transmission method, device and terminal equipment
CN106303526A (en) Method for encoding images, device and image processing equipment
US20240135594A1 (en) Adaptive geometry filtering for mesh compression
US20230156222A1 (en) Grid-based patch generation for video-based point cloud coding
US20240135593A1 (en) Method and apparatus for uv attributes coding for symmetry mesh
US20240087173A1 (en) Base mesh coding by using surface reflection symmetry
US20230334713A1 (en) On coding of boundary uv2xyz index for mesh compression
CN110941589A (en) Picture exporting method and device, electronic equipment and readable storage medium
WO2016192053A1 (en) Copy information coding method and apparatus, and image processing device
US20230040484A1 (en) Fast patch generation for video based point cloud coding
US20240312065A1 (en) Method and apparatus for dividing partial symmetry mesh
US20240212218A1 (en) Multiple sub-meshes encoding
CN117178294A (en) Grid compression based on atlas sampling using graphs with general topology
WO2016197312A1 (en) Method and apparatus for encoding pixel index and image processing device
Raju et al. Weighted Finite Automata Based Image Compression on Hadoop MapReduce Framework
CN118628867A (en) Method for training point cloud data processing model and related products
CN114972045A (en) An image processing method, apparatus, electronic device and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20190917