PDF rapid brightening method, device, electronic device and storage medium
By segmenting PDF documents and generating mapping conversion tables, the problem of unclear PDF document content and blurred color display is solved, fast and effective enhancement processing is achieved, and color brightness and processing efficiency are improved.
Patent Information
- Application Number
- CN202311234009.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-23
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2043-09-23
AI Technical Summary
Due to scan quality or image file quality issues in PDF documents, the content is not clear enough and the colors are blurred, affecting the user's reading experience.
By reading the PDF document, it is divided into multiple page blocks, the color mean and error mean of each page block are calculated, a mapping conversion table is generated, and the table is used to enhance the page blocks to improve the color brightness.
It achieves fast and effective color enhancement processing of PDF documents, improves color brightness, makes reading more convenient for users, and improves processing speed and efficiency.
Smart Images

Figure SMS_3 
Figure SMS_4 
Figure SMS_22
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of PDF document processing, and in particular to a PDF rapid brightening method, device, electronic device and storage medium. Background Art
[0002] PDF (Portable Document Format) is a widely used format for electronic documents. It has the characteristics of cross-platform compatibility and document consistency. However, the clarity and readability of PDF documents may be affected by many factors. If a PDF document is created by scanning a paper document, the scan quality will directly affect the clarity of the document. Using a low-resolution scan or a low-quality scanner will result in unclear fonts and fuzzy colors in the PDF document. If the PDF document contains images, low-resolution, over-compressed or low-quality image files will result in fuzzy colors in the PDF document, making it difficult for users to read. Summary of the invention
[0003] In view of this, the present application provides a PDF quick brightening method, device, electronic device and storage medium to solve the technical problems of unclear content and fuzzy color display of PDF documents.
[0004] The first aspect of the present application provides a method for quickly brightening a PDF, the method comprising:
[0005] Read PDF pages of a PDF document;
[0006] Segmenting the PDF page to obtain a plurality of PDF page blocks;
[0007] Obtaining a color mean value of each of the PDF page blocks and obtaining a color error mean value of each of the PDF page blocks;
[0008] Generate a corresponding PDF page block mapping conversion table based on the color error mean of the PDF page block;
[0009] The PDF page is enhanced using a plurality of the PDF page block mapping conversion tables.
[0010] In a possible implementation manner, obtaining the color mean value of each PDF page block includes:
[0011] Use the mean filter algorithm to obtain the color mean of each pixel;
[0012] Based on the color mean of each pixel in the PDF page block, the color mean of the PDF page block is calculated.
[0013] In a possible implementation manner, obtaining the color error mean value of each PDF page block includes:
[0014] For each pixel in the PDF page block, a color error value of the pixel is calculated based on a color mean value of the pixel and a color mean value of the PDF page block;
[0015] Based on the color error value of each pixel, a color error mean value of the PDF page block is calculated.
[0016] In a possible implementation manner, generating a corresponding PDF page block mapping conversion table based on the color error mean of the PDF page block includes:
[0017] Based on the color error mean value of the PDF page block and multiple preset index values, a preset index calculation formula is used to calculate a mapping value corresponding to each preset index value;
[0018] Based on the plurality of preset index values and the mapping value corresponding to each of the preset index values, a PDF page block mapping conversion table corresponding to the PDF page block is generated.
[0019] In a possible implementation manner, the preset index calculation formula is:
[0020] Among them, argv is the color error mean of the PDF page block, x is a preset index value, the value range of x is an integer in [0, 255], and table[x] is the mapping value corresponding to x.
[0021] In a possible implementation manner, the using the plurality of PDF page block mapping conversion tables to perform brightening processing on the PDF page includes:
[0022] For each of the PDF page blocks, obtaining a target index value corresponding to the original color value of each pixel in the PDF page block from a PDF page block mapping conversion table corresponding to the PDF page block, and obtaining a target mapping value corresponding to the target index value, and using the target mapping value as a color replacement value for the pixel;
[0023] The pixel points in the PDF page block are enhanced according to the color replacement value.
[0024] In a possible implementation, the PDF pages of the PDF document are read in a streaming manner, and each PDF page block is processed in a parallel manner.
[0025] A second aspect of the present application provides a PDF rapid brightening device, the device comprising:
[0026] A page reading module, used to read PDF pages of a PDF document;
[0027] A page segmentation module, used to segment the PDF page to obtain multiple PDF page blocks;
[0028] A mean value calculation module, used for obtaining a color mean value of each of the PDF page blocks and obtaining a color error mean value of each of the PDF page blocks;
[0029] A mapping generation module is used to generate a corresponding PDF page block mapping conversion table based on the color error mean of the PDF page block; and a brightening processing module uses a plurality of the PDF page block mapping conversion tables to perform brightening processing on the PDF page.
[0030] A third aspect of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the PDF fast brightening method when executing the computer program.
[0031] A fourth aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the PDF fast brightening method when executed by a processor.
[0032] The PDF fast brightening method, device, electronic device and storage medium provided in the embodiments of the present application read the PDF pages of a PDF document and segment the PDF pages to obtain multiple PDF page blocks; obtain the color mean of each of the PDF page blocks and obtain the color error mean of each of the PDF page blocks; generate a corresponding PDF page block mapping conversion table based on the color error mean of the PDF page blocks; finally, use the multiple PDF page block mapping conversion tables to perform brightening processing on the PDF pages, so as to quickly and effectively perform brightening processing on the PDF document, make the colors more vivid, and facilitate user reading. DETAILED DESCRIPTION
[0033] In order to make the objectives, technical solutions and advantages of the present application clearer, the technical solutions in the embodiments of the present application are described.
[0034] The PDF fast brightening method provided by the embodiment of the present invention is executed by an electronic device, and correspondingly, the PDF fast brightening device runs in the electronic device.
[0035] S11, reading PDF pages of the PDF document.
[0036] In a possible implementation, the PDF pages of the PDF document can be read in a streaming manner. The streaming reading of the PDF document is to access each page of the PDF document in sequence, without loading the entire PDF document into the memory at one time. After reading and processing the current PDF page, the next PDF page is read and processed. Using streaming reading of PDF pages can optimize memory usage and loading speed, facilitate subsequent rapid processing of PDF pages, and thus achieve rapid enhancement of PDF documents.
[0037] S12, dividing the PDF page into multiple PDF page blocks.
[0038] In order to make more efficient use of computing resources, each time a PDF page is read, the PDF page is segmented to obtain multiple PDF page blocks. Since the PDF page blocks are relatively independent, the multiple PDF page blocks can be processed in parallel. Parallel processing of multiple PDF page blocks can improve the overall processing speed.
[0039] S13, obtaining a color mean value of each of the PDF page blocks and obtaining a color error mean value of each of the PDF page blocks.
[0040] PDF pages are usually composed of pixels, each of which corresponds to a different color. Since each PDF page block in a PDF document may have different color distributions and characteristics, directly calculating the color mean of the entire PDF page based on the color values of all pixels may ignore these differences and produce inaccurate color mean results, and the amount of calculation and time will also increase significantly. Therefore, in order to accurately enhance the PDF document later, it is necessary to first calculate the color mean of each PDF page block, and then obtain the color error mean of the PDF page block based on the color mean of the PDF page block.
[0041] In a possible implementation manner, obtaining the color mean value of each PDF page block includes:
[0042] Use the mean filter algorithm to obtain the color mean of each pixel;
[0043] Based on the color mean of each pixel in the PDF page block, the color mean of the PDF page block is calculated.
[0044] In the RGB color space, each PDF page block corresponds to three color channels, namely, a red channel, a green channel, and a blue channel.
[0045] For each PDF page block in each color channel, the mean filtering algorithm is used to obtain the color mean of each color channel of each pixel in the PDF page block. Mean filtering is a common image smoothing method that can remove noise and reduce image details. The principle of the mean filtering algorithm is to replace each pixel value in the original image with the mean, that is, for a certain pixel point (x, y) in the original image, select a template, the template is composed of several pixels in the neighborhood of the pixel point (x, y), calculate the pixel mean of all pixels f(x, y) in the template, and then assign the pixel mean to the current pixel point (x, y) as the grayscale g(x, y) at this point, that is m is the total number of pixels in the template including the current pixel. The mean filter algorithm can be used to obtain the color mean of each pixel in each color channel in the PDF page block, and then the color mean of the PDF page block in the corresponding color channel can be calculated based on the color mean of each pixel in each color channel.
[0046] Exemplarily, a filter operator with a size of 3×3 is used to calculate the color mean of the current pixel (5, 5), that is, taking the current pixel as the center, the color values of the surrounding eight pixels (4, 4), (4, 5), (4, 6), (5, 4), (5, 6), (6, 4), (6, 5), and (6, 6) are obtained, and the color mean of these nine pixels is calculated as the color mean of the current pixel (5, 5), that is:
[0047]
[0048] In an optional implementation, multiple pixels in each of the PDF page blocks are processed in a serial manner.
[0049] In a possible implementation manner, obtaining the color error mean value of each PDF page block includes:
[0050] For each pixel in the PDF page block, a color error value of the pixel is calculated based on a color mean value of the pixel and a color mean value of the PDF page block;
[0051] Based on the color error value of each pixel, a color error mean value of the PDF page block is calculated.
[0052] For each pixel in the PDF page block, the difference between the color mean of the pixel and the color mean of the entire PDF page block is calculated to obtain the color error value of the pixel, and then the color error values of all the pixels are added together and divided by the total number of pixels in the PDF page block to obtain the average value of the color error values of the PDF page block. The average value of the color error value is called the color error mean, which can reflect the degree or quality of color deviation of the entire PDF page block. A higher color error mean may indicate a larger color difference, while a lower color error mean indicates a smaller color difference.
[0053] By comparing the color mean of each pixel with the color mean of the entire PDF page block to obtain the color error value of each pixel, and finally calculating the color error mean of the entire PDF page block, the color characteristics of each PDF page block can be described more accurately, and different brightening treatments can be performed on different PDF page blocks.
[0054] S14, generating a corresponding PDF page block mapping conversion table based on the color error mean of the PDF page block.
[0055] After obtaining the color error mean of each PDF page block, a PDF page block mapping conversion table can be generated according to the color error mean of each PDF page block. The PDF page block mapping conversion table can be a data structure that maps input colors to more appropriate output colors to correct the color deviation of the PDF page or improve its visual effect.
[0056] In a possible implementation manner, generating a corresponding PDF page block mapping conversion table based on the color error mean of the PDF page block includes:
[0057] Based on the color error mean value of the PDF page block and multiple preset index values, a preset index calculation formula is used to calculate a mapping value corresponding to each preset index value;
[0058] Based on the plurality of preset index values and the mapping value corresponding to each of the preset index values, a PDF page block mapping conversion table corresponding to the PDF page block is generated.
[0059] For each color channel of each PDF page block, a PDF page block color channel mapping conversion table is generated. The mapping conversion table of each color channel of each PDF page block is generated in the same manner.
[0060] First, create an array of 256 elements and name it table. The preset index calculation formula is as follows:
[0061]
[0062] Among them, argv is the color error mean of the PDF page block, x is the preset index value, the value range of x is an integer in [0, 255], and table[x] is the mapping value corresponding to x.
[0063] It should be noted that A floating point number with 1 decimal place.
[0064] The following takes a PDF page block as an example to describe the process of generating a PDF page block mapping conversion table for the PDF page block on three color channels.
[0065] For the red channel, create an array with 256 elements and name the array table. red ,use Computes the mapping value where argv red is the mean color error of the PDF page block in the red channel. For example, assuming that the mean color error of the PDF page block in the red channel is 30, the mapping values can be calculated in sequence Mapping Values Mapping Values Mapping Values
[0066] For the green channel, create an array with 256 elements and name the array table. green ,use Computes the mapping value where argv green is the mean color error of the PDF page block in the green channel. For example, assuming that the mean color error of the PDF page block in the green channel is 40, the mapping values can be calculated in sequence Mapping Values Mapping Values Mapping Values
[0067] For the blue channel, create an array with 256 elements and name the array table. blue ,use Computes the mapping value where argv blue is the mean color error of the PDF page block in the blue channel. For example, assuming that the mean color error of the PDF page block in the blue channel is 35, the mapping values can be calculated in sequence Mapping Values Mapping Values Mapping Values
[0068] By generating a PDF page block mapping conversion table based on the color error mean for each color channel of each PDF page block, the mapping related functions are automatically adjusted according to the color characteristics of different PDF page blocks. For example, if the color error mean is higher, the brightening processing is more intense, thereby improving the flexibility and adaptability of the brightening processing.
[0069] S15, using the plurality of PDF page block mapping conversion tables to perform brightening processing on the PDF page.
[0070] For each color channel of each pixel in each PDF page block, the PDF page block is enhanced using the PDF page block mapping of the corresponding color channel, thereby completing the enhancement of the PDF page.
[0071] In a possible implementation manner, the using the plurality of PDF page block mapping conversion tables to perform brightening processing on the PDF page includes:
[0072] For each of the PDF page blocks, obtaining a target index value corresponding to the original color value of each pixel in the PDF page block from a PDF page block mapping conversion table corresponding to the PDF page block, and obtaining a target mapping value corresponding to the target index value, and using the target mapping value as a color replacement value for the pixel;
[0073] The pixel points in the PDF page block are enhanced according to the color replacement value.
[0074] Traverse each pixel in the PDF page block, obtain the original color value of each pixel in each color channel respectively, use the original color value as the target index value of the pixel, then search for the target mapping value corresponding to the target index value in the PDF page block mapping conversion table corresponding to the color channel of the PDF page block, and use the target mapping value as the color replacement value of the pixel, write it into the position of the pixel in the PDF page block, so as to realize the brightness enhancement processing of the PDF page block.
[0075] In an optional implementation, the color mean of each pixel in each color channel may be obtained respectively, and the color mean may be used as the target index value of the pixel. Then, the target mapping value corresponding to the target index value may be searched in the PDF page block mapping conversion table corresponding to the color channel of the PDF page block. The target mapping value may be used as the color replacement value of the pixel and written into the position of the pixel in the PDF page block to achieve brightening processing of the PDF page block.
[0076] For example, when the original color value of the green channel of a pixel is 120, the item with an index value of 120 is queried in the PDF page block mapping conversion table corresponding to the green channel, and the table is obtained. green
[120] =130, then the color replacement value of the pixel in the green channel is 130.
[0077] The present application reads the PDF page of the PDF document and divides the PDF page to obtain multiple PDF page blocks; obtains the color mean of each PDF page block and the color error mean of each PDF page block; generates a corresponding PDF page block mapping conversion table based on the color error mean of the PDF page block; and finally uses the multiple PDF page block mapping conversion tables to perform color enhancement processing on the PDF page. The present application enhances the color vividness by performing color enhancement processing on the PDF page, making it more convenient for users to read. Moreover, since the PDF page is divided into multiple PDF page blocks, by processing the PDF page blocks, the speed and efficiency of the color enhancement processing are improved compared to processing the entire PDF page.
[0078] In some embodiments, the PDF fast brightening may include a plurality of function modules composed of computer program segments. The computer program of each program segment in the PDF fast brightening may be stored in a memory of an electronic device and executed by at least one processor to perform the function of PDF fast brightening.
[0079] In this embodiment, the PDF fast brightening can be divided into multiple functional modules according to the functions performed. The functional modules may include: page reading, page segmentation, mean value calculation, mapping generation and brightening processing. The module referred to in the present invention refers to a series of computer program segments that can be executed by at least one processor and can complete fixed functions, which are stored in a memory. In this embodiment, the functions of each module will be described in detail in subsequent embodiments.
[0080] Page reading, used to read PDF pages of a PDF document.
[0081] In a possible implementation, the PDF pages of the PDF document may be read in a streaming manner.
[0082] Streaming reading of PDF documents is to access each page of the PDF document in sequence. It does not need to load the entire PDF document into memory at one time. After reading and processing the current PDF page, the next PDF page is read and processed. Using streaming reading of PDF pages can optimize memory usage and loading speed, facilitate subsequent rapid processing of PDF pages, and thus achieve rapid enhancement of PDF documents.
[0083] Page segmentation is used to segment the PDF page to obtain multiple PDF page blocks.
[0084] In order to make more efficient use of computing resources, each time a PDF page is read, the PDF page is segmented to obtain multiple PDF page blocks. Since the PDF page blocks are relatively independent, the multiple PDF page blocks can be processed in parallel. Parallel processing of multiple PDF page blocks can improve the overall processing speed.
[0085] Mean calculation is used to obtain the color mean of each of the PDF page blocks and the color error mean of each of the PDF page blocks.
[0086] PDF pages are usually composed of pixels, each of which corresponds to a different color. Since each PDF page block in a PDF document may have different color distributions and characteristics, directly calculating the color mean of the entire PDF page based on the color values of all pixels may ignore these differences and produce inaccurate color mean results, and the amount of calculation and time will also increase significantly. Therefore, in order to accurately enhance the PDF document later, it is necessary to first calculate the color mean of each PDF page block, and then obtain the color error mean of the PDF page block based on the color mean of the PDF page block.
[0087] In a possible implementation manner, obtaining the color mean value of each PDF page block includes:
[0088] Use the mean filter algorithm to obtain the color mean of each pixel;
[0089] Based on the color mean of each pixel in the PDF page block, the color mean of the PDF page block is calculated.
[0090] In the RGB color space, each PDF page block corresponds to three color channels, namely, a red channel, a green channel, and a blue channel.
[0091] For each PDF page block in each color channel, the mean filtering algorithm is used to obtain the color mean of each color channel of each pixel in the PDF page block. Mean filtering is a common image smoothing method that can remove noise and reduce image details. The principle of the mean filtering algorithm is to replace each pixel value in the original image with the mean, that is, for a certain pixel point (x, y) in the original image, select a template, the template is composed of several pixels in the neighborhood of the pixel point (x, y), calculate the pixel mean of all pixels f(x, y) in the template, and then assign the pixel mean to the current pixel point (x, y) as the grayscale g(x, y) at this point, that is m is the total number of pixels in the template including the current pixel. The mean filter algorithm can be used to obtain the color mean of each pixel in each color channel in the PDF page block, and then the color mean of the PDF page block in the corresponding color channel can be calculated based on the color mean of each pixel in each color channel.
[0092] Exemplarily, a filter operator with a size of 3×3 is used to calculate the color mean of the current pixel (5, 5), that is, taking the current pixel as the center, the color values of the surrounding eight pixels (4, 4), (4, 5), (4, 6), (5, 4), (5, 6), (6, 4), (6, 5), and (6, 6) are obtained, and the color mean of these nine pixels is calculated as the color mean of the current pixel (5, 5), that is:
[0093]
[0094] In an optional implementation, multiple pixels in each of the PDF page blocks are processed in a serial manner.
[0095] In a possible implementation manner, obtaining the color error mean value of each PDF page block includes:
[0096] For each pixel in the PDF page block, a color error value of the pixel is calculated based on a color mean value of the pixel and a color mean value of the PDF page block;
[0097] Based on the color error value of each pixel, a color error mean value of the PDF page block is calculated.
[0098] For each pixel in the PDF page block, the difference between the color mean of the pixel and the color mean of the entire PDF page block is calculated to obtain the color error value of the pixel, and then the color error values of all the pixels are added together and divided by the total number of pixels in the PDF page block to obtain the average value of the color error values of the PDF page block. The average value of the color error value is called the color error mean, which can reflect the degree or quality of color deviation of the entire PDF page block. A higher color error mean may indicate a larger color difference, while a lower color error mean indicates a smaller color difference.
[0099] By comparing the color mean of each pixel with the color mean of the entire PDF page block to obtain the color error value of each pixel, and finally calculating the color error mean of the entire PDF page block, the color characteristics of each PDF page block can be described more accurately, and different brightening treatments can be performed on different PDF page blocks.
[0100] Mapping generation is used to generate a corresponding PDF page block mapping conversion table based on the color error mean of the PDF page block.
[0101] After obtaining the color error mean of each PDF page block, a PDF page block mapping conversion table can be generated according to the color error mean of each PDF page block. The PDF page block mapping conversion table can be a data structure that maps input colors to more appropriate output colors to correct the color deviation of the PDF page or improve its visual effect.
[0102] In a possible implementation manner, generating a corresponding PDF page block mapping conversion table based on the color error mean of the PDF page block includes:
[0103] Based on the color error mean value of the PDF page block and multiple preset index values, a preset index calculation formula is used to calculate a mapping value corresponding to each preset index value;
[0104] Based on the plurality of preset index values and the mapping value corresponding to each of the preset index values, a PDF page block mapping conversion table corresponding to the PDF page block is generated.
[0105] For each color channel of each PDF page block, a PDF page block color channel mapping conversion table is generated. The mapping conversion table of each color channel of each PDF page block is generated in the same manner.
[0106] First, create an array of 256 elements and name it table. The preset index calculation formula is as follows:
[0107]
[0108] Among them, argv is the color error mean of the PDF page block, x is the preset index value, the value range of x is an integer in [0, 255], and table[x] is the mapping value corresponding to x.
[0109] It should be noted that A floating point number with 1 decimal place.
[0110] The following takes a PDF page block as an example to describe the process of generating a PDF page block mapping conversion table for the PDF page block on three color channels.
[0111] For the red channel, create an array with 256 elements and name the array table. red ,use Computes the mapping value where argv red is the mean color error of the PDF page block in the red channel. For example, assuming that the mean color error of the PDF page block in the red channel is 30, the mapping values can be calculated in sequence Mapping Values Mapping Values Mapping Values
[0112] For the green channel, create an array with 256 elements and name the array table. green ,use Computes the mapping value where argv green is the mean color error of the PDF page block in the green channel. For example, assuming that the mean color error of the PDF page block in the green channel is 40, the mapping values can be calculated in sequence Mapping Values Mapping Values Mapping Values
[0113] For the blue channel, create an array with 256 elements and name the array table. blue ,use Computes the mapping value where argv blue is the mean color error of the PDF page block in the blue channel. For example, assuming that the mean color error of the PDF page block in the blue channel is 35, the mapping values can be calculated in sequence Mapping Values Mapping Values Mapping Values
[0114] By generating a PDF page block mapping conversion table based on the color error mean for each color channel of each PDF page block, the mapping related functions are automatically adjusted according to the color characteristics of different PDF page blocks. For example, if the color error mean is higher, the brightening processing is more intense, thereby improving the flexibility and adaptability of the brightening processing.
[0115] Brightening processing: using a plurality of the PDF page block mapping conversion tables to perform brightening processing on the PDF page.
[0116] For each color channel of each pixel in each PDF page block, the PDF page block is enhanced using the PDF page block mapping of the corresponding color channel, thereby completing the enhancement of the PDF page.
[0117] In a possible implementation manner, the using the plurality of PDF page block mapping conversion tables to perform brightening processing on the PDF page includes:
[0118] For each of the PDF page blocks, obtaining a target index value corresponding to the original color value of each pixel in the PDF page block from a PDF page block mapping conversion table corresponding to the PDF page block, and obtaining a target mapping value corresponding to the target index value, and using the target mapping value as a color replacement value for the pixel;
[0119] The pixel points in the PDF page block are enhanced according to the color replacement value.
[0120] Traverse each pixel in the PDF page block, obtain the original color value of each pixel in each color channel respectively, use the original color value as the target index value of the pixel, then search for the target mapping value corresponding to the target index value in the PDF page block mapping conversion table corresponding to the color channel of the PDF page block, and use the target mapping value as the color replacement value of the pixel, write it into the position of the pixel in the PDF page block, so as to realize the brightness enhancement processing of the PDF page block.
[0121] In an optional implementation, the color mean of each pixel in each color channel may be obtained respectively, and the color mean may be used as the target index value of the pixel. Then, the target mapping value corresponding to the target index value may be searched in the PDF page block mapping conversion table corresponding to the color channel of the PDF page block. The target mapping value may be used as the color replacement value of the pixel and written into the position of the pixel in the PDF page block to achieve brightening processing of the PDF page block.
[0122] For example, when the original color value of the green channel of a pixel is 120, the item with an index value of 120 is queried in the PDF page block mapping conversion table corresponding to the green channel, and the table is obtained. green
[120] =130, then the color replacement value of the pixel in the green channel is 130.
[0123] The present application reads the PDF page of the PDF document and divides the PDF page to obtain multiple PDF page blocks; obtains the color mean of each PDF page block and the color error mean of each PDF page block; generates a corresponding PDF page block mapping conversion table based on the color error mean of the PDF page block; and finally uses the multiple PDF page block mapping conversion tables to perform color enhancement processing on the PDF page. The present application enhances the color vividness by performing color enhancement processing on the PDF page, making it more convenient for users to read. Moreover, since the PDF page is divided into multiple PDF page blocks, by processing the PDF page blocks, the speed and efficiency of the color enhancement processing are improved compared to processing the entire PDF page.
[0124] The embodiment of the present application provides an electronic device. In a preferred embodiment of the present application, the said includes, at least one, at least one communication.
[0125] Those skilled in the art should understand that the structure of the electronic device shown does not constitute a limitation of the embodiments of the present application, and can be either a bus structure or a star structure, and can also include more or less other hardware or software than shown in the figure, or a different component arrangement.
[0126] In some embodiments, the device is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application-specific integrated circuits, programmable gate arrays, digital processors, and embedded devices. The device may also include other electronic devices, including but not limited to any electronic product that can interact with a user through a keyboard, mouse, remote control, touchpad, or voice-controlled device, such as a personal computer, tablet computer, smart phone, digital camera, etc.
[0127] It should be noted that the above is only an example, and other existing or future electronic products that are suitable for this application should also be included in the protection scope of this application and included here by reference.
[0128] In some embodiments, the computer program is stored in the at least one device, and when the at least one device is executed, the computer program implements all or part of the steps in the method for fast PDF enhancement. The at least one device includes a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electronically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, magnetic disk storage, magnetic tape storage, or any other computer-readable medium capable of carrying or storing data.
[0129] In some embodiments, the at least one is the control core (Control Unit) of the computer device 3, which uses various interfaces and lines to connect the various components of the whole, and executes various functions and processes data by running or executing the programs or modules stored in the memory, and calling the data stored in the memory. For example, when the at least one executes the computer program stored in the memory, it implements all or part of the steps of the PDF fast brightening method described in the embodiment of the present application; or implements all or part of the functions of the PDF fast brightening method. The at least one can be composed of an integrated circuit, for example, it can be composed of a single packaged integrated circuit, or it can be composed of multiple integrated circuits with the same function or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips.
[0130] In some embodiments, the at least one communication is configured to achieve connection communication between the at least one and the like. Although not shown, the at least one communication may also include a power supply (such as a battery) for powering each component. Preferably, the power supply may be logically connected to the at least one through a power management device, so that the power management device can manage charging, discharging, and power consumption management. The power supply may also include any components such as one or more DC or AC power supplies, recharging devices, power failure detection circuits, power converters or inverters, power status indicators, etc. The at least one communication may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.
[0131] The above-mentioned integrated unit implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, including a number of instructions for enabling an electronic device (which can be a personal computer, electronic device, or network device, etc.) or a processor to execute part of the method described in each embodiment of the present application.
[0132] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0133] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, and may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0134] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to be used as limitations to the present application. As used in the specification and the appended claims of the present application, the singular expressions "one", "a kind of", "said", "above", "the" and "this" are intended to also include plural expressions, unless there is a clear contrary indication in its context. It should also be understood that the term "and / or" used in the present application refers to any or all possible combinations containing one or more of the listed items. The terms "first" and "second" are only used for descriptive purposes and cannot be understood as implying or implying relative importance or implicitly indicating the number of indicated technical features. Thus, the features defined as "first" and "second" can expressly or implicitly include one or more of the features, and in the description of the embodiments of the present application, unless otherwise stated, the meaning of "multiple" is two or more.
[0135] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A PDF rapid brightening method, characterized in that: The method comprises: Read PDF pages of a PDF document; Segmenting the PDF page to obtain a plurality of PDF page blocks; Using a mean filtering algorithm to obtain the color mean of each pixel; based on the color mean of each pixel in the PDF page block, calculating the color mean of the PDF page block; for each pixel in the PDF page block, calculating the color error value of the pixel based on the color mean of the pixel and the color mean of the PDF page block; based on the color error value of each pixel, calculating the color error mean of the PDF page block; Based on the color error mean value of the PDF page block and multiple preset index values, a preset index calculation formula is used to calculate a mapping value corresponding to each preset index value; based on the multiple preset index values and the mapping value corresponding to each preset index value, a PDF page block mapping conversion table corresponding to the PDF page block is generated, and the preset index calculation formula is: table[x]=(x / 255) argv ×255, where argv is the color error mean of the PDF page block, x is a preset index value, the value range of x is an integer in [0, 255], and table[x] is the mapping value corresponding to x; The PDF page is enhanced using a plurality of the PDF page block mapping conversion tables.
2. The PDF rapid brightening method according to claim 1, characterized in that: The using a plurality of the PDF page block mapping conversion tables to perform brightening processing on the PDF page comprises: For each of the PDF page blocks, obtaining a target index value corresponding to the original color value of each pixel in the PDF page block from a PDF page block mapping conversion table corresponding to the PDF page block, and obtaining a target mapping value corresponding to the target index value, and using the target mapping value as a color replacement value for the pixel; The pixel points in the PDF page block are enhanced according to the color replacement value.
3. The PDF rapid brightening method according to claim 1 or 2, characterized in that: The PDF pages of the PDF document are read in a streaming manner, and each PDF page block is processed in a parallel manner.
4. A PDF rapid brightening device, characterized in that: The device comprises: A page reading module, used to read PDF pages of a PDF document; A page segmentation module, used to segment the PDF page to obtain multiple PDF page blocks; A mean calculation module is used to obtain the color mean of each pixel using a mean filtering algorithm; based on the color mean of each pixel in the PDF page block, the color mean of the PDF page block is calculated; for each pixel in the PDF page block, the color error value of the pixel is calculated based on the color mean of the pixel and the color mean of the PDF page block; based on the color error value of each pixel, the color error mean of the PDF page block is calculated; A mapping generation module is used to calculate the mapping value corresponding to each preset index value based on the color error mean value of the PDF page block and multiple preset index values using a preset index calculation formula; based on the multiple preset index values and the mapping value corresponding to each preset index value, generate a PDF page block mapping conversion table corresponding to the PDF page block, wherein the preset index calculation formula is: table[x]=(x / 255) argv ×255, where argv is the color error mean of the PDF page block, x is a preset index value, the value range of x is an integer in [0, 255], and table[x] is the mapping value corresponding to x; A brightening processing module is used to perform brightening processing on the PDF page using a plurality of the PDF page block mapping conversion tables.
5. An electronic device, characterized in that: The invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the PDF fast brightening method as claimed in any one of claims 1 to 3 when executing the computer program.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the PDF fast brightening method according to any one of claims 1 to 3 are implemented.
