A data processing method, system, electronic device and storage medium
By adding the compensation value k to the numerical value Y based on the probability Fk in data processing, the truncation error problem caused by bit width conversion is solved, real-time compensation for multiple errors is achieved, and image processing efficiency is improved.
Patent Information
- Application Number
- CN202510217855.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-26
- Publication Date
- 2025-06-27
- Estimated Expiration
- 2045-02-26
AI Technical Summary
During data processing, the truncation error caused by bit width conversion will cause 'water stains' or 'pseudo-contour' phenomena on the image, and the prior art is difficult to effectively compensate for the truncation error in multi-stage series connection, affecting the image processing efficiency.
By obtaining the numerical value Y after multiple bit width conversion, and adding the compensation value k to the numerical value Y based on the preset probability Fk, the compensated numerical value is obtained. This method compensates multiple truncation errors in one go through the form of probability, with high real-time performance and simple operation.
Effectively compensate for the truncation error in multiple bit width conversion, reduce the 'water stain' and 'pseudo-contour' phenomena in image processing, improve data processing efficiency, and is suitable for multi-level tandem image algorithms.
Smart Images

Figure CN119719608B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of data processing, and particularly relates to a data processing method, system, electronic device and storage medium. Background Art
[0002] In the process of data processing, bit-width conversion is a commonly used technique. For example, in the algorithm operation of an 8-bit image, in the intermediate calculation link, the 8-bit data is first converted to 12 bits, and after the calculation is completed, it is converted back to 8 bits for output. In the above-mentioned bit-width conversion process from 12 bits to 8 bits, usually the high 8 bits of the 12 bits are used as the output, and the low 4 bits are directly discarded. Thus, there is a truncation error in the bit-width conversion.
[0003] Taking image processing as an example, in the field of digital images, there are patterns of "water stains" or "pseudo-contours" on the image after bit-width conversion, as Figure 1 shown. Further, in the process of digital image processing, there are usually multiple image algorithms involving bit-width conversion, and the image algorithms often work in series, with the output of the previous-stage algorithm serving as the input of the next-stage algorithm.
[0004] If the truncation error in the bit-width conversion process is compensated after each stage of algorithm processing, it will affect the efficiency of image processing. Therefore, there is an urgent need for a data processing solution to solve the above problems. Summary of the Invention
[0005] A data processing method, system, electronic device and storage medium proposed in the present application are used to achieve the truncation error compensation in the above multi-stage series connection situation and improve the data processing efficiency.
[0006] To achieve the above object, the present application proposes the following technical solutions:
[0007] In the first aspect of the present application, a data processing method is provided, including:
[0008] Obtaining the value Y after multiple bit-width conversions;
[0009] Based on the preset probability F k , adding a compensation value k to the value Y to obtain a compensated value;
[0010] Wherein, ;
[0011] k represents any integer between 0 and Q; F kRepresents the probability of increasing the compensation value k on the numerical value Y; Q represents the total number of bit-width conversions; R represents the set composed of integers between 1 and Q; R1 represents a subset of the set R and contains k elements within the set R; R2 represents the complement of the set R1 within the range of the set R; i and j respectively represent the index values within the sets R1 and R2; p i Represents the truncation error during the i-th bit-width conversion, p j Represents the truncation error during the j-th bit-width conversion, and ; ; d i Represents, during the i-th bit-width conversion, when the data bit-width is M i bits, the difference between the numerical value before the bit-width conversion and the numerical value after the bit-width conversion; M i Represents the data bit-width before the conversion during the i-th bit-width conversion; N i Represents the data bit-width after the conversion during the i-th bit-width conversion.
[0012] Optionally, before obtaining the numerical value Y after multiple bit-width conversions, the method further includes:
[0013] Calculating the truncation error during each bit-width conversion.
[0014] Optionally, before increasing the compensation value k on the numerical value Y based on the preset probability F k , the method further includes:
[0015] Calculating the probability F corresponding to the compensation value k k .
[0016] Optionally, if the data undergoes one bit-width conversion, the method further includes:
[0017] Obtaining the bit-width M1 of the data before the bit-width conversion and the numerical value a before the conversion, as well as the bit-width N1 after the conversion and the numerical value b after the conversion;
[0018] Compensating the numerical value b based on the preset probability p1 to obtain the compensated numerical value c;
[0019] Wherein, the compensation formula is: in the case of the probability 1 - p1, c = b; in the case of the probability p1, c = b + 1; ; d1 = a - b.
[0020] Optionally, the compensating the numerical value b based on the preset probability p1 to obtain the compensated numerical value c includes:
[0021] Within the integer interval from 0 to , randomly extracting the numerical value e;
[0022] Based on the comparison result between the numerical value e and the difference d1, a compensated numerical value c is obtained; wherein, when the numerical value e ≤ d1, c = b + 1; when the numerical value e > d1, c = b.
[0023] Optionally, the numerical value Y includes the gray value of any pixel point.
[0024] In the second aspect of the present application, a data processing system is provided, including:
[0025] A numerical value acquisition module, configured to acquire the numerical value Y after multiple bit-width conversions;
[0026] A probability compensation module, configured to, based on a preset probability F k , add a compensation value k to the numerical value Y to obtain a compensated numerical value;
[0027] Wherein, ;
[0028] k represents any integer between 0 and Q; F k represents the probability of adding the compensation value k to the numerical value Y; Q represents the total number of bit-width conversions; R represents a set composed of integers between 1 and Q; R1 represents a subset of the set R and contains k elements within the set R; R2 represents the complement of the set R1 within the range of the set R; i and j respectively represent the index values within the sets R1 and R2; p i represents the truncation error in the i-th bit-width conversion process, p j represents the truncation error in the j-th bit-width conversion process, and ; ; d i represents, in the i-th bit-width conversion process, when the data bit-width is M i bits, the difference between the numerical value before bit-width conversion and the numerical value after bit-width conversion; M i represents the data bit-width before conversion in the i-th bit-width conversion process; N i represents the data bit-width after conversion in the i-th bit-width conversion process.
[0029] Optionally, the system further includes:
[0030] An error calculation module, configured to calculate the truncation error in each bit-width conversion process;
[0031] A probability calculation module, configured to calculate the probability F corresponding to the compensation value k k .
[0032] In the third aspect of the present application, an electronic device is provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory complete mutual communication through the communication bus;
[0033] A memory for storing computer programs;
[0034] A processor, when executing the program stored in the memory, implements the data processing method described in any item of the first aspect.
[0035] In the fourth aspect of the present application, a computer-readable storage medium is provided. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the data processing method described in any item of the first aspect is implemented.
[0036] The beneficial effects of the present application are as follows:
[0037] The present application provides a data processing method, including: obtaining a value Y after multiple bit-width conversions; based on a preset probability F k , adding a compensation value k to the value Y to obtain a compensated value.
[0038] Wherein, ;
[0039] k represents any integer between 0 and Q; F k represents the probability of adding the compensation value k to the value Y; Q represents the total number of bit-width conversions; R represents a set composed of integers between 1 and Q; R1 represents a subset of the set R and contains k elements in the set R; R2 represents the complement of the set R1 within the range of the set R; i and j respectively represent the index values in the sets R1 and R2; p i represents the truncation error in the i-th bit-width conversion process, p j represents the truncation error in the j-th bit-width conversion process, and ; ; d i represents, in the i-th bit-width conversion process, when the data bit-width is M i bits, the difference between the value before bit-width conversion and the value after bit-width conversion; M i represents the data bit-width before conversion in the i-th bit-width conversion process; N i represents the data bit-width after conversion in the i-th bit-width conversion process.
[0040] Based on the above processing, the data processing solution provided by the present application adds the compensation value k to the value Y based on the probability F k , and at the same time, based on the formula content of the probability F k , it can be seen that the probability F kThe expected probability obtained by multiplying by the compensation value k is the same as the sum of the truncation errors of the value Y in multiple bit-width conversions. Therefore, in this solution, the multiple truncation errors can be compensated at once in the form of probability, with high real-time performance, simple operation process, and less resource consumption, and it can be applied to multi-stage cascaded image algorithms. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The schematic embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation to the present invention. In the drawings:
[0042] Figure 1 is an image with water stains caused by truncation errors provided by this application;
[0043] Figure 2 is a schematic flowchart of a data processing method provided by this application;
[0044] Figure 3 is a schematic flowchart of another data processing method provided by this application;
[0045] Figure 4 is a schematic structural diagram of a pixel data processing device provided by this application;
[0046] Figure 5 is an image after error compensation provided by this application;
[0047] Figure 6 is a schematic structural diagram of a data processing system provided by this application;
[0048] Figure 7 is a structural diagram of an electronic device provided by this application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0049] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of this application. Apparently, the described embodiments are some but not all of the embodiments of this application.
[0050] During the process of converting M-bit image data to N-bit (M > N), the lower M - N bits are discarded, generating errors, which will form patterns such as "water stains" and "pseudo-contours" on the converted image, as Figure 1 shown. The reason for this phenomenon is that there are truncation errors during the bit-width conversion of the gray value, resulting in the loss of part of the image information, causing a sudden "pseudo-contour" to appear at certain positions in the originally gradually changing image.
[0051] To solve this problem, various technical means have been disclosed in the prior art, including methods of adding random noise, error diffusion, and random compensation.
[0052] In the existing method of adding random noise, such as Japanese Patent JP1993122523A and JP2003162717A, random noise is added to each pixel point in the M-bit image data, so that the part that would originally be definitely truncated and discarded may obtain the superposition of random noise to generate a carry, thereby showing the effect of an increased gray value, and can compensate for the truncation error to a certain extent, thus improving the "pseudo contour" problem.
[0053] Based on the technology of error diffusion, such as Chinese Patent CN 105391912 A, by calculating the truncation error of the current pixel point and dispersing and compensating it to the surrounding pixels, the truncation error can be offset macroscopically, thereby solving the "pseudo contour" problem.
[0054] In addition, in the field of direct digital synthesis, Chinese Patent CN117311442 A discloses a method of randomly compensating data with 0 or 1 after truncation, which can solve the problem of the deterioration of the radio frequency signal spectrum in the field of digital synthesis, and has a certain similarity to the problem to be solved in this application.
[0055] However, the prior art also has defects such as high noise, low real-time performance, large resource consumption, and narrow application range.
[0056] Specifically, in the method of adding random noise, by generating random numbers within a certain range, adding them to the image data before bit width conversion, and then performing bit width conversion, the noise of the output image will be increased, and the image quality will be reduced.
[0057] Based on the technology of error diffusion, by dispersing the gray truncation error of the current pixel to the surrounding pixels, it is necessary to cache L rows of image data (L>1), and pixel-level real-time processing cannot be achieved, with low real-time performance, and more resources will be consumed when implemented in a hardware circuit.
[0058] In addition, both the technology based on error diffusion and the method of randomly compensating data with 0 or 1 after truncation can only compensate for the truncation error once. However, in the process of digital image data processing, there are usually multiple image algorithms involving bit width conversion. These algorithms often work in series, and the output of the previous algorithm is used as the input of the next algorithm. In order to improve the calculation accuracy within each algorithm, the bit width is first increased for intermediate operations and then stage output. Therefore, the prior art can only process 1-level conversion and is difficult to be applied to multi-level cascaded image algorithms.
[0059] To solve the above problems, this application provides a data processing method, as Figure 2 shown, the method includes the following steps:
[0060] S1. Obtain the value Y after multiple bit-width conversions.
[0061] S2. Based on the preset probability F k , add the compensation value k to the value Y to obtain the compensated value.
[0062] Among them, ;
[0063] k represents any integer between 0 and Q; F k represents the probability of adding the compensation value k to the value Y; Q represents the total number of bit-width conversions; R represents the set composed of integers between 1 and Q; R1 represents a subset of the set R and contains k elements in the set R; R2 represents the complement of the set R1 within the range of the set R; i and j respectively represent the index values in the sets R1 and R2; p i represents the truncation error in the i-th bit-width conversion process, and p j represents the truncation error in the j-th bit-width conversion process, and ; ; d i represents the difference between the value before bit-width conversion and the value after bit-width conversion in the i-th bit-width conversion process when the data bit-width is M i bits; M i represents the data bit-width before conversion in the i-th bit-width conversion process; N i represents the data bit-width after conversion in the i-th bit-width conversion process.
[0064] Similarly, d j represents the difference between the value before bit-width conversion and the value after bit-width conversion in the j-th bit-width conversion process when the data bit-width is M j bits; M j represents the data bit-width before conversion in the j-th bit-width conversion process; N j represents the data bit-width after conversion in the j-th bit-width conversion process.
[0065] Based on the above processing, the data processing solution provided by this application adds the compensation value k to the value Y based on the probability F k . At the same time, based on the formula content of the probability F k , it can be known that the expected probability obtained by multiplying the probability F k by the compensation value k is the same as the sum of the truncation errors of the value Y in multiple bit-width conversions. Therefore, in this solution, the multiple truncation errors can be compensated at one time in the form of probability, with high real-time performance, simple operation process, and less resource consumption, and it can be applied to multi-stage cascaded image algorithms.
[0066] Compared with the prior art, the present application uses a probability - statistics - based method to perform appropriate expected compensation for truncation errors, having advantages such as good processing effect, high real - time performance, less resource consumption, and wide application range.
[0067] As Figure 3 shown, the data - processing solution provided by the present application further includes the following steps before step S1:
[0068] S3. Calculate the truncation error in each bit - width conversion process.
[0069] Among them, the truncation error of each bit - width conversion ; . Note that when using the compensation values of 0 and 1 to compensate for a truncation error, to meet the requirement that the probability expectation is the same as the truncation error, therefore, the probability corresponding to the compensation value 1 is also p i or p j .
[0070] Before step S2, the present application further includes the following steps:
[0071] S4. Calculate the probability F corresponding to the compensation value k k .
[0072] Among them, .
[0073] In some embodiments, if the data undergoes a bit - width conversion once, the data - processing method provided by the present application further includes the following steps:
[0074] S5. Obtain the bit - width M1 of the data before the bit - width conversion and the value a before the conversion, as well as the bit - width N1 after the conversion and the value b after the conversion.
[0075] S6. Compensate the value b based on a preset probability p1 to obtain the compensated value c.
[0076] Among them, the compensation formula is: in the case of probability 1 - p1, c = b; in the case of probability p1, c = b + 1; ; d1 = a - b.
[0077] In some embodiments, step S6 includes the following content:
[0078] S601. Randomly draw a value e within the integer interval from 0 to .
[0079] S602. Based on the comparison result between the value e and the difference d1, obtain the compensated value c. Among them, when the value e ≤ d1, c = b + 1; when the value e > d1, c = b.
[0080] The following takes digital image processing as an example to illustrate data compensation in one-time bit-width conversion.
[0081] Step 1: During the bit-width conversion, the data bit-width of the input image is M1 bits, and the data bit-width of the output image is required to be N1 bits (M1 > N1 > 0). Among them, the N1 bits of the output image are the high bits of the M1-bit input data. Denote the input (i.e., the gray value of the pixel point before bit-width conversion) as a, and the output (i.e., the gray value of the pixel point after bit-width conversion) as b. Then b = a>>(M1 - N1), that is, b is equal to a shifted to the right by M1 - N1 bits.
[0082] Step 2: Calculate the truncation error d1 at this time, where d1 = a - b. Here, d1 represents the truncation error in M1 bits, and the corresponding truncation error in N1 bits is d1 / (2^(M1 - N1)).
[0083] Step 3: Perform a data compensation of LSB (Least Significant Bit) for the output data b with a probability p1 to obtain c. Specifically,
[0084] c = b (with a probability of 1 - p1)
[0085] c = b + 1 (with a probability of p1)
[0086] Among them, the probability . The principle is that truncation in bit-width conversion brings errors in the converted image. This error is d1 before conversion and is discarded as a decimal, which is d1 / (2^(M1 - N1)). Set this error as the probability p1, and compensate the gray value of 1 with a probability of p1. Then the compensation expectation = p1×1 = d1 / (2^(M1 - N1)). From a statistical perspective, the output c is compensated compared to b, and the compensation statistical value is equal to the truncation error. Therefore, the "pseudo contour" or "water stain" problem existing in the digital image during the bit-width conversion process can be solved.
[0087] In addition, for Step 3, the present application also provides a specific implementation method: generate a natural random number e that follows a uniform distribution, and the range is 0~ . Then the probability that 1 <= e <= d1 is d1 / (2^(M1 - N1)), that is, the probability that 1 <= e <= d1 is p1. Therefore, if the generated random number e satisfies 1 <= e <= d1, then implement c = b + 1 (with a probability of p1), otherwise implement c = b (with a probability of 1 - p1).
[0088] When the digital image data is processed and undergoes multiple-level bit-width conversion, for the value Y output at the last level, in the solution provided by the present application, error compensation is performed through Step S2. The principle description of multi-level error compensation is as follows:
[0089] In the bit-width conversion of Q levels, for each level, the probability p i is for compensation 1, and the probability (1 - p j ) is for compensation 0. Therefore, the probability of compensating k in total for Q levels is that there are k levels compensating 1 and Q - k levels compensating 0 among the Q levels. Considering independent and identically distributed, multiplying the probabilities, it is the product of p i multiplied k times and then multiplied by the product of (1 - p j ) multiplied Q - k times.
[0090] Let the natural numbers from 1 to Q form the set R. Then, k levels can be drawn from it to form the set R1, and R1 is a subset of R, and its complement is defined as R2. Thus, there are multiple combination ways of R1 and R2, and the probabilities of different combination ways need to be added.
[0091] For example, there are 2 bit-width conversion levels A and B executed in series. According to the foregoing analysis, bit-width truncation will occur in each level. The truncation error generated by A will be transmitted to the input of level B, resulting in the output data of level B containing not only the truncation error of level B itself but also the truncation error of the output data of level A.
[0092] Referring to the principle of the foregoing scheme, if the compensation expectation of level A is pa and the compensation expectation of level B is pb, then it can be considered that the final required compensation expectation p_total = pa + pb. The value range of p_total is 0 to 2, which means there are three possible cases for the final compensation value: 0, 1, and 2. Correspondingly, if there are Q levels, the value range of the compensation value p_total is 0 to Q, and there are Q + 1 compensation cases in total: 0 / 1 / 2…Q.
[0093] The probabilities of each compensation case are different. Taking levels A and B as an example for calculation: Compensation value 2: That is, both A and B links need to compensate 1 respectively, and the probability is pa×pb. Compensation value 1: That is, one of the A and B links needs to compensate 1 and the other does not need to compensate, and the probability is pa×(1 - pb)+(1 - pa)×pb. Compensation value 0: That is, neither the A nor the B link needs to compensate, and the probability is (1 - pb)×(1 - pa).
[0094] Verify that the total compensation expectation according to this scheme = 2×pa×pb + 1×(pa×(1 - pb)+(1 - pa)×pb)+0×(1 - pb)×(1 - pa)=pa + pb, which is the same as the expected p_total = pa + pb.
[0095] Since the calculation of F k is relatively complex, the value of F k can be calculated in advance and saved. When used, it can be directly loaded for use, which can improve the operation efficiency of this scheme.
[0096] In addition, the data processing solution provided by this application, compared with the existing technology based on "error diffusion", only performs real-time processing on the current pixel without the need to associate with other pixels. Therefore, when implemented in a hardware system, there is no need to cache additional image data, reducing resource consumption. At the same time, this application performs appropriate expected compensation for the truncation error based on probability statistics and can be applied to the case of multi-level bit-width conversion.
[0097] Regarding the truncation error in digital image processing, this application also provides a pixel data processing device, as Figure 4 shown, the device includes:
[0098] Digital image algorithm circuit 1: used to execute digital image algorithm 1.
[0099] Bit-width conversion circuit 1: used to convert the bit-width of the output image data of digital image algorithm circuit 1 to the required bit-width.
[0100] Truncation error calculation circuit 1: used to calculate the truncation error generated by bit-width conversion circuit 1 after converting the bit-width of a pixel.
[0101] Digital image algorithm circuit 2: used to execute digital image algorithm 2.
[0102] Bit-width conversion circuit 2: used to convert the bit-width of the output image data of digital image algorithm circuit 2 to the required bit-width.
[0103] Truncation error calculation circuit 2: used to calculate the truncation error generated by bit-width conversion circuit 2 after converting the bit-width of a pixel.
[0104] F k Lookup table circuit: stores the probability F of the compensation k corresponding to each truncation error value algorithm level k Random number generator circuit: used to generate a random number to determine whether an event with probability F k occurs.
[0105] Truncation compensation circuit: receives the value of probability F k and the random number generated by the random number generator circuit, determines whether an event with probability F k occurs. If it occurs, compensates the image data with gray level k, and loops for k = 1 to Q. Q is the number of bit-width conversion circuits, and the number in this pixel data processing device is 2. Figure 5 This is an image after error compensation provided by this application, as Figure 5 shown. The data processing solution provided by this application can effectively compensate for the truncation error in the bit-width conversion process.
[0106] In addition, the number of the digital image algorithm circuit, the bit-width conversion circuit, and the truncation error calculation circuit of the pixel data processing device provided in this application is not limited to 2, and may be 3, 4, 5, or more.
[0107] Based on the same inventive concept, this application also provides a data processing system, as Figure 6 shown, the system includes:
[0108] A numerical value acquisition module 601, configured to acquire the numerical value Y after multiple bit-width conversions;
[0109] A probability compensation module 602, configured to add a compensation value k to the numerical value Y based on a preset probability F k to obtain a compensated numerical value;
[0110] Wherein, ;
[0111] k represents any integer between 0 and Q; F k represents the probability of adding the compensation value k to the numerical value Y; Q represents the total number of bit-width conversions; R represents a set composed of integers between 1 and Q; R1 represents a subset of the set R and contains k elements within the set R; R2 represents the complement of R1 within the range of the set R; i and j respectively represent the index values within the sets R1 and R2; p i represents the truncation error in the i-th bit-width conversion process, and p j represents the truncation error in the j-th bit-width conversion process, and ; ; d i represents the difference between the numerical value before bit-width conversion and the numerical value after bit-width conversion in the i-th bit-width conversion process when the data bit-width is M i bits; M i represents the data bit-width before conversion in the i-th bit-width conversion process; N i represents the data bit-width after conversion in the i-th bit-width conversion process.
[0112] In some embodiments, the data processing system provided in this application further includes:
[0113] An error calculation module, configured to calculate the truncation error in each bit-width conversion process;
[0114] A probability calculation module, configured to calculate the probability F corresponding to the compensation value k k .
[0115] An embodiment of this application also provides an electronic device, as Figure 7As shown, it includes a processor 701, a communication interface 702, a memory 703, and a communication bus 704. Among them, the processor 701, the communication interface 702, and the memory 703 complete their mutual communication through the communication bus 704;
[0116] The memory 703 is used to store computer programs;
[0117] When the processor 701 is used to execute the program stored on the memory 703, the above-mentioned any data processing method is implemented.
[0118] The communication bus mentioned in the above electronic device may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation, only a thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0119] The communication interface is used for the communication between the above electronic device and other devices.
[0120] The memory may include a Random Access Memory (RAM), or may also include a Non-Volatile Memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located far from the aforementioned processor.
[0121] The above-mentioned processor may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0122] In another embodiment provided by the present application, a computer-readable storage medium is also provided. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned any data processing method steps are implemented.
[0123] In another embodiment provided by the present application, a computer program product containing instructions is further provided. When it runs on a computer, it causes the computer to execute any of the data processing method steps in the above embodiments.
[0124] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A data processing method, characterized in that: The method deals with the truncation error of grayscale values in digital images during bit width conversion, including: Get the value Y after multiple bit width conversions; Based on the preset probability F k , add the compensation value k to the value Y to get the compensated value; in, ; k represents any integer between 0 and Q; F k represents the probability of adding compensation value k to value Y; Q represents the total number of bit width conversions; R represents a set consisting of integers between 1 and Q; R1 represents a subset of set R and contains k elements in set R; R2 represents the complement of set R1 within the range of set R; i and j represent index values in set R1 and set R2 respectively; p i represents the truncation error during the i-th bit width conversion process, p j represents the truncation error during the j-th bit width conversion process, and ; ;d i Indicates that during the i-th bit width conversion, when the data bit width is M i In the case of bit width conversion, the difference between the value before bit width conversion and the value after bit width conversion is subtracted; M i Indicates the data bit width before conversion during the i-th bit width conversion process; N i Indicates the data bit width after conversion during the i-th bit width conversion process.
2. The method according to claim 1, characterized in that Before obtaining the value Y after multiple bit width conversions, the method further includes: Calculate the truncation error during each bit width conversion.
3. The method according to claim 1, characterized in that Based on the preset probability F k , before adding the compensation value k to the value Y, the method further includes: Calculate the probability F corresponding to the compensation value k k .
4. The method according to claim 1, characterized in that: If the data undergoes a bit width conversion, the method further includes: Obtaining the bit width M1 of the data before bit width conversion and the value a before conversion, as well as the bit width N1 and the value b after conversion; Compensate the value b based on the preset probability p1 to obtain a compensated value c; The compensation formula is: in the case of probability 1-p1, c=b; in the case of probability p1, c=b+1; ;d1=ab.
5. The method according to claim 4, characterized in that The compensating the value b based on the preset probability p1 to obtain the compensated value c includes: From 0 to Randomly select a value e from the integer interval; Based on the comparison result between the value e and the difference d1, the compensated value c is obtained; wherein, when the value e≤d1, c=b+1; when the value e>d1, c=b.
6. The method according to any one of claims 1 to 5, characterized in that: The value Y includes the grayscale value of any pixel.
7. A data processing system, characterized in that: The system handles truncation errors in grayscale values in digital images during bit-width conversion, including: A value acquisition module is used to obtain the value Y after multiple bit width conversions; Probabilistic compensation module, used for k , add the compensation value k to the value Y to get the compensated value; in, ; k represents any integer between 0 and Q; F k represents the probability of adding compensation value k to value Y; Q represents the total number of bit width conversions; R represents a set consisting of integers between 1 and Q; R1 represents a subset of set R and contains k elements in set R; R2 represents the complement of set R1 within the range of set R; i and j represent index values in set R1 and set R2 respectively; p i represents the truncation error during the i-th bit width conversion process, p j represents the truncation error during the j-th bit width conversion process, and ; ;d i Indicates that during the i-th bit width conversion, when the data bit width is M i In the case of bit width conversion, the difference between the value before bit width conversion and the value after bit width conversion is subtracted; M i Indicates the data bit width before conversion during the i-th bit width conversion process; N i Indicates the data bit width after conversion during the i-th bit width conversion process.
8. The system according to claim 7, characterized in that The system further comprises: An error calculation module is used to calculate the truncation error in each bit width conversion process; Probability calculation module, used to calculate the probability F corresponding to the compensation value k k .
9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the data processing method according to any one of claims 1 to 6 when executing a program stored in a memory.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the data processing method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Imaging processing method based on error diffusion
CN105391912A
Direct digital synthesis system and method based on random frequency compensation
CN117311442A
Gradation conversion circuit
JP1993122523A
Image processing method and device and printer system
JP2003162717A
Lossy compression algorithm based on peak clipping and tail insertion technology and geometrical progression companding transform
CN106992787A