An Image Processing Method, Apparatus, Device, and Medium
By segmenting the image channels and determining the purple edge pixel points using the local matching algorithm, and correcting the R and B channel values, the problem of misjudgment of the purple edge in the existing technology is solved, and a more accurate color correction effect is achieved.
Patent Information
- Application Number
- CN202211458980.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-17
- Publication Date
- 2025-08-05
- Estimated Expiration
- 2042-11-17
AI Technical Summary
The prior art has misjudgment when processing the purple edge of an image, which affects the correction effect. Especially in images taken under backlight and large aperture conditions, the color correction of the purple edge area is not accurate enough.
By obtaining the R, G, and B sub-images corresponding to the RGB channels of the target image, and dividing each sub-image into a preset number of sub-image blocks, the similar sub-image blocks and their motion vectors of the R and B sub-image blocks in the G sub-image blocks are determined using the image local matching algorithm, filtering the candidate pixel points, determining the purple-edged pixel points, and correcting their R and B channel values.
Improves the accuracy of color correction in the purple edge area, reduces misjudgment, and improves image quality.
Smart Images

Figure CN115713470B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to an image processing method, apparatus, device and medium. Background Art
[0002] Image chromatic aberration is a common problem in images captured by current digital imaging devices, such as mobile phone cameras, digital cameras, and surveillance cameras. When these devices are used to capture images under backlit conditions or at wide apertures, localized areas of the image, particularly high-contrast areas (i.e., areas with a sharp contrast between light and dark, such as the sky or the edges where light bulbs meet objects), can exhibit colors that do not belong to the objects. These edges are called chromatic fringing, with purple fringing being particularly prominent. Imaging systems typically focus the green channel, but lens chromatic aberration prevents different wavelengths of light from converging at the same point after passing through the lens. This causes the blue and red channels to be out of focus, resulting in a purple-red color fringing around the edges of objects.
[0003] Existing technologies usually determine the purple-fringe area based on the difference between the blue intensity and the red intensity in the image and the green intensity, and then perform correction processing. However, the colors of some image areas are purple or red, so there is a certain probability of misjudgment, which affects the effect of the correction processing.
[0004] Therefore, there is an urgent need for a more accurate image processing method for purple fringing, so as to effectively solve the image purple fringing problem. Summary of the Invention
[0005] The present application provides an image processing method, apparatus, device and medium for solving the problem of purple fringing in images.
[0006] In a first aspect, the present application provides an image processing method, the method comprising:
[0007] Obtain R, G, and B sub-images corresponding to the red, green, and blue (RGB) channels of the target image, respectively, and divide each sub-image into a preset number of sub-image blocks; for each sub-image block in the R sub-image and the B sub-image, determine a similar sub-image block in the G sub-image based on an image local matching algorithm, and determine a motion vector between the sub-image block and the similar sub-image block;
[0008] For each pixel in the target image, determine the difference between the R channel value and the B channel value of the pixel and the G channel value, and select the pixel whose difference exceeds a first threshold as a candidate pixel; for any candidate pixel, determine whether the candidate pixel is a purple-fringed pixel based on whether the number of candidate pixels among the candidate pixel's neighboring pixels does not exceed a second threshold and whether the motion vector of the sub-image block corresponding to the candidate pixel in the R sub-image and the B sub-image is zero;
[0009] Correct the R channel value and B channel value of each purple-fringe pixel.
[0010] Furthermore, before determining the similar sub-image block of the sub-image block in the G sub-image according to the image local matching algorithm, the method further includes:
[0011] Determine a reference sub-image block for the sub-image block in the G sub-image according to the position of the sub-image block and a preset offset;
[0012] Determining a similar sub-image block of the sub-image block in the G sub-image according to a local image matching algorithm includes: determining a similar sub-image block of the sub-image block in the reference sub-image block according to a local image matching algorithm.
[0013] Furthermore, determining a reference sub-image block of the sub-image block in the G sub-image according to the position of the sub-image block and a preset offset includes:
[0014] According to the position of the sub-image block, the corresponding sub-image block of the sub-image block in the G sub-image is determined; the position of the corresponding sub-image block is shifted in each preset direction by the preset offset amount to determine each reference sub-image block.
[0015] Furthermore, determining a similar sub-image block of the sub-image block in the G sub-image according to the image local matching algorithm includes:
[0016] According to the local image matching algorithm, the sum of the absolute errors between the sub-image block and the values of each pixel point in the corresponding sub-image block in the G sub-image is determined; the sub-image block with the smallest sum of the absolute errors is determined as the similar sub-image block of the sub-image block.
[0017] Furthermore, the process of determining the first threshold includes:
[0018] For each pixel in the target image, the saturation of the pixel is determined, and a first threshold of the pixel is calculated based on the saturation.
[0019] Further, determining whether the candidate pixel is a purple-fringed pixel based on whether the number of candidate pixels among the neighboring pixels of the candidate pixel does not exceed a second threshold and whether the motion vector of the sub-image block corresponding to the candidate pixel in the R sub-image and the B sub-image is zero includes:
[0020] If the number of candidate pixels among the adjacent pixels of the candidate pixel does not exceed the second threshold, and at least one of the motion vectors of the sub-image blocks corresponding to the candidate pixel in the R sub-image and the B sub-image is not zero, then the candidate pixel is determined to be a purple-fringe pixel.
[0021] In a second aspect, the present application provides an image processing device, comprising:
[0022] A determination module is configured to obtain R, G, and B sub-images corresponding to the red, green, and blue (RGB) channels of the target image, respectively, and divide each sub-image into a preset number of sub-image blocks; for each sub-image block in the R sub-image and the B sub-image, determine a similar sub-image block of the sub-image block in the G sub-image based on an image local matching algorithm, and determine a motion vector between the sub-image block and the similar sub-image block; for each pixel point in the target image, determine the difference between the R channel value and the B channel value of the pixel point and the G channel value, respectively, and select pixels whose differences exceed a first threshold as candidate pixels; for any candidate pixel point, determine whether the candidate pixel point is a purple-fringed pixel point based on whether the number of candidate pixels among the candidate pixel points' neighboring pixels does not exceed a second threshold and whether the motion vector of the sub-image block corresponding to the candidate pixel point in the R sub-image and the B sub-image is zero;
[0023] The correction module is used to correct the R channel value and the B channel value of each purple-fringed pixel point.
[0024] Furthermore, the determination module is specifically used to determine the reference sub-image block of the sub-image block in the G sub-image based on the position of the sub-image block and a preset offset; and determine the similar sub-image block of the sub-image block in the reference sub-image block based on the image local matching algorithm.
[0025] Furthermore, the determination module is specifically used to determine the corresponding sub-image block of the sub-image block in the G sub-image based on the position of the sub-image block; offset the position of the corresponding sub-image block by the preset offset in each preset direction to determine each reference sub-image block.
[0026] Furthermore, the determination module is specifically used to determine the sum of absolute errors between the sub-image block and the values of each pixel point in the corresponding sub-image block in the G sub-image based on the image local matching algorithm; and determine the sub-image block with the smallest sum of absolute errors as the similar sub-image block of the sub-image block.
[0027] Furthermore, the determination module is further configured to determine the saturation of each pixel in the target image, and calculate a first threshold value of the pixel based on the saturation.
[0028] Furthermore, the determination module is specifically used to determine that the candidate pixel point is a purple-fringe pixel point if the number of candidate pixel points among the adjacent pixel points of the candidate pixel point does not exceed a second threshold, and at least one of the motion vectors of the sub-image blocks corresponding to the candidate pixel point in the R sub-image and the B sub-image is not zero.
[0029] In a third aspect, the present application provides an electronic device, which includes at least a processor and a memory, and the processor is used to implement the steps of any of the above-mentioned image processing methods when executing a computer program stored in the memory.
[0030] In a fourth aspect, the present application provides a computer-readable storage medium storing a computer program, which implements the steps of any of the above-mentioned image processing methods when executed by a processor.
[0031] In an embodiment of the present application, sub-images corresponding to the RGB channels of the target image are obtained, and each sub-image is divided into a preset number of sub-image blocks, so as to determine the motion vector of each sub-image block in the R sub-image and the B sub-image in the G sub-image; each pixel in the target image whose difference between the value of the R channel and the value of the B channel and the value of the G channel exceeds a first threshold is taken as a candidate pixel; based on whether the number of candidate pixels among the adjacent pixels of the candidate pixel does not exceed a second threshold, and whether the motion vector of the sub-image block corresponding to the candidate pixel in the R sub-image and the B sub-image is zero, it is determined whether the candidate pixel is a purple-fringed pixel, so as to accurately correct the value of the R channel and the value of the B channel of each purple-fringed pixel. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0033] Figure 1 A schematic diagram of an image processing process provided in an embodiment of the present application;
[0034] Figure 2 A schematic diagram of the structure of an image processing device provided in an embodiment of the present application;
[0035] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0036] In order to make the purpose and implementation of this application clearer, the exemplary implementation of this application will be clearly and completely described below in conjunction with the drawings in the exemplary embodiments of this application. Obviously, the described exemplary embodiments are only part of the embodiments of this application, not all of the embodiments.
[0037] It should be noted that the brief descriptions of terms in this application are only for the purpose of facilitating the understanding of the embodiments described below, and are not intended to limit the embodiments of this application. Unless otherwise specified, these terms should be understood according to their ordinary and usual meanings.
[0038] In the specification and claims of this application and the accompanying drawings, the terms "first," "second," "third," etc. are used to distinguish similar or similar objects or entities, and are not necessarily intended to limit a particular order or sequence, unless otherwise noted. It should be understood that the terms used in this manner are interchangeable under appropriate circumstances.
[0039] The terms "comprise," "include," and "have," and any variations thereof, are intended to cover but not exclude inclusion; for example, a product or device comprising a list of components is not necessarily limited to all the components expressly listed but may include other components not expressly listed or inherent to such product or device.
[0040] The term "module" refers to any known or later developed hardware, software, firmware, artificial intelligence, fuzzy logic, or combination of hardware and / or software code that is capable of performing the functionality associated with that element.
[0041] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some or all of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application.
[0042] For ease of explanation, the above description has been made with reference to specific embodiments. However, the above exemplary discussion is not intended to be exhaustive or to limit the embodiments to the specific forms disclosed above. Based on the above teachings, various modifications and variations are possible. The above embodiments are selected and described to better explain the principles and practical applications, so that those skilled in the art can better utilize the embodiments and various different variations of the embodiments suitable for specific use considerations.
[0043] The present application provides an image processing method, apparatus, device and medium, in which R, G and B sub-images corresponding to the red, green and blue (RGB) channels of a target image are obtained, and each sub-image is divided into a preset number of sub-image blocks; for each sub-image block in the R sub-image and the B sub-image, a similar sub-image block of the sub-image block in the G sub-image is determined according to an image local matching algorithm, and a motion vector between the sub-image block and the similar sub-image block is determined; for each pixel point in the target image, the difference between the R channel value and the B channel value of the pixel point and the G channel value is determined, and the pixel points whose differences exceed a first threshold are regarded as candidate pixel points; for any candidate pixel point, whether the candidate pixel point is a purple-fringed pixel point is determined based on whether the number of candidate pixel points among the adjacent pixel points of the candidate pixel point does not exceed a second threshold and whether the motion vector of the sub-image block corresponding to the candidate pixel point in the R sub-image and the B sub-image is zero; and the R channel value and the B channel value of each purple-fringed pixel point are corrected.
[0044] Example 1:
[0045] In order to solve the problem of purple fringing in images, embodiments of the present application provide an image processing method, apparatus, device, and medium.
[0046] Figure 1 A schematic diagram of an image processing process provided in an embodiment of the present application, the process includes the following steps:
[0047] S101: Obtain R, G, and B sub-images corresponding to the red, green, and blue (RGB) channels of a target image, respectively, and divide each sub-image into a preset number of sub-image blocks.
[0048] The image processing method provided in the embodiments of the present application is applied to an electronic device, which may be a digital imaging device such as a mobile phone, a digital camera, or a webcam.
[0049] Image chromatic aberration is widespread in images captured by current digital imaging devices, such as mobile phones, digital cameras, and surveillance cameras. When these devices are used in backlit conditions or at wide apertures, localized areas of the image, particularly high-contrast areas (i.e., areas with a sharp contrast between light and dark, such as the sky or the edges where light bulbs meet objects), can exhibit colors not belonging to the objects. This is known as chromatic fringing, with purple fringing being particularly prominent. Purple fringing is primarily caused by optical chromatic aberration in the lens, which is divided into longitudinal chromatic aberration (LoCA) and lateral chromatic aberration (Lateral Chromatic Aberration). Longitudinal chromatic aberration, also known as axial chromatic aberration, can be significantly reduced by stopping down the lens aperture. Lateral chromatic aberration cannot be eliminated by stopping down the aperture, but it can be removed through post-processing. Lateral chromatic aberration is caused by the positional offset of the red, green, and blue (RGB) channels.
[0050] In an embodiment of the present application, in order to determine whether there is a positional offset of each RGB channel, the R, G, and B sub-images corresponding to the RGB channels of the target image are obtained. Since the amplitudes of the positional offsets of different lateral chromatic aberrations are inconsistent, each sub-image can be divided into a preset number of sub-image blocks, wherein each sub-image block contains N*N pixels, and N is the number of pixels contained in each row and column of the sub-image block. The selection of N is associated with the image resolution. The larger the resolution, the larger the value of N, and the smaller the resolution, the smaller the value of N. For example, if the image resolution is 1920x1080, the value of N can be 16. The R, G, and B sub-images are divided into multiple sub-image blocks using the same division method. Since the size of the sub-image blocks is relatively small, it can be approximately considered that the offsets of each point in each sub-image block are the same, so that the image purple edge problem caused by different positional offsets can be processed more accurately.
[0051] S102: For each sub-image block in the R sub-image and the B sub-image, determine a similar sub-image block of the sub-image block in the G sub-image according to an image local matching algorithm, and determine a motion vector between the sub-image block and the similar sub-image block.
[0052] Because the cones of the human eye are more sensitive to green, to accommodate the human eye, image sensors commonly used in digital imaging devices capture image colors using the RGGB format. This means the image sensor contains a 50% green filter, a 25% red filter, and a 25% blue filter. Therefore, the G channel accounts for a larger portion of the image. In this embodiment, the positional offsets of the R and B sub-images relative to the G sub-image are estimated based on the G sub-image. Motion estimation methods can be used to determine whether there is an offset. For each sub-image block in the R sub-image and the B sub-image, determine the similar sub-image block of the sub-image block in the G sub-image, and calculate the sum of the absolute errors between the R channel value and the G channel value, or between the B channel value and the G channel value, of each pixel point corresponding to the sub-image block and the sub-image block of the same size in the G sub-image based on the image local matching algorithm. The sub-image block with the smallest sum of the absolute errors corresponding to the R channel values is determined as the similar sub-image block of the sub-image block in the R sub-image to the G sub-image; and the sub-image block with the smallest sum of the absolute errors corresponding to the B channel values is determined as the similar sub-image block of the sub-image block in the B sub-image to the G sub-image.
[0053] The similar sub-image block can be regarded as the sub-image block that the sub-image block actually corresponds to in the G sub-image. Since the R\G\B sub-images are divided into multiple sub-image blocks using the same segmentation method, the motion vector of the sub-image block and the similar sub-image block can be determined. For example, the motion vector is determined based on the difference between the first vector formed by the coordinates of the center point of the sub-image block and the second vector formed by the coordinates of the center point of the similar sub-image block, thereby determining the position offset of the area where the sub-image block of the R sub-image and the B sub-image is located relative to the G sub-image.
[0054] S103: For each pixel in the target image, determine the difference between the R channel value and the B channel value of the pixel and the G channel value, and select the pixel whose difference exceeds the first threshold as a candidate pixel.
[0055] Since the area where the purple-fringe pixel is located has high saturation, and the blue intensity and red intensity are much greater than the green intensity, for each pixel in the target image, it is possible to determine whether the pixel is a candidate pixel based on whether the difference between the R channel value and the B channel value of the pixel and the G channel value exceeds the first threshold. The candidate pixel may be a pixel located on the purple fringe.
[0056] S104: For any candidate pixel point, determine whether the candidate pixel point is a purple-fringe pixel point based on whether the number of candidate pixel points among the neighboring pixel points of the candidate pixel point does not exceed the second threshold, and whether the motion vector of the sub-image block corresponding to the candidate pixel point in the R sub-image and the B sub-image is zero.
[0057] Because purple fringing often occurs at high-contrast image boundaries, candidate pixels that may be purple fringed need to be further screened to determine whether the candidate pixel is located at the boundary. The boundary determination method can be based on whether the number of candidate pixels among the candidate pixel's neighboring pixels does not exceed a second threshold for any candidate pixel. In other words, if many of the candidate pixel's neighboring pixels are also candidate pixels, it indicates that the pixel is not at the boundary; if there are few candidate pixels among the candidate pixel's neighboring pixels, the candidate pixel is likely located at the boundary. The neighboring pixels can be the first pixel in the four directions above, below, left, or right of the candidate pixel, or the first pixel in the four directions above, below, left, right, or diagonally opposite the candidate pixel. Whether the candidate pixel is a purple-fringed pixel is then determined based on whether the candidate pixel is offset in the R and B sub-images relative to the corresponding sub-image block of the G sub-image, that is, whether the motion vector is zero. If the number of candidate pixels among the adjacent pixels of the candidate pixel does not exceed the second threshold, and at least one of the motion vectors of the sub-image blocks corresponding to the candidate pixel in the R sub-image and the B sub-image is not zero, then the candidate pixel is determined to be a purple-fringe pixel.
[0058] S105: Correct the R channel value and the B channel value of each purple-fringed pixel point.
[0059] Because green can correct the red and blue in the purple-fringed pixels, the following formula is used to correct the R and B channel values of each purple-fringed pixel:
[0060] Rcorrect=α*R0+β*R1+(1-α-β)*G 0<α<1; 0<β<1
[0061] Bcorrect=δ*B0+γ*B1+(1-δ-γ)*G 0<δ<1; 0<γ<1
[0062] Among them, Rcorrect and Bcorrect are the values of the R channel and B channel after the purple-fringed pixel is corrected; R0 and B0 are the values of the R channel and B channel before the purple-fringed pixel is corrected; G is the value of the G channel before the purple-fringed pixel is corrected; R1 is the value of the R channel of the pixel corresponding to the coordinates of the purple-fringed pixel after the coordinates are increased or decreased according to the motion vector of the corresponding sub-image block in the R sub-image; B1 is the value of the B channel of the pixel corresponding to the coordinates of the purple-fringed pixel after the coordinates are increased or decreased according to the motion vector of the corresponding sub-image block in the B sub-image; α and β are preset correction coefficients, respectively, and δ and γ are preset correction coefficients.
[0063] In an embodiment of the present application, sub-images corresponding to the RGB channels of the target image are obtained, and each sub-image is divided into a preset number of sub-image blocks, so as to determine the motion vector of each sub-image block in the R sub-image and the B sub-image in the G sub-image; each pixel in the target image whose difference between the value of the R channel and the value of the B channel and the value of the G channel exceeds a first threshold is taken as a candidate pixel; based on whether the number of candidate pixels among the adjacent pixels of the candidate pixel does not exceed a second threshold, and whether the motion vector of the sub-image block corresponding to the candidate pixel in the R sub-image and the B sub-image is zero, it is determined whether the candidate pixel is a purple-fringed pixel, so as to accurately correct the value of the R channel and the value of the B channel of each purple-fringed pixel.
[0064] Example 2:
[0065] In order to more accurately determine similar sub-image blocks, based on the above embodiment, in the embodiment of the present application, before determining similar sub-image blocks of the sub-image block in the G sub-image according to the image local matching algorithm, the method further includes:
[0066] Determine a reference sub-image block for the sub-image block in the G sub-image according to the position of the sub-image block and a preset offset;
[0067] The determining, based on the local image matching algorithm, a similar sub-image block of the sub-image block in the G sub-image includes:
[0068] According to an image local matching algorithm, a similar sub-image block of the sub-image block in the reference sub-image block is determined.
[0069] Because the position offset of the channel is limited, in order to reduce the amount of calculation, the determination range can be narrowed first. According to the position of the sub-image block and the preset offset, the reference sub-image block of the sub-image block in the G sub-image is determined, that is, the sub-image block that may be a similar sub-image block.
[0070] Then, based on the local image matching algorithm, the similar sub-image block that best matches the sub-image block in the reference sub-image block is determined, thereby more accurately and efficiently determining the similar sub-image blocks in the R sub-image and the B sub-image in the G sub-image.
[0071] Specifically, the corresponding sub-image block of the sub-image block in the G sub-image can be determined based on the position of the sub-image block, and the position of the corresponding sub-image block can be moved in the four directions of upward, downward, left and right by a preset offset to determine the reference sub-image block; then, based on the image local matching algorithm, the sum of the absolute errors between the sub-image block and the values of each corresponding pixel point in each reference sub-image block can be determined; and the reference sub-image block with the smallest sum of absolute errors can be determined as the similar sub-image block of the sub-image block.
[0072] To more accurately determine the reference sub-image block, based on the above embodiments, in the embodiment of the present application, determining the reference sub-image block of the sub-image block in the G sub-image according to the position of the sub-image block and the preset offset includes:
[0073] Determine, according to the position of the sub-image block, a corresponding sub-image block of the sub-image block in the G sub-image;
[0074] The position of the corresponding sub-image block is shifted in each preset direction by the preset offset amount to determine each reference sub-image block.
[0075] Because the channel position offset is limited, and the sub-image block may not have been offset, the corresponding sub-image block in the G sub-image is first determined based on the sub-image block's position. This is the sub-image block at the same position as the sub-image block in the G sub-image. Using this corresponding sub-image block as a reference, the position of the corresponding sub-image block is offset in each predetermined direction by a predetermined offset amount to determine each reference sub-image block.
[0076] Furthermore, the preset directions include up, down, left, right, and four diagonal directions, and the preset offset can be 1 pixel or 0, that is, the corresponding sub-image block also serves as a reference sub-image block. Specifically, the horizontal coordinate or vertical coordinate of the corresponding sub-image block can be increased or decreased by 1 pixel or 0, where each sub-image block corresponds to 9 reference sub-image blocks.
[0077] In order to more accurately determine similar sub-image blocks, based on the above embodiments, in the embodiment of the present application, the sum of absolute errors of the values of each pixel in the sub-image block and the corresponding sub-image block in the G sub-image are determined according to the local image matching algorithm;
[0078] The sub-image block with the smallest sum of absolute errors is determined as a similar sub-image block of the sub-image block.
[0079] In an embodiment of the present application, in order to determine the similar sub-image block that best matches the sub-image block in the G sub-image, an image local matching algorithm (Sum of absolute differences, SAD) can be used to determine the sum of the absolute errors of the values of each pixel point corresponding to the sub-image block and the corresponding sub-image block in the G sub-image, and the sub-image block with the smallest sum of absolute errors is determined as the similar sub-image block of the sub-image block.
[0080] Specifically, the absolute error sum is determined according to the following formula:
[0081]
[0082] Among them, f(x k,y k ) is the coordinate of the sub-image block in the R sub-image or the B sub-image (x k ,y k ) is the value of the R channel or the B channel, g(x k ,y k ) is the coordinate of the sub-image block in the corresponding sub-image block in the G sub-image (x k ,y k ) is the value of the G channel, and n is the number of pixels contained in each row and column of the sub-image block.
[0083] In an embodiment of the present application, by adopting an image local matching algorithm, the sum of absolute errors between the sub-image block and the values of each pixel point corresponding to the corresponding sub-image block in the G sub-image is determined; the sub-image block with the smallest sum of absolute errors is determined as the similar sub-image block of the sub-image block, so that similar sub-image blocks can be determined more accurately.
[0084] Example 3:
[0085] In order to more accurately determine the candidate pixel points, based on the above embodiments, in the embodiment of the present application, the process of determining the first threshold includes:
[0086] For each pixel in the target image, the saturation of the pixel is determined, and a first threshold of the pixel is calculated based on the saturation.
[0087] Because the area where the purple fringing is located has high saturation, and the blue and red intensities are much greater than the green intensity, the first threshold of the pixel can be calculated based on the saturation of the pixel using the following formula:
[0088]
[0089] ΔS=a+b*S
[0090] Where s is the saturation of the pixel, max(R,G,B) is the maximum value of the R, G, and B channels of the pixel, min(R,G,B) is the minimum value of the R, G, and B channels of the pixel, ΔS is the first threshold, and a and b are preset parameters.
[0091] Example 4:
[0092] To more accurately determine a purple-fringed pixel, based on the above embodiments, in an embodiment of the present application, determining whether the candidate pixel is a purple-fringed pixel based on whether the number of candidate pixels among the neighboring pixels of the candidate pixel does not exceed a second threshold and whether the motion vector of the sub-image block corresponding to the candidate pixel in the R sub-image and the B sub-image is zero includes:
[0093] If the number of candidate pixels among the adjacent pixels of the candidate pixel does not exceed the second threshold, and at least one of the motion vectors of the sub-image blocks corresponding to the candidate pixel in the R sub-image and the B sub-image is not zero, then the candidate pixel is determined to be a purple-fringe pixel.
[0094] Because purple fringing often occurs at high-contrast image boundaries, candidate pixels that may be purple fringed must be further screened to determine whether they are located at the boundary. The boundary determination method is to, for any candidate pixel, determine that the pixel is likely located at the boundary if the number of candidate pixels among its neighboring pixels does not exceed a second threshold. In other words, if there are very few candidate pixels among the neighboring pixels of the candidate pixel, the candidate pixel is likely located at the boundary. For example, for any candidate pixel, if there are no more than three candidate pixels among its neighboring pixels in eight directions (a total of eight directions: above, below, left, right, and the four diagonals), the candidate pixel is considered likely to be located at the boundary. Furthermore, if the candidate pixel that is likely located at the boundary is offset in the R and B sub-images relative to the corresponding sub-image blocks of the G sub-image, meaning that at least one of the motion vectors of the candidate pixel in the corresponding sub-image blocks of the R and B sub-images is non-zero, the candidate pixel is determined to be a purple-fringed pixel.
[0095] Example 5:
[0096] Based on the same technical concept, on the basis of the above embodiments, the present application also provides an image processing device, Figure 2 A schematic diagram of the structure of an image processing device provided in an embodiment of the present application is shown in FIG. Figure 2 As shown, the device includes:
[0097] Determination module 201 is used to obtain R, G, and B sub-images corresponding to the red, green, and blue (RGB) channels of the target image, respectively, and divide each sub-image into a preset number of sub-image blocks; for each sub-image block in the R sub-image and the B sub-image, determine a similar sub-image block of the sub-image block in the G sub-image based on an image local matching algorithm, and determine a motion vector between the sub-image block and the similar sub-image block; for each pixel in the target image, determine the difference between the R channel value and the B channel value of the pixel and the G channel value, respectively, and select pixels whose differences exceed a first threshold as candidate pixels; for any candidate pixel, determine whether the candidate pixel is a purple-fringed pixel based on whether the number of candidate pixels among the candidate pixel's neighboring pixels does not exceed a second threshold and whether the motion vector of the sub-image block corresponding to the candidate pixel in the R sub-image and the B sub-image is zero;
[0098] The correction module 202 is used to correct the R channel value and the B channel value of each purple-fringed pixel point.
[0099] In a possible implementation, the determination module 201 is specifically configured to determine a reference sub-image block of the sub-image block in the G sub-image based on the position of the sub-image block and a preset offset; and determine a similar sub-image block of the sub-image block in the reference sub-image block based on a local image matching algorithm.
[0100] In a possible implementation, the determination module 201 is specifically configured to determine, based on the position of the sub-image block, a corresponding sub-image block of the sub-image block in the G sub-image; and offset the position of the corresponding sub-image block by the preset offset in each preset direction to determine each reference sub-image block.
[0101] In a possible embodiment, the determination module 201 is specifically used to determine the sum of absolute errors between the sub-image block and the values of each pixel point in the corresponding sub-image block in the G sub-image according to the image local matching algorithm; and determine the sub-image block with the smallest sum of absolute errors as a similar sub-image block of the sub-image block.
[0102] In a possible implementation, the determination module 201 is further configured to determine the saturation of each pixel in the target image, and calculate a first threshold value of the pixel based on the saturation.
[0103] In one possible implementation, the determination module 201 is specifically used to determine that the candidate pixel point is a purple-fringe pixel point if the number of candidate pixel points among the adjacent pixel points of the candidate pixel point does not exceed a second threshold, and at least one of the motion vectors of the sub-image blocks corresponding to the candidate pixel point in the R sub-image and the B sub-image is not zero.
[0104] Example 6:
[0105] Based on the same technical concept, on the basis of the above embodiments, the present application also provides an electronic device, Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 3 As shown, it includes: a processor 301, a communication interface 302, a memory 303 and a communication bus 304, wherein the processor 301, the communication interface 302, and the memory 303 communicate with each other through the communication bus 304;
[0106] The memory 303 stores a computer program. When the program is executed by the processor 301, the processor 301 performs the following steps:
[0107] Obtain R, G, and B sub-images corresponding to the red, green, and blue (RGB) channels of the target image, respectively, and divide each sub-image into a preset number of sub-image blocks; for each sub-image block in the R sub-image and the B sub-image, determine a similar sub-image block in the G sub-image based on an image local matching algorithm, and determine a motion vector between the sub-image block and the similar sub-image block;
[0108] For each pixel in the target image, determine the difference between the R channel value and the B channel value of the pixel and the G channel value, and select the pixel whose difference exceeds a first threshold as a candidate pixel; for any candidate pixel, determine whether the candidate pixel is a purple-fringed pixel based on whether the number of candidate pixels among the candidate pixel's neighboring pixels does not exceed a second threshold and whether the motion vector of the sub-image block corresponding to the candidate pixel in the R sub-image and the B sub-image is zero;
[0109] Correct the R channel value and B channel value of each purple-fringe pixel.
[0110] In a possible implementation, the processor is further configured to:
[0111] According to the position of the sub-image block and the preset offset, a reference sub-image block of the sub-image block in the G sub-image is determined; and according to the image local matching algorithm, a similar sub-image block of the sub-image block in the reference sub-image block is determined.
[0112] In a possible implementation, the processor is further configured to:
[0113] According to the position of the sub-image block, the corresponding sub-image block of the sub-image block in the G sub-image is determined; the position of the corresponding sub-image block is shifted in each preset direction by the preset offset amount to determine each reference sub-image block.
[0114] In a possible implementation, the processor is further configured to:
[0115] According to the local image matching algorithm, the sum of the absolute errors between the sub-image block and the values of each pixel point in the corresponding sub-image block in the G sub-image is determined; the sub-image block with the smallest sum of the absolute errors is determined as the similar sub-image block of the sub-image block.
[0116] In a possible implementation, the processor is further configured to:
[0117] For each pixel in the target image, the saturation of the pixel is determined, and a first threshold of the pixel is calculated based on the saturation.
[0118] In a possible implementation, the processor is further configured to:
[0119] If the number of candidate pixels among the adjacent pixels of the candidate pixel does not exceed the second threshold, and at least one of the motion vectors of the sub-image blocks corresponding to the candidate pixel in the R sub-image and the B sub-image is not zero, then the candidate pixel is determined to be a purple-fringe pixel.
[0120] Since the principle of solving the problem by the above electronic device is similar to that of the image processing method, the implementation of the above electronic device can refer to the implementation of the telecommunication user identification method, and the repeated parts will not be repeated.
[0121] The communication bus mentioned in the electronic device mentioned above may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is used in the figure, but this does not mean that there is only one bus or only one type of bus.
[0122] The communication interface 302 is used for communication between the electronic device and other devices.
[0123] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk memory. Alternatively, the memory may be at least one storage device located away from the processor.
[0124] The above-mentioned processor can be a general-purpose processor, including a central processing unit, a network processor (NP), etc.; it can also be a digital signal processing processor (DSP), an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, etc.
[0125] Example 7:
[0126] Based on the same technical concept and on the basis of the above embodiments, the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program executable by an electronic device. When the program is executed on a processor, the processor implements the following steps:
[0127] Obtain R, G, and B sub-images corresponding to the red, green, and blue (RGB) channels of the target image, respectively, and divide each sub-image into a preset number of sub-image blocks; for each sub-image block in the R sub-image and the B sub-image, determine a similar sub-image block in the G sub-image based on an image local matching algorithm, and determine a motion vector between the sub-image block and the similar sub-image block;
[0128] For each pixel in the target image, determine the difference between the R channel value and the B channel value of the pixel and the G channel value, and select the pixel whose difference exceeds a first threshold as a candidate pixel; for any candidate pixel, determine whether the candidate pixel is a purple-fringed pixel based on whether the number of candidate pixels among the candidate pixel's neighboring pixels does not exceed a second threshold and whether the motion vector of the sub-image block corresponding to the candidate pixel in the R sub-image and the B sub-image is zero;
[0129] Correct the R channel value and B channel value of each purple-fringe pixel.
[0130] In a possible implementation, before determining the similar sub-image block of the sub-image block in the G sub-image according to the local image matching algorithm, the method further includes:
[0131] Determine a reference sub-image block for the sub-image block in the G sub-image according to the position of the sub-image block and a preset offset;
[0132] Determining a similar sub-image block of the sub-image block in the G sub-image according to a local image matching algorithm includes: determining a similar sub-image block of the sub-image block in the reference sub-image block according to a local image matching algorithm.
[0133] In a possible implementation manner, determining the reference sub-image block of the sub-image block in the G sub-image according to the position of the sub-image block and the preset offset includes:
[0134] According to the position of the sub-image block, the corresponding sub-image block of the sub-image block in the G sub-image is determined; the position of the corresponding sub-image block is shifted in each preset direction by the preset offset amount to determine each reference sub-image block.
[0135] In a possible implementation, determining a similar sub-image block of the sub-image block in the G sub-image according to the local image matching algorithm includes:
[0136] According to the local image matching algorithm, the sum of the absolute errors between the sub-image block and the values of each pixel point in the corresponding sub-image block in the G sub-image is determined; the sub-image block with the smallest sum of the absolute errors is determined as the similar sub-image block of the sub-image block.
[0137] In a possible implementation, the process of determining the first threshold includes:
[0138] For each pixel in the target image, the saturation of the pixel is determined, and a first threshold of the pixel is calculated based on the saturation.
[0139] In a possible implementation, determining whether the candidate pixel is a purple-fringed pixel based on whether the number of candidate pixels among the neighboring pixels of the candidate pixel does not exceed a second threshold and whether the motion vector of the sub-image block corresponding to the candidate pixel in the R sub-image and the B sub-image is zero includes:
[0140] If the number of candidate pixels among the adjacent pixels of the candidate pixel does not exceed the second threshold, and at least one of the motion vectors of the sub-image blocks corresponding to the candidate pixel in the R sub-image and the B sub-image is not zero, then the candidate pixel is determined to be a purple-fringe pixel.
[0141] Since the principle of solving the problem by the above-mentioned computer-readable storage medium is similar to that of the image processing method, the implementation of the above-mentioned computer-readable storage medium can refer to the embodiment of the image processing method, and the repeated parts are not repeated here.
[0142] The above-mentioned computer-readable storage medium can be any available medium or data storage device that can be accessed by the processor in the electronic device, including but not limited to magnetic storage such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc., optical storage such as CDs, DVDs, BDs, HVDs, etc., and semiconductor storage such as ROMs, EPROMs, EEPROMs, non-volatile memories (NANDFLASH), solid-state drives (SSDs), etc.
[0143] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0144] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0145] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0146] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0147] Obviously, those skilled in the art may make various changes and modifications to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalents, this application is intended to include these modifications and variations.
Claims
1. An image processing method, characterized in that: The method comprises: Obtain R, G, and B sub-images corresponding to the red, green, and blue (RGB) channels of the target image, respectively, and divide each sub-image into a preset number of sub-image blocks; for each sub-image block in the R sub-image and the B sub-image, determine a similar sub-image block in the G sub-image based on an image local matching algorithm, and determine a motion vector between the sub-image block and the similar sub-image block; For each pixel in the target image, determine the difference between the R channel value and the B channel value of the pixel and the G channel value, and select the pixel whose difference exceeds a first threshold as a candidate pixel; for any candidate pixel, determine whether the candidate pixel is a purple-fringed pixel based on whether the number of candidate pixels among the candidate pixel's neighboring pixels does not exceed a second threshold and whether the motion vector of the sub-image block corresponding to the candidate pixel in the R sub-image and the B sub-image is zero; Correct the R channel value and B channel value of each purple-fringe pixel.
2. The method according to claim 1, characterized in that The method further comprises: determining, based on the image local matching algorithm, that the sub-image block is before a similar sub-image block in the G sub-image; Determine a reference sub-image block for the sub-image block in the G sub-image according to the position of the sub-image block and a preset offset; The determining, based on the local image matching algorithm, a similar sub-image block of the sub-image block in the G sub-image includes: According to an image local matching algorithm, a similar sub-image block of the sub-image block in the reference sub-image block is determined.
3. The method according to claim 2, characterized in that Determining the reference sub-image block of the sub-image block in the G sub-image according to the position of the sub-image block and the preset offset includes: Determine, according to the position of the sub-image block, a corresponding sub-image block of the sub-image block in the G sub-image; The position of the corresponding sub-image block is shifted in each preset direction by the preset offset amount to determine each reference sub-image block.
4. The method according to claim 3, characterized in that The determining, based on the local image matching algorithm, a similar sub-image block of the sub-image block in the G sub-image includes: Determine, based on a local image matching algorithm, the sum of absolute errors between the sub-image block and the values of each pixel in the corresponding sub-image block in the G sub-image; the corresponding sub-image block is any sub-image block in the reference sub-image block; the corresponding sub-image block also serves as a reference sub-image block; The sub-image block with the smallest sum of absolute errors is determined as a similar sub-image block of the sub-image block.
5. The method according to claim 1, wherein The process of determining the first threshold includes: For each pixel in the target image, the saturation of the pixel is determined, and a first threshold of the pixel is calculated based on the saturation.
6. The method according to claim 1, characterized in that The determining whether the candidate pixel is a purple-fringed pixel according to whether the number of candidate pixels among the neighboring pixels of the candidate pixel does not exceed a second threshold and whether the motion vector of the sub-image block corresponding to the candidate pixel in the R sub-image and the B sub-image is zero includes: If the number of candidate pixels among the adjacent pixels of the candidate pixel does not exceed the second threshold, and at least one of the motion vectors of the sub-image blocks corresponding to the candidate pixel in the R sub-image and the B sub-image is not zero, then the candidate pixel is determined to be a purple-fringe pixel.
7. An image processing device, characterized in that The device comprises: A determination module is configured to obtain R, G, and B sub-images corresponding to the red, green, and blue (RGB) channels of the target image, respectively, and divide each sub-image into a preset number of sub-image blocks; for each sub-image block in the R sub-image and the B sub-image, determine a similar sub-image block of the sub-image block in the G sub-image based on an image local matching algorithm, and determine a motion vector between the sub-image block and the similar sub-image block; for each pixel point in the target image, determine the difference between the R channel value and the B channel value of the pixel point and the G channel value, respectively, and select pixels whose differences exceed a first threshold as candidate pixels; for any candidate pixel point, determine whether the candidate pixel point is a purple-fringed pixel point based on whether the number of candidate pixels among the candidate pixel points' neighboring pixels does not exceed a second threshold and whether the motion vector of the sub-image block corresponding to the candidate pixel point in the R sub-image and the B sub-image is zero; The correction module is used to correct the R channel value and the B channel value of each purple-fringed pixel point.
8. The device according to claim 7, characterized in that The determination module is specifically used to determine the reference sub-image block of the sub-image block in the G sub-image based on the position of the sub-image block and a preset offset; and determine the similar sub-image block of the sub-image block in the reference sub-image block based on the image local matching algorithm.
9. An electronic device, characterized in that: The electronic device comprises at least a processor and a memory, and the processor is configured to implement the steps of the image processing method according to any one of claims 1 to 6 when executing a computer program stored in the memory.
10. A computer-readable storage medium, characterized in that The computer program is stored therein, and when the computer program is executed by a processor, the steps of the image processing method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Automatic removal of purple fringing from images
CN101366019A
Color edge removing method based on transverse chromatic aberration calibration
CN114943658A