Method and device for correcting purple edge of image, electronic equipment and medium

By comprehensively utilizing the hue, contrast and brightness dimensions of the image, accurately detecting and efficiently correcting the purple edge pixel points in the image, the problems of low efficiency and high complexity of purple edge correction in the prior art are solved, and efficient image processing effect suitable for real-time video processing is achieved.

CN120125474APending Publication Date: 2025-06-10SHENZHEN MICROBT ELECTRONICS TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311684168.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-08
Publication Date
2025-06-10

AI Technical Summary

Technical Problem

When solving the problem of purple edges in the prior art, the correction efficiency is low and the complexity is high, making it difficult to apply to video shooting products with real-time requirements.

Method used

By comprehensively determining the purple edge pixel points based on the three dimensions of hue, contrast and brightness, the accuracy of purple edge detection is improved, and the saturation correction factor for performing purple edge correction is used to comprehensively determine the efficiency of purple edge correction.

Benefits of technology

It realizes high accuracy and high efficiency purple edge detection and correction, which is suitable for real-time video processing, reducing R&D costs and cycles.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120125474A_ABST
    Figure CN120125474A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides an image purple edge correction method and device, electronic equipment and a medium. The method comprises the steps of obtaining image data; determining a brightness plane and a hue plane of the image data; based on the brightness plane, determining pixel points which belong to a highlight area and a high-contrast area at the same time in the image data; based on the hue plane, purple edge pixel points are determined from the pixel points belonging to the highlight area and the high-contrast area at the same time; and correcting the purple edge pixel points. Purple edge pixel points are comprehensively determined based on hue, contrast and brightness, so that the accuracy of purple edge detection is improved; and the saturation correction factor is comprehensively determined by using the hue, the contrast ratio and the brightness, so that the purple edge correction efficiency is improved, and rapid purple edge correction can be realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of image processing technologies, and in particular, to a method, apparatus, electronic device, and medium for correcting purple fringing in images. Background Art

[0002] Purple fringing commonly exists in images captured by digital imaging systems such as mobile phone cameras, digital cameras, surveillance cameras, etc. When using a digital imaging device to take pictures under backlight or large aperture conditions, purple fringing often appears in local areas of the captured images, especially in high-contrast areas (image areas with a large contrast between light and dark, such as the edge where the sky, light tube meets an object). The appearance of purple fringing is related to chromatic aberration of the camera lens, too small imaging area of the charge-coupled device (CCD), and signal processing algorithms inside the camera. Solving purple fringing helps the imaging device to obtain high-quality images.

[0003] Currently, hardware structures such as cameras or lenses are usually changed to avoid purple fringing. However, changing the hardware structure has the disadvantages of high cost and long R & D cycle. Summary of the Invention

[0004] Embodiments of the present disclosure propose a method, apparatus, electronic device, and medium for correcting purple fringing in images.

[0005] A method for correcting purple fringing in an image includes:

[0006] Obtain image data;

[0007] Determine the luminance plane and the hue plane of the image data;

[0008] Based on the luminance plane, determine the pixel points in the image data that belong to both the high-brightness area and the high-contrast area;

[0009] Based on the hue plane, determine the purple fringing pixel points from the pixel points that belong to both the high-brightness area and the high-contrast area;

[0010] Correct the purple fringing pixel points.

[0011] In one embodiment, the determining the pixel points in the image data that belong to both the high-brightness area and the high-contrast area based on the luminance plane includes:

[0012] Taking the current pixel point as the center, determine a first window and a second window with respective predetermined sizes;

[0013] Based on the luminance plane, determine the luminance value of each pixel point in the first window;

[0014] Determine the number of pixel points in the first window whose luminance value is greater than a predetermined first threshold;

[0015] Determine the difference between the maximum brightness value and the minimum brightness value in the second window;

[0016] When the number is greater than or equal to a predetermined second threshold and the difference is greater than or equal to a predetermined third threshold, determine that the current pixel point belongs to both the highlight area and the high-contrast area.

[0017] In one embodiment, the first window and the second window have the same size.

[0018] In one embodiment, determining the purple edge pixel points from the pixel points that belong to both the highlight area and the high-contrast area based on the hue plane includes:

[0019] Based on the hue plane, determine the hue value of the pixel points that belong to both the highlight area and the high-contrast area;

[0020] Determine the pixel points whose hue value is greater than or equal to the minimum value of the hue range of purple and less than or equal to the maximum value of the hue range of purple as the purple edge pixel points.

[0021] In one embodiment, correcting the purple edge pixel points includes:

[0022] Determine the saturation correction factor of the purple edge pixel points;

[0023] Based on the saturation correction factor of the purple edge pixel points, correct the pixel values of the purple edge pixel points to reduce the saturation of the purple edge area including the purple edge pixel points.

[0024] In one embodiment, determining the saturation correction factor of the purple edge pixel points includes:

[0025] Based on the hue value of the purple edge pixel points, determine a first correction factor, where the first correction factor increases as the hue value increases in a first interval of the hue value, remains unchanged in a second interval of the hue value, and decreases as the hue value increases in a third interval of the hue value; where the right endpoint of the first interval is less than or equal to the left endpoint of the second interval, and the right endpoint of the second interval is less than or equal to the left endpoint of the third interval;

[0026] Determine a second correction factor based on the difference between the maximum luminance value and the minimum luminance value within a predetermined area including the purple fringing pixel points, where the second correction factor remains at a first predetermined value within a fourth interval of the difference, increases as the difference increases within a fifth interval of the difference, and remains at a second predetermined value within a sixth interval of the difference; wherein the right endpoint of the fourth interval is less than or equal to the left endpoint of the fifth interval, and the right endpoint of the fifth interval is less than or equal to the left endpoint of the sixth interval; and the second predetermined value is greater than the first predetermined value;

[0027] Determine a third correction factor based on the luminance value of the purple fringing pixel points, where the third correction factor remains at a third predetermined value within a seventh interval of the luminance value, increases as the luminance value increases within an eighth interval of the luminance value, and remains at a fourth predetermined value within a ninth interval of the luminance value; wherein the right endpoint of the seventh interval is less than or equal to the left endpoint of the eighth interval, and the right endpoint of the eighth interval is less than or equal to the left endpoint of the ninth interval; and the fourth predetermined value is greater than the third predetermined value;

[0028] Determine the saturation correction factor based on the first correction factor, the second correction factor, and the third correction factor.

[0029] In one embodiment, the determining the saturation correction factor based on the first correction factor, the second correction factor, and the third correction factor includes:

[0030] Determine the product of the first correction factor, the second correction factor, and the third correction factor as the saturation correction factor.

[0031] An apparatus for correcting purple fringing in an image, comprising:

[0032] An acquisition module, configured to acquire image data;

[0033] A first determination module, configured to determine the luminance plane and the hue plane of the image data;

[0034] A second determination module, configured to determine, based on the luminance plane, the pixel points in the image data that simultaneously belong to the high-brightness region and the high-contrast region;

[0035] A third determination module, configured to determine, based on the hue plane, the purple fringing pixel points from the pixel points that simultaneously belong to the high-brightness region and the high-contrast region;

[0036] A correction module, configured to correct the purple fringing pixel points.

[0037] An electronic device, comprising:

[0038] A memory;

[0039] Processor;

[0040] Wherein, an application program executable by the processor is stored in the memory, and is used to cause the processor to execute the method for correcting purple fringing of an image as described above.

[0041] A computer-readable storage medium stores computer-readable instructions for executing the method for correcting purple fringing of an image as described above.

[0042] As can be seen from the above technical solutions, in the embodiments of the present invention, purple fringing pixel points are comprehensively determined based on three dimensions of hue, contrast, and brightness, which improves the accuracy of purple fringing detection. Moreover, a saturation correction factor for performing purple fringing correction is comprehensively determined based on the three dimensions of hue, contrast, and brightness, which improves the efficiency of purple fringing correction and can also achieve fast purple fringing correction. Description of the Drawings

[0043] The drawings here are incorporated into the description and form a part of this description, showing embodiments consistent with the present disclosure, and are used together with the description to explain the principles of the present disclosure, and do not constitute an improper limitation to the present disclosure.

[0044] Figure 1 It is a schematic flowchart of the method for correcting purple fringing of an image according to an embodiment of the present invention.

[0045] Figure 2 It is a schematic diagram of a first correction factor according to an embodiment of the present invention.

[0046] Figure 3 It is a schematic diagram of a second correction factor according to an embodiment of the present invention.

[0047] Figure 4 It is a schematic diagram of a third correction factor according to an embodiment of the present invention.

[0048] Figure 5 It is a schematic structural diagram of the device for correcting purple fringing of an image according to an embodiment of the present invention.

[0049] Figure 6 It is a structural diagram of an electronic device according to an embodiment of the present invention. Detailed Embodiments

[0050] In order to enable those of ordinary skill in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the drawings.

[0051] For the sake of simplicity and intuitiveness in description, the solutions of the present invention will be elaborated below by describing several representative embodiments. A large number of details in the embodiments are only used to help understand the solutions of the present invention. However, it is obvious that the technical solutions of the present invention can be implemented without being limited to these details. In order to avoid unnecessarily obscuring the solutions of the present invention, some embodiments are not described in detail, but only the frameworks are given. In the following text, "including" means "including but not limited to", and "according to..." means "at least according to..., but not limited to only according to...". Due to the language habits of Chinese, when the quantity of a component is not specifically pointed out in the following text, it means that the component can be one or more, or can be understood as at least one.

[0052] Currently, changing hardware structures such as cameras or lenses to avoid purple fringing in photos has the disadvantages of high cost and long R & D cycle. Therefore, it is desirable to process the purple fringing problem of images through software algorithms. Solving the purple fringing problem using software algorithms has advantages such as low R & D cost and short R & D cycle.

[0053] The applicant has found that: the existing image purple fringing correction algorithms generally have the disadvantages of low correction efficiency and high complexity, and are difficult to be applied to video shooting products with real-time requirements. The applicant further studies and finds that the reasons for the above disadvantages may include at least one of the following: (1) not considering the characteristic that purple fringing usually appears in high-contrast regions, resulting in inaccurate purple fringing detection; (2) only considering the purple fringing regions with high saturation during correction, while ignoring the purple fringing with low saturation; (3) performing correction by means of edge color detection, etc., and the corrected marked image still needs to be multiplied by the original image, with complex operations.

[0054] In the embodiments of the present invention, purple fringing pixel points are comprehensively determined based on three dimensions of hue, contrast, and brightness, improving the accuracy of purple fringing detection, and a saturation correction factor for performing purple fringing correction is comprehensively determined based on the three dimensions of hue, contrast, and brightness, improving the efficiency of purple fringing correction and enabling fast purple fringing correction.

[0055] The above disclosure details the technical defects existing in the prior art, the reasons for the technical defects, and the thinking and analysis process for overcoming the technical defects. In fact, the recognition of the above technical defects is not common knowledge in the art, but a novel discovery by the applicant in the research. In addition, the cause tracing of the technical defects and the thinking and analysis process for overcoming the technical defects are also the gradual analysis results of the applicant in the actual research process, and none of them are common knowledge in the art.

[0056] First, some technical terms in the embodiments of the present invention will be explained.

[0057] Hue: Indicates color information, that is, the position of the spectrum color. This parameter is expressed as an angle, ranging from 0 to 360 degrees.

[0058] Saturation: Also known as color purity, it refers to the vividness of a color. Saturation depends on the ratio of the color component to the achromatic component (gray) in the color. The primary color has the highest saturation. The larger the color component, the greater the saturation; the larger the achromatic component, the smaller the saturation.

[0059] Brightness (Value): Indicates the brightness of the color. For light source color, the brightness value is related to the brightness of the light source; for object color, this value is related to the transmittance or reflectance of the object.

[0060] RGB color mode: Various colors are obtained by changing the three color channels of red (R), green (G), and blue (B) and superimposing them on each other. RGB represents the colors of the three channels: red, green, and blue.

[0061] HSV (Hue, Saturation, Value): A color space based on the intuitive characteristics of color, also known as the Hexcone Model. The HSV color model refers to a subset of visible light in the H, S, V three-dimensional color space, which contains all colors in a certain color domain.

[0062] Figure 1 FIG. 1 is an exemplary flow chart of a method for correcting purple fringing of an image according to an embodiment of the present invention. Figure 1 As shown, the method includes:

[0063] Step 101: Acquire image data.

[0064] For example, you can use cameras and other video equipment to obtain real-time image data, and you can also obtain previously captured image data from storage spaces such as the cloud.

[0065] Specifically, the image data may be in Bayer format, Raw format, RGB format, JPEG format, DDS format, PSD format, PDT format, WebP format, XMP format, GIF format, BMP format, SVG format, TIFF format, and the like.

[0066] Step 102: Determine the brightness plane and the hue plane of the image data.

[0067] Here, the data acquired in step 102 may be converted into RGB image data, and then the brightness plane and the hue plane of the RGB image data may be determined.

[0068] For example, for each pixel point (R, G, B) in the RGB image data, calculate the luminance luma of the pixel point based on the following formula (1):

[0069] luma = 0.299 × R + 0.587 × G + 0.114 × B; Formula (1)

[0070] Where: R is the red channel value; G is the green channel value; B is the blue channel value. After calculating the luminance of all pixel points, a luminance plane is formed.

[0071] For example: According to the formula (2) for converting RGB to HSV, calculate the hue H of each pixel point. The hues of all pixel points form a hue plane:

[0072]

[0073] Where: Max = max(R, G, B), Min = min(R, G, B), and the functions max() and min() represent taking the maximum value and the minimum value respectively; R is the red channel value; G is the green channel value; B is the blue channel value.

[0074] The above exemplary description shows typical examples of determining the luminance plane and the hue plane of image data. Those skilled in the art can realize that such a description is only exemplary and is not used to limit the protection scope of the embodiments of the present invention.

[0075] Step 103: Based on the luminance plane, determine the pixel points in the image data that belong to both the high-brightness area and the high-contrast area.

[0076] In one embodiment, step 103 includes: taking the current pixel point as the center, determining a first window and a second window with respective predetermined sizes; based on the luminance plane, determining the luminance values of each pixel point in the first window; determining the number of pixel points in the first window whose luminance values are greater than a predetermined first threshold; determining the difference between the maximum luminance value and the minimum luminance value in the second window; when the number is greater than or equal to a predetermined second threshold and the difference is greater than or equal to a predetermined third threshold, determining that the current pixel point belongs to both the high-brightness area and the high-contrast area. Preferably, the sizes of the first window and the second window are the same.

[0077] Example: A moving window with a size of Nx×Ny is obtained on the luminance plane centered on the current pixel. Herein: Nx is the length of the window, and Ny is the height of the window. Preferably, Nx is equal to Ny. For example, Nx×Ny can be implemented as 3×3. For each pixel point within the window, it is determined whether the luminance value of each pixel point exceeds a preset luminance threshold (i.e., the first threshold). Then, the number of pixel points Ynum within the window that exceed the luminance threshold is counted. When Ynum exceeds the set threshold of the number of pixel points in the highlighted area (i.e., the second threshold), it is determined that the current pixel point belongs to the highlighted area; otherwise, it is determined that the current pixel point does not belong to the highlighted area. By analogy, it is possible to determine whether each pixel point belongs to the highlighted area.

[0078] Then, for each pixel point that has been determined to belong to the highlighted area, the following operations are respectively performed: A moving window with a size of Nx×Ny is obtained on the luminance plane centered on the current pixel. Herein: Nx is the length of the window, and Ny is the height of the window. Preferably, Nx is equal to Ny. For example, Nx×Ny can be implemented as 3×3. The maximum luminance value Ymax and the minimum luminance value Ymin are obtained within the moving window. The difference Contrast is used to measure the contrast of the area, where Contrast = Ymax - Ymin. If the difference Contrast is larger, it indicates that the contrast of the area is stronger; when the difference Contrast exceeds the set contrast threshold (i.e., the third threshold), it is determined that the current pixel point belongs to the high-contrast area, that is, the current pixel point belongs to both the highlighted area and the high-contrast area; otherwise, it is determined that the current pixel point does not belong to the high-contrast area.

[0079] By analogy, it is possible to determine whether each pixel point that has been determined to belong to the highlighted area belongs to the high-contrast area.

[0080] Step 104: Based on the hue plane, determine the purple-edge pixel points from the pixel points that belong to both the highlighted area and the high-contrast area;

[0081] In one embodiment, step 104 specifically includes: Based on the hue plane, determine the hue values of the pixel points that belong to both the highlighted area and the high-contrast area; The pixel points whose hue values are greater than or equal to the minimum value of the hue range of purple and less than or equal to the maximum value of the hue range of purple are determined as purple-edge pixel points.

[0082] For example, the hue range of purple can be 150 to 175. Correspondingly, the maximum value of the hue range is 175, and the minimum value is 150. Based on this hue range, it is possible to determine whether the pixel points that belong to both the highlighted area and the high-contrast area are purple-edge pixel points.

[0083] Example: When a certain pixel belongs to both the highlight area and the high-contrast area, and the hue is 130, it can be determined that this pixel is not a purple fringing pixel. When a certain pixel belongs to both the highlight area and the high-contrast area, and the hue is 158, it can be determined that this pixel is a purple fringing pixel.

[0084] The above exemplary description of the hue range of purple can be understood by those skilled in the art that such a description is only exemplary and is not used to limit the protection scope of the embodiments of the present invention.

[0085] Therefore, in the embodiments of the present invention, fully considering the characteristic that purple fringing usually appears in high-contrast areas, purple fringing pixels are comprehensively determined based on the three dimensions of hue, contrast, and brightness, improving the accuracy of purple fringing detection.

[0086] Step 105: Correct the purple fringing pixels.

[0087] In one embodiment, step 105 specifically includes: determining the saturation correction factor of the purple fringing pixels; based on the saturation correction factor of the purple fringing pixels, correcting the pixel values of the purple fringing pixels, thereby reducing the saturation of the purple fringing area containing the purple fringing pixels.

[0088] In one embodiment, determining the saturation correction factor of the purple fringing pixels includes:

[0089] (1) Based on the hue value of the purple fringing pixels, determine the first correction factor, where the first correction factor increases (for example, linearly increases) with the increase of the hue value within the first interval of the hue value, remains unchanged within the second interval of the hue value, and decreases (for example, linearly decreases) with the increase of the hue value within the third interval of the hue value; where the right endpoint of the first interval is less than or equal to the left endpoint of the second interval, and the right endpoint of the second interval is less than or equal to the left endpoint of the third interval.

[0090] Example: According to the following formula (3), based on the hue value (H) of the purple fringing pixels, the first correction factor (hue_factor) of the purple fringing pixels can be determined. Where: hue_th0, hue_th1, hue_th2, and hue_th3 are preset hue thresholds, hue_th3 is greater than hue_th2, hue_th2 is greater than hue_th1, and hue_th1 is greater than hue_th0. hue_th1 and hue_th2 can be two thresholds of the hue range of purple. hue_gain0 and hue_gain1 are two values set for the first correction factor. hue_gain1 is greater than hue_gain0.

[0091] Preferably, both hue_gain0 and hue_gain1 are in the interval of [0, 1].

[0092]

[0093] Figure 2 is a schematic diagram of a first correction factor according to an embodiment of the present invention. Figure 2 In the figure, the horizontal axis is the hue value (H) of the purple-fringe pixel, and the vertical axis is the first correction factor (hue_factor).

[0094] It can be seen that when H is less than hue_th0 (corresponding to interval OA), hue_factor is equal to hue_gain0; when H is greater than hue_th0 and less than hue_th1 (corresponding to interval AB), hue_factor increases with the increase of H in the range of [hue_gain0, hue_gain1]; when H is greater than hue_th1 and less than hue_th2 (corresponding to interval BC), hue_factor remains unchanged at hue_gain1; when H is greater than hue_th2 and less than hue_th3 (corresponding to interval CD), hue_factor decreases with the increase of H in the range of [hue_gain0, hue_gain1]. Moreover, when H is greater than hue_th3, hue_factor remains unchanged at hue_gain0.

[0095] exist Figure 2 In the example of linear increase and linear decrease of the first correction factor as H increases, different linear segmented intervals are used to exemplarily describe. Those skilled in the art will appreciate that this description is only exemplary. In fact, the first correction factor may increase and decrease nonlinearly (e.g., a parabola-like shape, etc.) as contrast increases.

[0096] The above describes a specific method of determining the first correction factor using a partition interval function. Since the partition interval function has the advantage of fast solution, the first correction factor can be determined quickly, which is particularly beneficial for real-time video processing.

[0097] (2) Based on the difference between the maximum brightness value and the minimum brightness value in a predetermined area including the purple-fringed pixel point (for example, the predetermined area can be the second window used in step 103), determine a second correction factor, wherein the second correction factor remains at the first predetermined value in a fourth interval of the difference, increases with the increase of the difference in a fifth interval of the difference, and remains at the second predetermined value in a sixth interval of the difference; wherein the right endpoint of the fourth interval is less than or equal to the left endpoint of the fifth interval, and the right endpoint of the fifth interval is less than or equal to the left endpoint of the sixth interval; and the second predetermined value is greater than the first predetermined value.

[0098] Example: According to the following formula (4), based on the contrast of the purple fringing pixel points, the second correction factor (contrast_factor) of the purple fringing pixel points can be determined. Wherein: contrast_th0 and contrast_th1 are preset contrast thresholds, and contrast_th1 is greater than contrast_th0. contrast_gain0 and contrast_gain1 are two values set for the second correction factor. contrast_gain1 is greater than contrast_gain0. Preferably, both contrast_gain0 and contrast_gain1 are in the range of [0, 1].

[0099]

[0100] Figure 3 It is a schematic diagram of the second correction factor according to an embodiment of the present invention.

[0101] In Figure 3 the abscissa is the contrast value (contrast) of the purple fringing pixel points, and the ordinate is the second correction factor (contrast_factor).

[0102] It can be seen that when contrast is less than contrast_th0 (corresponding to the interval OE), contrast_factor is equal to contrast_gain0; when contrast is greater than contrast_th0 and less than contrast_th1 (corresponding to the interval EF), contrast_factor increases with the increase of contrast within the range of [contrast_gain0, contrast_gain1]; when contrast is greater than contrast_th1, contrast_factor remains unchanged at contrast_gain1.

[0103] In Figure 3 an example of the second correction factor increasing linearly with the increase of contrast is described in a linearly segmented interval. Those skilled in the art can realize that this description is only exemplary. In fact, the second correction factor can increase non-linearly with the increase of contrast (for example, a parabolic shape, etc.).

[0104] The above describes the specific method for determining the second correction factor with a piecewise function. Since the piecewise function has the advantage of fast solution, the second correction factor can be determined quickly, which is especially beneficial for real-time video processing.

[0105] (3) Determine a third correction factor based on the brightness value of the purple fringing pixel points, where the third correction factor remains at a third predetermined value within the seventh interval of the brightness value, increases as the brightness value increases within the eighth interval of the brightness value, and remains at a fourth predetermined value within the ninth interval of the brightness value; wherein the right endpoint of the seventh interval is less than or equal to the left endpoint of the eighth interval, and the right endpoint of the eighth interval is less than or equal to the left endpoint of the ninth interval; the fourth predetermined value is greater than the third predetermined value; determine the saturation correction factor based on the first correction factor, the second correction factor, and the third correction factor.

[0106] For example, based on the following formula (5), the third correction factor (luma_factor) of the purple fringing pixel points can be determined based on the brightness (luma) of the purple fringing pixel points. Wherein: luma_th0 and luma_th1 are preset brightness values, and luma_th1 is greater than luma_th0. luma_gain0 and luma_gain1 are two values set for the third correction factor. luma_gain1 is greater than luma_gain0. Preferably, both luma_gain0 and luma_gain1 are within the interval [0, 1].

[0107]

[0108] Figure 4 It is a schematic diagram of the third correction factor according to an embodiment of the present invention.

[0109] In Figure 4 , the abscissa is the brightness value (luma) of the purple fringing pixel points, and the ordinate is the third correction factor (luma_factor).

[0110] It can be seen that when luma is less than luma_th0 (corresponding to the interval OH), luma_factor is equal to luma_gain0; when luma is greater than luma_th0 and less than luma_th1 (corresponding to the interval HI), luma_factor increases as luma increases within the range of [luma_gain0, luma_gain1]; when luma is greater than luma_th1, luma_factor remains unchanged at luma_gain1.

[0111] In Figure 4 , an example in which the third correction factor increases linearly as luma increases is described by a linear piecewise interval. Those skilled in the art can realize that this description is only exemplary. In fact, the third correction factor can increase non-linearly as luma increases (for example, a parabola-like shape, etc.).

[0112] The specific method for determining the third correction factor is described by the piecewise function above. Since the piecewise function has the advantage of fast solution, the third correction factor can be determined quickly, which is especially beneficial for real-time video processing.

[0113] In one embodiment, based on the first correction factor, the second correction factor, and the third correction factor, determining the saturation correction factor includes: determining the product of the first correction factor, the second correction factor, and the third correction factor as the saturation correction factor.

[0114] Continuing with the above example, the calculation formula for the saturation correction factor (desat_factor) is Formula (6) as follows:

[0115] desat_factor = hue_factor × contrast_factor × luma_factor; Formula (6).

[0116] After determining the saturation correction factor for each purple fringing pixel point based on Formula (6), each purple fringing pixel point can be corrected to effectively reduce the saturation in the purple fringing area, thereby eliminating the purple fringing phenomenon.

[0117] Example: Assume that the purple fringing pixel point to be corrected is (R in , G in , B in ); where R in is the red channel value of the purple fringing pixel point to be corrected; G in is the green channel value of the purple fringing pixel point to be corrected; B in is the blue channel value of the purple fringing pixel point to be corrected; the corrected pixel point is (R out , G out , B out ): where R out is the red channel value of the corrected pixel point; G out is the green channel value of the corrected pixel point; B out is the blue channel value of the corrected pixel point; desat_factor is the saturation correction factor of the purple fringing pixel point to be corrected; Y in is the luminance value of the purple fringing pixel point to be corrected; where: R out = R in + desat_factor * (Y in - R in ); G out = G in + desat_factor * (Y in - G in ); B out = B in + desat_factor * (Yin -B in )。

[0118] Therefore, the embodiments of the present invention also comprehensively determine the saturation correction factor for specifically performing purple fringing correction by using three dimensions of hue, contrast, and brightness, improving the efficiency of purple fringing correction. Moreover, the first correction factor, the second correction factor, and the third correction factor can be determined based on an interval division method, which has the advantage of simple operation and can achieve fast purple fringing correction, especially suitable for real-time video processing.

[0119] Figure 5 is a schematic structural diagram of an apparatus for correcting purple fringing of an image according to an embodiment of the present invention. As Figure 5 shown, the apparatus 500 for correcting purple fringing of an image includes: an acquisition module 501 for acquiring image data; a first determination module 502 for determining the luminance plane and the hue plane of the image data; a second determination module 503 for determining, based on the luminance plane, the pixel points that simultaneously belong to the high-brightness region and the high-contrast region in the image data; a third determination module 504 for determining, based on the hue plane, the purple fringing pixel points from the pixel points that simultaneously belong to the high-brightness region and the high-contrast region; and a correction module 505 for correcting the purple fringing pixel points.

[0120] In one embodiment, the second determination module 503 is configured to determine, with the current pixel point as the center, a first window and a second window having respective predetermined sizes; determine the luminance values of each pixel point in the first window based on the luminance plane; determine the number of pixel points in the first window whose luminance values are greater than a predetermined first threshold; determine the difference between the maximum luminance value and the minimum luminance value in the second window; and when the number is greater than or equal to a predetermined second threshold and the difference is greater than or equal to a predetermined third threshold, determine that the current pixel point simultaneously belongs to the high-brightness region and the high-contrast region.

[0121] In one embodiment, the first window and the second window have the same size.

[0122] In one embodiment, the third determination module 504 is configured to determine the hue values of the pixel points that simultaneously belong to the high-brightness region and the high-contrast region based on the hue plane; and determine the pixel points whose hue values are greater than or equal to the minimum value of the hue range of purple and less than or equal to the maximum value of the hue range of purple as the purple fringing pixel points.

[0123] In one embodiment, the correction module 505 is configured to determine the saturation correction factor of the purple fringing pixel points; and correct the pixel values of the purple fringing pixel points based on the saturation correction factor of the purple fringing pixel points to reduce the saturation of the purple fringing region including the purple fringing pixel points.

[0124] In one embodiment, the calibration module 505 is configured to determine a first calibration factor based on the hue value of the purple fringing pixel points, where the first calibration factor increases as the hue value increases within a first interval of the hue value, remains unchanged within a second interval of the hue value, and decreases as the hue value increases within a third interval of the hue value; wherein the right endpoint of the first interval is less than or equal to the left endpoint of the second interval, and the right endpoint of the second interval is less than or equal to the left endpoint of the third interval; to determine a second calibration factor based on the difference between the maximum luminance value and the minimum luminance value within a predetermined area containing the purple fringing pixel points, where the second calibration factor remains at a first predetermined value within a fourth interval of the difference, increases as the difference increases within a fifth interval of the difference, and remains at a second predetermined value within a sixth interval of the difference; wherein the right endpoint of the fourth interval is less than or equal to the left endpoint of the fifth interval, and the right endpoint of the fifth interval is less than or equal to the left endpoint of the sixth interval; the second predetermined value is greater than the first predetermined value; to determine a third calibration factor based on the luminance value of the purple fringing pixel points, where the third calibration factor remains at a third predetermined value within a seventh interval of the luminance value, increases as the luminance value increases within an eighth interval of the luminance value, and remains at a fourth predetermined value within a ninth interval of the luminance value; wherein the right endpoint of the seventh interval is less than or equal to the left endpoint of the eighth interval, and the right endpoint of the eighth interval is less than or equal to the left endpoint of the ninth interval; the fourth predetermined value is greater than the third predetermined value; and to determine a saturation calibration factor based on the first calibration factor, the second calibration factor, and the third calibration factor.

[0125] In one embodiment, the calibration module 505 is configured to determine the product of the first calibration factor, the second calibration factor, and the third calibration factor as the saturation calibration factor.

[0126] In addition, an embodiment of the present application further provides a computer program product. When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device is enabled to execute the steps of the above-described method for correcting purple fringing in an image. Embodiments of the present invention also respectively propose an electronic device. The electronic device includes: a processor; a memory; wherein the memory stores an application program executable by the processor for enabling the processor to execute the method for correcting purple fringing in an image as described in the above embodiments. Among them, the memory can be specifically implemented as various storage media such as an electrically erasable programmable read-only memory (EEPROM), a flash memory, and a programmable read-only memory (PROM). The processor can be implemented as including one or more central processing units or one or more field-programmable gate arrays, where the field-programmable gate array integrates one or more central processing unit cores. Specifically, the central processing unit or the central processing unit core can be implemented as a CPU, an MCU, or a digital signal processor.

[0127] Figure 6It is a structural diagram of an electronic device according to an embodiment of the present invention. The electronic device includes: a processor 601 and a memory 602. The processor 601 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 601 may be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), or programmable logic array (PLA). The processor 601 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the wake state, also known as the central processing unit (CPU); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 601 may be integrated with a graphics processing unit (GPU), and the GPU is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 601 may further include an AI processor, which is used to process computational operations related to machine learning. For example, the AI processor may be implemented as a neural network processor. The memory 602 may include one or more computer-readable storage media, and the computer-readable storage media may be non-transitory. The memory 602 may further include high-speed random access memory and non-volatile memory, such as one or more disk storage devices and flash storage devices.

[0128] In some embodiments, the non-transitory computer-readable storage medium in the memory 602 is used to store at least one instruction, and the at least one instruction is used to be executed by the processor 601 to implement the method for correcting purple fringing of images provided in various embodiments of the present disclosure. In some embodiments, the electronic device 600 may further optionally include: a peripheral device interface 603 and at least one peripheral device. The processor 601, the memory 602, and the peripheral device interface 603 may be connected through a bus or signal lines. Each peripheral device may be connected to the peripheral device interface 603 through a bus, signal lines, or a circuit board. Specifically, the peripheral device includes at least one of a radio frequency circuit 604, a touch display screen 605, a camera assembly 606, an audio circuit 607, a positioning component 608, and a power supply 609.

[0129] The peripheral device interface 603 can be used to connect at least one peripheral device related to input / output (I / O) to the processor 601 and the memory 602. In some embodiments, the processor 601, the memory 602, and the peripheral device interface 603 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 601, the memory 602, and the peripheral device interface 603 can be implemented on separate chips or circuit boards, and this embodiment does not limit this.

[0130] The radio frequency circuit 604 is used to receive and transmit radio frequency (RF) signals, also known as electromagnetic signals. The radio frequency circuit 604 communicates with a communication network and other communication devices through electromagnetic signals. The radio frequency circuit 604 converts an electrical signal into an electromagnetic signal for transmission, or converts a received electromagnetic signal into an electrical signal. Optionally, the radio frequency circuit 604 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a subscriber identity module card, and so on. The radio frequency circuit 604 can communicate with other terminals through at least one wireless communication protocol. The wireless communication protocol includes but is not limited to: metropolitan area network, generations of mobile communication networks (2G, 3G, 4G, and 5G), wireless local area network, and / or wireless fidelity (Wi-Fi) network. In some embodiments, the radio frequency circuit 604 may further include a circuit related to near field communication (NFC), and this disclosure does not limit this.

[0131] The display screen 605 is used to display a user interface (UI). The UI may include graphics, text, icons, videos, and any combination thereof. When the display screen 605 is a touch display screen, the display screen 605 also has the ability to collect touch signals on or above the surface of the display screen 605. The touch signals can be input to the processor 601 as control signals for processing. At this time, the display screen 605 can also be used to provide virtual buttons and / or a virtual keyboard, also known as soft buttons and / or a soft keyboard. In some embodiments, there can be one display screen 605, which is disposed on the front panel of the electronic device 600; in other embodiments, there can be at least two display screens 605, which are respectively disposed on different surfaces of the electronic device 600 or are in a foldable design; in some embodiments, the display screen 605 can be a flexible display screen, which is disposed on a curved surface or a folding surface of the electronic device 600. Even further, the display screen 605 can be set to an irregular non-rectangular shape, that is, an irregular-shaped screen. The display screen 605 can be prepared using materials such as a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc.

[0132] The camera module 606 is used to capture images or videos. Optionally, the camera module 606 includes a front camera and a rear camera. Generally, the front camera is disposed on the front panel of the terminal, and the rear camera is disposed on the back of the terminal. In some embodiments, there are at least two rear cameras, which are respectively any one of a main camera, a depth camera, a wide-angle camera, and a telephoto camera, so as to implement functions such as the fusion of the main camera and the depth camera to achieve the background blurring function, the fusion of the main camera and the wide-angle camera to achieve panoramic shooting and virtual reality (VR) shooting functions, or other fusion shooting functions. In some embodiments, the camera module 606 can also include a flash. The flash can be a single-color temperature flash or a dual-color temperature flash. The dual-color temperature flash refers to the combination of a warm light flash and a cold light flash, and can be used for light compensation under different color temperatures.

[0133] The audio circuit 607 may include a microphone and a speaker. The microphone is used to collect sound waves of the user and the environment, and convert the sound waves into electrical signals for input to the processor 601 for processing, or input to the radio frequency circuit 604 to achieve voice communication. For the purpose of stereo collection or noise reduction, there may be multiple microphones, which are respectively arranged at different parts of the electronic device 600. The microphone may also be an array microphone or an omnidirectional collection microphone. The speaker is used to convert the electrical signals from the processor 601 or the radio frequency circuit 604 into sound waves. The speaker may be a traditional thin film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert electrical signals into sound waves audible to humans, but also convert electrical signals into sound waves inaudible to humans for uses such as ranging. In some embodiments, the audio circuit 607 may further include a headphone jack.

[0134] The positioning component 608 is used to locate the current geographical location of the electronic device 600 to achieve navigation or location-based service (LBS). The positioning component 608 may be a positioning component based on the Global Positioning System (GPS) of the United States, the Beidou system of China, the GLONASS system of Russia, or the Galileo system of the European Union.

[0135] The power supply 609 is used to supply power to each component in the electronic device 600. The power supply 609 may be alternating current, direct current, a disposable battery, or a rechargeable battery. When the power supply 609 includes a rechargeable battery, the rechargeable battery may support wired charging or wireless charging.

[0136] Those skilled in the art can understand that the above structure does not limit the electronic device 600, and it may include more or fewer components than shown in the figure, or combine some components, or adopt different component arrangements.

[0137] It should be noted that not all steps and modules in the above processes and structure diagrams are necessary, and some steps or modules can be ignored according to actual needs. The execution order of each step is not fixed and can be adjusted according to needs. The division of each module is only for the convenience of description in terms of functional division. In actual implementation, one module can be implemented by multiple modules, and the functions of multiple modules can also be implemented by the same module. These modules can be located in the same device or in different devices.

[0138] The hardware modules in the various embodiments can be implemented mechanically or electronically. For example, a hardware module can include specially designed permanent circuits or logic devices (such as dedicated processors, such as FPGAs or ASICs) for performing specific operations. A hardware module can also include programmable logic devices or circuits (such as including general-purpose processors or other programmable processors) temporarily configured by software for performing specific operations. As for whether to specifically implement the hardware module in a mechanical manner, or using dedicated permanent circuits, or using temporarily configured circuits (such as configured by software), it can be determined based on cost and time considerations.

[0139] The present invention also provides a machine-readable storage medium storing instructions for causing a machine to execute the methods as described in this application. Specifically, a system or device equipped with a storage medium can be provided, on which software program codes for implementing the functions of any one of the above-described embodiments are stored, and the computer (or CPU or MPU) of the system or device is caused to read and execute the program codes stored in the storage medium. In addition, part or all of the actual operations can also be completed by an operating system or the like operating on the computer based on the instructions of the program codes. The program codes read from the storage medium can also be written to the memory provided in an expansion board inserted into the computer or to the memory provided in an expansion unit connected to the computer, and then based on the instructions of the program codes, the CPU or the like installed on the expansion board or the expansion unit is caused to execute part and all of the actual operations, thereby implementing the functions of any one of the above-described embodiments.

[0140] Embodiments of the storage medium for providing program codes include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), magnetic tapes, non-volatile memory cards, and ROMs. Optionally, the program codes can be downloaded from a server computer or the cloud via a communication network.

[0141] The above are only the preferred embodiments of the present invention and are not intended to limit the protection scope of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.

Claims

1. A method for correcting purple fringing in an image, characterized in that, it includes: Obtain image data; Determine the luminance plane and the hue plane of the image data; Based on the luminance plane, determine the pixel points in the image data that simultaneously belong to the high-brightness area and the high-contrast area; Based on the hue plane, determine the purple-fringing pixel points from the pixel points that simultaneously belong to the high-brightness area and the high-contrast area; Correct the purple-fringing pixel points.

2. The method according to claim 1, characterized in that, The step of determining the pixel points in the image data that simultaneously belong to the high-brightness area and the high-contrast area based on the luminance plane includes: Taking the current pixel point as the center, determine a first window and a second window with respective predetermined sizes; Based on the luminance plane, determine the luminance values of each pixel point in the first window; Determine the number of pixel points in the first window whose luminance values are greater than a predetermined first threshold; Determine the difference between the maximum luminance value and the minimum luminance value in the second window; When the number is greater than or equal to a predetermined second threshold and the difference is greater than or equal to a predetermined third threshold, determine that the current pixel point simultaneously belongs to the high-brightness area and the high-contrast area.

3. The method according to claim 2, characterized in that, The first window and the second window have the same size.

4. The method according to claim 1, characterized in that, The step of determining the purple-fringing pixel points from the pixel points that simultaneously belong to the high-brightness area and the high-contrast area based on the hue plane includes: Based on the hue plane, determine the hue values of the pixel points that simultaneously belong to the high-brightness area and the high-contrast area; Determine the pixel points whose hue values are greater than or equal to the minimum value of the hue range of purple and less than or equal to the maximum value of the hue range of purple as the purple-fringing pixel points.

5. The method according to any one of claims 1-4, characterized in that, The step of correcting the purple-fringing pixel points includes: Determine the saturation correction factor of the purple-fringing pixel points; Based on the saturation correction factor of the purple-fringing pixel points, correct the pixel values of the purple-fringing pixel points to reduce the saturation of the purple-fringing area containing the purple-fringing pixel points.

6. The method according to claim 5, characterized in that, The step of determining the saturation correction factor of the purple-fringing pixel points includes: Based on the hue value of the purple-fringing pixel points, determine a first correction factor, where the first correction factor increases with the increase of the hue value in the first interval of the hue value, remains unchanged in the second interval of the hue value, and decreases with the increase of the hue value in the third interval of the hue value; where the right endpoint of the first interval is less than or equal to the left endpoint of the second interval, and the right endpoint of the second interval is less than or equal to the left endpoint of the third interval; Determine a second correction factor based on the difference between the maximum luminance value and the minimum luminance value within a predetermined area including the purple fringing pixel points, where the second correction factor remains at a first predetermined value within a fourth interval of the difference, increases as the difference increases within a fifth interval of the difference, and remains at a second predetermined value within a sixth interval of the difference; wherein the right endpoint of the fourth interval is less than or equal to the left endpoint of the fifth interval, and the right endpoint of the fifth interval is less than or equal to the left endpoint of the sixth interval; and the second predetermined value is greater than the first predetermined value. Determine a third correction factor based on the luminance value of the purple fringing pixel points, where the third correction factor remains at a third predetermined value within a seventh interval of the luminance value, increases as the luminance value increases within an eighth interval of the luminance value, and remains at a fourth predetermined value within a ninth interval of the luminance value; wherein the right endpoint of the seventh interval is less than or equal to the left endpoint of the eighth interval, and the right endpoint of the eighth interval is less than or equal to the left endpoint of the ninth interval; and the fourth predetermined value is greater than the third predetermined value. Determine the saturation correction factor based on the first correction factor, the second correction factor, and the third correction factor.

7. The method according to claim 6, wherein, the determining the saturation correction factor based on the first correction factor, the second correction factor, and the third correction factor includes: determining the product of the first correction factor, the second correction factor, and the third correction factor as the saturation correction factor.

8. An apparatus for correcting purple fringing in an image, wherein, it includes: an acquisition module for acquiring image data; a first determination module for determining the luminance plane and the hue plane of the image data; a second determination module for determining, based on the luminance plane, the pixel points in the image data that simultaneously belong to the high-brightness area and the high-contrast area; a third determination module for determining, based on the hue plane, the purple fringing pixel points from the pixel points that simultaneously belong to the high-brightness area and the high-contrast area; a correction module for correcting the purple fringing pixel points.

9. An electronic device, wherein, it includes: a memory; a processor; wherein an application program executable by the processor is stored in the memory, and is used to cause the processor to execute the method for correcting purple fringing in an image according to any one of claims 1-7.

10. A computer-readable storage medium, wherein, computer-readable instructions are stored therein, and the computer-readable instructions are used to execute the method for correcting purple fringing in an image according to any one of claims 1-7.