A shading optimization method, device and storage medium

By determining the image brightness peak and threshold value and calculating the brightness replacement value, the jagging problem of the image transition color area is solved, and a better deshaping effect is achieved.

CN120259069BActive Publication Date: 2025-08-22BEIJING HANGSHENG TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510671671.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-23
Publication Date
2025-08-22
Estimated Expiration
2045-05-23

AI Technical Summary

Technical Problem

In the prior art, since many fonts and table line edges on the image are transition colors, when using manually determined brightness thresholds to remove the shading and background, the transition colors on the font or table line edges may be deleted at the same time, resulting in serious jagging.

Method used

By determining the brightness peak and threshold of the target image, calculating the brightness replacement value, and using the product of the power index and the brightness threshold to replace the brightness value of the transition color area, avoiding the cliff drop of the brightness value and reducing jagging phenomenon.

Benefits of technology

Effectively remove the shading and background, reduce the jagging phenomenon on the edges of fonts or table lines, and achieve better shading removal effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120259069B_ABST
    Figure CN120259069B_ABST
Patent Text Reader

Abstract

The present application discloses a shading optimization method, device, and storage medium, including: determining the brightness value of a target image and each pixel in the target image, determining a first brightness peak value and a second brightness peak value corresponding to the target image based on the brightness value of each pixel; determining a brightness threshold corresponding to the target image based on the first brightness peak value and the second brightness peak value; determining a brightness value decrease rate corresponding to a transition color region in the target image, wherein the transition color region is used to indicate a region with a smooth transition between multiple colors; calculating a brightness replacement value for each pixel, wherein when the brightness value is greater than or equal to the brightness threshold, the brightness replacement value is equal to the brightness value; otherwise, the brightness replacement value corresponds to the product of a brightness value decrease rate power exponent and a brightness threshold decrease rate power exponent; and performing shading processing on the target image after determining the brightness replacement value for each pixel. The method achieves the technical effect of accurately removing shading and background.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to a shading removal optimization method, device and storage medium. Background Art

[0002] Image shading removal (i.e., removing background textures or interfering patterns) is a common requirement in image processing, particularly in document scanning, cultural relic restoration, and medical imaging. Among existing methods for image shading removal, the most common approach is to manually set a brightness threshold. Pixels with brightness values ​​below the threshold are set to 0, while pixels with brightness values ​​above the threshold are retained. The specific formula is as follows:

[0003]

[0004] in, Represents image pixels i The brightness value of i =1~n. Indicates the brightness threshold.

[0005] While the above correction method can easily remove light shading and backlighting, there are some issues: First, because the brightness of different images is not very consistent, some images are darker and some are lighter. Therefore, when using a manually determined brightness threshold to remove shading and background from different images, the main content of some lighter images may be deleted. Second, because the edges of many fonts and table lines in an image are transitional colors, and the brightness values ​​of transitional colors often change gradually from high to low, when using a fixed brightness threshold to remove shading and background, the transitional colors of the edges of fonts or table lines may also be deleted, resulting in severe jagged edges.

[0006] Publication number CN111915509A is titled "A Method for Identifying the Status of a Protective Platen Based on Image Processing and Shadow Removal Optimization." The method involves converting a color image of the protective platen into a grayscale image, then enhancing the contrast and binarizing the grayscale image to eliminate shadow areas. The Graham algorithm is used to obtain the convex hull of each protective platen switch. The convex hulls are then connected to form rectangles using the minimum enclosing rectangle principle to determine the rectangular area. A threshold is set for the rectangular area. If the rectangular area exceeds the threshold, the switch is considered "out," otherwise, it is "in."

[0007] Publication number CN119762404A, entitled "Document Image Shadow Removal Method, Apparatus, Computer Device, and Storage Medium." The method includes: using image processing techniques to adjust the contrast of a document shadow image to be processed, obtaining a contrast heat map that highlights shadow areas; employing a multi-scale shadow flow matching framework to evenly divide the shadow removal process of the document shadow image into K stages representing different shadow scales; within each stage, using a flow matching model to learn the conditional probability path between the data and noise in the current stage, and performing shadow removal on the current stage based on the conditional probability path; based on the shadow removal results of the current stage, using a next-scale prediction mechanism to predict the shadow scale of the next stage, and using the contrast heat map to guide shadow removal in the next stage.

[0008] In view of the technical problem in the above-mentioned prior art that the colors of many fonts and table line edges on the image are transition colors, when using an artificially determined brightness threshold to remove the shading and background, the transition colors of the font or table line edges may be deleted at the same time, resulting in serious jagged edges of the font or table line. No effective solution has been proposed yet. Summary of the Invention

[0009] The embodiments of the present disclosure provide a shading removal optimization method, device and storage medium to at least solve the technical problem in the prior art that, since the colors of many fonts and table line edges on an image are transition colors, when using an artificially determined brightness threshold to remove shading and background, the transition colors of the font or table line edges may be deleted at the same time, resulting in severe jagged edges of the font or table lines.

[0010] According to one aspect of an embodiment of the present disclosure, a shading optimization method is provided, comprising: determining a target image and brightness values ​​of each pixel in the target image, and determining a first brightness peak value and a second brightness peak value corresponding to the target image based on the brightness values ​​of each pixel; determining a brightness threshold corresponding to the target image based on the first brightness peak value and the second brightness peak value; determining a brightness value decrease rate corresponding to a transition color area in the target image, wherein the transition color area is used to indicate an area with smooth transition between multiple colors; calculating a brightness replacement value for each pixel, wherein when the brightness value is greater than or equal to the brightness threshold, the brightness replacement value is equal to the brightness value, otherwise, the brightness replacement value corresponds to the product of a brightness value decrease rate power exponent and a brightness threshold decrease rate power exponent; and performing shading removal on the target image when the brightness replacement value of each pixel is determined.

[0011] According to another aspect of an embodiment of the present disclosure, a storage medium is further provided, the storage medium including a stored program, wherein when the program is run, a processor executes any one of the above methods.

[0012] According to another aspect of an embodiment of the present disclosure, a shading optimization device is also provided, including: a brightness peak determination module, used to determine the brightness values ​​of a target image and each pixel in the target image, and determine a first brightness peak and a second brightness peak corresponding to the target image based on the brightness values ​​of each pixel; a brightness threshold determination module, used to determine the brightness threshold corresponding to the target image based on the first brightness peak and the second brightness peak; a brightness value decrease rate determination module, used to determine the brightness value decrease rate corresponding to a transition color area in the target image, wherein the transition color area is used to indicate an area with smooth transition between multiple colors; a brightness replacement value determination module, used to calculate the brightness replacement value of each pixel, wherein when the brightness value is greater than or equal to the brightness threshold, the brightness replacement value is equal to the brightness value, otherwise, the brightness replacement value corresponds to the product of the decrease rate power exponent of the brightness value and the decrease rate power exponent of the brightness threshold; and a shading processing module, used to perform shading processing on the target image when the brightness replacement value of each pixel is determined.

[0013] According to another aspect of an embodiment of the present disclosure, a shading optimization device is also provided, including: a processor; and a memory connected to the processor, for providing the processor with instructions for processing the following processing steps: determining the brightness values ​​of a target image and each pixel in the target image, and determining a first brightness peak value and a second brightness peak value corresponding to the target image based on the brightness values ​​of each pixel; determining a brightness threshold corresponding to the target image based on the first brightness peak value and the second brightness peak value; determining a brightness value decrease rate corresponding to a transition color area in the target image, wherein the transition color area is used to indicate an area with smooth transition between multiple colors; calculating a brightness replacement value for each pixel, wherein when the brightness value is greater than or equal to the brightness threshold, the brightness replacement value is equal to the brightness value, otherwise, the brightness replacement value corresponds to the product of a brightness value decrease rate power exponent and a brightness threshold decrease rate power exponent; and performing shading removal processing on the target image when the brightness replacement value of each pixel is determined.

[0014] The present application provides a method for optimizing shading removal. First, the processor determines the target image and the brightness value of each pixel in the target image, and determines the first brightness peak value and the second brightness peak value corresponding to the target image based on the brightness value of each pixel. Then, the processor determines the brightness threshold corresponding to the target image based on the first brightness peak value and the second brightness peak value. Further, the processor determines the brightness value decrease rate corresponding to the transition color area in the target image. Thereafter, the processor calculates the brightness replacement value of each pixel, and determines the brightness replacement value as the brightness value when the brightness value is greater than or equal to the brightness threshold; when the brightness value is less than the brightness threshold, the brightness replacement value corresponds to the product of the brightness value decrease rate power exponent and the brightness threshold decrease rate power exponent. Finally, the processor performs shading removal on the target image after determining the brightness replacement value of each pixel.

[0015] With reference to the above-described contents, it can be seen that since the present application does not simply determine the brightness replacement value to be 0 or the corresponding brightness value based on an artificially fixed brightness threshold, and remove the shading and background of the transition color area, but determines the brightness replacement value as the brightness value or the brightness value corresponding to the product of the power exponent of the brightness value's decreasing rate and the power exponent of the brightness threshold when the brightness threshold is determined, when removing the shading and background of the transition color area based on the above-mentioned method, the jagged phenomenon of the table or text caused by the cliff drop of the data can be slowed down, thereby achieving a better shading removal effect and avoiding the technical effect of the jagged phenomenon.

[0016] Furthermore, the brightness threshold in this application is not manually set. Instead, after determining the first and second brightness peaks, the brightness threshold is determined based on the characteristics represented by the first brightness peak (the number of brightness values ​​corresponding to the shading and background) and the characteristics represented by the second brightness peak (the number of brightness values ​​corresponding to the main content). This brightness threshold maximizes the retention of pixels corresponding to the second brightness peak and minimizes the removal of pixels corresponding to the first brightness peak. This achieves the technical effect of accurately removing shading and background.

[0017] This solves the technical problem in the prior art that, since the colors of many fonts and table line edges on the image are transition colors, when using an artificially determined brightness threshold to remove the shading and background, the transition colors of the font or table edges may be deleted at the same time, resulting in serious jagged edges on the font or table edges. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The drawings described herein are used to provide a further understanding of the present disclosure and constitute a part of this application. The illustrative embodiments of the present disclosure and their descriptions are used to explain the present disclosure and do not constitute an improper limitation of the present disclosure. In the drawings:

[0019] Figure 1 is a hardware structure block diagram of a computing device for implementing the method according to embodiment 1 of the present application;

[0020] Figure 2 is a schematic diagram of the shading removal optimization system according to Example 1 of the present application;

[0021] Figure 3 is a flow chart of the shading optimization method according to Example 1 of the present application;

[0022] Figure 4A is a schematic diagram of a target image to be processed according to Example 1 of the present application;

[0023] Figure 4B is a schematic diagram of an image generated after processing a target image based on a traditional shading removal algorithm according to Example 1 of the present application;

[0024] Figure 4C is a schematic diagram of an image generated after processing a target image based on the shading removal optimization algorithm described in Example 1 of the present application;

[0025] Figure 5A According to the embodiment 1 of the present application Figure 4A Corresponding partial enlarged image;

[0026] Figure 5B According to the embodiment 1 of the present application Figure 4B Corresponding partial enlarged image;

[0027] Figure 5C According to the embodiment 1 of the present application Figure 4C Corresponding partial enlarged image;

[0028] Figure 6 is a brightness peak image of the target image according to Example 1 of the present application;

[0029] Figure 7 is a schematic diagram of the shading optimization device according to Example 2 of the present application; and

[0030] Figure 8 This is a schematic diagram of the shading optimization device described in Example 3 of the present application. DETAILED DESCRIPTION

[0031] In order to enable those skilled in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments of the present disclosure, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present disclosure.

[0032] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0033] Example 1

[0034] According to this embodiment, a method embodiment of shading optimization is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0035] The method embodiment provided in this embodiment can be executed in a mobile terminal, a computer terminal, a server or a similar computing device. Figure 1 FIG. 1 shows a hardware structure block diagram of a computing device for implementing a shading optimization method. Figure 1 As shown, a computing device may include one or more processors (the processor may include, but is not limited to, a microprocessor (MCU) or a programmable logic device (FPGA) or other processing device), a memory for storing data, a transmission device for communication functions, and an input / output interface. The memory, transmission device, and input / output interface are connected to the processor via a bus. In addition, it may also include: a display, a keyboard, and a cursor control device connected to the input / output interface. Those skilled in the art will understand that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components than shown, or with Figure 1Different configurations shown.

[0036] It should be noted that the one or more processors and / or other data processing circuits described above may generally be referred to herein as "data processing circuitry." The data processing circuitry may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuitry may be a single, independent processing module, or may be fully or partially integrated into any of the other components of the computing device. As discussed in the embodiments of the present disclosure, the data processing circuitry functions as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).

[0037] The memory can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the deshading optimization method in the embodiment of the present disclosure. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, implementing the deshading optimization method of the above-mentioned application. The memory may include a high-speed random access memory and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely located relative to the processor, and these remote memories may be connected to the computing device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0038] The transmission device is used to receive or send data via a network. Specific examples of the aforementioned network may include a wireless network provided by a communications provider of the computing device. In one embodiment, the transmission device includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, the transmission device may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0039] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computing device.

[0040] It should be noted that, in some optional embodiments, the above Figure 1 The computing device shown may include hardware elements (including circuits), software elements (including computer code stored on a computer-readable medium), or a combination of both hardware and software elements. Figure 1 This is merely one example of a particular embodiment and is intended to illustrate the types of components that may be present in the computing device described above.

[0041] Figure 2 Schematic diagram of the shading optimization system according to this embodiment. Figure 2 As shown, the system includes: a terminal device 100 and a processor 200. A user uses the terminal device 100 to determine a target image requiring shading removal and sends the target image to the processor 200. Upon receiving the target image, the processor 200 determines a brightness threshold corresponding to the target image and, based on the determined brightness threshold and the rate of decrease in brightness of transitional color regions in the target image, determines a brightness replacement value corresponding to each pixel in the target image. The processor 200 is further configured to perform shading removal on the target image after determining the brightness replacement value corresponding to each pixel.

[0042] It should be noted that the terminal device 100 and the processor 200 in the system can both be applicable to the hardware structure described above.

[0043] Under the above operating environment, according to the first aspect of this embodiment, a shading optimization method is provided. Figure 2 The processor 200 shown in FIG. Figure 3 A schematic diagram showing the process of the method is shown in FIG. Figure 3 As shown, the method includes:

[0044] S302: Determine a target image and a brightness value of each pixel in the target image, and determine a first brightness peak value and a second brightness peak value corresponding to the target image based on the brightness value of each pixel;

[0045] S304: Determine a brightness threshold corresponding to the target image based on the first brightness peak value and the second brightness peak value;

[0046] S306: Determine a brightness value decrease rate corresponding to a transition color region in the target image, where the transition color region is used to indicate a region with smooth transitions between multiple colors;

[0047] S308: Calculating a brightness replacement value for each pixel, wherein if the brightness value is greater than or equal to the brightness threshold, the brightness replacement value is equal to the brightness value; otherwise, the brightness replacement value corresponds to the product of the brightness value decrease rate power exponent and the brightness threshold decrease rate power exponent; and

[0048] S310: After determining the brightness replacement value of each pixel, perform shading removal on the target image.

[0049] Specifically, first, the user determines the target image that needs to be deshaded through the terminal device 100 and sends the target image to the processor 200. The target image can be pre-stored in a memory or obtained through a scanning technology, which is not specifically limited here.

[0050] When the processor 200 receives a target image, the brightness value of each pixel in the target image is determined. Specifically, when the target image received by the processor 200 is a grayscale image, the processor 200 uses the pixel value of each pixel in the target image as the corresponding brightness value. When the target image received by the processor 200 is a color image (i.e., including three channels of RGB), the processor 200 can calculate the brightness value of each pixel based on the grayscale conversion formula. In addition, when the target image received by the processor 200 is a color image (i.e., including three channels of RGB), the processor 200 can also convert the RGB values ​​of the pixels of the color image to the HSV color model to obtain the brightness value of each pixel (where V represents the brightness value). This will not be further elaborated here.

[0051] Furthermore, after the processor 200 determines the brightness value of each pixel in the target image, it determines a first brightness peak value and a second brightness peak value corresponding to the target image (S302). Specifically, the processor 200 first constructs a brightness peak map corresponding to the first brightness peak value and the second brightness peak value based on the brightness value of each pixel in the target image. The abscissa of the brightness peak map represents the brightness value, and the ordinate represents the number of pixels corresponding to each brightness value. The processor 200 then determines the first brightness peak value and the second brightness peak value based on the brightness peak map. This will be described in detail later and will not be repeated here.

[0052] It is worth noting that, when determining the first and second brightness peaks corresponding to the target image, the processor 200 determines that the first brightness peak corresponds to pixels with a brightness value of "0," while the second brightness peak corresponds to the brightness value of pixels corresponding to text, tables, and / or images (i.e., the main content) in the target image. Therefore, the pixels that the processor 200 needs to retain are primarily those at the second brightness peak. In other words, the brightness threshold should be selected to retain as many pixels as possible at the second brightness peak and as few pixels as possible at the first brightness peak. Therefore, the brightness threshold should correspond to the valley between the first and second brightness peaks. In an embodiment of the present application, after determining the brightness peak map corresponding to the target image, the processor 200 can calculate the brightness threshold using a slope extrapolation method (S304). Furthermore, as noted above, since different images correspond to different second brightness peaks, the brightness threshold corresponding to each image can be calculated using the above method.

[0053] After the processor 200 determines the brightness threshold corresponding to the target image, it further determines the brightness decrease rate corresponding to the transition color region in the target image (S306). The transition color region is used to indicate a region with a smooth transition between multiple colors. In embodiments of the present application, the transition color region may be, for example, the edge of a font or a table. Specifically, the edges of text or tables in the target image do not change directly from black to white, but rather undergo a transition process. For example, they gradually change from dark black to light black, from light black to brown, from brown to gray, and then from gray to white.

[0054] Furthermore, the luminance value decrease rate indicates the rate at which the luminance value of a pixel in a transitional color region decreases over distance. For example, if the edge of text in a target image is a transitional color region, and the text edge gradually changes from dark black to light black, from light black to brown, from brown to gray, and finally from gray to white, the luminance value decrease rate indicates the rate at which the luminance value corresponding to dark black decreases over distance (the distance from dark black to white) as the luminance value transitions from dark black to white.

[0055] The processor 200 then calculates a brightness replacement value for each pixel (S308). Specifically, the processor 200 first determines the relationship between the brightness value of each pixel in the target image and the brightness threshold. If the brightness value is greater than or equal to the brightness threshold, the brightness replacement value is equal to the brightness value. If the brightness value is less than the brightness threshold, the brightness replacement value corresponds to the product of the brightness value's exponential rate of decline and the brightness threshold's exponential rate of decline.

[0056] As can be seen from the above, the purpose of using the power function in this application is to prevent pixels below the brightness threshold from experiencing a cliff-like drop in brightness when replacing their brightness values. Instead, it allows for a slow transition when replacing the brightness values ​​of pixels below the brightness threshold. As a result, when replacing brightness values ​​based on the above method, jagged edges on text or tables will not appear. Furthermore, although the above method cannot completely remove the shading of the target image, the shading that is not removed is not visible to the human eye, meaning it does not affect the viewing or use of the processed target image.

[0057] Finally, when the processor 200 determines the brightness replacement value of each pixel in the target image, the brightness value of the corresponding pixel is replaced with the brightness replacement value, thereby completing the shading removal process of the target image (S310).

[0058] Figure 4A is a schematic diagram of a target image to be processed according to an embodiment of the present application. Figure 4B It is a schematic diagram of an image generated after processing a target image based on a traditional shading removal algorithm according to an embodiment of the present application. Figure 4C It is a schematic diagram of an image generated after processing a target image based on the shading removal optimization algorithm described in an embodiment of the present application. Figure 5A According to the embodiment of the present application Figure 4A Corresponding partial enlargement. Figure 5B According to the embodiment of the present application Figure 4B Corresponding partial enlargement. Figure 5C According to the embodiment of the present application Figure 4C Corresponding partial enlargement.

[0059] refer to Figure 4A to Figure 4C ,as well as Figure 5A to Figure 5C As shown, the target image to be processed has many dark lines and noise points. Using a traditional de-shading algorithm to replace the brightness value will result in a clear boundary and obvious aliasing. When the de-shading optimization algorithm provided by this application is used to process the target image, not only can noise be removed, but a better transition can also be achieved, thereby avoiding aliasing in the processed target image.

[0060] As described in the background, while existing correction methods can easily remove light shading and backlighting, there are still some issues: First, because the brightness of different images is not very consistent, some images have darker brightness and some images have lighter brightness. Therefore, when using a fixed brightness threshold to remove shading and background, the main content of the lighter images may be deleted. Second, because the colors of many fonts and table line edges on an image are transitional colors, and the brightness values ​​of transitional colors often change gradually from high to low, when using a fixed brightness threshold to remove shading and background, the transitional colors of the font or table line edges may also be deleted, resulting in severe jagged edges.

[0061] In view of this, the present application provides an optimized algorithm for removing shading. Furthermore, since the present application does not simply determine the brightness replacement value to be 0 or a corresponding brightness value based on a fixed brightness threshold to remove the shading and background in the transitional color area, but rather, when determining the brightness threshold, determines the brightness replacement value to be the brightness value or a value corresponding to the product of the power exponent of the brightness value's rate of decline and the power exponent of the brightness threshold's rate of decline, when removing the shading and background in the transitional color area based on the above method, the jagged phenomenon of the shading or text caused by the cliff drop of the data can be mitigated, thereby achieving a better shading removal effect and avoiding the technical effect of the jagged phenomenon.

[0062] Furthermore, the brightness threshold in this application is not manually set based on experience. Instead, after determining the first and second brightness peaks, the brightness threshold is determined based on the characteristics represented by the first brightness peak (the number of pixels corresponding to a brightness value of 0) and the characteristics represented by the second brightness peak (the number of pixels corresponding to a brightness value of 220). This brightness threshold maximizes the retention of pixels corresponding to the second brightness peak, thereby achieving the technical effect of accurately removing shading and background.

[0063] This solves the technical problem in the prior art that since the colors of many fonts and table line edges on the image are transition colors, when using a fixed brightness threshold to remove the background and background, the transition colors of the font or table line edges may be deleted at the same time, resulting in serious jagged edges of the font or table line.

[0064] Optionally, the operation of determining the brightness replacement value of each pixel includes: determining the brightness replacement value of each pixel using the following formula:

[0065]

[0066] in, Represents the brightness value corresponding to the i-th pixel, represents the brightness threshold, and n represents the brightness value decrease rate of the transition color area.

[0067] Specifically, in the embodiment of the present application, the processor 200 uses the power function operation method to alleviate the serious jagged phenomenon of text edges or table edges caused by the cliff drop of brightness value. And when the brightness value drop rate n is infinite, The corresponding function curve is infinitely close to .

[0068] In addition, among nonlinear trigonometric functions such as the inverse tangent function and the inverse cotangent function, there is no function that can directly satisfy the requirement of being a monotonically increasing concave function in the first quadrant and requiring that part of the function take values ​​below the image y=x (that is, being able to achieve a slower replacement of the brightness value within a specified range). The only function that can be modified to meet the above requirements is the tangent function. The tangent function can achieve a monotonically increasing function within a certain range by enlarging the x-axis, and then reducing the y-axis to achieve part of the function below y=x. However, if the tangent function after the above modification is used on a single pixel point, it will greatly increase the time for calculating the brightness replacement value of the target image. Therefore, in the embodiments of the present application, the power function is used for calculation instead of other functions.

[0069] Further optionally, the value of n is 2.4.

[0070] Specifically, in the embodiment of the present application, when n=2.4, the shading effect of the target image is the best, and the jagged phenomenon can be reduced to the greatest extent. It is worth noting that the value of n in the embodiment of the present application is determined after a large number of tests. For example, scans of ordinary A4 white paper, red line manuscript paper, red-headed documents, positive numbers, and green grid paper were first collected, and about 10 images with large differences in brightness and darkness were extracted for each scan, and finally about 100 images were collected. And although the value range of n can be between 0 and positive infinity, when n is greater than 10, the change in brightness value on the image can no longer be observed by the naked eye, and when n<1, it is no longer visible to the naked eye. The corresponding function curve is convex, which does not meet the purpose of reducing noise brightness values. Therefore, before testing, the value of n was predetermined to be in the range of 1 to 10. In addition, during the testing process, low-orbit testing was performed using the median removal method. Ultimately, it was determined that when n = 2.4, the shading effect of all collected images was optimal and aliasing could be minimized.

[0071] Optionally, the operation of determining the target image and the brightness value of each pixel in the target image, and determining a first brightness peak value and a second brightness peak value corresponding to the target image based on the brightness value of each pixel, includes: constructing a brightness peak map corresponding to the first brightness peak value and the second brightness peak value based on the brightness value of each pixel, wherein the abscissa of the brightness peak map represents the brightness value and the ordinate represents the number of pixels corresponding to each brightness value; and determining the first brightness peak value and the second brightness peak value based on the brightness peak map. Further optionally, the operation of determining a brightness threshold corresponding to the target image based on the first brightness peak value and the second brightness peak value includes: when the first brightness peak value and the second brightness peak value are determined, using a slope extrapolation algorithm to calculate a valley value in the brightness peak map, and determining the valley value as the brightness threshold value.

[0072] Specifically, when the processor 200 determines the brightness value of each pixel on the target image, a brightness peak map is constructed based on the brightness value corresponding to each pixel. Figure 6 is a brightness peak image of the target image according to the embodiment of the present application. Figure 6 As shown in the figure, the brightness peak map corresponding to the target image conforms to the characteristics of a "bimodal distribution." The first brightness peak is composed of pixels with brightness values ​​close to "0," i.e., pixels corresponding to the background in the target image. The second brightness peak is composed of pixels with brightness values ​​close to "220," i.e., pixels corresponding to text and tables in the target image.

[0073] Based on the above, it can be seen that if you want to retain as many pixels as possible on the second brightness peak, the brightness threshold should be located to the left of the second brightness peak, and you should retain as many pixels as possible on the second brightness peak and as few pixels as possible on the first brightness peak. In other words, the optimal brightness threshold should be located at the lowest point in the valley between the first and second brightness peaks. In the embodiments of the present application, the valley value, i.e., the brightness threshold, can be automatically calculated using the slope extrapolation method.

[0074] It's worth noting that the second brightness peak corresponding to "220" is specific to the target image. Since different images have different corresponding second brightness peaks, the brightness thresholds determined based on the first and second brightness peaks also differ. In other words, using this approach, different brightness thresholds can be calculated for different images.

[0075] Unlike existing techniques that use manually determined brightness thresholds to remove shading and background, which can result in the deletion of parts of lighter-brightness images, this application, after testing tens of thousands of images, discovered that image brightness values ​​conform to a "bimodal distribution" characteristic. This allows the determination of a brightness threshold based on the first brightness peak, the second brightness peak, and a brightness peak map. Furthermore, because this application calculates the corresponding brightness threshold for each image, even if the brightness levels of different images are inconsistent, the problem of accidentally deleting the main content of an image due to a fixed brightness threshold will not occur.

[0076] Therefore, according to the first aspect of this embodiment, the jagged phenomenon of shading or text caused by the cliff drop of data can be alleviated, thereby achieving a better shading removal effect and avoiding the jagged phenomenon.

[0077] In addition, reference Figure 1 As shown, according to a second aspect of this embodiment, a storage medium is provided, wherein the storage medium includes a stored program, wherein when the program is run, a processor executes any one of the above methods.

[0078] Therefore, according to this embodiment, the aliasing phenomenon of shading or text caused by the cliff drop of data can be alleviated, thereby achieving a better shading removal effect and avoiding the aliasing phenomenon.

[0079] It should be noted that for the aforementioned method embodiments, for simplicity of description, they are all expressed as a series of action combinations. However, those skilled in the art should be aware that the present invention is not limited by the order of the actions described, because according to the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.

[0080] Through the description of the above embodiments, those skilled in the art will clearly understand that the methods according to the above embodiments can be implemented using software plus the necessary general-purpose hardware platform. Of course, hardware can also be used, but in many cases the former is a more preferred embodiment. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, or optical disk) and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in various embodiments of the present invention.

[0081] Example 2

[0082] Figure 7 FIG. 7 shows a shading optimization device 700 according to this embodiment, which corresponds to the method according to embodiment 1. Figure 7 As shown, the apparatus 700 includes: a brightness peak determination module 710, for determining the brightness value of a target image and each pixel in the target image, and determining a first brightness peak value and a second brightness peak value corresponding to the target image based on the brightness value of each pixel; a brightness threshold determination module 720, for determining a brightness threshold corresponding to the target image based on the first brightness peak value and the second brightness peak value; a brightness value decrease rate determination module 730, for determining a brightness value decrease rate corresponding to a transition color region in the target image, wherein the transition color region is used to indicate a region with smooth transitions between multiple colors; a brightness replacement value determination module 740, for calculating a brightness replacement value for each pixel, wherein when the brightness value is greater than or equal to the brightness threshold, the brightness replacement value is equal to the brightness value, otherwise, the brightness replacement value corresponds to the product of a decrease rate power exponent of the brightness value and a decrease rate power exponent of the brightness threshold; and a shading removal processing module 750, for performing shading removal on the target image when the brightness replacement value of each pixel is determined.

[0083] Optionally, the brightness replacement value determination module 750 includes: determining the brightness replacement value of each pixel point using the following formula:

[0084]

[0085] in, Represents the brightness value corresponding to the i-th pixel, represents the brightness threshold, and n represents the brightness value decrease rate of the transition color area.

[0086] Optionally, n is set to 2.4.

[0087] Optionally, the brightness peak determination module 710 includes: a brightness peak map construction module, which is used to construct a brightness peak map corresponding to the first brightness peak and the second brightness peak based on the brightness values ​​of each pixel point, wherein the horizontal axis of the brightness peak map represents the brightness value and the vertical axis represents the number of pixel points corresponding to each brightness value; and a brightness peak determination submodule, which is used to determine the first brightness peak and the second brightness peak based on the brightness peak map.

[0088] Optionally, the brightness threshold determination module 720 includes: a brightness threshold determination submodule, which is used to calculate the valley value in the brightness peak graph using the slope extrapolation algorithm when the first brightness peak value and the second brightness peak value are determined, and determine the brightness value corresponding to the valley value as the brightness threshold.

[0089] Therefore, according to this embodiment, the aliasing phenomenon of shading or text caused by the cliff drop of data can be alleviated, thereby achieving a better shading removal effect and avoiding the aliasing phenomenon.

[0090] Example 3

[0091] Figure 8 FIG. 8 shows a shading optimization device 800 according to this embodiment, which corresponds to the method according to embodiment 1. Figure 8 As shown, the device 800 includes: a processor 810; and a memory 820, which is connected to the processor 810 and is used to provide the processor 810 with instructions for processing the following processing steps: determining the brightness value of the target image and each pixel in the target image, and determining a first brightness peak value and a second brightness peak value corresponding to the target image based on the brightness value of each pixel; determining a brightness threshold corresponding to the target image based on the first brightness peak value and the second brightness peak value; determining a brightness value decrease rate corresponding to a transition color area in the target image, wherein the transition color area is used to indicate an area with smooth transition between multiple colors; calculating a brightness replacement value for each pixel, wherein when the brightness value is greater than or equal to the brightness threshold, the brightness replacement value is equal to the brightness value, otherwise, the brightness replacement value corresponds to the product of a brightness value decrease rate power exponent and a brightness threshold decrease rate power exponent; and when the brightness replacement value of each pixel is determined, performing shading removal on the target image.

[0092] Optionally, the operation of determining the brightness replacement value of each pixel includes: determining the brightness replacement value of each pixel using the following formula:

[0093]

[0094] in, Represents the brightness value corresponding to the i-th pixel, represents the brightness threshold, and n represents the brightness value decrease rate of the transition color area.

[0095] Optionally, n is set to 2.4.

[0096] Optionally, the operation of determining the target image and the brightness values ​​of each pixel in the target image, and determining the first brightness peak and the second brightness peak corresponding to the target image based on the brightness values ​​of each pixel includes: constructing a brightness peak map corresponding to the first brightness peak and the second brightness peak based on the brightness values ​​of each pixel, wherein the horizontal axis of the brightness peak map represents the brightness value and the vertical axis represents the number of pixels corresponding to each brightness value; and determining the first brightness peak and the second brightness peak based on the brightness peak map.

[0097] Optionally, the operation of determining the brightness threshold corresponding to the target image based on the first brightness peak and the second brightness peak includes: when determining the first brightness peak and the second brightness peak, using the slope extrapolation algorithm to calculate the trough value in the brightness peak graph, and determining the trough value as the brightness threshold.

[0098] Therefore, according to this embodiment, the aliasing phenomenon of shading or text caused by the cliff drop of data can be alleviated, thereby achieving a better shading removal effect and avoiding the aliasing phenomenon.

[0099] The serial numbers of the above embodiments of the present invention are for description only and do not represent the advantages or disadvantages of the embodiments.

[0100] In the above embodiments of the present invention, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0101] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0102] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0103] In addition, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0104] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes various media that can store program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), a mobile hard drive, a magnetic disk, or an optical disk.

[0105] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as within the scope of protection of the present invention.

Claims

1. A shading optimization method, characterized in that: include: Determining a target image and a brightness value of each pixel in the target image, and determining a first brightness peak value and a second brightness peak value corresponding to the target image based on the brightness value of each pixel; determining a brightness threshold corresponding to the target image based on the first brightness peak value and the second brightness peak value; Determining a brightness value decrease rate corresponding to a transition color region in the target image, wherein the transition color region is used to indicate a region with smooth transitions between multiple colors; Calculating a brightness replacement value for each pixel point, wherein if the brightness value is greater than or equal to the brightness threshold, the brightness replacement value is equal to the brightness value; otherwise, the brightness replacement value corresponds to the product of a decrease rate power exponent of the brightness value and a decrease rate power exponent of the brightness threshold; as well as When the brightness replacement value of each pixel is determined, the target image is subjected to shading removal processing, wherein The operation of determining the brightness replacement value of each pixel point includes: The formula for determining the brightness replacement value of each pixel is as follows: in, Represents the brightness value corresponding to the i-th pixel, represents the brightness threshold, n represents the brightness value decrease rate of the transition color area, and the value range of n is 1~10.

2. The method according to claim 1, characterized in that The value of n is 2.

4.

3. The method according to claim 1, characterized in that The operation of determining a target image and a brightness value of each pixel in the target image, and determining a first brightness peak value and a second brightness peak value corresponding to the target image based on the brightness value of each pixel, includes: constructing a brightness peak map corresponding to the first brightness peak and the second brightness peak based on the brightness values ​​of the respective pixels, wherein the abscissa of the brightness peak map represents the brightness value and the ordinate represents the number of pixels corresponding to each brightness value; and Based on the brightness peak map, the first brightness peak value and the second brightness peak value are determined.

4. The method according to claim 3, characterized in that The operation of determining a brightness threshold corresponding to the target image based on the first brightness peak value and the second brightness peak value includes: When the first brightness peak value and the second brightness peak value are determined, a slope extrapolation algorithm is used to calculate a valley value in the brightness peak graph, and a brightness value corresponding to the valley value is determined as the brightness threshold.

5. A shading optimization device, characterized in that: include: a brightness peak determination module, configured to determine a target image and the brightness value of each pixel in the target image, and determine a first brightness peak value and a second brightness peak value corresponding to the target image based on the brightness value of each pixel; a brightness threshold determination module, configured to determine a brightness threshold corresponding to the target image based on the first brightness peak value and the second brightness peak value; a brightness value decreasing rate determining module, configured to determine a brightness value decreasing rate corresponding to a transition color region in the target image, wherein the transition color region is used to indicate a region with smooth transitions between multiple colors; a brightness replacement value determination module, configured to calculate a brightness replacement value for each pixel point, wherein if the brightness value is greater than or equal to the brightness threshold, the brightness replacement value is equal to the brightness value; otherwise, the brightness replacement value corresponds to the product of a decrease rate power exponent of the brightness value and a decrease rate power exponent of the brightness threshold; as well as A shading removal processing module is configured to perform shading removal on the target image while determining a brightness replacement value for each pixel point, wherein the brightness replacement value determination module includes: The formula for determining the brightness replacement value of each pixel is as follows: in, Represents the brightness value corresponding to the i-th pixel, represents the brightness threshold, n represents the brightness value decrease rate of the transition color area, and the value range of n is 1~10.

6. The device according to claim 5, characterized in that The value of n is 2.

4.

7. A storage medium, characterized in that: The storage medium includes a stored program, wherein when the program is run, the processor executes the method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Protection pressing plate state identification method based on image processing shadow removal optimization

    CN111915509A

  • Document image shadow removing method and device, computer equipment and storage medium

    CN119762404A

  • Method and system for removing image background

    CN104657969A

  • Character display method and system

    JP2004226679A