Shading removal optimization method and device and storage medium

By dynamically adjusting the brightness threshold, and calculating the brightness replacement value based on the brightness value drop rate of the brightness peak and transition color areas, the problem of mistaken deletion of the transition color at the edge of the font and table line in the image is solved, and the improvement of the deshaping effect and the avoidance of jagging are achieved.

CN120259069AActive Publication Date: 2025-07-04BEIJING HANGSHENG TECH CO LTD
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202510671671.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-23
Publication Date
2025-07-04
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 value of the target image and the brightness value drop rate of the transition color area, calculate the brightness replacement value as the product of the brightness value or the drop rate of the brightness value and the brightness threshold, dynamically adjust the brightness threshold to slow down the data cliff and avoid jagging.

Benefits of technology

Effectively remove the shading and background, reduce jagging, retain the main body of the image content, and achieve better shading removal effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120259069A_ABST
    Figure CN120259069A_ABST
Patent Text Reader

Abstract

The invention discloses a shading removal optimization method and device and a storage medium, and the method comprises the steps: determining a target image and the brightness value of each pixel point 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 point; determining a brightness threshold value 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 for indicating a smooth transition region among multiple colors; the brightness replacement value of each pixel point is calculated, when the brightness value is larger than or equal to the brightness threshold value, the brightness replacement value is equal to the brightness value, and otherwise, the brightness replacement value corresponds to the product of the decline rate power exponent of the brightness value and the decline rate power exponent of the brightness threshold value; and under the condition that the brightness replacement value of each pixel point is determined, performing shading removal processing on the target image. The technical effect of accurately removing the shading and the background is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technologies, and particularly to a method and device for optimizing background removal and a storage medium. Background Art

[0002] In fields such as document scanning, cultural relic restoration, and medical imaging, image background removal (i.e., removing the background texture or interference pattern of an image) is a common requirement in image processing. Among the existing correction methods for image background removal, the most common correction method is to manually set a brightness threshold. And set the pixel points in the image whose brightness values are less than the brightness threshold to 0; retain the pixel points in the image whose brightness values are greater than the brightness threshold. The specific formula is as follows:

[0003] Wherein, represents the brightness value of the image pixel point i where i = 1 to n. represents the brightness threshold.

[0004] Although using the above correction method can simply remove light-colored backgrounds and backlights, there are still certain problems: First, since the brightness of different images is not very consistent, some images are darker and some are lighter. Therefore, when using the manually determined brightness threshold to remove the backgrounds and backgrounds of different images, there may be a problem of deleting part of the content body of the lighter images. Second, since the colors at the edges of many fonts and table lines on the 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 the background and background, the transitional colors at the edges of the fonts or table lines may be deleted at the same time, resulting in serious jagged phenomena at the edges of the fonts or table lines.

[0005] The publication number is CN111915509A, and the name is a method for identifying the state of a protection pressure plate based on image processing for shadow removal optimization. It includes graying the color image of the protection pressure plate to convert it into a gray image, and then enhancing the contrast and binaryzation of the gray image to eliminate the shadow area. The convex hull of each protection pressure plate switch is obtained through the principle of the Graham algorithm, and then the convex hulls are connected into a rectangle by the principle of the minimum circumscribed rectangle to obtain the rectangle area. A threshold is set for the rectangle area, and if the rectangle area is greater than the threshold, it is determined to be thrown out, otherwise it is determined to be put in.

[0006] Publication number: CN119762404A, Title: Method, Device, Computer Equipment and Storage Medium for Removing Shadow from Document Image. The method includes: using image processing technology to adjust the contrast of the document shadow image to be processed to obtain a contrast heat map highlighting the shadow area; adopting 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. In each stage, a conditional probability path between the data and noise in the current stage is learned through a flow matching model, and shadow removal is performed on the current stage according to the conditional probability path; based on the shadow removal result of the current stage, a next-scale prediction mechanism is used to predict the shadow scale of the next stage, and the contrast heat map is used to guide the shadow removal in the next stage.

[0007] Regarding the technical problem in the above-mentioned prior art that since many font and table line edges on the image have transitional colors, when using a manually determined brightness threshold to remove the background pattern, the transitional colors at the font or table line edges may be deleted simultaneously, resulting in serious jagged phenomena at the font or table line edges, no effective solution has been proposed yet. Summary of the Invention

[0008] Embodiments of the present disclosure provide a method, device and storage medium for background pattern optimization, so as to at least solve the technical problem in the prior art that since many font and table line edges on the image have transitional colors, when using a manually determined brightness threshold to remove the background pattern, the transitional colors at the font or table line edges may be deleted simultaneously, resulting in serious jagged phenomena at the font or table line edges.

[0009] According to one aspect of the embodiments of the present disclosure, a method for background pattern optimization is provided, including: determining a target image and the brightness values of each pixel point in the target image, and based on the brightness values of each pixel point, determining a first brightness peak and a second brightness peak corresponding to the target image; based on the first brightness peak and the second brightness peak, determining a brightness threshold corresponding to the target image; determining a brightness value decrease rate corresponding to the transitional color area in the target image, where the transitional color area is used to indicate an area where multiple colors transition smoothly; calculating a brightness replacement value for each pixel point, where in the case where 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 power exponent of the brightness value decrease rate and the power exponent of the brightness threshold decrease rate; and in the case where the brightness replacement value of each pixel point is determined, performing background pattern removal on the target image.

[0010] According to another aspect of the embodiments of the present disclosure, a storage medium is further provided. The storage medium includes a stored program, where, when the program runs, the method described in any one of the above is executed by a processor.

[0011] According to another aspect of the embodiments of the present disclosure, there is also provided a device for optimizing background removal, including: a brightness peak determination module, configured to determine a target image and the brightness values of each pixel point 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 point; a brightness threshold determination module, configured to determine a 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, configured to determine the brightness value decrease rate corresponding to the transitional color region in the target image, where the transitional color region is used to indicate a region where multiple colors smoothly transition; a brightness replacement value determination module, configured to calculate the brightness replacement value of each pixel point, where when the brightness value is greater than or equal to the brightness threshold, the brightness replacement value is equal to the brightness value, and conversely, the brightness replacement value corresponds to the product of the power exponent of the brightness value decrease rate and the power exponent of the brightness threshold decrease rate; and a background removal processing module, configured to perform background removal processing on the target image when the brightness replacement value of each pixel point is determined.

[0012] According to another aspect of the embodiments of the present disclosure, there is also provided a device for optimizing background removal, including: a processor; and a memory, connected to the processor and configured to provide instructions for the processor to perform the following processing steps: determine a target image and the brightness values of each pixel point 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 point; determine a brightness threshold corresponding to the target image based on the first brightness peak and the second brightness peak; determine the brightness value decrease rate corresponding to the transitional color region in the target image, where the transitional color region is used to indicate a region where multiple colors smoothly transition; calculate the brightness replacement value of each pixel point, where when the brightness value is greater than or equal to the brightness threshold, the brightness replacement value is equal to the brightness value, and conversely, the brightness replacement value corresponds to the product of the power exponent of the brightness value decrease rate and the power exponent of the brightness threshold decrease rate; and perform background removal processing on the target image when the brightness replacement value of each pixel point is determined.

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

[0014] As can be seen from the above, since the present application does not simply determine the brightness replacement value as 0 or the corresponding brightness value based on a manually fixed brightness threshold and remove the shading and background of the transitional color area, but when the brightness threshold is determined, 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 decrease rate and the power exponent of the brightness threshold decrease rate. Therefore, when removing the shading and background of the transitional color area in the above manner, it is possible to slow down the jagged phenomenon of the table or text caused by the sharp drop of data, and thus can achieve a better shading removal effect and avoid the technical effect of the jagged phenomenon.

[0015] In addition, the brightness threshold in the present application is not based on manual setting, but 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 second brightness peak (the number of brightness values corresponding to the main content of the image) when the first brightness peak and the second brightness peak are determined. The brightness threshold can retain the pixel points corresponding to the second brightness peak to the greatest extent and remove the pixel points corresponding to the first brightness peak to the greatest extent. Thus, the technical effect of being able to accurately remove the shading and background is achieved.

[0016] Furthermore, it solves the technical problem in the prior art that since many font and table line edges on the image are transitional colors, when using a manually determined brightness threshold to remove the shading and background, the transitional colors of the font or table edge may be deleted at the same time, resulting in a serious jagged phenomenon on the font or table edge. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The drawings described herein are used to provide a further understanding of the present disclosure, and constitute a part of the present 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: Figure 1 It is a hardware structure block diagram of a computing device for implementing the method according to Embodiment 1 of the present application; Figure 2 It is a schematic diagram of the background removal optimization system according to Embodiment 1 of the present application; Figure 3 It is a flowchart of the background removal optimization method according to Embodiment 1 of the present application; Figure 4A It is a schematic diagram of the target image to be processed according to Embodiment 1 of the present application; Figure 4B It is a schematic diagram of the image generated after processing the target image based on the traditional background removal algorithm according to Embodiment 1 of the present application; Figure 4C It is a schematic diagram of the image generated after processing the target image based on the background removal optimization algorithm according to Embodiment 1 of the present application; Figure 5A It is according to Embodiment 1 of the present application and Figure 4A The corresponding local enlarged view; Figure 5B It is according to Embodiment 1 of the present application and Figure 4B The corresponding local enlarged view; Figure 5C It is according to Embodiment 1 of the present application and Figure 4C The corresponding local enlarged view; Figure 6 It is the brightness peak map of the target image according to Embodiment 1 of the present application; Figure 7 It is a schematic diagram of the background removal optimization device according to Embodiment 2 of the present application; and Figure 8 It is a schematic diagram of the background removal optimization device according to Embodiment 3 of the present application. Detailed implementation manners

[0018] 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 accompanying drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, rather than all the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present disclosure.

[0019] It should be noted that the terms "first", "second", etc. in the description, claims and above-mentioned drawings of the present disclosure are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present disclosure described here can be implemented in an order different from those illustrated or described here. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device including a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.

[0020] Embodiment 1 According to this embodiment, a method embodiment for optimizing removing shading 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 the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that here.

[0021] 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 A hardware structure block diagram of a computing device for implementing the method for optimizing removing shading is shown. As Figure 1 shown, the computing device may include one or more processors (the processor may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory for storing data, a transmission device for communication functions, and an input / output interface. Among them, the memory, the transmission device and the input / output interface are connected to the processor through a bus. In addition, it may further include: a display, a keyboard and a cursor control device connected to the input / output interface. Those of ordinary skill in the art can understand that Figure 1 the structure shown is only schematic and does not limit the structure of the above-mentioned electronic device. For example, the computing device may further include more or fewer components than Figure 1 shown, or have a different configuration from Figure 1 shown.

[0022] It should be noted that one or more of the above-mentioned processors and / or other data processing circuits can generally be referred to as "data processing circuits" herein. The data processing circuit can be embodied in software, hardware, firmware, or any combination thereof, in whole or in part. In addition, the data processing circuit can be a single independent processing module, or be incorporated in whole or in part into any one of other elements in the computing device. As involved in the embodiments of the present disclosure, the data processing circuit is a kind of processor control (such as the selection of a variable resistance terminal path connected to an interface).

[0023] 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 method for removing shading optimization in the embodiments 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, realizes the method for removing shading optimization of the above application program. The memory can include high-speed random access memory, and can also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memories. In some instances, the memory can further include a memory remotely disposed relative to the processor, and these remote memories can be connected to the computing device through a network. Examples of the above network include but are not limited to the Internet, enterprise intranet, local area network, mobile communication network, and combinations thereof.

[0024] The transmission device is used to receive or send data via a network. Specific examples of the above network can include a wireless network provided by a communication provider of the computing device. In one instance, the transmission device includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station and thus communicate with the Internet. In one instance, the transmission device can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0025] The display can be, for example, a touch-screen liquid crystal display (LCD), which enables a user to interact with the user interface of the computing device.

[0026] It should be noted here that in some alternative embodiments, the above-mentioned Figure 1 shown computing device can include hardware elements (including circuits), software elements (including computer code stored on a computer-readable medium), or a combination of both hardware elements and software elements. It should be pointed out that Figure 1 is only an example of a specific specific instance and is intended to illustrate the types of components that can exist in the above-mentioned computing device.

[0027] Figure 2It is a schematic diagram of the shading removal optimization system according to this embodiment. Refer to Figure 2 As shown, the system includes: a terminal device 100 and a processor 200. Among them, the user determines the target image that needs to be shaded-removed through the terminal device 100 and sends the target image to the processor 200. When the processor 200 receives the target image, it determines the brightness threshold corresponding to the target image and, based on the determined brightness threshold and the brightness value decrease rate of the transitional color area in the target image, determines the brightness replacement value corresponding to each pixel point in the target image. The processor 200 is also used to perform shading removal processing on the target image when determining the brightness replacement value corresponding to each pixel point.

[0028] It should be noted that both the terminal device 100 and the processor 200 in the system can apply the above-mentioned hardware structure.

[0029] Under the above operating environment, according to the first aspect of this embodiment, a shading removal optimization method is provided, and this method is implemented by the Figure 2 processor 200 shown in Figure 3 shows the flow schematic diagram of this method. Refer to Figure 3 As shown, this method includes: S302: Determine the target image and the brightness values of each pixel point in the target image, and based on the brightness values of each pixel point, determine the first brightness peak and the second brightness peak corresponding to the target image; S304: Based on the first brightness peak and the second brightness peak, determine the brightness threshold corresponding to the target image; S306: Determine the brightness value decrease rate corresponding to the transitional color area in the target image, where the transitional color area is used to indicate the area of smooth transition between multiple colors; S308: Calculate the brightness replacement value of each pixel point, where 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 power exponent of the brightness value decrease rate and the power exponent of the brightness threshold decrease rate; and S310: Perform shading removal processing on the target image when determining the brightness replacement value of each pixel point.

[0030] Specifically, first, the user determines the target image that needs to be shaded-removed through the terminal device 100 and sends the target image to the processor 200. Among them, the target image can be, for example, pre-stored in the memory or an image obtained through scanning technology, and no specific limitation is made here.

[0031] When the processor 200 receives the target image, the brightness values of each pixel point in the target image are determined. Among them, when the target image received by the processor 200 is a grayscale image, the processor 200 uses the pixel value of each pixel point 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 values of each pixel point 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 pixel points of the color image to the HSV color model, so as to obtain the brightness values of each pixel point (where V represents the brightness value). This will not be elaborated here.

[0032] Further, when the processor 200 determines the brightness values of each pixel point in the target image, a first brightness peak and a second brightness peak corresponding to the target image are determined (S302). Specifically, first, the processor 200 constructs a brightness peak map corresponding to the first brightness peak and the second brightness peak based on the brightness values of each pixel point in the target image. The abscissa of the brightness peak map represents the brightness value, and the ordinate represents the number of pixel points corresponding to each brightness value. Then, the processor 200 determines the first brightness peak and the second brightness peak based on the brightness peak map. The above content will be described in detail later, so it will not be elaborated here.

[0033] It should be noted that since when determining the first brightness peak and the second brightness peak corresponding to the target image, the processor 200 determines that the first brightness peak corresponds to the pixel point with the brightness value of "0", and the second brightness peak corresponds to the brightness values of the pixel points corresponding to the text, table and / or image (i.e., the main content) in the target image, the pixel points that the processor 200 needs to retain are mainly on the second brightness peak. That is, the selection of the brightness threshold should retain as many pixel points of the second brightness peak as possible and as few pixel points of the first brightness peak as possible. Therefore, the brightness threshold should correspond to the trough value between the first brightness peak and the second brightness peak. In the embodiments of the present application, when determining the brightness peak map corresponding to the target image, the processor 200 can calculate the brightness threshold by using the slope estimation method (S304). In addition, referring to the above content, since different images correspond to different second brightness peaks, the brightness thresholds corresponding to different images can be calculated based on the above method.

[0034] When the processor 200 determines the brightness threshold corresponding to the target image, it further determines the brightness value decrease rate corresponding to the transitional color area in the target image (S306). The transitional color area is used to indicate the area where multiple colors transition smoothly. And in the embodiments of the present application, the transitional color area can be, for example, the edge of a font or the edge of a table, etc. Specifically, the edge of the text or the edge of the table in the target image does not change directly from black to white, but has a transitional process. For example, it gradually changes from deep black to light black, from light black to brown, then from brown to gray, and finally from gray to white.

[0035] In addition, the brightness value decrease rate is used to indicate the decrease rate of the brightness value of the pixel points in the transitional color area over time. For example, the edge of the text in the target image is the transitional color area, and the edge of the text gradually changes from deep black to light black, from light black to brown, then from brown to gray, and finally from gray to white. Then the brightness value decrease rate is used to indicate the decrease rate over time (the distance from deep black to white) when transitioning from the brightness value corresponding to deep black to the brightness value corresponding to white.

[0036] After that, the processor 200 calculates the brightness replacement value of each pixel point (S308). Specifically, first, the processor 200 determines the relationship between the brightness value of each pixel point in the target image and the brightness threshold. When the brightness value is greater than or equal to the brightness threshold, the brightness replacement value is equal to the brightness value; when the brightness value is less than the brightness threshold, the brightness replacement value corresponds to the product of the power exponent of the brightness value decrease rate and the power exponent of the brightness threshold decrease rate.

[0037] As can be seen from the above content, the purpose of using the power exponential function in the present application is not to allow the pixel points below the brightness threshold to have a cliff-like drop when performing brightness value replacement, but to enable the pixel points below the brightness threshold to have a slow transition when performing brightness value replacement. Thus, when performing brightness value replacement based on the above method, there will be no jagged phenomenon at the text edge or table edge. In addition, although the above method cannot completely remove the background pattern of the target image, the remaining background pattern is not visible to the human eye, that is, it does not affect the viewing or use of the processed target image.

[0038] Finally, when the processor 200 determines the brightness replacement value of each pixel point in the target image, it replaces the brightness value of the corresponding pixel point with the brightness replacement value, thereby completing the background pattern removal process for the target image (S310).

[0039] Figure 4A It is a schematic diagram of the target image to be processed according to the embodiments of the present application. Figure 4B It is a schematic diagram of the image generated after processing the target image based on the traditional background pattern removal algorithm according to the embodiments of the present application.Figure 4C It is a schematic diagram of an image generated after processing a target image based on a shading removal optimization algorithm according to an embodiment of the present application. Figure 5A According to the embodiment of the present application Figure 4A The corresponding enlarged image. Figure 5B According to the embodiment of the present application Figure 4B The corresponding enlarged image. Figure 5C According to the embodiment of the present application Figure 4C The corresponding enlarged image.

[0040] refer to Figures 4A - 4C ,as well as Figures 5A - 5C As shown, there are many dark lines and noise points on the target image to be processed, and using the traditional de-shading algorithm to replace the brightness value will have an obvious boundary and produce obvious jagged phenomenon. When the de-shading optimization algorithm provided by the present application is used to process the target image, not only can noise be removed, but there will also be a better transition, thereby avoiding the jagged phenomenon in the processed target image.

[0041] As described in the background technology, although the correction methods in the prior art can be used to easily remove light-colored shading and backlighting, there are still some problems: First, because the brightness of different images is not very consistent, some images are darker in brightness, and some images are lighter in brightness. Therefore, when using a fixed brightness threshold to remove shading and background, the problem of deleting the main content of some images with lighter brightness may occur. Second, because the colors of many fonts and table line edges on the image are transition colors, and the brightness values ​​of transition colors often change gradually from high to low, when using a fixed brightness threshold to remove shading and background, the transition colors of the edges of fonts or table lines may be deleted at the same time, resulting in serious jagged edges of fonts or table lines.

[0042] In view of this, the present application provides an optimization algorithm for removing shading. And because the present application does not simply determine the brightness replacement value as 0 or a corresponding brightness value based on a fixed brightness threshold to remove the shading and background of the transition color area, but determines the brightness replacement value as the brightness value or a value corresponding to the product of the power exponent of the rate of decrease of the brightness value and the power exponent of the rate of decrease 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 method, the jagged phenomenon of the shading 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 jagged phenomenon.

[0043] In addition, the brightness threshold in this application is not manually set based on experience, but when the first brightness peak value and the second brightness peak value are determined, the brightness threshold value is determined based on the characteristics represented by the first brightness peak value (the number of pixels corresponding to the brightness value 0) and the characteristics represented by the second brightness peak value (the number of pixels corresponding to the brightness value 220). The brightness threshold value can retain the pixels corresponding to the second brightness peak value to the greatest extent. Thus, the technical effect of accurately removing the shading and background is achieved.

[0044] 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 a fixed brightness threshold is used 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 on the font or table line edges.

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

[0046] 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.

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

[0048] In addition, among the nonlinear trigonometric functions such as the inverse tangent function and the inverse cotangent function, there is no function that can directly satisfy the requirement that it is a monotonically increasing concave function in the first quadrant and that some functions need to take values ​​below the image y=x (that is, it can achieve a slower replacement of the brightness values ​​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 a partial function below y=x. However, if the tangent function after the above modification is used on a single pixel, 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.

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

[0050] Specifically, in the embodiments of the present application, when n = 2.4, the effect of removing the background pattern from the target image is the best, and the phenomenon of jaggedness can be minimized to the greatest extent. It should be noted that the value of n in the embodiments of the present application is determined through a large number of tests. For example, first, scanned images of ordinary A4 white paper, red line paper, red-headed documents, positive numbers, and green grid paper, etc. were collected, and about 10 images with relatively large differences in brightness were extracted from each type of scan. Eventually, 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 the brightness value on the image can no longer be observed by the naked eye, and when n < 1, the corresponding function curve is a convex curve, which does not meet the purpose of reducing the brightness value of the noise points. Therefore, before the test, the value range of n was determined in advance to be 1 to 10. In addition, during the test, the low-orbit test was carried out according to the method of removing the median value. Eventually, it was determined that when n = 2.4, the effect of removing the background pattern from all the collected pictures is the best and the phenomenon of jaggedness can be minimized to the greatest extent.

[0051] Optionally, the operation of determining the target image and the brightness values of each pixel point 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 point 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 point, where the abscissa of the brightness peak map represents the brightness value, and the ordinate represents the number of pixel points corresponding to each brightness value; and determining the first brightness peak and the second brightness peak based on the brightness peak map. Further 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: in the case of determining the first brightness peak and the second brightness peak, calculating the trough value in the brightness peak map by using the slope extrapolation method, and determining the trough value as the brightness threshold.

[0052] Specifically, in the case where the processor 200 determines the brightness values of each pixel point on the target image, a brightness peak map is constructed based on the brightness values corresponding to each pixel point. Figure 6 is the brightness peak map of the target image according to the embodiments of the present application. Refer to Figure 6 as shown, the brightness peak map corresponding to the target image conforms to the characteristic of "bimodal distribution". Among them, the first brightness peak is composed of pixel points with brightness values close to "0", that is, the pixel points corresponding to the background in the target image. The second brightness peak is composed of pixel points with brightness values close to "220", that is, the pixel points corresponding to the text and tables in the target image.

[0053] Based on the above content, it can be known that if you want to retain as many pixels as possible on the second brightness peak, the brightness threshold should be located on the left side of the second brightness peak, and as many pixels as possible on the second brightness peak should be retained while as few pixels as possible on the first brightness peak. That is, the optimal point of the brightness threshold should be located at the lowest point of the valley between the first brightness peak and the second brightness peak. In the embodiment of the present application, the valley value, that is, the brightness threshold, can be automatically calculated using the slope extrapolation method.

[0054] It is worth noting that the second brightness peak value corresponding to "220" corresponds to the target image. Since different images correspond to different second brightness peak values, the brightness thresholds determined based on the first brightness peak value and the second brightness peak value are also different. That is, based on the above method, different brightness thresholds can be calculated for different images.

[0055] Therefore, unlike the prior art that uses artificially determined brightness thresholds to remove shading and background, which may result in the deletion of part of the content of the image with lighter brightness, the present application finds that the brightness value of the image meets the characteristics of "bimodal distribution" after testing tens of thousands of images, so the brightness threshold can be determined based on the first brightness peak, the second brightness peak, and the brightness peak map. And because the present application calculates the corresponding brightness threshold for each image, even if the brightness of different images is inconsistent, there will be no problem of mistakenly deleting the content of the image due to a fixed brightness threshold.

[0056] 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 mitigated, thereby achieving a better shading removal effect and avoiding the jagged phenomenon.

[0057] In addition, reference Figure 1 As shown, according to the 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.

[0058] 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.

[0059] It should be noted that, for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the present invention.

[0060] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, in essence or the part 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, optical disk), and includes several instructions for causing a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in various embodiments of the present invention.

[0061] Embodiment 2 Figure 7 The de-shading optimization device 700 according to the present embodiment is shown. The device 700 corresponds to the method according to Embodiment 1. Refer to Figure 7 As shown, the device 700 includes: a brightness peak determination module 710, configured to determine a target image and the brightness values of each pixel point in the target image, and based on the brightness values of each pixel point, determine a first brightness peak and a second brightness peak corresponding to the target image; a brightness threshold determination module 720, configured to determine a 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 730, configured to 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 where multiple colors smoothly transition; a brightness replacement value determination module 740, configured to calculate a brightness replacement value for each pixel point, where in the case that the brightness value is greater than or equal to the brightness threshold, the brightness replacement value is equal to the brightness value, and conversely, the brightness replacement value corresponds to the product of the power exponent of the brightness value decrease rate and the power exponent of the brightness threshold decrease rate; and a de-shading processing module 750, configured to perform de-shading processing on the target image in the case of determining the brightness replacement value for each pixel point.

[0062] Optionally, the brightness replacement value determination module 750 includes: The formula for determining the brightness replacement value for each pixel point is as follows:

[0063] Where 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.

[0064] Optionally, n takes a value of 2.4.

[0065] Optionally, the brightness peak determination module 710: a brightness peak map construction module, 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, used to determine the first brightness peak and the second brightness peak based on the brightness peak map.

[0066] 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 diagram 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.

[0067] 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.

[0068] Example 3 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 the first brightness peak value and the second brightness peak value corresponding to the target image based on the brightness value of each pixel; determining the brightness threshold corresponding to the target image based on the first brightness peak value and the second brightness peak value; determining the brightness value decrease rate corresponding to the 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 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 brightness value decrease rate power exponent and the brightness threshold decrease rate power exponent; and when the brightness replacement value of each pixel is determined, performing shading removal processing on the target image.

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

[0070] 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.

[0071] Optionally, n takes a value of 2.4.

[0072] Optionally, the operation of determining the target image and the 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, includes: constructing a brightness peak map corresponding to the first brightness peak value and the second brightness peak value 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 value and the second brightness peak value based on the brightness peak map.

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

[0074] 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.

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

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

[0077] 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. There may be other division methods in actual implementation. For example, 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.

[0078] The unit described as a separation component may or may not be physically separated. The component shown as a unit may or may not be a physical unit, that is, it may be located in one place or may be distributed over multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0079] In addition, each functional unit in various embodiments of the present invention may be integrated in a processing unit, may exist separately as individual physical units, or two or more units may be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit.

[0080] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of this 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, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes: USB flash drives, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), mobile hard disks, magnetic disks, or optical discs and other various media that can store program codes.

[0081] The above is only the preferred embodiment of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present invention, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present invention.

Claims

1. A method for optimizing removing background patterns, characterized in that, Including: Determine the target image and the brightness values of each pixel point in the target image, and based on the brightness values of each pixel point, determine the first brightness peak and the second brightness peak corresponding to the target image; Based on the first brightness peak and the second brightness peak, determine the brightness threshold corresponding to the target image; Determine the brightness value decline rate corresponding to the transitional color area in the target image, where the transitional color area is used to indicate the area of smooth transition between multiple colors; Calculate the brightness replacement value of each pixel point, where 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 power exponent of the brightness value decline rate and the power exponent of the brightness threshold decline rate; And When the brightness replacement value of each pixel point is determined, perform background removal processing on the target image.

2. The method according to claim 1, 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 point is as follows: ; Among them, represents the brightness value corresponding to the i th pixel point, represents the brightness threshold, and n represents the brightness value decrease rate of the transition color area.

3. The method according to claim 2, wherein n takes the value of 2.

4.

4. The method according to claim 1, characterized in that The operation of determining the target image and the brightness values of each pixel point in the target image, and based on the brightness values of each pixel point, determining the first brightness peak and the second brightness peak corresponding to the target image includes: Based on the brightness values of each pixel point, construct a brightness peak graph corresponding to the first brightness peak and the second brightness peak, where the abscissa of the brightness peak graph represents the brightness value, and the ordinate represents the number of pixel points corresponding to each brightness value; and Based on the brightness peak graph, determine the first brightness peak and the second brightness peak.

5. The method according to claim 4, wherein 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 the first brightness peak and the second brightness peak are determined, use the slope extrapolation method to calculate the trough value in the brightness peak graph, and determine the brightness value corresponding to the trough value as the brightness threshold.

6. A device for optimizing the removal of shading, characterized in that, Including: A brightness peak determination module, configured to determine the target image and the brightness values of each pixel point in the target image, and based on the brightness values of each pixel point, determine the first brightness peak and the second brightness peak corresponding to the target image; A brightness threshold determination module, configured to determine the brightness threshold corresponding to the target image based on the first brightness peak and the second brightness peak; A brightness value decline rate determination module, configured to determine the brightness value decline rate corresponding to the transitional color area in the target image, where the transitional color area is used to indicate the area of smooth transition between multiple colors; A brightness replacement value determination module, configured to calculate the brightness replacement value of each pixel point, where 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 power exponent of the brightness value decline rate and the power exponent of the brightness threshold decline rate; And The background removal processing module is used to perform background removal processing on the target image when the brightness replacement values of the respective pixel points are determined.

7. The device according to claim 6, characterized in that The brightness replacement value determination module includes: The formula for determining the brightness replacement values of the respective pixel points is as follows: ; Among them, represents the brightness value corresponding to the i th pixel point, represents the brightness threshold, and n represents the brightness value decrease rate of the transitional color area.

8. The device according to claim 7, characterized in that, n takes a value of 2.

4.

9. A storage medium, characterized in that, The storage medium includes a stored program, wherein the method according to any one of claims 1 to 5 is executed by a processor when the program runs.

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

  • Display apparatus, display method, display controller, letter image creating device, and computer-readable recording medium in which letter image generation program is recorded

    US20020060689A1