Image processing method and device, electronic equipment and medium

文档序号:1447057 发布日期:2020-02-18 浏览:27次 中文

阅读说明:本技术 一种图像处理的方法、装置、电子设备及介质 (Image processing method and device, electronic equipment and medium ) 是由 邓斌 于 2018-07-18 设计创作,主要内容包括:本发明实施例提供了一种图像处理的方法、装置、电子设备及介质,涉及计算机应用技术领域,用以在保证PDF文件中图像的清晰度情况下,控制PDF文件的大小。本申请实施例的方案包括:将便携文档格式PDF文件中的待处理图像的分辨率降低至第一阈值,得到待处理图像对应的压缩图像,从待处理图像中提取待处理图像的差异化信息,差异化信息用于表示待处理图像中除压缩图像之外的像素特征,保存压缩图像和差异化信息,后续在打开PDF文件时,通过压缩图像和差异化信息还原待处理图像。(The embodiment of the invention provides an image processing method, an image processing device, electronic equipment and a medium, relates to the technical field of computer application, and is used for controlling the size of a PDF file under the condition of ensuring the definition of an image in the PDF file. The scheme of the embodiment of the application comprises the following steps: the method comprises the steps of reducing the resolution of an image to be processed in a portable document format PDF file to a first threshold value to obtain a compressed image corresponding to the image to be processed, extracting differential information of the image to be processed from the image to be processed, wherein the differential information is used for representing pixel characteristics of the image to be processed except the compressed image, storing the compressed image and the differential information, and restoring the image to be processed through the compressed image and the differential information when the PDF file is opened subsequently.)

1. A method of image processing, comprising:

reducing the resolution of an image to be processed in a portable document format PDF file to a first threshold value to obtain a compressed image corresponding to the image to be processed;

extracting differentiation information of the image to be processed from the image to be processed, wherein the differentiation information is used for representing pixel characteristics of the image to be processed except the compressed image;

saving the compressed image and the differentiation information;

and when the PDF file is opened, restoring the image to be processed through the compressed image and the differentiation information.

2. The method according to claim 1, wherein the restoring the image to be processed through the compressed image and the feature information when the PDF file is opened comprises:

when the PDF file is opened, acquiring the compressed image and the characteristic information;

and restoring the compressed image and the characteristic information into the image to be processed by adopting an image super-resolution reconstruction technology.

3. The method according to claim 2, wherein before the reducing the resolution of the image to be processed to the first threshold value to obtain the compressed image corresponding to the image to be processed, the method further comprises:

determining the resolution of each image in the PDF file;

and determining the image with the resolution ratio larger than a second threshold value in the PDF file as the image to be processed.

4. The method according to any one of claims 1 to 3, wherein the extracting the difference information of the image to be processed from the image to be processed comprises:

dividing the image to be processed into a specified number of regions;

respectively extracting the differential information of each region in the image to be processed;

and taking a set formed by the differentiation information of each region in the image to be processed as the differentiation information of the image to be processed.

5. An apparatus for image processing, comprising:

the portable document format PDF file processing device comprises a compression module, a processing module and a processing module, wherein the compression module is used for reducing the resolution of an image to be processed in the portable document format PDF file to a first threshold value to obtain a compressed image corresponding to the image to be processed;

the extraction module is used for extracting the differentiation information of the image to be processed from the image to be processed, wherein the differentiation information is used for representing the pixel characteristics of the image to be processed except the compressed image;

the storage module is used for storing the compressed image obtained by the compression module and the differentiation information extracted by the extraction module;

and the restoring module is used for restoring the image to be processed through the compressed image and the differential information when the PDF file is opened.

6. The apparatus of claim 5,

the restoring module is specifically configured to obtain the compressed image and the feature information when the PDF file is opened; and restoring the compressed image and the characteristic information into the image to be processed by adopting an image super-resolution reconstruction technology.

7. The apparatus of claim 6, further comprising a determination module;

the determining module is used for determining the resolution of each image in the PDF file; and determining the image with the resolution ratio larger than a second threshold value in the PDF file as the image to be processed.

8. The apparatus according to any one of claims 5 to 7,

the extraction module is specifically used for dividing the image to be processed into a specified number of areas; respectively extracting the differential information of each region in the image to be processed; and taking a set formed by the differentiation information of each region in the image to be processed as the differentiation information of the image to be processed.

9. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;

a memory for storing a computer program;

a processor for implementing the method steps of any of claims 1 to 4 when executing a program stored in the memory.

10. A computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, which computer program, when being executed by a processor, carries out the method steps of any one of claims 1 to 4.

Technical Field

The present invention relates to the field of computer application technologies, and in particular, to a method and an apparatus for image processing, an electronic device, and a medium.

Background

A Portable Document Format (PDF) is an electronic Document Format, in which an industry-standard compression algorithm is used to a PDF file, so that each character, color, and image of an original Document can be reproduced truly, and the resolution of an image in the PDF file is generally high in order to display the image clearly. It can be seen that the prior art cannot control the size of a PDF file while ensuring the sharpness of an image in the PDF.

Disclosure of Invention

The embodiment of the invention aims to provide an image processing method, which is used for controlling the size of a PDF file under the condition of ensuring the definition of an image in the PDF file. The specific technical scheme is as follows:

in a first aspect, an embodiment of the present invention provides an image processing method, where the method includes:

reducing the resolution of an image to be processed in a portable document format PDF file to a first threshold value to obtain a compressed image corresponding to the image to be processed;

extracting differentiation information of the image to be processed from the image to be processed, wherein the differentiation information is used for representing pixel characteristics of the image to be processed except the compressed image;

saving the compressed image and the differentiation information;

and when the PDF file is opened, restoring the image to be processed through the compressed image and the differentiation information.

In a possible implementation manner, the restoring the to-be-processed image through the compressed image and the feature information when the PDF file is opened includes:

when the PDF file is opened, acquiring the compressed image and the characteristic information;

and restoring the compressed image and the characteristic information into the image to be processed by adopting an image super-resolution reconstruction technology.

In a possible implementation manner, before the reducing the resolution of the image to be processed to the first threshold to obtain the compressed image corresponding to the image to be processed, the method further includes:

determining the resolution of each image in the PDF file;

and determining the image with the resolution ratio larger than a second threshold value in the PDF file as the image to be processed.

In a possible implementation manner, the extracting, from the image to be processed, the difference information of the image to be processed includes:

dividing the image to be processed into a specified number of regions;

respectively extracting the differential information of each region in the image to be processed;

and taking a set formed by the differentiation information of each region in the image to be processed as the differentiation information of the image to be processed.

In a second aspect, an embodiment of the present invention provides an apparatus for image processing, where the method includes:

the portable document format PDF file processing device comprises a compression module, a processing module and a processing module, wherein the compression module is used for reducing the resolution of an image to be processed in the portable document format PDF file to a first threshold value to obtain a compressed image corresponding to the image to be processed;

the extraction module is used for extracting the differentiation information of the image to be processed from the image to be processed, wherein the differentiation information is used for representing the pixel characteristics of the image to be processed except the compressed image;

the storage module is used for storing the compressed image obtained by the compression module and the differentiation information extracted by the extraction module;

and the restoring module is used for restoring the image to be processed through the compressed image and the differential information when the PDF file is opened.

In a possible implementation manner, the restoring module is specifically configured to obtain the compressed image and the feature information when the PDF file is opened; and restoring the compressed image and the characteristic information into the image to be processed by adopting an image super-resolution reconstruction technology.

In one possible implementation, the apparatus further includes a determining module;

the determining module is used for determining the resolution of each image in the PDF file; and determining the image with the resolution ratio larger than a second threshold value in the PDF file as the image to be processed.

In a possible implementation manner, the extraction module is specifically configured to divide the image to be processed into a specified number of regions; respectively extracting the differential information of each region in the image to be processed; and taking a set formed by the differentiation information of each region in the image to be processed as the differentiation information of the image to be processed.

In a third aspect, an embodiment of the present invention further provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor and the communication interface complete communication between the memory and the processor through the communication bus;

a memory for storing a computer program;

a processor adapted to perform the method steps of any of the above first aspects when executing a program stored in the memory.

In a fourth aspect, the present invention further provides a computer-readable storage medium, in which a computer program is stored, and the computer program, when executed by a processor, implements the method steps in any one of the above first aspects.

In a fifth aspect, embodiments of the present invention also provide a computer program product containing instructions, which when run on a computer, cause the computer to perform the method of any one of the first aspect.

In the image processing method, the apparatus, the electronic device, and the medium according to the embodiments of the present invention, when storing the to-be-processed image in the PDF, the compressed image can be obtained by reducing the resolution of the to-be-processed image, and the difference information of the to-be-processed image is extracted, and further, the to-be-processed image does not need to be stored, but only the compressed image and the difference information corresponding to the to-be-processed image need to be stored, and since the size of the compressed image and the difference information corresponding to the to-be-processed image is smaller than that of the to-be-processed image, the size of the PDF file can be reduced by storing the image in the PDF in this way, and in addition, when subsequently opening the PDF file, the to-be-processed image can be restored by compressing the image and the difference image, which is equivalent to the to-be-processed image with higher resolution displayed after opening the PDF, the size of the PDF file is controlled.

Of course, not all of the advantages described above need to be achieved at the same time in the practice of any one product or method of the invention.

Drawings

In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.

Fig. 1 is a flowchart of a method for image processing according to an embodiment of the present invention;

fig. 2 is a schematic structural diagram of an image processing apparatus according to an embodiment of the present invention;

fig. 3 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.

Detailed Description

The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.

In order to control the size of a PDF file while ensuring the sharpness of an image in the PDF file, embodiments of the present invention provide an image processing method that can be executed by an electronic device having a function of processing the PDF file, such as a portable computer, a mobile phone, a tablet computer, and the like.

As shown in fig. 1, the method includes:

s101, reducing the resolution of the image to be processed in the PDF file to a first threshold value to obtain a compressed image corresponding to the image to be processed.

It can be understood that by reducing the resolution of the image to be processed, a compressed image with a smaller size can be obtained, and accordingly, the definition of the compressed image is poorer than that of the image to be processed.

The first threshold value can be preset, and a compressed image obtained by reducing the image to be processed by the first threshold value can meet a certain definition condition.

S102, extracting the difference information of the image to be processed from the image to be processed.

The difference information is used to represent pixel characteristics of the image to be processed except for the compressed image, and it should be noted that the difference information does not include all pixel information of the image to be processed except for the compressed image, but is used to represent pixel characteristics that can reflect the pixel information.

It can be understood that the larger the difference information is, the better the restoring effect of the image to be processed is, and the difference information in the embodiment of the present application is determined by equalizing the restoring effect of the image to be processed and the expected size of the PDF file.

In a possible implementation manner, the method for extracting the difference information of the image to be processed includes:

an image to be processed is divided into a specified number of regions. For example, the image to be processed may be uniformly divided into a plurality of meshes.

Then, the differentiation information of each region is extracted separately.

Optionally, the compressed image may also be divided into a specified number of regions according to the same method, for example, the to-be-processed image and the compressed image are both divided into 9 meshes, when the difference information is extracted, pixels in the first mesh of the to-be-processed image may be identified, then, pixels other than the pixels in the first mesh of the compressed image among the pixels in the first mesh of the to-be-processed image are screened, and further, pixel features of the screened pixels are extracted. The pixel characteristics of each grid are respectively extracted according to the method, namely the pixel characteristics are the differentiation information of each area, and then a set formed by the differentiation information of each area in the image to be processed is used as the differentiation information of the image to be processed.

S103, storing the compressed image and the differentiation information.

Since the difference information does not include all information except the compressed image in the image to be processed, the sizes of the compressed image and the difference information are smaller than the size of the image to be processed.

And S104, when the PDF file is opened, restoring the image to be processed through the compressed image and the differential information.

When the PDF file is opened, the compressed image and the characteristic information of each image to be processed can be obtained from the stored PDF file, and then the compressed image and the characteristic information corresponding to the image to be processed are restored into the image to be processed by adopting an image super-resolution reconstruction technology.

By adopting the image processing method provided by the embodiment of the invention, when the image to be processed in the PDF is stored, the compressed image can be obtained by reducing the resolution of the image to be processed, and the differentiation information of the image to be processed is extracted, further, the image to be processed is not required to be stored, only the compressed image and the differentiation information corresponding to the image to be processed are required to be stored, since the size of the compressed image and the difference information corresponding to the image to be processed is smaller than that of the image to be processed, storing images in a PDF in this manner can reduce the size of the PDF file and, in addition, when the PDF file is subsequently opened, the to-be-processed image can be restored through the compressed image and the differential image, which is equivalent to the to-be-processed image with higher resolution displayed after the PDF file is opened, therefore, the method realizes the control of the size of the PDF file under the condition of ensuring the definition of the image in the PDF file.

In a possible implementation manner, all images in the PDF file need not be processed by the processing flow shown in fig. 1, before the flow shown in fig. 1 is executed, to-be-processed images in the PDF file may be screened out, specifically, the resolution of each image in the PDF file may be determined, and then, an image with the resolution greater than the second threshold in the PDF file is determined to be a to-be-processed image.

Wherein the second threshold may be the same as the first threshold, or the second threshold is greater than the first threshold.

By adopting the method, only the image with overlarge resolution in the PDF file can be processed, the image with smaller resolution does not occupy too large storage space, and the image with smaller resolution can not be processed, so that the processing overhead is saved, and the speed of storing the PDF file is ensured.

Corresponding to the above method embodiment, an embodiment of the present invention further provides an apparatus for image processing, as shown in fig. 2, the apparatus including: a compression module 201, an extraction module 202, a saving module 203 and a restoring module 204.

The compression module 201 is configured to reduce the resolution of the image to be processed in the portable document format PDF file to a first threshold, so as to obtain a compressed image corresponding to the image to be processed;

the extraction module 202 is configured to extract differentiation information of the image to be processed from the image to be processed, where the differentiation information is used to represent pixel features of the image to be processed except for a compressed image;

a storage module 203, configured to store the compressed image obtained by the compression module 201 and the difference information extracted by the extraction module 202;

the restoring module 204 is configured to restore the image to be processed by using the compressed image and the difference information when the PDF file is opened.

In another embodiment of the present invention, the restoring module 204 is specifically configured to obtain a compressed image and feature information when a PDF file is opened; and restoring the compressed image and the characteristic information into an image to be processed by adopting an image super-resolution reconstruction technology.

Optionally, in an implementation manner provided in the embodiment of the present invention, the apparatus further includes a determining module 205;

a determining module 205, configured to determine a resolution of each image in the PDF file; and determining the image with the resolution ratio larger than the second threshold value in the PDF file as the image to be processed.

In another embodiment of the present invention, the extracting module 202 is specifically configured to divide the image to be processed into a specified number of regions; respectively extracting the differential information of each region in the image to be processed; and taking a set formed by the difference information of each area in the image to be processed as the difference information of the image to be processed.

The embodiment of the present invention further provides an electronic device, as shown in fig. 3, which includes a processor 301, a communication interface 302, a memory 303, and a communication bus 304, where the processor 301, the communication interface 302, and the memory 303 complete mutual communication through the communication bus 304,

a memory 303 for storing a computer program;

the processor 301, when executing the program stored in the memory 303, implements the following steps:

reducing the resolution of an image to be processed in a portable document format PDF file to a first threshold value to obtain a compressed image corresponding to the image to be processed;

extracting differentiation information of the image to be processed from the image to be processed, wherein the differentiation information is used for representing pixel characteristics of the image to be processed except for the compressed image;

saving the compressed image and the differentiation information;

when the PDF file is opened, the image to be processed is restored through the compressed image and the differential information.

The processor 301 is further configured to implement other steps in the above method flow, and refer to the description in the above method embodiment specifically.

The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.

The communication interface is used for communication between the electronic equipment and other equipment.

The Memory may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.

The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component.

In yet another embodiment provided by the present invention, a computer-readable storage medium is further provided, in which a computer program is stored, and the computer program realizes the steps of any one of the image processing methods described above when executed by a processor.

In a further embodiment provided by the present invention, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform any of the image processing methods of the above embodiments.

In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.

It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.

All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, as for the apparatus embodiment, since it is substantially similar to the method embodiment, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the method embodiment.

The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

11页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种文档编辑的方法、装置、计算机存储介质及终端

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!