Image processing method and device, electronic equipment, storage medium and program product
By inferring the quantization parameters from the quantized image and adjusting the pixel values, the problem of quantization noise is solved, achieving effective noise reduction when the original data is unavailable.
Patent Information
- Application Number
- CN202410940338.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2026-01-13
AI Technical Summary
In existing technologies, quantized images contain quantization noise, and it is difficult to effectively reduce or eliminate quantization noise when the original image data cannot be obtained.
By determining the pixel value distribution of each pixel in the image, the quantization parameters are inferred, and the pixel values in the image are adjusted based on these parameters to generate a new image with reduced or eliminated quantization noise.
Without obtaining the original image data, it can effectively reduce quantization noise and ensure good visual quality of the denoised image.
Smart Images

Figure CN121329802A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of image processing, and more particularly to an image processing method, apparatus, electronic device, storage medium, and program product. Background Technology
[0002] In related technologies, electronic devices can perform quantization processing on images to obtain quantized images.
[0003] However, when quantization noise exists in the quantized image, the relevant technologies have not adopted effective means to eliminate or reduce the quantization noise in the image. Summary of the Invention
[0004] To overcome the problems in related technologies, this disclosure provides an image processing method, apparatus, electronic device, storage medium, and program product to effectively reduce quantization noise present in a first image.
[0005] According to a first aspect of the present disclosure, an image processing method is provided, the method comprising:
[0006] If the first image is acquired, determine whether the original image data that generated the first image was detected; wherein, the first image is an image obtained by quantizing the original image data;
[0007] In the absence of detecting the original image data, determine the pixel value of each pixel in the first image;
[0008] Based on the distribution of pixel values of each pixel, the quantization parameters corresponding to each pixel in the first image are determined.
[0009] The pixel values of at least some pixels in the first image are adjusted based on quantization parameters to obtain the second image;
[0010] At least some of the pixels are located in image regions with quantization noise.
[0011] In some embodiments, determining the quantization parameters corresponding to each pixel in the first image based on the distribution of pixel values includes:
[0012] By traversing the image, the distance between any pixel and all other pixels in the first image is determined until the distance value for each pixel is obtained; where the distance value is used to indicate the distribution of pixel values for each pixel.
[0013] Based on the distance value corresponding to each pixel, the quantization parameters corresponding to each pixel in the first image are determined.
[0014] In some embodiments, any pixel has a first pixel value; determining the distance values between any pixel in the first image and all other pixels until the distance values corresponding to each pixel are obtained includes:
[0015] Determine a first distance value between any pixel and a first pixel having a second pixel value, and a second distance value between any pixel and a second pixel having a third pixel value; wherein the first pixel value is greater than the second pixel value, and the first pixel value is less than the third pixel value, the difference between the first pixel value and the second pixel value is less than a first threshold, and the difference between the first pixel value and the third pixel value is less than a second threshold;
[0016] Based on the distance value corresponding to each pixel, the quantization parameters corresponding to each pixel in the first image are determined, including:
[0017] Based on the first distance value and the second distance value corresponding to each pixel, the quantization parameters corresponding to each pixel in the first image are determined respectively.
[0018] In some embodiments, determining a first distance value between the any pixel and a first pixel having a second pixel value, and a second distance value between the any pixel and a second pixel having a third pixel value, includes:
[0019] Determine a third distance value between any given pixel and a third pixel located within a predetermined range of that given pixel;
[0020] Based on the pixel value of each third pixel, the first distance value and the third distance value corresponding to each third pixel, determine the first distance value corresponding to any pixel.
[0021] Based on the pixel value of each third pixel, the second distance value and the third distance value corresponding to each third pixel, the second distance value corresponding to any pixel is determined.
[0022] In some embodiments, determining the first distance value corresponding to any pixel point based on the pixel value of each third pixel point, the first distance value corresponding to each third pixel point, and the third distance value includes:
[0023] For each third pixel, if any pixel has a first distance value and the third pixel has a first pixel value, if the first sum between the first distance value and the third distance value is less than the first distance value corresponding to any pixel, then the first distance value corresponding to any pixel is updated to the first sum.
[0024] For each third pixel, if any pixel has a first distance value and the third pixel has a second pixel value, if the third distance value is less than the first distance value corresponding to any pixel, then the first distance value corresponding to any pixel is updated to the third distance value.
[0025] The first distance value corresponding to any pixel is either the initially set distance value or the distance value obtained after updating the initially set distance value.
[0026] In some embodiments, determining the second distance value corresponding to any pixel point based on the pixel value of each third pixel point, the second distance value corresponding to each third pixel point, and the third distance value includes:
[0027] For each third pixel, if any pixel has a second distance value and the third pixel has a first pixel value, if the second sum between the second distance value and the third distance value corresponding to the third pixel is less than the second distance value corresponding to any pixel, then the second distance value corresponding to any pixel is updated to the second sum.
[0028] For each third pixel, if there is a second distance value corresponding to any pixel and the third pixel has a third pixel value, if the third distance value is less than the second distance value corresponding to any pixel, then the second distance value corresponding to any pixel is updated to the third distance value.
[0029] The second distance value corresponding to any pixel is either the initially set distance value or the distance value obtained after updating the initially set distance value.
[0030] In some embodiments, the quantization parameters corresponding to each pixel in the first image are determined based on the first distance value and the second distance value corresponding to each pixel, including:
[0031] Based on the first distance value and the second distance value corresponding to each pixel, the quantization relationship between the pixel value of each pixel in the first image and the pixel value before quantization corresponding to the pixel is determined, as well as the quantization error value between the pixel value of each pixel in the first image and the pixel value before quantization corresponding to the pixel is determined.
[0032] The pixel values of at least some pixels in the first image are adjusted based on quantization parameters to obtain the second image, including:
[0033] Based on the quantization relationship and quantization error value, the pixel values of at least some pixels in the first image are adjusted.
[0034] In some embodiments, the method further includes:
[0035] Generate a third image; wherein the pixel values of the pixels in the third image are randomly and uniformly distributed; the resolution of the third image is the same as that of the first image; and the pixels in the third image and the first image at the same position correspond to each other.
[0036] Based on the quantization relationship and quantization error value, the pixel values of at least some pixels in the first image are adjusted, including:
[0037] If the quantization relationship indicates that the pixel value of a pixel in the first image is less than the pixel value before quantization, and the product of the quantization error value and the preset value is greater than the pixel value of the corresponding pixel in the third image, then the pixel value of the pixel in the first image is increased; wherein, the preset value is determined according to the range of pixel values in the first image.
[0038] If the quantization relationship indicates that the pixel value of a pixel in the first image is greater than the pixel value before quantization, and the product of the quantization error value and the preset value is greater than the pixel value of the corresponding pixel in the third image, then the pixel value of the pixel in the first image is reduced.
[0039] In some embodiments, adjusting the pixel values of at least a portion of the pixels in the first image based on quantization parameters includes:
[0040] Based on the quantization parameters, the pixel values of all pixels in the first image are adjusted; and / or,
[0041] Based on the quantization parameters, the target image region containing quantization noise is determined from the first image, and the pixel values of the pixels in the target image region are adjusted.
[0042] According to a second aspect of the present disclosure, an image processing apparatus is provided, the apparatus comprising:
[0043] The determination module is configured to, upon acquiring the first image, determine whether the original image data that generated the first image is detected; wherein, the first image is an image obtained by quantizing the original image data;
[0044] In the absence of detecting the original image data, determine the pixel value of each pixel in the first image;
[0045] Based on the distribution of pixel values of each pixel, the quantization parameters corresponding to each pixel in the first image are determined.
[0046] The adjustment module is configured to adjust the pixel values of at least some pixels in the first image based on quantization parameters to obtain the second image;
[0047] At least some of the pixels are located in image regions with quantization noise.
[0048] In some embodiments, the determining module is further configured as follows:
[0049] By traversing the image, the distance between any pixel and all other pixels in the first image is determined until the distance value for each pixel is obtained; where the distance value is used to indicate the distribution of pixel values for each pixel.
[0050] Based on the distance value corresponding to each pixel, the quantization parameters corresponding to each pixel in the first image are determined.
[0051] In some embodiments, any pixel has a first pixel value;
[0052] The module is also configured as follows:
[0053] Determine a first distance value between any pixel and a first pixel having a second pixel value, and a second distance value between any pixel and a second pixel having a third pixel value; wherein the first pixel value is greater than the second pixel value, and the first pixel value is less than the third pixel value, the difference between the first pixel value and the second pixel value is less than a first threshold, and the difference between the first pixel value and the third pixel value is less than a second threshold;
[0054] Based on the first distance value and the second distance value corresponding to each pixel, the quantization parameters corresponding to each pixel in the first image are determined respectively.
[0055] In some embodiments, the determining module is further configured as follows:
[0056] Determine a third distance value between any given pixel and a third pixel located within a predetermined range of that given pixel;
[0057] Based on the pixel value of each third pixel, the first distance value and the third distance value corresponding to each third pixel, determine the first distance value corresponding to any pixel.
[0058] Based on the pixel value of each third pixel, the second distance value and the third distance value corresponding to each third pixel, the second distance value corresponding to any pixel is determined.
[0059] In some embodiments, the determining module is further configured as follows:
[0060] For each third pixel, if any pixel has a first distance value and the third pixel has a first pixel value, if the first sum between the first distance value and the third distance value is less than the first distance value corresponding to any pixel, then the first distance value corresponding to any pixel is updated to the first sum.
[0061] For each third pixel, if any pixel has a first distance value and the third pixel has a second pixel value, if the third distance value is less than the first distance value corresponding to any pixel, then the first distance value corresponding to any pixel is updated to the third distance value.
[0062] The first distance value corresponding to any pixel is either the initially set distance value or the distance value obtained after updating the initially set distance value.
[0063] In some embodiments, the determining module is further configured as follows:
[0064] For each third pixel, if any pixel has a second distance value and the third pixel has a first pixel value, if the second sum between the second distance value and the third distance value corresponding to the third pixel is less than the second distance value corresponding to any pixel, then the second distance value corresponding to any pixel is updated to the second sum.
[0065] For each third pixel, if there is a second distance value corresponding to any pixel and the third pixel has a third pixel value, if the third distance value is less than the second distance value corresponding to any pixel, then the second distance value corresponding to any pixel is updated to the third distance value.
[0066] The second distance value corresponding to any pixel is either the initially set distance value or the distance value obtained after updating the initially set distance value.
[0067] In some embodiments, the determining module is further configured to include:
[0068] Based on the first distance value and the second distance value corresponding to each pixel, the quantization relationship between the pixel value of each pixel in the first image and the pixel value before quantization corresponding to the pixel is determined, as well as the quantization error value between the pixel value of each pixel in the first image and the pixel value before quantization corresponding to the pixel is determined.
[0069] The adjustment module is also configured as follows:
[0070] Based on the quantization relationship and quantization error value, the pixel values of at least some pixels in the first image are adjusted.
[0071] In some embodiments, the device further includes:
[0072] The generation module is configured to generate a third image; wherein the pixel values of the pixels in the third image are randomly and uniformly distributed; the resolution of the third image is the same as that of the first image; and the pixels in the third image and the first image at the same position correspond to each other.
[0073] The adjustment module is also configured as follows:
[0074] If the quantization relationship indicates that the pixel value of a pixel in the first image is less than the pixel value before quantization, and the product of the quantization error value and the preset value is greater than the pixel value of the corresponding pixel in the third image, then the pixel value of the pixel in the first image is increased; wherein, the preset value is determined according to the range of pixel values in the first image.
[0075] If the quantization relationship indicates that the pixel value of a pixel in the first image is greater than the pixel value before quantization, and the product of the quantization error value and the preset value is greater than the pixel value of the corresponding pixel in the third image, then the pixel value of the pixel in the first image is reduced.
[0076] In some embodiments, the adjustment module is further configured as follows:
[0077] Based on the quantization parameters, the pixel values of all pixels in the first image are adjusted; and / or,
[0078] Based on the quantization parameters, the target image region containing quantization noise is determined from the first image, and the pixel values of the pixels in the target image region are adjusted.
[0079] According to a third aspect of the present disclosure, an electronic device is provided, comprising:
[0080] processor;
[0081] Memory used to store computer programs or instructions;
[0082] The processor executes computer programs or instructions to implement the steps in any of the image processing methods in the first aspect described above.
[0083] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium is provided, comprising:
[0084] When a computer program or instruction in a storage medium is executed by a processor, the steps in any of the image processing methods in the first aspect described above are implemented.
[0085] According to a fifth aspect of the present disclosure, a computer program product is provided, including a computer program or instructions, which, when executed by a processor, implement the steps of any of the image processing methods in the first aspect described above.
[0086] The technical solutions provided by the embodiments of this disclosure may include the following beneficial effects:
[0087] In this embodiment of the disclosure, when a first image is acquired but its original image data is not detected, the quantization parameters corresponding to each pixel in the first image can be inferred based on the distribution of pixel values. Then, based on the inferred quantization parameters, the pixel values of pixels in the image region with quantization noise in the first image are adjusted to obtain a second image with reduced or eliminated quantization noise. Thus, even when the original image data of the first image is difficult to obtain, quantization noise in the first image can be reduced, ensuring good visual quality of the resulting second image.
[0088] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0089] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.
[0090] Figure 1 This is a schematic diagram of a first image according to an exemplary embodiment.
[0091] Figure 2 This is a flowchart illustrating an image processing method according to an exemplary embodiment.
[0092] Figure 3 This is a schematic diagram illustrating the effect of an image processing method according to an exemplary embodiment. Figure 1 .
[0093] Figure 4 This is a schematic diagram illustrating the effect of an image processing method according to an exemplary embodiment. Figure 2 .
[0094] Figure 5 This is a schematic diagram illustrating a first preset mask according to an exemplary embodiment.
[0095] Figure 6 This is a schematic diagram illustrating a second preset mask according to an exemplary embodiment.
[0096] Figure 7 This is a schematic diagram illustrating the effect of an image processing method according to an exemplary embodiment. Figure 3 .
[0097] Figure 8 This is a schematic diagram illustrating the effect of an image processing method according to an exemplary embodiment. Figure 4 .
[0098] Figure 9This is a schematic diagram illustrating the effect of an image processing method according to an exemplary embodiment. Figure 5 .
[0099] Figure 10 This is a structural block diagram of an image processing apparatus according to an exemplary embodiment.
[0100] Figure 11 This is a structural block diagram of an electronic device according to an exemplary embodiment.
[0101] Figure 12 This is a block diagram of an apparatus according to an exemplary embodiment.
[0102] Figure label:
[0103] First image 1; Distance transformation result Figure 2 ; Second image 3. Detailed Implementation
[0104] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0105] To better understand the technical solutions in the embodiments of this disclosure, some image processing methods in related technologies are described by example below:
[0106] In related technologies, noise is an important factor in evaluating image quality. Noise can be divided into various types, and quantization noise is an unavoidable type of noise in digital images. If not handled properly, it can easily cause a noticeable step effect in the image. Various factors, from environmental conditions to camera sensors, can introduce noise into images. Quantization noise generally refers to a form of distortion caused by insufficient sampling precision when a digital system samples an analog signal. Currently, 8-bit quantization is used to quantize the original image data, which usually yields good results. However, when describing monochromatic flat areas (such as white walls), a noticeable step effect can easily appear (for example, such as...). Figure 1 (As shown).
[0107] When processing raw image data using low-pass filtering algorithms, such as Gaussian blur, mean blur, and most noise reduction algorithms, floating-point data is converted to integer data, introducing quantization errors. This results in a step effect in the generated image, which is particularly noticeable in areas with gradual transitions.
[0108] This quantization noise problem not only occurs in grayscale images, but also in images with at least two color channels. Current methods for addressing this issue typically involve image jittering.
[0109] In related technologies, when the quantization error value corresponding to each pixel in the image is known, the quantization error value can be propagated to reduce the average quantization error in the image.
[0110] In some embodiments, the average quantization error value may be indicated as: Where x is the x-coordinate of a pixel in the image, y is the y-coordinate of a pixel in the image, w is the width of the image, and h is the height of the image. q For the quantized image, I q The pixel values of the pixels in the image are generally within the range of [0, 255]. I represents the image before quantization, and Q represents the pixel values before quantization. e (x, y) represents the quantization error value. Wherein, the quantization error value Q... e (x, y) can be equal to I(x, y) - I q (x, y).
[0111] In some application scenarios, if only the quantized image I can be obtained... q If the image has not been processed by an electronic device, image dithering is not possible, meaning that quantization noise in the quantized image cannot be eliminated. For example, images processed by denoising algorithms / Gaussian blurring, or images obtained after image compression, are prone to developing striped quantization noise. For this type of quantization noise, if the original unquantized image is available, a general image dithering algorithm can eliminate the noise. However, in some applications, if the image was not processed by an electronic device, it is difficult to obtain the original unquantized image data, making it impossible to eliminate the quantization noise.
[0112] Based on this Figure 2 This is a flowchart illustrating an image processing method according to an exemplary embodiment, such as... Figure 2 As shown, the method includes:
[0113] Step 21: If the first image is obtained, determine whether the original image data that generated the first image is detected; wherein, the first image is an image obtained by quantizing the original image data.
[0114] The image processing method shown in this disclosure can be applied to electronic devices. Here, the electronic device may include a mobile terminal or a fixed terminal. The mobile terminal may include devices such as mobile phones, Bluetooth headsets, tablet computers, laptops, and in-vehicle terminals. The fixed terminal may include desktop computers, smart TVs, etc. In some embodiments, the operating system of the electronic device may include an Input Output System (IOS) operating system, an Android operating system, etc.
[0115] It should be noted that electronic devices may include, but are not limited to, mobile communication terminals, portable entertainment devices, wearable devices, home appliances, and special-purpose equipment. Mobile communication terminals may include, but are not limited to, mobile phones, tablets, and smartwatches; portable entertainment devices may include, but are not limited to, audio players and digital cameras; wearable devices may include, but are not limited to, smart bracelets and smart glasses; home appliances may include, but are not limited to, televisions, stereos, and video recorders; and special-purpose equipment may include, but is not limited to, drones and video game consoles.
[0116] It should be noted that the execution entity of the embodiments of this disclosure can be the central processing unit (CPU) in an electronic device in terms of hardware, and can be, for example, a related background service or application in an electronic device in terms of software, without limitation.
[0117] In some embodiments, the quantization processing operation performed on the original image data may include, but is not limited to, at least one of the following: image compression operation, Gaussian blur processing operation, and noise reduction operation.
[0118] In some embodiments, upon acquiring a first image, it is determined whether quantization noise exists in the first image; if quantization noise exists in the first image, it is determined whether the original image data used to generate the first image has been detected. Alternatively, if quantization noise does not exist in the first image, the original image data of the first image is not detected. Thus, even if quantization noise exists in the first image, the presence of original image data used to generate the first image can be detected promptly, allowing image jittering of the first image to be performed using the detected original image data. If quantization noise does not exist in the first image, there is no need to detect the original image data of the first image, thereby reducing power consumption.
[0119] It should be noted that quantization noise refers to image noise generated when the quantization error between the pixel value of at least some pixels in the first image and the pixel value before quantization is greater than a third threshold. In some application scenarios, the first image obtained after processing with noise reduction algorithms / Gaussian blur, or the first image obtained after image compression, is prone to forming striped quantization noise.
[0120] It should be noted that the electronic device that performs quantization processing on the original image data to obtain the first image and the electronic device that acquires the first image can be different electronic devices. Alternatively, the electronic device that performs quantization processing on the original image data to obtain the first image and the electronic device that acquires the first image can be the same electronic device.
[0121] For example, the original image data can be quantized in a first electronic device to obtain a first image. A second electronic device can receive the first image sent by a different first electronic device. In this case, since the first image is not obtained by quantizing the original image data in the second electronic device, the original image data that generated the first image cannot be detected in the second electronic device.
[0122] For example, the original image data can be quantized in the same electronic device to obtain a first image. After a predetermined time has passed since the first image was obtained, the original image data can be deleted. At this time, if the moment the first image is acquired is the moment the original image data has already been deleted, the original image data that generated the first image cannot be detected in the first electronic device.
[0123] Step 22: Determine the pixel value of each pixel in the first image if the original image data is not detected.
[0124] In some embodiments, when raw image data is detected, the pixel value of each pixel in the first image may be uncertain.
[0125] In some embodiments, the first image may be a grayscale image. Alternatively, the first image may be an image having at least two color channels. For example, the color channels of the first image may include a red channel, a green channel, and a blue channel; that is, the first image may be an RGB image. Alternatively, the color channels of the first image may include a Y (Luminance) channel corresponding to luminance, a U (Chrominance) channel corresponding to chroma, and a V (Chroma) channel corresponding to saturation; that is, the first image may be a YUV image.
[0126] In some embodiments, when the first image is an image having at least two color channels, determining the pixel value of each pixel in the first image may refer to determining the pixel value of each pixel in the first image in each color channel.
[0127] For example, determining the pixel value of each pixel in the first image in each color channel may include: determining at least two single-channel images of the first image for each color channel of the first image; determining the pixel value of each pixel in the first image may include: determining the pixel value of each pixel in each single-channel image.
[0128] Step 23: Based on the distribution of pixel values of each pixel, determine the quantization parameters corresponding to each pixel in the first image.
[0129] In some embodiments, determining the quantization parameters corresponding to each pixel in the first image based on the distribution of pixel values of each pixel includes: determining the quantization parameters corresponding to each pixel in the first image in each color channel based on the distribution of pixel values of each pixel in each color channel.
[0130] For example, the quantization parameters corresponding to each pixel in each single-channel image can be determined based on the distribution of pixel values in each pixel in each single-channel image.
[0131] Step 24: Adjust the pixel values of at least some pixels in the first image based on the quantization parameters to obtain the second image;
[0132] At least some of the pixels are located in image regions with quantization noise.
[0133] It should be noted that adjusting the pixel values of at least some pixels in the first image based on quantization parameters can refer to image dithering of the first image based on quantization parameters to adjust the pixel values of at least some pixels in the first image. This allows image regions with quantization noise to be smoothed after adjustment. The image dithering method here can be any known image dithering method in related technologies.
[0134] In some embodiments, the pixel values of at least some pixels in the first image are adjusted based on quantization parameters. Specifically, based on the quantization parameters of the pixels in the first image, it is determined whether the quantization error between the pixel value of a pixel in the first image and the pixel value before quantization is greater than a third threshold. If the quantization error value of the pixel is greater than the third threshold, the pixel value of the pixel is adjusted.
[0135] In some embodiments, adjusting the pixel values of at least some pixels in the first image includes: increasing the pixel values of at least some pixels and / or decreasing the pixel values of at least some pixels.
[0136] In some embodiments, the pixel value of a pixel can be increased based on a first preset value. The first preset value is within a first preset pixel value range. For example, the first preset value within the first preset pixel value range can be greater than 0, and the first preset value can be less than or equal to 2. In this case, if the first preset value is 1, the pixel value of the pixel can be increased from 1 to 1+1 based on the first preset value. If the first preset value is 2, the pixel value of the pixel can be increased from 1 to 1+2 based on the first preset value.
[0137] In some embodiments, when it is determined that the pixel value of a pixel needs to be increased, a first preset value can be randomly selected from a first preset pixel value range, and the pixel value of the pixel can be increased based on the first preset value. In this case, the first preset value corresponding to different pixels can be the same, or the first preset value corresponding to different pixels can be different.
[0138] In some embodiments, the pixel value of a pixel can be increased based on a second preset value. The second preset value is within a second preset pixel value range. For example, a first preset value within the second preset pixel value range can be less than 0, and the second preset value can be greater than or equal to -2. In this case, if the first preset value is -1, the pixel value of the pixel can be reduced from 1 to 1-1 based on the second preset value. If the first preset value is 2, the pixel value of the pixel can be reduced from 1 to 1-2 based on the second preset value.
[0139] In some embodiments, when it is determined that the pixel value of a pixel needs to be reduced, a second preset value can be randomly selected from a range of second preset pixel values, and the pixel value of the pixel can be reduced based on the second preset value. In this case, the second preset value may be the same for different pixels, or the second preset value may be different for different pixels.
[0140] It should be noted that by adjusting the pixel values of at least some pixels in the first image, the pixel values of each pixel in the image region where quantization noise occurs can be made to approach a uniform distribution. This reduces the occurrence of striped quantization noise in the first image caused by pixels having the same pixel value in different image regions and excessively large differences in pixel values between adjacent image regions.
[0141] In some embodiments, adjusting the pixel values of at least some pixels in a first image based on quantization parameters to obtain a second image includes: adjusting the pixel values of at least some pixels in each color channel based on the quantization parameters corresponding to each pixel in each color channel to obtain a second image.
[0142] For example, the pixel values of at least some pixels in each single-channel image can be adjusted based on the quantization parameters corresponding to each pixel in each single-channel image to obtain at least two fourth images; wherein the different fourth images correspond to different color channels; and a second image is generated based on the pixel values of each pixel in the at least two fourth images. The second image includes the color channels corresponding to all the fourth images.
[0143] In some embodiments, the first image can be dequantized based on the distribution of pixel values of each pixel to obtain a fourth image; the pixel values of the pixels in the first image can be adjusted based on the differences between the pixel values of corresponding pixels in the first image and the fourth image to obtain a second image. The corresponding pixels in the first and fourth images are located in the same positions within the images. Here, the quantized image I can be used... q The process of estimating the unquantized image I is called dequantization. Furthermore, the dequantized image I can be used for image jittering, which can achieve a good smoothing effect on images with severe quantization noise.
[0144] In this embodiment of the disclosure, when a first image is acquired but its original image data is not detected, the quantization parameters corresponding to each pixel in the first image can be inferred based on the distribution of pixel values. Then, based on the inferred quantization parameters, the pixel values of pixels in the image region with quantization noise in the first image are adjusted to obtain a second image with reduced or eliminated quantization noise. Thus, even when the original image data of the first image is difficult to obtain, quantization noise in the first image can be reduced, ensuring good visual quality of the resulting second image.
[0145] In some embodiments, determining the quantization parameters corresponding to each pixel in the first image based on the distribution of pixel values includes:
[0146] By traversing the image, the distance between any pixel and all other pixels in the first image is determined until the distance value for each pixel is obtained; where the distance value is used to indicate the distribution of pixel values for each pixel.
[0147] Based on the distance value corresponding to each pixel, the quantization parameters corresponding to each pixel in the first image are determined.
[0148] It should be noted that here, the distance value between any pixel in the first image and all other pixels is determined by traversal until the distance value corresponding to each pixel is obtained. This can be understood as determining the distance value corresponding to each pixel in turn by traversal until all pixels have been traversed and the distance value corresponding to all pixels has been obtained.
[0149] It should be noted that, given the pixel value of each pixel, if the distance value corresponding to each pixel is determined, the relationship between the pixel value of each pixel and the pixel values of other pixels at different distances from that pixel can be determined, thus indicating the distribution of pixel values of each pixel.
[0150] In some embodiments, the distance value corresponding to a pixel may include, but is not limited to, at least one of the following: Euclidean distance (ED), city block distance (CBD), and chessboard distance (CD).
[0151] For example, such as Figure 3 and Figure 4 As shown, Figure 3 and Figure 4 It includes a first image 1, and a distance transformation result obtained by performing a distance transformation on the first image 1. Figure 2 Distance transformation results Figure 2 The pixel values of each pixel in the first image 1 can be used to indicate the distance values corresponding to each pixel in the first image 1.
[0152] In some embodiments, the distance values between any pixel in each single-channel image corresponding to the first image and all other pixels are determined in a traversal manner until the distance values corresponding to each pixel in each single-channel image are obtained. Based on the distance values corresponding to each pixel in each single-channel image, the quantization parameters corresponding to each pixel in each single-channel image corresponding to the first image are determined.
[0153] In this embodiment of the disclosure, the distribution state of the pixel values corresponding to each pixel in the first image after quantization can be determined based on the distance value corresponding to each pixel and the distribution of the pixel values indicated by the distance value, and the quantization parameters corresponding to each pixel in the first image during the quantization process can be further indicated.
[0154] In some embodiments, any pixel has a first pixel value; determining the distance values between any pixel and all other pixels in the first image until the distance values corresponding to each pixel are obtained includes:
[0155] Determine a first distance value between any pixel and a first pixel having a second pixel value, and a second distance value between any pixel and a second pixel having a third pixel value; wherein the first pixel value is greater than the second pixel value, and the first pixel value is less than the third pixel value, the difference between the first pixel value and the second pixel value is less than a first threshold, and the difference between the first pixel value and the third pixel value is less than a second threshold;
[0156] Based on the distance value corresponding to each pixel, the quantization parameters corresponding to each pixel in the first image are determined, including:
[0157] Based on the first distance value and the second distance value corresponding to each pixel, the quantization parameters corresponding to each pixel in the first image are determined respectively.
[0158] In some embodiments, determining a first distance value between any pixel and a first pixel having a second pixel value, and a second distance value between any pixel and a second pixel having a third pixel value, includes: determining a first distance value set between any pixel and all first pixels, and a second distance value set between any pixel and all second pixels; determining the first distance value corresponding to any pixel from the first distance value set, and determining the second distance value corresponding to any pixel from the second distance value set.
[0159] In some embodiments, the first distance value corresponding to any pixel may be the smallest distance value in the set of first distance values. The second distance value corresponding to any pixel may be the smallest distance value in the set of second distance values. It is understood that here, the first distance value may be the distance between any pixel and the nearest first pixel among all first pixels. The second distance value may be the distance between any pixel and the nearest second pixel among all second pixels.
[0160] In some embodiments, the first distance value corresponding to any pixel may be the average of distance values in a first set of distance values. The second distance value corresponding to any pixel may be the average of distance values in a second set of distance values.
[0161] In some embodiments, determining a first distance value between any pixel and a first pixel having a second pixel value, and a second distance value between any pixel and a second pixel having a third pixel value, includes: determining a first distance value between any pixel and a first pixel located within a first preset range of any pixel, and a second distance value between any pixel and a second pixel located within a second preset range of any pixel.
[0162] In some embodiments, a first preset range and / or a second preset range can be determined based on the area of the image region containing quantization noise in the first image. The first preset range may be positively correlated with the area of the image region containing quantization noise. The second preset range may be positively correlated with the area of the image region containing quantization noise. In this way, pixels located within or near the image region containing quantization noise can be identified as first pixels or second pixels, allowing for the determination of a first distance value between a small number of first pixels and either pixel, and a second distance value between a small number of second pixels and either pixel, thereby reducing resource overhead.
[0163] In some embodiments, determining a first distance value between any pixel and a first pixel located within a first preset range of the pixel, and a second distance value between any pixel and a second pixel located within a second preset range of the pixel, includes: determining a third set of distance values between any pixel and all first pixels located within the first preset range of the pixel, and determining a fourth set of distance values between any pixel and all second pixels located within the second preset range of the pixel. The first distance value corresponding to the pixel is determined from the third set of distance values, and the second distance value corresponding to the pixel is determined from the fourth set of distance values.
[0164] In some embodiments, the first distance value corresponding to any pixel may be the smallest distance value in the third set of distance values. The second distance value corresponding to any pixel may be the smallest distance value in the fourth set of distance values.
[0165] In some embodiments, the first distance value corresponding to any pixel may be the average of the distance values in a third set of distance values. The second distance value corresponding to any pixel may be the average of the distance values in a fourth set of distance values.
[0166] In some embodiments, the first threshold may be the same as the second threshold, or the first threshold may be different from the second threshold.
[0167] In some embodiments, a predetermined number of neighboring pixels can be determined from the first image, and a first threshold and / or a second threshold can be determined based on the pixel value differences between the predetermined number of neighboring pixels. Exemplarily, the first threshold and / or the second threshold can be determined based on the average of the pixel value differences between the predetermined number of neighboring pixels. For example, the first threshold and / or the second threshold can be the average of the pixel value differences.
[0168] In some embodiments, a first threshold and / or a second threshold can be determined based on the pixel value difference between pixels in a first image region and pixels in a second image region of the first image. Pixel values in the first image region are the same, or the difference in pixel values between pixels in the first image region is less than a fourth threshold. Pixel values in the second image region are the same, or the difference in pixel values between pixels in the second image region is less than a fifth threshold. The difference in pixel values between pixels in the first image region and pixels in the second image region is greater than a sixth threshold. It should be noted that here, the first image region and the second image region are image regions in the first image that contain striped quantization noise.
[0169] In some embodiments, the first threshold may be positively correlated with the pixel value difference, and the second threshold may be positively correlated with the pixel value difference.
[0170] In some embodiments, the first threshold and / or the second threshold may be preset thresholds. It should be noted that "greater than" in this disclosure may be understood as "greater than" or "equal to" in some application scenarios. Similarly, "less than" in this disclosure may be understood as "less than" or "equal to" in some application scenarios.
[0171] For example, both the first threshold and / or the second threshold can be set to 1. In this case, the difference between the first pixel value and the second pixel value can be equal to 1, and the difference between the first pixel value and the third pixel value can be equal to 1.
[0172] For example, the first pixel value of any pixel can be I. q (x, y), where x can be the abscissa of any pixel in the pixel coordinate system corresponding to the first image, and y can be the ordinate of any pixel in the pixel coordinate system corresponding to the first image. In this case, the second pixel value can be I. q (x, y) + 1, the value of the third pixel can be I. q (x, y)-1.
[0173] It should be noted that when the second pixel value is I q In the case of (x, y)+1, the first distance value corresponding to any pixel can be understood as: the distance value of any pixel I q (x, y) and pixel value equal to I q The nearest distance d1 in the region (x, y)+1, the second distance value corresponding to any pixel can be understood as: the pixel value I of any pixel. q (x, y) and pixel value equal to I q The nearest distance d2 in the region (x, y)-1.
[0174] In some embodiments, the quantization parameters corresponding to each pixel in the first image are determined based on the first distance value and the second distance value corresponding to each pixel, including: determining the quantization relationship between the pixel value of each pixel in the first image and the pixel value of the pixel before quantization based on the first distance value and the second distance value corresponding to each pixel.
[0175] For example, if the first distance value corresponding to a pixel is greater than the second distance value, then it is determined that the pixel value of the pixel in the first image is greater than the pixel value before quantization. In this case, during the adjustment of the pixel value, the pixel value can be reduced. For example, the first pixel value of the pixel can be reduced to the second pixel value. It should be noted that here, when the first distance value corresponding to a pixel with the first pixel value is greater than the second distance value, it means that the distance between the pixel with the first pixel value and the pixel with the second pixel value is less than the distance between the pixel with the first pixel value and the pixel with the third pixel value. In this case, since the pixel values corresponding to each pixel in the original image data are uniformly distributed, the pixel value before quantization corresponding to the pixel with the first pixel value is likely to be the second pixel value.
[0176] For example, if the first distance value corresponding to a pixel is less than the second distance value, it is determined that the pixel value of the pixel in the first image is less than the pixel value before quantization. In this case, during the adjustment of the pixel value, the pixel value can be increased. For example, the first pixel value of the pixel can be increased to a third pixel value. It should be noted that here, when the first distance value corresponding to a pixel with the first pixel value is less than the second distance value, it means that the distance between the pixel with the first pixel value and the pixel with the second pixel value is greater than the distance between the pixel with the first pixel value and the pixel with the third pixel value. In this case, since the pixel values corresponding to each pixel in the original image data are uniformly distributed, the pixel value before quantization corresponding to the pixel with the first pixel value is likely to be the third pixel value.
[0177] For example, if the first distance value corresponding to a pixel is equal to the second distance value, then the pixel value of the pixel in the first image is determined to be equal to the pixel value of that pixel before quantization. In this case, the pixel value of that pixel can be maintained.
[0178] In some embodiments, the quantization parameter may include the quantization error value between the pixel value of each pixel in the first image and the pixel value before quantization.
[0179] For example, the formula for calculating the quantization error value can be as follows:
[0180] Q e(x, y)= f(d1 / (d1+d2))-0.5 (1);
[0181] In formula (1), Q e (x, y) can be the quantization error value corresponding to the pixel in the x-th row and y-th column of the first image, d1 can be the first distance value corresponding to the pixel in the x-th row and y-th column of the first image, and d2 can be the second distance value corresponding to the pixel in the x-th row and y-th column of the first image. f(d1 / (d1+d2)) is a function used to indicate the relationship between the first distance value and the second distance value. f(d1 / (d1+d2)) can be equal to d1 / (d1+d2).
[0182] In some embodiments, an error diffusion operation can be performed on at least a portion of the pixels in the first image based on the quantization error value corresponding to each pixel to obtain the second image.
[0183] In some embodiments, the first image can be dequantized based on the first distance value and the second distance value to obtain the fourth image.
[0184] For example, the formula for calculating the pixel value of each pixel in the fourth image is as follows:
[0185] I(x, y) = I q (x,y)-0.5+f(d1 / (d1+d2)) (2);
[0186] In formula (2), I(x, y) can be the pixel value before quantization corresponding to the pixel point in the x-th row and y-th column of the first image. q (x, y) can be the pixel value of the pixel in the x-th row and y-th column of the first image, representing the quantization error value. d1 can be the first distance value corresponding to the pixel in the x-th row and y-th column of the first image, and d2 can be the second distance value corresponding to the pixel in the x-th row and y-th column of the first image. f(d1 / (d1+d2)) is a function used to indicate the relationship between the first and second distance values. f(d1 / (d1+d2)) can be equal to d1 / (d1+d2).
[0187] In this embodiment of the disclosure, based on the first distance value between any pixel having a first pixel value and a first pixel having a second pixel value, and the second distance value between any pixel having a first pixel value and a second pixel having a third pixel value, it can be indicated that the pixel value of any pixel before quantization is closer to the second pixel value or the third pixel value, thereby enabling precise determination of the quantization parameters corresponding to each pixel.
[0188] In some embodiments, determining a first distance value between the any pixel and a first pixel having a second pixel value, and a second distance value between the any pixel and a second pixel having a third pixel value, includes:
[0189] Determine a third distance value between any given pixel and a third pixel located within a predetermined range of that given pixel;
[0190] Based on the pixel value of each third pixel, the first distance value and the third distance value corresponding to each third pixel, determine the first distance value corresponding to any pixel.
[0191] Based on the pixel value of each third pixel, the second distance value and the third distance value corresponding to each third pixel, the second distance value corresponding to any pixel is determined.
[0192] In some embodiments, the predetermined range can be a pre-set distance range. For example, one end of the predetermined range can be greater than 0, and the other end can be less than or equal to 2. In this case, the third pixel can include pixels located above, below, to the left, and to the right of any first pixel, and the distance between the third pixel and the first pixel is less than or equal to 2.
[0193] In some embodiments, a predetermined range can be determined based on the area of the image region in the first image where quantization noise exists. The predetermined range can be positively correlated with the area of the image region where quantization noise exists.
[0194] In some embodiments, a preset mask can be used to cover the area to be processed of the first image; a pixel at a predetermined position in the area to be processed can be identified as the arbitrary pixel, and other pixels in the area to be processed other than the arbitrary pixel can be identified as a third pixel within a predetermined range of the arbitrary pixel.
[0195] In some embodiments, a third distance value is determined between any pixel and each third pixel located in the region to be processed; a first distance value corresponding to any pixel is determined based on the pixel value of each third pixel, the first distance value corresponding to each third pixel, and the third distance value; a second distance value corresponding to any pixel is determined based on the pixel value of each third pixel, the second distance value corresponding to each third pixel, and the third distance value. After traversing all third pixels in the region to be processed, the first distance value and the second distance value corresponding to any pixel are obtained, and the region to be processed covered by the preset mask is adjusted according to a preset order until all regions to be processed in the first image have been traversed.
[0196] In some embodiments, a first region to be processed in a first image can be covered by a first preset mask, and a first distance value and a second distance value corresponding to any pixel in the first region to be processed can be determined. After obtaining the first distance value and the second distance value corresponding to any pixel in the first region to be processed, the first region to be processed covered by the first preset mask is adjusted according to a first preset order until all image regions in the first image have been traversed. If all image regions in the first image have been traversed based on the first preset mask, a second region to be processed in the first image can be covered by a second preset mask, and a first distance value and a second distance value corresponding to any pixel in the second region to be processed can be determined. After obtaining the first distance value and the second distance value corresponding to any pixel in the second region to be processed, the second region to be processed covered by the second preset mask is adjusted according to a second preset order until all image regions in the first image have been traversed. The first preset mask and the second preset mask may have different shapes, and / or the first preset order and the second preset order may be different.
[0197] In some embodiments, within the first processing area covered by the first preset mask, any pixel may be located at the lower right corner, and the third pixel may include pixels located to the left and above the first pixel. Exemplarily, the shape of the first preset mask may be as follows: Figure 5 As shown, pixel q can be any pixel, and pixel p can be the third pixel.
[0198] The first preset order can be used to indicate the movement order of the first preset mask. For example, the first preset order can be used to indicate that the first preset mask moves from left to right and from top to bottom. It should be noted that the movement distance of the first preset mask according to the first preset order can be 1. Furthermore, the first area to be processed initially covered by the first preset mask can be the edge image area located in the upper left corner of the first image.
[0199] In some embodiments, within the second processing area covered by the second preset mask, any pixel may be located at the upper left corner, and the third pixel may include pixels located to the right and below the any pixel. Exemplarily, the shape of the second preset mask may be as follows: Figure 6 As shown, pixel q can be any pixel, and pixel p can be the third pixel.
[0200] The second preset order can be used to indicate the movement order of the second preset mask. For example, the second preset order can be used to indicate that the second preset mask moves from right to left and from bottom to top. It should be noted that the movement distance of the second preset mask according to the second preset order can be 1. Furthermore, the second processing area initially covered by the second preset mask can be the edge image area located in the lower right corner of the first image.
[0201] Compared to related technologies that require comparing the distance values between any given pixel and all first and second pixels in the first image, this embodiment of the present disclosure can accurately determine the first and / or second distance values corresponding to any given pixel based on the first, second, and third distance values corresponding to a third pixel located within a predetermined range of the given pixel, and the pixel values thereon. Thus, the first and second distance values corresponding to any given pixel can be quickly determined based on a small number of relevant parameters corresponding to the third pixel, improving the computational efficiency for determining the distance values corresponding to any given pixel.
[0202] In some embodiments, determining the first distance value corresponding to any pixel point based on the pixel value of each third pixel point, the first distance value corresponding to each third pixel point, and the third distance value includes:
[0203] For each third pixel, if any pixel has a first distance value and the third pixel has a first pixel value, if the first sum between the first distance value and the third distance value is less than the first distance value corresponding to any pixel, then the first distance value corresponding to any pixel is updated to the first sum.
[0204] For each third pixel, if any pixel has a first distance value and the third pixel has a second pixel value, if the third distance value is less than the first distance value corresponding to any pixel, then the first distance value corresponding to any pixel is updated to the third distance value.
[0205] The first distance value corresponding to any pixel is either the initially set distance value or the distance value obtained after updating the initially set distance value.
[0206] It should be noted that before determining the first distance value corresponding to any given pixel based on the pixel values of each third pixel, the corresponding first distance value, and the third distance value, the first distance values corresponding to all pixels in the first image can be set to a first preset distance value. This can be understood as the initially set distance value. During the process of determining the first distance value corresponding to any given pixel based on the pixel values of each third pixel, the corresponding first distance value, and the third distance value, the first distance value corresponding to any given pixel can be maintained as the initially set first preset distance value, or the initially set first preset distance value can be updated to obtain an updated first distance value.
[0207] In some embodiments, the first preset distance value may be determined based on the resolution of the first image. The first preset distance value may be positively correlated with the resolution of the first image. For example, the first preset distance value may be greater than sqrt(w*w+h*h), where w is the number of pixels in the first image in the horizontal direction, and h is the number of pixels in the first image in the vertical direction.
[0208] In some embodiments, a first array corresponding to the first image is generated; wherein the resolution of the first array is the same as the resolution of the first image. The first array can be a two-dimensional array, and the elements in the first array correspond one-to-one with the pixels in the first image. For example, the element in the x-th row and y-th column of the first array can correspond to the pixel in the first image located in the x-th row and y-th column. The elements in the first array can be used to store the first distance value of the corresponding pixel in the first image. That is, the first array can be used to store the distance transformation result for the first distance value.
[0209] In some embodiments, in the first processing area covered by the first preset mask, for each third pixel, if the sum of the first distance value and the third distance value corresponding to the third pixel is less than the first distance value corresponding to the third pixel, then the first distance value corresponding to the third pixel is updated to the first sum value; for each third pixel, if the sum of the first distance value and the third distance value corresponding to the third pixel is less than the first distance value corresponding to the third pixel, then the first distance value corresponding to the third pixel is updated to the third distance value; wherein, the first distance value corresponding to the third pixel is an initially set distance value, or a distance value obtained after updating the initially set distance value.
[0210] In some embodiments, when any pixel corresponds to a first distance value and a third pixel has a first pixel value, if the first sum between the first distance value corresponding to the third pixel value and the third distance value is greater than the first distance value corresponding to any pixel, then the first distance value corresponding to any pixel is not updated. When any pixel corresponds to a first distance value and a third pixel has a second pixel value, if the third distance value is greater than the first distance value corresponding to any pixel, then the first distance value corresponding to any pixel is not updated. When any pixel corresponds to a first distance value, if the third pixel does not have a first pixel value and does not have a second pixel value, then the first distance value corresponding to any pixel may not be updated.
[0211] In some embodiments, the formula for calculating the first distance value may be as follows:
[0212] F(q)=MIN(F(q),D(p,q)+F(p)), q∈mask1, if I(p)==I(q) (3);
[0213] F(q)=MIN(F(q),D(p,q)), q∈mask1, if I(p)==I(q)-1 (4);
[0214] In formulas (3) and (4), point q is any pixel in the first image, F(q) on the left side of the equation is the updated first distance value corresponding to that pixel, and F(q) on the right side of the equation is the unupdated first distance value corresponding to that pixel. Point p is the third pixel in the first image located within a predetermined range of point q, and D(p, q) is the third distance value between that pixel and the third pixel. F(p) is the first distance value corresponding to the third pixel. mask1 is the first processing area covered by the first preset mask, I(p) is the pixel value of the third pixel, and I(q) is the first pixel value of that pixel. I(q)-1 can be the second pixel value.
[0215] MIN(F(q), D(p, q) + F(p)) is the minimum of F(q) and D(p, q) + F(p).
[0216] MIN(F(q), D(p, q)) is the minimum value of F(q) and D(p, q).
[0217] It should be noted that if any pixel has a first distance value and the third pixel has a first pixel value, then formula (3) is used to determine the first distance value corresponding to any pixel. If any pixel has a first distance value and the third pixel has a second pixel value, then formula (4) is used to determine the first distance value corresponding to any pixel.
[0218] It should be noted that if the value of MIN(F(q), D(p, q) + F(p)) in formula (3) is F(q), then the first distance value corresponding to any pixel point does not need to be updated. If the value of MIN(F(q), D(p, q)) in formula (4) is F(q), then the first distance value corresponding to any pixel point does not need to be updated. If any pixel point has a first distance value, and the third pixel point does not have a first pixel value and the third pixel point does not have a second pixel value, then the first distance value corresponding to any pixel point does not need to be updated.
[0219] Compared to related technologies that require comparing the distance values between any given pixel and all first pixels in the first image, this embodiment of the present disclosure can accurately determine the first distance value corresponding to any given pixel based on the first distance value corresponding to a third pixel located within a predetermined range of the given pixel, the third distance value, and the pixel value thereof. Thus, the first distance value corresponding to any given pixel can be quickly determined based on a small number of related parameters corresponding to the third pixel, improving the computational efficiency of determining the first distance value corresponding to any given pixel.
[0220] In some embodiments, determining the second distance value corresponding to any pixel point based on the pixel value of each third pixel point, the second distance value corresponding to each third pixel point, and the third distance value includes:
[0221] For each third pixel, if any pixel has a second distance value and the third pixel has a first pixel value, if the second sum between the second distance value and the third distance value corresponding to the third pixel is less than the second distance value corresponding to any pixel, then the second distance value corresponding to any pixel is updated to the second sum.
[0222] For each third pixel, if there is a second distance value corresponding to any pixel and the third pixel has a third pixel value, if the third distance value is less than the second distance value corresponding to any pixel, then the second distance value corresponding to any pixel is updated to the third distance value.
[0223] The second distance value corresponding to any pixel is either the initially set distance value or the distance value obtained after updating the initially set distance value.
[0224] It should be noted that before determining the second distance value corresponding to any given pixel based on the pixel values of each third pixel, the corresponding second distance value, and the third distance value, the second distance values corresponding to all pixels in the first image can be set to the second preset distance value. This can be understood as the initially set distance value. During the process of determining the second distance value corresponding to any given pixel based on the pixel values of each third pixel, the corresponding first distance value, and the third distance value, the second distance value corresponding to any given pixel can be maintained as the initially set second preset distance value, or the initially set first preset distance value can be updated to obtain the updated second distance value.
[0225] In some embodiments, the second preset distance value can be determined based on the resolution of the first image. The second preset distance value can be positively correlated with the resolution of the first image. For example, the second preset distance value can be greater than sqrt(w*w+h*h), where w is the number of pixels in the first image in the horizontal direction, and h is the number of pixels in the first image in the vertical direction.
[0226] In some embodiments, a second array corresponding to the first image is generated; wherein the resolution of the second array is the same as the resolution of the first image. The second array can be a two-dimensional array, and the elements in the second array correspond one-to-one with the pixels in the first image. For example, the element in the x-th row and y-th column of the second array can correspond to the pixel in the first image located at the x-th row and y-th column. The elements in the second array can be used to store the second distance value of the corresponding pixel in the first image. That is, the second array can be used to store the distance transformation result for the first distance value.
[0227] In some embodiments, in the second processing area covered by the second preset mask, for each third pixel, if the second sum of the second distance value and the third distance value corresponding to the third pixel is less than the second distance value corresponding to the pixel, then the second distance value corresponding to the pixel is updated to the second sum; for each third pixel, if the third distance value is less than the second distance value corresponding to the pixel, then the second distance value corresponding to the pixel is updated to the third distance value; wherein, the second distance value corresponding to the pixel is the initially set distance value, or the distance value obtained after updating the initially set distance value.
[0228] In some embodiments, when any pixel corresponds to a second distance value and a third pixel has a first pixel value, if the second sum between the second distance value corresponding to the third pixel value and the third distance value is greater than the second distance value corresponding to any pixel, then the second distance value corresponding to any pixel is not updated. When any pixel corresponds to a second distance value and a third pixel has a second pixel value, if the third distance value is greater than the second distance value corresponding to any pixel, then the second distance value corresponding to any pixel is not updated. When any pixel corresponds to a second distance value, if the third pixel does not have a first pixel value and does not have a second pixel value, then the second distance value corresponding to any pixel may not be updated.
[0229] In some embodiments, the formula for calculating the second distance value may be as follows:
[0230] F(q)=MIN(F(q),D(p,q)+F(p)), q∈mask1, if I(p)==I(q) (5);
[0231] F(q)=MIN(F(q),D(p,q)), q∈mask1, if I(p)==I(q)+1 (6);
[0232] In formulas (5) and (6), point q is any pixel in the first image, F(q) on the left side of the equation is the updated second distance value corresponding to that pixel, and F(q) on the right side of the equation is the unupdated second distance value corresponding to that pixel. Point p is a third pixel in the first image located within a predetermined range of point q, and D(p, q) is the third distance value between that pixel and the third pixel. F(p) is the second distance value corresponding to the third pixel. mask2 is the second processing area covered by the second preset mask, I(p) is the pixel value of the third pixel, and I(q) is the first pixel value of that pixel. I(q)+1 can be the third pixel value.
[0233] MIN(F(q), D(p, q) + F(p)) is the minimum of F(q) and D(p, q) + F(p).
[0234] MIN(F(q), D(p, q)) is the minimum value of F(q) and D(p, q).
[0235] It should be noted that if any pixel has a second distance value and the third pixel has a first pixel value, then formula (5) is used to determine the second distance value corresponding to any pixel. If any pixel has a second distance value and the third pixel has a second pixel value, then formula (6) is used to determine the second distance value corresponding to any pixel.
[0236] It should be noted that if the value of MIN(F(q), D(p, q) + F(p)) in formula (5) is F(q), then the second distance value corresponding to any pixel point does not need to be updated. If the value of MIN(F(q), D(p, q)) in formula (6) is F(q), then the second distance value corresponding to any pixel point does not need to be updated. If any pixel point has a second distance value, and the third pixel point does not have a first pixel value and does not have a second pixel value, then the second distance value corresponding to any pixel point does not need to be updated.
[0237] Compared to related technologies that require comparing the distance values between any given pixel and all second pixels in the first image, this embodiment of the present disclosure can accurately determine the second distance value corresponding to any given pixel based on the second distance value, the third distance value, and the pixel value of a third pixel located within a predetermined range of the given pixel. Thus, the second distance value corresponding to any given pixel can be quickly determined based on a small number of related parameters corresponding to the third pixels, improving the computational efficiency of determining the second distance value corresponding to any given pixel.
[0238] In some embodiments, the quantization parameters corresponding to each pixel in the first image are determined based on the first distance value and the second distance value corresponding to each pixel, including:
[0239] Based on the first distance value and the second distance value corresponding to each pixel, the quantization relationship between the pixel value of each pixel in the first image and the pixel value before quantization corresponding to the pixel is determined, as well as the quantization error value between the pixel value of each pixel in the first image and the pixel value before quantization corresponding to the pixel is determined.
[0240] The pixel values of at least some pixels in the first image are adjusted based on quantization parameters to obtain the second image, including:
[0241] Based on the quantization relationship and quantization error value, the pixel values of at least some pixels in the first image are adjusted.
[0242] It should be noted that the pixel values of each pixel in the first image can be understood as quantized pixel values.
[0243] It should be noted that the quantization relationship corresponding to a pixel can be used to indicate one of the following: the pixel value of a pixel in the first image is greater than the pixel value before quantization; the pixel value of a pixel in the first image is less than the pixel value before quantization; the pixel value of a pixel in the first image is equal to the pixel value before quantization.
[0244] For example, if the first distance value corresponding to a pixel with a first pixel value is greater than the second distance value, then it is determined that the pixel value of the pixel in the first image is greater than the pixel value before quantization. It should be noted that if the first distance value corresponding to a pixel with a first pixel value is greater than the second distance value, it means that the distance between the pixel with the first pixel value and the pixel with the second pixel value is less than the distance between the pixel with the first pixel value and the pixel with the third pixel value. In this case, since the pixel values corresponding to each pixel in the original image data are uniformly distributed, the pixel value before quantization corresponding to the pixel with the first pixel value is highly likely to approach the second pixel value or the first pixel value. Therefore, during the adjustment of the pixel value, the pixel value can be reduced or maintained. For example, the first pixel value of the pixel can be reduced to the second pixel value, or the pixel value of the pixel can be maintained as the first pixel value.
[0245] For example, if the first distance value corresponding to a pixel is less than the second distance value, then it is determined that the pixel value of the pixel in the first image is less than the pixel value before quantization. It should be noted that when the first distance value corresponding to a pixel with the first pixel value is less than the second distance value, it means that the distance between the pixel with the first pixel value and the pixel with the second pixel value is greater than the distance between the pixel with the first pixel value and the pixel with the third pixel value. In this case, since the pixel values corresponding to each pixel in the original image data are uniformly distributed, the pixel value before quantization corresponding to the pixel with the first pixel value is highly likely to approach the third pixel value or the first pixel value. Therefore, during the adjustment of the pixel value, the pixel value can be increased or maintained. For example, the first pixel value of the pixel can be increased to the third pixel value, or the pixel value of the pixel can be maintained as the first pixel value.
[0246] In some embodiments, adjusting the pixel values of at least some pixels in a first image based on a quantization relation and a quantization error value includes: when the quantization relation indicates that the pixel value of a pixel in the first image is greater than the pixel value of the pixel before quantization, determining, based on the quantization error value, to either maintain the pixel value of the pixel in the first image or decrease the pixel value of the pixel in the first image. The quantization error value can be used to indicate the probability of maintaining the pixel value of the pixel in the first image and / or the probability of decreasing the pixel value of the pixel in the first image.
[0247] In some embodiments, adjusting the pixel values of at least some pixels in a first image based on a quantization relation and a quantization error value includes: when the quantization relation indicates that the pixel value of a pixel in the first image is less than the pixel value of the pixel before quantization, determining, based on the quantization error value, to either maintain the pixel value of the pixel in the first image or increase the pixel value of the pixel in the first image. The quantization error value can be used to indicate the probability of maintaining the pixel value of the pixel in the first image and / or the probability of increasing the pixel value of the pixel in the first image.
[0248] In some embodiments, if the quantization relationship indicates that the pixel value of a pixel in the first image is equal to the pixel value of that pixel before quantization, the pixel value of the pixel in the first image is maintained.
[0249] In this embodiment of the disclosure, the quantization relationship and quantization error value corresponding to the pixel can be determined based on the first distance value and the second distance value corresponding to the pixel. The pixel value of the pixel in the first image can be precisely adjusted based on the quantization relationship and the quantization error value, so that the pixel value of each pixel approaches a uniform distribution, thereby reducing the quantization noise present in the first image.
[0250] In some embodiments, the method further includes:
[0251] Generate a third image; wherein the pixel values of the pixels in the third image are randomly and uniformly distributed; the resolution of the third image is the same as that of the first image; and the pixels in the third image and the first image at the same position correspond to each other.
[0252] Based on the quantization relationship and quantization error value, the pixel values of at least some pixels in the first image are adjusted, including:
[0253] If the quantization relationship indicates that the pixel value of a pixel in the first image is less than the pixel value before quantization, and the product of the quantization error value and the preset value is greater than the pixel value of the corresponding pixel in the third image, then the pixel value of the pixel in the first image is increased; wherein, the preset value is determined according to the range of pixel values in the first image.
[0254] If the quantization relationship indicates that the pixel value of a pixel in the first image is greater than the pixel value before quantization, and the product of the quantization error value and the preset value is greater than the pixel value of the corresponding pixel in the third image, then the pixel value of the pixel in the first image is reduced.
[0255] It should be noted that the product between the quantization error value and the preset value here can refer to the product between the absolute value of the quantization error value and the preset value.
[0256] In some embodiments, the pixel values in the third image are integer values, and the range of pixel values in the third image can be the same as the range of pixel values in the first image. For example, if the pixel values in the first image are greater than or equal to 0 and less than or equal to 255, then the pixel values in the third image can also be greater than or equal to 0 and less than or equal to 255. It should be noted that the method of randomly generating the pixel values in the third image is not limited; it is only necessary to ensure that the pixel values in the generated third image are randomly and uniformly distributed.
[0257] In some embodiments, if the quantization relation indicates that the pixel value of a pixel in the first image is less than the pixel value before quantization, and the product of the quantization error value and a preset value is less than the pixel value of the corresponding pixel in the third image, then the pixel value of the pixel in the first image is maintained. If the quantization relation indicates that the pixel value of a pixel in the first image is greater than the pixel value before quantization, and the product of the quantization error value and a preset value is less than the pixel value of the corresponding pixel in the third image, then the pixel value of the pixel in the first image is maintained. If the quantization relation indicates that the pixel value of a pixel in the first image is equal to the pixel value before quantization, then the pixel value of the pixel in the first image is maintained.
[0258] For example, the formula for calculating the pixel value of a pixel in the first image is as follows:
[0259] I q (x, y) = I q (x, y)-1; if (R(x, y)<(-Q)-1; if (R(x, y)<(-Q)-1); e (x, y))*255, Q e (x, y) < 0) (7);
[0260] I q (x, y) = I q (x, y) + 1; if (R(x, y) + 1); e (x, y) * 255, Q e (x, y)>0) (8);
[0261] I q (x, y) = I q (x, y); if (R(x, y) < (-Q) e (x, y))*255, Q e (x, y) < 0) || if
[0262] (R(x,y)>(-Q) e (x, y))*255, Qe (x, y) > 0) || if Q e (x, y) = 0 (9).
[0263] In formulas (7), (8), and (9), I is located on the left side of the equation. q (x, y) represents the adjusted pixel value of the pixel located in the x-th row and y-th column of the first image, and the value on the right side of the equation represents the unadjusted pixel value of the pixel located in the x-th row and y-th column of the first image. R(x, y) represents the pixel value of the pixel located in the x-th row and y-th column of the third image, and Q... e (x, y) represents the quantization error value corresponding to the pixel in the x-th row and y-th column of the first image.
[0264] It should be noted that the I here q It could refer to the single-channel image corresponding to the first image.
[0265] For example, see Figure 7 ,exist Figure 7 In the image, there are pixels P1, P2, and P3.
[0266] The quantized pixel value of pixel P1 is v, and the quantization error at pixel P1 is -0.2. The quantization relationship corresponding to pixel P1 indicates that the pixel value of pixel P1 in the first image is greater than the pixel value before quantization corresponding to P1. At this time, the expected value of the pixel value before quantization corresponding to pixel P1 is I(P1) = v - 0.2.
[0267] It should be noted that at this time, the adjusted pixel value corresponding to P1 can be determined using formula (7). In formula (7), Q e (x, y) < 0, and R(x, y) < (-Q) e The probability of (x, y))*255 is 0.2 (which can be understood as the probability that the value of R(x, y) falls within the range [0, 51] is 0.2), that is, I q (x, y) = I q The probability of (x, y) - 1 is 0.2. R(x, y) > (-Q) e The probability of (x, y))*255 is 0.8, which can be understood as the probability that the value of R(x, y) falls within the range [51, 255] is 0.8. That is, I q (x, y) = I q The probability of (x, y) is 0.8.
[0268] The quantized pixel value of pixel P2 is v, the quantization error at pixel P2 is 0, and the quantization relation corresponding to pixel P2 indicates that the pixel value of pixel P2 in the first image is equal to the pixel value before quantization corresponding to P2. At this time, the expected value of the pixel value before quantization corresponding to pixel P2 is I(P2) = v.
[0269] It should be noted that at this time, the adjusted pixel value corresponding to P1 can be determined using formula (9). In formula (9), Q e If (x, y) = 0, then let I q (x, y) = I q (x, y). That is, keep the pixel value of the pixel unchanged.
[0270] The quantized pixel value of pixel P3 is v, and the quantization error at pixel P3 is 0.4. The quantization relationship corresponding to pixel P3 indicates that the pixel value of pixel P3 in the first image is less than the pixel value before quantization corresponding to P3. At this time, the expected value of the pixel value before quantization corresponding to pixel P3 is I(P3) = v + 0.4.
[0271] It should be noted that at this time, the adjusted pixel value corresponding to P1 can be determined using formula (8). In formula (8), Q e (x, y) > 0, and R(x, y) > 0. e The probability of (x, y)*255 is 0.4 (which can be understood as the probability that the value of R(x, y) falls within the range [0, 102] is 0.4), that is, I q (x, y) = I q The probability of (x, y) + 1 is 0.4. R(x, y) > Q e The probability of (x, y)*255 is 0.6, which can be understood as the probability that the value of R(x, y) falls within the range [102, 255] is 0.6. That is, I q (x, y) = I q The probability of (x, y)+1 is 0.6.
[0272] Here, the pixel value I of the pixel point in the first image can be determined by the value of R(x, y) in the randomly generated third image. q Random image jitter is applied to (x, y) to make the pixel values of the pixels in the first image approach a uniform distribution.
[0273] For example, if the pixel values of all pixels in the first image region are 128, and the pixel values of all pixels in the second image region are 130, and the first and second image regions are adjacent, then by dithering the pixel values of some pixels in the first image region to 127 and 129, and the pixel values of some pixels in the second image region to 129 and 131, the first and second image regions can be made to form image regions with pixel values evenly distributed in the range of 127 to 131, thereby obtaining a second image with reduced quantization noise.
[0274] For example, see Figure 8 Figures (1), (2), (3), and (4) are shown in the figure. Figure (1) is the first image, Figure (3) is a local area of the first image, Figure (2) is the second image obtained after adjusting the pixel values of at least some pixels in the first image, and Figure (4) is a local area in the second image corresponding to the local area in Figure (3).
[0275] For example, see Figure 9 , Figure 9 This includes first image 1 and second image 3. In Figure 9 In the first image 1, there is striped quantization noise, while the image region in the second image 3 is smoother and there is no striped quantization noise in the second image region 3.
[0276] In some embodiments, the range of adjusted pixel values corresponding to pixels in the first image is determined based on the color depth (n-bit) of the first image. The range of adjusted pixel values is greater than or equal to 0, and the range of adjusted pixel values is less than or equal to 2. n -1. This reduces the possibility of overflow of adjusted pixel values corresponding to pixels in the first image.
[0277] In this embodiment of the disclosure, the adjustment direction for adjusting the pixel values of pixels in the first image can be accurately determined based on the quantization relationship and quantization error value, thereby enabling the pixel values of pixels in the adjusted second image to be evenly distributed, ensuring that the visual effect of the second image meets the requirements.
[0278] In some embodiments, adjusting the pixel values of at least a portion of the pixels in the first image based on quantization parameters includes:
[0279] Based on the quantization parameters, the pixel values of all pixels in the first image are adjusted; and / or,
[0280] Based on the quantization parameters, the target image region containing quantization noise is determined from the first image, and the pixel values of the pixels in the target image region are adjusted.
[0281] It should be noted that, based on the quantization parameters, the pixel values of the pixels are adjusted, including: based on the quantization parameters corresponding to each pixel, increasing the pixel value of the pixels in the first image, decreasing the pixel value of the pixels in the first image, and / or maintaining the pixel value of the pixels in the first image.
[0282] In some embodiments, a target image region can be determined from the first image based on touch operations on the first image; the pixel values of the pixels in the target image region can be adjusted based on the quantization parameters corresponding to each pixel in the target image region. Here, precise image jittering of the first image can be performed based on the user's touch operations on the first image, adapting to the user's needs.
[0283] In this embodiment, the pixel values of all pixels in the first image can be adjusted so that the pixels in all image regions of the resulting second image are nearly uniformly distributed, improving the visual effect of the second image. Alternatively, the pixel values of pixels in target image regions with quantization noise in the first image can be adjusted to specifically make the pixel values of each pixel in the image regions with quantization noise nearly uniformly distributed. In this case, the quantization noise in the target image region can be reduced while minimizing resource waste caused by adjusting too many pixel values.
[0284] In some embodiments, this disclosure exemplarily provides an image processing method, which includes the following steps:
[0285] Step 31, acquire the first quantized image I to be processed. q .
[0286] The first image can be a grayscale image, an RGB color image, or a YUV image; this disclosure does not impose any limitation on it. For RGB or YUV images, the color channels of the first image can be separated, and subsequent processing can be performed channel by channel. The subsequent steps... q Refers to a single-channel image.
[0287] Step 32, iterate through each pixel I in the image. q (x, y), calculate the point and the pixel value equal to I. q Find the nearest distance d1 to the region (x, y)-1, and calculate the distance between that point and the pixel value equal to I. q The nearest distance d2 in the region (x, y)+1. The concept of distance is not strictly defined in this case, and Euclidean distance can generally be used.
[0288] Step 33: This disclosure provides a method for calculating the distances d1 and d2 mentioned in step 32. Taking the calculation of d1 as an example, the fast distance transformation method is as follows:
[0289] 1) Generate a two-dimensional array of distance transformation results with the same resolution as the first image, and initialize all its values to be greater than sqrt(w*w+h*h).
[0290] 2) Perform the first image traversal: Following the first preset order from left to right and top to bottom, use methods such as... Figure 5 The first preset mask shown sequentially covers the first region to be processed in the first image. Based on the above formulas (3) and (4) of this disclosure, the first distance value d1 corresponding to point q in the first region to be processed currently covered by the first preset mask is calculated.
[0291] 3) After the first image traversal, perform a second image traversal: following the second preset order from bottom to top and from right to left, using... Figure 6 The second preset mask shown sequentially covers the second region to be processed in the first image. Based on the above-described formulas (3) and (4) of this disclosure, the first distance value d2 corresponding to point q in the second region to be processed currently covered by the second preset mask is updated.
[0292] It should be noted that after the second traversal of the image, the final first distance value d1 corresponding to each pixel in the first image can be obtained. The second distance value d2 can be calculated in a similar way to the calculation of the first distance value d1. Specifically, the first distance value d2 corresponding to point q in the second processing area currently covered by the second preset mask can be updated using the above formulas (5) and (6).
[0293] Step 34: The quantization error value Q corresponding to the pixel can be calculated based on the above formula (1). e (x, y), and the pixel I of the first image calculated based on the above formula (2). q The corresponding original image data I(x, y).
[0294] Step 35: Using existing image jittering algorithms, smooth the image based on the original image data and / or quantization error values obtained above to obtain the jittered image result.
[0295] This case does not impose restrictions on the image jitter algorithm; an example method for random image jitter can be provided here:
[0296] A third image R is generated; wherein the pixel values of the pixels in the third image R are randomly and uniformly distributed; the resolution of the third image R is the same as that of the first image; and the pixels in the third image R and the first image at the same position correspond to each other. The pixel value range of the third image R can be [0, 255]. Image jitter processing can be performed on the first image based on the above formulas (7), (8) and (9).
[0297] In this disclosure, the method provided can significantly reduce quantization noise in an image, making the image smoother.
[0298] Figure 10 This is a block diagram illustrating an image processing apparatus according to an exemplary embodiment, such as Figure 10 As shown, the device includes:
[0299] The determining module 101 is configured to determine whether the original image data that generated the first image is detected when the first image is acquired; wherein the first image is an image obtained by quantizing the original image data;
[0300] In the absence of detecting the original image data, determine the pixel value of each pixel in the first image;
[0301] Based on the distribution of pixel values of each pixel, the quantization parameters corresponding to each pixel in the first image are determined.
[0302] The adjustment module 102 is configured to adjust the pixel values of at least some pixels in the first image based on quantization parameters to obtain the second image;
[0303] At least some of the pixels are located in image regions with quantization noise.
[0304] In some embodiments, the determining module 101 is further configured to:
[0305] By traversing the image, the distance between any pixel and all other pixels in the first image is determined until the distance value for each pixel is obtained; where the distance value is used to indicate the distribution of pixel values for each pixel.
[0306] Based on the distance value corresponding to each pixel, the quantization parameters corresponding to each pixel in the first image are determined.
[0307] In some embodiments, each pixel has a first pixel value;
[0308] Module 101 is also configured as follows:
[0309] Determine a first distance value between any pixel and a first pixel having a second pixel value, and a second distance value between any pixel and a second pixel having a third pixel value; wherein the first pixel value is greater than the second pixel value, and the first pixel value is less than the third pixel value, the difference between the first pixel value and the second pixel value is less than a first threshold, and the difference between the first pixel value and the third pixel value is less than a second threshold;
[0310] Based on the first distance value and the second distance value corresponding to each pixel, the quantization parameters corresponding to each pixel in the first image are determined respectively.
[0311] In some embodiments, the determining module 101 is further configured to:
[0312] Determine a third distance value between any given pixel and a third pixel located within a predetermined range of that given pixel;
[0313] Based on the pixel value of each third pixel, the first distance value and the third distance value corresponding to each third pixel, determine the first distance value corresponding to any pixel.
[0314] Based on the pixel value of each third pixel, the second distance value and the third distance value corresponding to each third pixel, the second distance value corresponding to any pixel is determined.
[0315] In some embodiments, the determining module 101 is further configured to:
[0316] For each third pixel, if any pixel has a first distance value and the third pixel has a first pixel value, if the first sum between the first distance value and the third distance value is less than the first distance value corresponding to any pixel, then the first distance value corresponding to any pixel is updated to the first sum.
[0317] For each third pixel, if any pixel has a first distance value and the third pixel has a second pixel value, if the third distance value is less than the first distance value corresponding to any pixel, then the first distance value corresponding to any pixel is updated to the third distance value.
[0318] The first distance value corresponding to any pixel is either the initially set distance value or the distance value obtained after updating the initially set distance value.
[0319] In some embodiments, the determining module 101 is further configured to:
[0320] For each third pixel, if any pixel has a second distance value and the third pixel has a first pixel value, if the second sum between the second distance value and the third distance value corresponding to the third pixel is less than the second distance value corresponding to any pixel, then the second distance value corresponding to any pixel is updated to the second sum.
[0321] For each third pixel, if there is a second distance value corresponding to any pixel and the third pixel has a third pixel value, if the third distance value is less than the second distance value corresponding to any pixel, then the second distance value corresponding to any pixel is updated to the third distance value.
[0322] The second distance value corresponding to any pixel is either the initially set distance value or the distance value obtained after updating the initially set distance value.
[0323] In some embodiments, the determining module 101 is further configured to include:
[0324] Based on the first distance value and the second distance value corresponding to each pixel, the quantization relationship between the pixel value of each pixel in the first image and the pixel value before quantization corresponding to the pixel is determined, as well as the quantization error value between the pixel value of each pixel in the first image and the pixel value before quantization corresponding to the pixel is determined.
[0325] Adjust module 102 is also configured as follows:
[0326] Based on the quantization relationship and quantization error value, the pixel values of at least some pixels in the first image are adjusted.
[0327] In some embodiments, the device further includes:
[0328] The generation module is configured to generate a third image; wherein the pixel values of the pixels in the third image are randomly and uniformly distributed; the resolution of the third image is the same as that of the first image; and the pixels in the third image and the first image at the same position correspond to each other.
[0329] Adjust module 102 is also configured as follows:
[0330] If the quantization relationship indicates that the pixel value of a pixel in the first image is less than the pixel value before quantization, and the product of the quantization error value and the preset value is greater than the pixel value of the corresponding pixel in the third image, then the pixel value of the pixel in the first image is increased; wherein, the preset value is determined according to the range of pixel values in the first image.
[0331] If the quantization relationship indicates that the pixel value of a pixel in the first image is greater than the pixel value before quantization, and the product of the quantization error value and the preset value is greater than the pixel value of the corresponding pixel in the third image, then the pixel value of the pixel in the first image is reduced.
[0332] In some embodiments, the adjustment module 102 is further configured to:
[0333] Based on the quantization parameters, the pixel values of all pixels in the first image are adjusted; and / or,
[0334] Based on the quantization parameters, the target image region containing quantization noise is determined from the first image, and the pixel values of the pixels in the target image region are adjusted.
[0335] Figure 11 This is a structural block diagram illustrating an electronic device 1100 according to an exemplary embodiment. For example, device 1100 may be a mobile phone, computer, digital broadcasting terminal, messaging device, game console, tablet device, medical device, fitness equipment, personal digital assistant, etc.
[0336] Reference Figure 11 The device 1100 may include one or more of the following components: processing component 1102, memory 1104, power supply component 1106, multimedia component 1108, audio component 1110, input / output (I / O) interface 1112, sensor component 1114, and communication component 1116.
[0337] Processing component 1102 typically controls the overall operation of device 1100, such as operations associated with at least one of display, telephone call, data communication, camera operation, and recording operation. Processing component 1102 may include one or more processors 1120 to execute instructions to perform all or part of the steps of the methods described above. Furthermore, processing component 1102 may include one or more modules to facilitate interaction between processing component 1102 and other components. For example, processing component 1102 may include a multimedia module to facilitate interaction between multimedia component 1108 and processing component 1102.
[0338] Memory 1104 is configured to store various types of data to support operation of device 1100. Examples of such data include at least one of the following: instructions for any application or method operating on device 1100, contact data, phonebook data, messages, pictures, and videos. Memory 1104 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0339] Power supply component 1106 provides power to various components of device 1100. Power supply component 1106 may include at least one of the following: a power management system, one or more power sources, and other components associated with generating, managing, and distributing power to device 1100.
[0340] Multimedia component 1108 includes a screen that provides an output interface between device 1100 and the user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a Touch Panel, the screen may be implemented as a touchscreen to receive input signals from the user. The Touch Panel includes one or more touch sensors to sense touches, swipes, and gestures on the Touch Panel. The touch sensors may sense not only the boundaries of touch or swipe actions but also the duration and pressure associated with the touch or swipe operation. In some embodiments, multimedia component 1108 includes a front-facing camera and / or a rear-facing camera. When device 1100 is in an operating mode, such as a shooting mode or a video mode, the front-facing camera and / or rear-facing camera may receive external multimedia data. Each front-facing camera and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
[0341] Audio component 1110 is configured to output and / or input audio signals. For example, audio component 1110 includes a microphone (MIC) configured to receive external audio signals when device 1100 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 1104 or transmitted via communication component 1116. In some embodiments, audio component 1110 also includes a speaker for outputting audio signals.
[0342] I / O interface 1112 provides an interface between processing component 1102 and peripheral interface modules, such as keyboards, click wheels, and buttons. These buttons may include, but are not limited to, home buttons, volume buttons, power buttons, and lock buttons.
[0343] Sensor assembly 1114 includes one or more sensors for providing state assessment of various aspects of device 1100. For example, sensor assembly 1114 may detect the on / off state of device 1100, the relative positioning of components, such as the display and keypad of device 1100, changes in position of device 1100 or one of its components, the presence or absence of user contact with device 1100, orientation or acceleration / deceleration of device 1100, and temperature changes of device 1100. Sensor assembly 1114 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 1114 may also include an optical sensor, such as a complementary metal-oxide-semiconductor (CMOS) or charge-coupled device (CCD) image sensor, for use in imaging applications. In some embodiments, sensor assembly 1114 may also include, but is not limited to, at least one of the following: an accelerometer, a gyroscope, a magnetometer, a pressure sensor, and a temperature sensor.
[0344] Communication component 1116 is configured to facilitate wired or wireless communication between device 1100 and other devices. Device 1100 can access wireless networks based on communication standards, such as Wi-Fi, 4G, 5G, or combinations thereof. In one exemplary embodiment, communication component 1116 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 1116 also includes a Near Field Communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID), Infrared Data Association (IrDA), Ultra Wide Band (UWB), Bluetooth (BT), and other technologies.
[0345] In an exemplary embodiment, device 1100 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components.
[0346] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 1104 including executable instructions or a computer program, which can be executed by the processor 1120 of the device 1100 to perform the above-described method. For example, the non-transitory computer-readable storage medium may be a ROM, random access memory (RAM), a compact disc read-only memory (CD-ROM), magnetic tape, floppy disk, and optical data storage device, etc.
[0347] A non-transitory computer-readable storage medium, when the instructions in the storage medium are executed by the processor of a mobile terminal, enables the mobile terminal to perform any of the image processing methods described in the embodiments of this disclosure. For example, the image processing method includes:
[0348] If the first image is acquired, determine whether the original image data that generated the first image was detected; wherein, the first image is an image obtained by quantizing the original image data;
[0349] In the absence of detecting the original image data, determine the pixel value of each pixel in the first image;
[0350] Based on the distribution of pixel values of each pixel, the quantization parameters corresponding to each pixel in the first image are determined.
[0351] The pixel values of at least some pixels in the first image are adjusted based on quantization parameters to obtain the second image;
[0352] At least some of the pixels are located in image regions with quantization noise.
[0353] This disclosure provides a computer program product comprising a computer program or executable instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer program or executable instructions from the computer-readable storage medium and executes the computer program or executable instructions, causing the computer device to perform any of the image processing methods described above in this disclosure.
[0354] Figure 12 This is a block diagram illustrating a display device 1200 according to an exemplary embodiment. For example, device 1200 may be provided as a server. (Refer to...) Figure 12 The device 1200 includes a processing component 1222, which further includes one or more processors, and memory resources represented by memory 1232 for storing instructions, such as application programs, that can be executed by the processing component 1222. The application programs stored in memory 1232 may include one or more modules, each corresponding to a set of instructions. Furthermore, the processing component 1222 is configured to execute instructions to perform the aforementioned image processing method.
[0355] If the first image is acquired, determine whether the original image data that generated the first image was detected; wherein, the first image is an image obtained by quantizing the original image data;
[0356] In the absence of detecting the original image data, determine the pixel value of each pixel in the first image;
[0357] Based on the distribution of pixel values of each pixel, the quantization parameters corresponding to each pixel in the first image are determined.
[0358] The pixel values of at least some pixels in the first image are adjusted based on quantization parameters to obtain the second image;
[0359] At least some of the pixels are located in image regions with quantization noise.
[0360] Device 1200 may also include a power supply component 1226 configured to perform power management of device 1200, a wired or wireless network interface 1250 configured to connect device 1200 to a network, and an input / output (I / O) interface 1258. Device 1200 can operate an operating system stored in memory 1232, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, or similar.
[0361] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the foregoing claims.
[0362] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. An image processing method, characterized in that, include: If a first image is acquired, it is determined whether the original image data that generated the first image is detected; wherein, the first image is an image obtained by quantizing the original image data; In the absence of detecting the original image data, determine the pixel value of each pixel in the first image; Based on the distribution of pixel values of each pixel, the quantization parameters corresponding to each pixel in the first image are determined. The pixel values of at least some pixels in the first image are adjusted based on the quantization parameters to obtain the second image; Wherein, at least some of the pixels are located in the image region where quantization noise exists.
2. The image processing method according to claim 1, characterized in that, The step of determining the quantization parameters corresponding to each pixel in the first image based on the distribution of pixel values of each pixel includes: By traversing the image, the distance between any pixel and all other pixels in the first image is determined until the distance value corresponding to each pixel is obtained; wherein, the distance value is used to indicate the distribution of pixel values of each pixel. Based on the distance value corresponding to each pixel, the quantization parameter corresponding to each pixel in the first image is determined.
3. The image processing method according to claim 2, characterized in that, Each pixel has a first pixel value; determining the distance between each pixel in the first image and all other pixels until the distance values corresponding to each pixel are obtained includes: A first distance value is determined between any pixel and a first pixel having a second pixel value, and a second distance value is determined between any pixel and a second pixel having a third pixel value; wherein the first pixel value is greater than the second pixel value, and the first pixel value is less than the third pixel value, the difference between the first pixel value and the second pixel value is less than a first threshold, and the difference between the first pixel value and the third pixel value is less than a second threshold; The step of determining the quantization parameters corresponding to each pixel in the first image based on the distance value corresponding to each pixel includes: Based on the first distance value and the second distance value corresponding to each pixel, the quantization parameters corresponding to each pixel in the first image are determined respectively.
4. The method according to claim 3, characterized in that, Determining the first distance value between any pixel and a first pixel having a second pixel value, and the second distance value between any pixel and a second pixel having a third pixel value, includes: Determine a third distance value between any given pixel and a third pixel located within a predetermined range of the given pixel; Based on the pixel value of each of the third pixels, the first distance value corresponding to each of the third pixels, and the third distance value, the first distance value corresponding to any pixel is determined; Based on the pixel value of each of the third pixels, the second distance value corresponding to each of the third pixels, and the third distance value, the second distance value corresponding to any pixel is determined.
5. The method according to claim 4, characterized in that, The step of determining the first distance value corresponding to any pixel point based on the pixel value of each of the third pixels, the first distance value corresponding to each of the third pixels, and the third distance value includes: For each of the third pixels, if any pixel corresponds to the first distance value and the third pixel has the first pixel value, if the first sum between the first distance value and the third distance value is less than the first distance value corresponding to any pixel, then the first distance value corresponding to any pixel is updated to the first sum. For each of the third pixels, if any pixel corresponds to the first distance value and the third pixel has the second pixel value, and if the third distance value is less than the first distance value corresponding to any pixel, then the first distance value corresponding to any pixel is updated to the third distance value. Wherein, the first distance value corresponding to any pixel is the initially set distance value, or the distance value obtained after updating the initially set distance value.
6. The method according to claim 4, characterized in that, The step of determining the second distance value corresponding to any pixel point based on the pixel value of each of the third pixels, the second distance value corresponding to each of the third pixels, and the third distance value includes: For each of the third pixels, if any pixel corresponds to the second distance value and the third pixel has the first pixel value, if the second sum between the second distance value and the third distance value is less than the second distance value corresponding to any pixel, then the second distance value corresponding to any pixel is updated to the second sum. For each of the third pixels, if any pixel corresponds to the second distance value and the third pixel has the third pixel value, and if the third distance value is less than the second distance value corresponding to any pixel, then the second distance value corresponding to any pixel is updated to the third distance value. Wherein, the second distance value corresponding to any pixel is the initially set distance value, or the distance value obtained after updating the initially set distance value.
7. The image processing method according to any one of claims 3 to 6, characterized in that, The step of determining the quantization parameters corresponding to each pixel in the first image based on the first distance value and the second distance value corresponding to each pixel includes: Based on the first distance value and the second distance value corresponding to each pixel, the quantization relationship between the pixel value of each pixel in the first image and the pixel value before quantization corresponding to the pixel is determined, as well as the quantization error value between the pixel value of each pixel in the first image and the pixel value before quantization corresponding to the pixel is determined; The step of adjusting the pixel values of at least some pixels in the first image based on the quantization parameters to obtain the second image includes: Based on the quantization relationship and the quantization error value, the pixel values of at least some pixels in the first image are adjusted.
8. The image processing method according to claim 7, characterized in that, The method further includes: A third image is generated; wherein the pixel values of the pixels in the third image are randomly and uniformly distributed; the resolution of the third image is the same as that of the first image; and the pixels in the third image and the first image at the same position correspond to each other. The step of adjusting the pixel values of at least some pixels in the first image based on the quantization relationship and the quantization error value includes: If the quantization relationship indicates that the pixel value of the pixel in the first image is less than the pixel value before quantization, and the product of the quantization error value and the preset value is greater than the pixel value of the corresponding pixel in the third image, then the pixel value of the pixel in the first image is increased; wherein, the preset value is determined according to the range of pixel values in the first image. If the quantization relationship indicates that the pixel value of the pixel in the first image is greater than the pixel value before quantization, and the product of the quantization error value and the preset value is greater than the pixel value of the corresponding pixel in the third image, then the pixel value of the pixel in the first image is reduced.
9. The image processing method according to claim 1, characterized in that, The adjustment of pixel values of at least some pixels in the first image based on the quantization parameters includes: Based on the quantization parameters, the pixel values of all pixels in the first image are adjusted; and / or, Based on the quantization parameters, a target image region containing quantization noise is determined from the first image, and the pixel values of the pixels in the target image region are adjusted.
10. An image processing apparatus, characterized in that, The device includes: The determining module is configured to, upon acquiring a first image, determine whether the original image data used to generate the first image is detected; wherein, the first image is an image obtained by quantizing the original image data; In the absence of detecting the original image data, determine the pixel value of each pixel in the first image; Based on the distribution of pixel values of each pixel, the quantization parameters corresponding to each pixel in the first image are determined. The adjustment module is configured to adjust the pixel values of at least some pixels in the first image based on the quantization parameters to obtain a second image; Wherein, at least some of the pixels are located in the image region where quantization noise exists.
11. An electronic device, characterized in that, include: processor; Memory used to store computer programs or instructions; The processor executes the computer program or instructions to implement the steps of the method according to any one of claims 1 to 9.
12. A non-transitory computer-readable storage medium storing a computer program or instructions, characterized in that, When the computer program or instructions in the storage medium are executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.
13. A computer program product, comprising a computer program or instructions, characterized in that, When the computer program or instructions are executed by a processor, they implement the steps of the method according to any one of claims 1 to 9.