Method and device for detecting purple edge region of image, storage medium and computer device

By using the sliding window and gradient analysis combined with hue saturation judgment in the YUV color space, the problem of low accuracy in image purple fringing detection is solved, and efficient and accurate purple fringing area recognition and correction are achieved.

CN119904478BActive Publication Date: 2025-10-10ZHUHAI HUGE IC CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411986675.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-10-10
Estimated Expiration
2044-12-31

AI Technical Summary

Technical Problem

Existing technologies have low accuracy and complex calculations in image purple fringing detection, and misidentification is common, which affects the efficiency and effect of image processing.

Method used

In the YUV color space, sliding window, Y channel gradient analysis and hue saturation judgment are used, and multiple discrimination conditions are combined to identify the purple-fringe area, and the final target area is obtained by taking the intersection.

Benefits of technology

The accuracy and efficiency of purple fringing detection are improved, the possibility of misjudgment is reduced, and a reliable basis for purple fringing correction is provided.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119904478B_ABST
    Figure CN119904478B_ABST
Patent Text Reader

Abstract

The embodiment of the application discloses a kind of methods for detecting image purple edge area, device, storage medium and computer equipment, it is related to image processing field.The application is judged by Y channel value difference, this method can preliminarily screen out the pixel point located at high contrast edge, these pixel points are more likely to belong to purple edge area.Using the relationship of adjacent pixel points, further expand the coverage of purple edge candidate area, improve the sensitivity of detection.Through calculating the horizontal gradient and vertical gradient of Y channel, and combining the gradient analysis of U, V channel, this method can more accurately identify the pixel point with purple edge characteristics, effectively reduce the possibility of misjudgment.Combining the judgment of hue and saturation, further improve the accuracy of purple edge detection, because purple edge phenomenon is usually accompanied by specific hue and higher saturation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing, and in particular to a method, apparatus, storage medium, and computer equipment for detecting purple-fringe areas in an image. Background Art

[0002] Optimizing image quality is crucial, and eliminating purple fringing is a key technology for enhancing image visual quality. Purple fringing typically occurs at high-contrast edges, particularly when using a digital camera to capture scenes where high- and low-brightness objects are adjacent. Due to lens dispersion or the inherent characteristics of the sensor's photosensitive elements, an unnatural purple edge appears at the edge of the image. This phenomenon not only affects image clarity but also degrades the overall visual aesthetic.

[0003] To effectively eliminate purple fringing in images, existing technical approaches mostly focus on processing within the image's RGB (red, green, and blue) color space. As the foundation of image processing, the RGB domain provides a way to directly manipulate image color information. A common method for removing purple fringing first involves detecting purple-fringed regions. This step is typically achieved by setting specific thresholds for each RGB channel, or by calculating brightness values ​​based on the RGB channels and defining potential purple-fringed regions based on the brightness thresholds, referred to as purple-fringed candidate regions 1. This method is simple and easy to implement, but the accuracy of the detection results may be limited due to the subjectivity of threshold setting and the diversity of image content.

[0004] Furthermore, to enhance the accuracy of purple fringing detection, color judgment is required. This typically relies on the difference between the R and G channels, or the calculation results of the B and G channels. By analyzing these differences or calculation results, more likely candidate purple fringing regions can be further screened. The choice of color judgment formula directly affects the accuracy of purple fringing detection, but it also carries the risk of misjudgment, where non-purple fringed regions are mistakenly identified as purple fringed.

[0005] After identifying potential purple-fringing regions, edge detection operators or pixel variance statistics are used to accurately identify edge information in the image, thereby determining the final purple-fringing candidate regions. 3 The application of edge detection technology can significantly improve the accuracy of purple-fringing identification, but it also increases computational complexity.

[0006] Combining the above steps, by taking the intersection of multiple purple fringing candidate regions, the purple fringing region in the image can be accurately located. Subsequently, an appropriate correction algorithm is used to correct the detected purple fringing to restore the natural transition and color balance of the image.

[0007] However, while existing purple fringing removal techniques have achieved some success, detection accuracy still relies heavily on the choice of RGB color judgment formula and threshold setting. This can lead to misidentification in practical applications, where non-purple-fringed areas are mistakenly identified as purple fringed, thus affecting the efficiency and effectiveness of image processing. Therefore, developing a more accurate and efficient purple fringing removal method remains an urgent issue in the field of image signal processing. Summary of the Invention

[0008] The present invention provides a method, apparatus, storage medium, and computer device for detecting purple fringing in images, which can solve the problem of low accuracy and complexity in detecting purple fringing in images in the prior art. The technical solution is as follows:

[0009] In a first aspect, an embodiment of the present application provides a method for detecting purple-fringed areas in an image, the method comprising:

[0010] A sliding window is used to slide in the YUV image to traverse each pixel point, and if the central pixel point of the sliding window meets the first discrimination condition: the Y channel value is less than the threshold value Yt1 and there is at least one other pixel point in the sliding window with a Y channel value greater than the threshold value Yt2, the central pixel point is identified as a purple fringing candidate point; and a first purple fringing candidate region is generated based on all purple fringing pixels in the YUV image that meet the above Y channel discrimination condition;

[0011] For each pixel in the YUV image, if the row-adjacent pixel (i-1, j) or the column-adjacent pixel (i, j-1) of the current pixel (i, j) is a purple fringing candidate point that meets the Y channel discrimination condition, identify the current pixel (i, j) as a purple fringing candidate point, and add the current pixel to the first purple fringing candidate area;

[0012] Calculating the Y channel horizontal gradient and the Y channel vertical gradient of the current pixel in the YUV image, determining the edge direction of the current pixel based on the Y channel horizontal gradient, the Y channel vertical gradient and a gradient threshold Gt1, calculating the U channel gradient and the V channel gradient of the current pixel in the edge direction, and identifying the current pixel as a purple fringing candidate point if the maximum value of the U channel gradient and the V channel gradient is greater than the gradient threshold Gt2; and generating a second purple fringing candidate region based on all purple fringing pixels in the YUV image that meet the above gradient discrimination conditions;

[0013] calculate a hue value and a color saturation of a current pixel point in the YUV image, identify the current pixel point as a purple edge candidate point if the hue value is in a preset purple edge hue range and the color saturation is greater than a saturation threshold value, and generate a third purple edge candidate region according to all the purple edge candidate points in the YUV image that satisfy the above hue saturation discrimination condition;

[0014] take an intersection of the first purple edge candidate region, the second purple edge candidate region and the third purple edge candidate region to obtain a final target purple edge region.

[0015] In a second aspect, an embodiment of the present application provides a device for detecting a purple edge region of an image, and the device comprises:

[0016] a brightness discrimination module configured to traverse each pixel point in a YUV image to be detected by sliding a sliding window in the YUV image, identify a center pixel point of the sliding window as a purple edge candidate point if the center pixel point satisfies a first discrimination condition that a Y channel value is less than a threshold value Yt1 and there is at least one other pixel point in the sliding window whose Y channel value is greater than a threshold value Yt2, and generate a first purple edge candidate region according to all the purple edge candidate points in the YUV image that satisfy the Y channel discrimination condition.

[0017] a neighbor discrimination module configured to, for each pixel point in the YUV image, identify a current pixel point (i, j) as a purple edge candidate point if a row neighbor pixel point (i-1, j) or a column neighbor pixel point (i, j-1) of the current pixel point (i, j) is a purple edge candidate point that satisfies the Y channel discrimination condition, and add the current pixel point to the first purple edge candidate region.

[0018] a gradient discrimination module configured to calculate a Y channel horizontal gradient and a Y channel vertical gradient of a current pixel point in the YUV image, determine an edge direction of the current pixel point according to the Y channel horizontal gradient and the Y channel vertical gradient and a gradient threshold value Gt1, calculate a U channel gradient and a V channel gradient of the current pixel point in the edge direction, identify the current pixel point as a purple edge candidate point if a maximum value of the U channel gradient and the V channel gradient is greater than a gradient threshold value Gt2, and generate a second purple edge candidate region according to all the purple edge candidate points in the YUV image that satisfy the gradient discrimination condition.

[0019] a color discrimination module configured to calculate a hue value and a color saturation of a current pixel point in the YUV image, identify the current pixel point as a purple edge candidate point if the hue value is in a preset purple edge hue range and the color saturation is greater than a saturation threshold value, and generate a third purple edge candidate region according to all the purple edge candidate points in the YUV image that satisfy the above hue saturation discrimination condition.

[0020] The merging module is configured to obtain a final target purple-fringe region by taking an intersection of the first purple-fringe candidate region, the second purple-fringe candidate region, and the third purple-fringe candidate region.

[0021] In a third aspect, an embodiment of the present application provides a computer storage medium, wherein the computer storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded by a processor and executing the above-mentioned method steps.

[0022] In a fourth aspect, an embodiment of the present application provides a computer device, which may include: a processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the above-mentioned method steps.

[0023] The beneficial effects of the technical solutions provided by some embodiments of the present application include at least:

[0024] By determining the difference in Y channel values, this method can initially screen out pixels located on high-contrast edges, which are more likely to belong to purple-fringed regions. By leveraging the relationship between adjacent pixels, the coverage of candidate purple-fringed regions is further expanded, improving detection sensitivity. By calculating the horizontal and vertical gradients of the Y channel and combining them with gradient analysis of the U and V channels, this method can more accurately identify pixels with purple-fringing characteristics, effectively reducing the possibility of false positives. Incorporating hue and saturation determination further improves the accuracy of purple-fringing detection, as purple fringing is often associated with specific hues and high saturation. Compared to traditional purple-fringing detection methods in the RGB color space, the method of this application operates in the YUV color space, identifying purple-fringed regions through objective criteria such as gradient analysis and hue and saturation determination, reducing the subjectivity and dependency of threshold setting. Each step of this application is based on basic image processing operations and algorithms, such as sliding windows and gradient calculations, which can be efficiently executed on modern computers. The final target purple-fringed region is obtained by taking the intersection of multiple candidate purple-fringed regions, ensuring detection accuracy while avoiding unnecessary recalculation and improving overall detection efficiency. By combining multiple discrimination conditions, this method can more accurately identify the purple-fringe area in the image, providing a reliable basis for subsequent purple-fringe correction. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. 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 paying any creative work.

[0026] Figure 1is a flowchart of a method for detecting a purple edge region of an image provided by an embodiment of the present application;

[0027] Figure 2 is a schematic diagram of a sliding window provided by the present application;

[0028] Figure 3 is a structural schematic diagram of a device for detecting a purple edge region of an image provided by the present application;

[0029] Figure 4 is a structural schematic diagram of a computer device provided by the present application. DETAILED DESCRIPTION

[0030] In order to make the purpose, technical scheme and advantages of the present application clearer, the embodiments of the present application will be further described in detail below with reference to the drawings.

[0031] Please refer to Figure 2 , a flowchart of a method for detecting a purple edge region of an image provided by an embodiment of the present application. As shown in Figure 2 , the method provided by the present embodiment can include the following steps:

[0032] S101, using a sliding window to slide in a YUV image to be detected to traverse each pixel point, if the center pixel point of the sliding window satisfies a first discrimination condition: the Y channel value is less than a threshold Yt1 and there is at least one other pixel point in the sliding window with a Y channel value greater than a threshold Yt2, the center pixel point is identified as a purple edge candidate point; and a first purple edge candidate region is generated according to all the purple edge pixel points in the YUV image that satisfy the Y channel discrimination condition.

[0033] Wherein, the size of the sliding window is set (such as 3x3, 5x5, etc.), for example: referring to the sliding window shown in Figure 2 , the size of the sliding window is 3x3, the selection of the window size depends on the image resolution and the desired accuracy. The center position of the window is initialized, starting from the top left corner of the image. Two layers of loops (usually nested loops) are used to traverse each pixel point of the image. In each round of loop, the center pixel point of the window is updated. For the center pixel point of the current window, read its Y channel value and compare it with the preset threshold Yt1. Traverse all the pixel points in the window and check if there is at least one pixel point with a Y channel value greater than the threshold Yt2. If the Y channel value of the center pixel point is less than Yt1 and there is at least one pixel point in the window with a Y channel value greater than Yt2, the center pixel point is marked as a purple edge candidate point. All the purple edge candidate points that satisfy the Y channel discrimination condition are stored in a set or list, forming a first purple edge candidate region.

[0034] S102. For each pixel in the YUV image, if the row-adjacent pixel (i-1, j) or the column-adjacent pixel (i, j-1) of the current pixel (i, j) is a purple fringing candidate point that meets the Y channel discrimination condition, identify the current pixel (i, j) as a purple fringing candidate point, and add the current pixel to the first purple fringing candidate area.

[0035] Each pixel (i, j) in the image is checked. The row-adjacent pixel (i-1, j) and column-adjacent pixel (i, j-1) of the current pixel are checked. If any of these adjacent pixels is marked as a purple fringing candidate point (meets the Y channel discrimination condition in S101), the current pixel (i, j) is also marked as a purple fringing candidate point. The newly marked purple fringing candidate point is added to the first purple fringing candidate region.

[0036] S103, calculating the Y channel horizontal gradient and the Y channel vertical gradient of the current pixel in the YUV image, and determining the edge direction of the current pixel based on the Y channel horizontal gradient, the Y channel vertical gradient and the gradient threshold Gt1, calculating the U channel gradient and the V channel gradient of the current pixel in the edge direction, if the maximum value of the U channel gradient and the V channel gradient is greater than the gradient threshold Gt2, identifying the current pixel as a purple fringing candidate point; and generating a second purple fringing candidate area based on all purple fringing pixels in the YUV image that meet the above gradient discrimination conditions.

[0037] For each pixel point (i, j), the Sobel operator or other gradient calculation method is used to calculate the horizontal gradient (Gx) and vertical gradient (Gy) of its Y channel. The magnitudes of the horizontal gradient (Gx) and vertical gradient (Gy) of the Y channel are compared. Horizontal edge direction: If the horizontal gradient (Gx) of the Y channel is greater than the vertical gradient (Gy) of the Y channel, and the horizontal gradient (Gx) of the Y channel is greater than the preset gradient threshold Gt1, then the edge direction of the current pixel point is determined to be horizontal. Vertical edge direction: If the vertical gradient (Gy) of the Y channel is greater than the horizontal gradient (Gx) of the Y channel, and the vertical gradient (Gy) of the Y channel is greater than the preset gradient threshold Gt1, then the edge direction of the current pixel point is determined to be vertical. If both gradients are less than or equal to Gt1, or their difference is not sufficient to clearly determine the edge direction, it can be considered that the pixel point does not meet the edge direction determination conditions of the current step, but may still be identified as a purple fringe candidate point based on other conditions in subsequent steps.

[0038] According to the determined edge direction (horizontal or vertical), the corresponding direction is selected to calculate the gradients of the U channel and the V channel. For the horizontal edge direction, the U channel gradient (Gu_h) and the V channel gradient (Gv_h) along the horizontal direction (for example, using the difference between adjacent row pixels) can be calculated. For the vertical edge direction, the U channel gradient (Gu_v) and the V channel gradient (Gv_v) along the vertical direction (for example, using the difference between adjacent column pixels) can be calculated. Note: In actual implementation, the above steps may need to be adjusted according to the specific gradient calculation method. For example, if the Sobel operator is used, its horizontal and vertical convolution kernels can be directly applied to calculate the gradients of the U and V channels.

[0039] After determining the edge direction, compare the gradient values ​​of the U and V channels in that direction. If the maximum value of the U channel gradient (Gu) and the V channel gradient (Gv) (Gu_h / Gu_v and Gv_h / Gv_v are selected according to the edge direction) is greater than the preset gradient threshold Gt2, the current pixel is marked as a purple fringing candidate point. All purple fringing candidate points that meet the above gradient discrimination conditions are stored in a set or list to form the second purple fringing candidate region.

[0040] S104. Calculate the hue value and color saturation of the current pixel in the YUV image. If the hue value is within a preset purple-fringe hue range and the color saturation is greater than a saturation threshold, identify the current pixel as a purple-fringe candidate point. Generate a third purple-fringe candidate area based on all purple-fringe candidate points in the YUV image that meet the above hue and saturation judgment conditions.

[0041] For each pixel (i, j), the YUV to HSV conversion formula is used to calculate its hue value (Hue) and color saturation (Saturation). Check whether the hue value is within the preset purple-fringe hue range (usually a hue range related to purple). Check whether the color saturation is greater than the preset saturation threshold. If the hue value and color saturation of the current pixel meet the above conditions, it is marked as a purple-fringe candidate point. All purple-fringe candidate points that meet the hue and saturation judgment conditions are stored in a set or list to form the third purple-fringe candidate region.

[0042] In some embodiments of the present application, the formula for calculating the hue value is: The formula for calculating color saturation is: Sat(i,j)=abs(V(i,j)-128)+abs(U(i,j)-128).

[0043] S105 , taking the intersection of the first purple fringing candidate region, the second purple fringing candidate region, and the third purple fringing candidate region to obtain a final target purple fringing region.

[0044] An intersection operation is performed on the first, second, and third purple-fringed candidate regions to obtain a final target purple-fringed region. The final target purple-fringed region is output, typically as an image or image mask. Through the above steps, the computer device can accurately identify purple-fringed regions in the YUV image.

[0045] After detecting the target purple-fringed region, purple-fringing correction is performed. All pixels marked as target purple-fringed regions are traversed. This can be achieved by traversing the previously generated list of purple-fringed candidate regions or by directly applying a mask to the image.

[0046] For each pixel traversed, check whether it falls within the target purple-fringed region. This is typically done by comparing the pixel's coordinates with the coordinate range of the purple-fringed region. If the pixel falls within the target purple-fringed region, set its U and V channel values ​​to 128. This can be accomplished by directly accessing the image's YUV data. In YUV color space, the U and V channels represent hue and saturation, respectively. Setting them to 128 neutralizes the purple tint, as 128 is the midpoint of the hue channel. While replacing the U and V channel values, the Y channel (luminance) value remains unchanged. This ensures that the corrected image maintains consistent brightness. After replacing the U and V channel values ​​for all purple-fringed pixels, update the image data. This typically means writing the modified YUV data back to the image file or display device. Finally, verify that the corrected image has effectively reduced purple fringing. This can be done through visual inspection or using image quality assessment tools.

[0047] Furthermore, in some embodiments of the present application, for the task of generating the first purple fringing candidate region, the second purple fringing candidate region, and the third purple fringing candidate region, the computer device may implement parallel processing in the following manner:

[0048] 1. Thread parallelism.

[0049] Create a thread: Create a separate thread for each candidate region generation task. This can be achieved by using a multithreading library in the programming language (such as std::thread in C++, threading module in Python).

[0050] Task allocation: Assign image data (which may be the entire image or a part of the image) to each thread and specify the specific candidate region generation task to be performed.

[0051] Synchronization and communication: Ensure synchronization and data consistency between threads, especially when accessing shared resources (such as image data or candidate point lists). You can use mutexes or condition variables to manage access to shared resources.

[0052] Result merging: After all threads complete their tasks, the candidate regions generated by each thread are merged into the final candidate region set.

[0053] 2. Task parallelism.

[0054] Use parallel frameworks: Leverage existing parallel computing frameworks (such as OpenMP, Cilk Plus, Intel TBB, etc.) to parallelize the candidate region generation task. These frameworks provide high-level parallel programming abstractions, eliminating the need for developers to manually manage threads and synchronization.

[0055] Task division: The image is divided into multiple small blocks, each of which is assigned to a parallel task. Each task is responsible for processing its assigned small block and generating the corresponding candidate region.

[0056] Result collection: The framework is responsible for collecting the results of each task and merging them into the final output.

[0057] 3.GPU acceleration.

[0058] Use CUDA or OpenCL: For large-scale image processing tasks, consider using GPU acceleration. By writing code in CUDA (NVIDIA's parallel computing platform and programming model) or OpenCL (an open standard for heterogeneous platforms), the task of generating candidate regions can be offloaded to the GPU for execution.

[0059] Data layout and transfer: Ensure that image data is laid out in a manner suitable for GPU processing and transfer data to the GPU efficiently.

[0060] Kernel design: Design one or more GPU kernels for each candidate region generation task, which will process image data in parallel.

[0061] Result return: The results generated on the GPU are returned to the CPU for necessary post-processing.

[0062] The embodiments of the present application specifically include the following beneficial effects:

[0063] By determining the difference in Y channel values, this method can initially screen out pixels located on high-contrast edges, which are more likely to belong to purple-fringed regions. By leveraging the relationship between adjacent pixels, the coverage of candidate purple-fringed regions is further expanded, improving detection sensitivity. By calculating the horizontal and vertical gradients of the Y channel and combining them with gradient analysis of the U and V channels, this method can more accurately identify pixels with purple-fringing characteristics, effectively reducing the possibility of false positives. Incorporating hue and saturation determination further improves the accuracy of purple-fringing detection, as purple fringing is often associated with specific hues and high saturation. Compared to traditional purple-fringing detection methods in the RGB color space, the method of this application operates in the YUV color space, identifying purple-fringed regions through objective criteria such as gradient analysis and hue and saturation determination, reducing the subjectivity and dependency of threshold setting. Each step of this application is based on basic image processing operations and algorithms, such as sliding windows and gradient calculations, which can be efficiently executed on modern computers. The final target purple-fringed region is obtained by taking the intersection of multiple candidate purple-fringed regions, ensuring detection accuracy while avoiding unnecessary recalculation and improving overall detection efficiency. By combining multiple discrimination conditions, this method can more accurately identify the purple-fringe area in the image, providing a reliable basis for subsequent purple-fringe correction.

[0064] The following are device embodiments of the present application, which can be used to implement the method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.

[0065] See Figure 3 , which shows a schematic diagram of the structure of an apparatus for detecting purple-fringed areas in an image, provided by an exemplary embodiment of the present application, hereinafter referred to as apparatus 3. Apparatus 3 can be implemented as all or part of a computer device through software, hardware, or a combination of both. Apparatus 3 includes a brightness determination unit 301, an adjacent determination unit 302, a gradient determination unit 303, a color determination unit 304, and a merging unit 305.

[0066] The brightness discrimination module 301 is configured to use a sliding window to slide through each pixel in the YUV image to be detected, identify the central pixel as a purple fringing candidate point if the central pixel of the sliding window meets a first discrimination condition: the Y channel value is less than a threshold value Yt1 and there is at least one other pixel in the sliding window with a Y channel value greater than a threshold value Yt2; and generate a first purple fringing candidate region based on all purple fringing pixels in the YUV image that meet the above Y channel discrimination condition.

[0067] The neighboring discrimination module 302 is configured to, for each pixel in the YUV image, identify the current pixel (i, j) as a purple fringing candidate point if the row-adjacent pixel (i-1, j) or the column-adjacent pixel (i, j-1) of the current pixel (i, j) is a purple fringing candidate point that meets the Y channel discrimination condition, and add the current pixel to the first purple fringing candidate area;

[0068] The gradient discrimination module 303 is configured to calculate the Y-channel horizontal gradient and the Y-channel vertical gradient of the current pixel in the YUV image, determine the edge direction of the current pixel based on the Y-channel horizontal gradient, the Y-channel vertical gradient, and a gradient threshold Gt1, calculate the U-channel gradient and the V-channel gradient of the current pixel in the edge direction, and identify the current pixel as a purple fringing candidate point if the maximum value of the U-channel gradient and the V-channel gradient is greater than the gradient threshold Gt2; and generate a second purple fringing candidate region based on all purple-fringed pixels in the YUV image that meet the above gradient discrimination conditions.

[0069] The color discrimination module 304 is configured to calculate the hue value and color saturation of a current pixel in the YUV image, identify the current pixel as a purple-fringing candidate point if the hue value is within a preset purple-fringing hue range and the color saturation is greater than a saturation threshold, and generate a third purple-fringing candidate region based on all purple-fringing candidate points in the YUV image that meet the above hue and saturation discrimination conditions.

[0070] The merging module 305 is configured to obtain a final target purple-fringe region by taking the intersection of the first purple-fringe candidate region, the second purple-fringe candidate region, and the third purple-fringe candidate region.

[0071] In one or more possible embodiments, the formula for calculating the hue value is: ; the formula for calculating the color saturation is:.

[0072] In one or more possible embodiments, the Sobel operator or the Laplace algorithm is used to calculate the gradient.

[0073] In one or more possible embodiments, the size of the sliding window is 3×3.

[0074] In one or more possible embodiments, the first purple fringing candidate region, the second purple fringing candidate region, and the third purple fringing candidate region are generated in parallel.

[0075] In one or more possible embodiments, determining the edge direction of the current pixel according to the Y channel horizontal gradient, the Y channel vertical gradient, and the gradient threshold Gt1 includes:

[0076] If the Y channel horizontal gradient is greater than the Y channel vertical gradient, and the Y channel horizontal gradient is greater than the gradient threshold Gt1, then the edge direction of the current pixel is horizontal; or

[0077] If the Y channel vertical gradient is greater than the Y channel horizontal gradient, and the Y channel vertical gradient is greater than the gradient threshold Gt1, the edge point of the current pixel is in the vertical direction.

[0078] In one or more possible embodiments, it further includes:

[0079] The correction unit is used to replace the U channel value and the V channel value of each purple-fringed pixel point in the target purple-fringed area with 128.

[0080] It should be noted that the device 4 provided in the above embodiment, when executing the method for detecting purple-fringed areas in images, is only illustrated by the division of the above-mentioned functional modules. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the above-mentioned functions. In addition, the device for detecting purple-fringed areas in images provided in the above embodiment and the method for detecting purple-fringed areas in images are based on the same concept. The implementation process is detailed in the method embodiment and will not be repeated here.

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

[0082] The present application also provides a computer storage medium that can store multiple instructions, which are suitable for being loaded and executed by a processor as described above. Figure 1 The method steps of the embodiment shown, the specific execution process can be found in Figure 1 The detailed description of the illustrated embodiment will not be repeated here.

[0083] The present application also provides a computer program product, which stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the method for detecting purple-fringed areas in an image as described in the above embodiments.

[0084] See Figure 4 , provides a schematic diagram of the structure of a computer device according to an embodiment of the present application. Figure 4 As shown, the computer device 400 may include: at least one processor 401 , at least one network interface 404 , a user interface 403 , a memory 405 , and at least one communication bus 402 .

[0085] The communication bus 402 is used to implement the connection and communication between these components.

[0086] The user interface 403 may include a display screen (Display) and a camera (Camera). Optionally, the user interface 403 may also include a standard wired interface and a wireless interface.

[0087] The network interface 404 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).

[0088] The processor 401 may include one or more processing cores. The processor 401 utilizes various interfaces and circuits to connect the various components within the entire computer device 400. It executes various functions and processes data within the computer device 400 by running or executing instructions, programs, code sets, or instruction sets stored in the memory 405, as well as accessing data stored in the memory 405. Optionally, the processor 401 may be implemented in the form of at least one hardware component selected from the group consisting of a digital signal processing (DSP), a field-programmable gate array (FPGA), and a programmable logic array (PLA). The processor 401 may integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. The CPU primarily processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; and the modem handles wireless communications. It is understood that the modem may not be integrated into the processor 401 and may be implemented separately on a single chip.

[0089] Among them, the memory 405 may include a random access memory (Random Access Memory, RAM) and may also include a read-only memory (Read-Only Memory). Optionally, the memory 405 includes a non-transitory computer-readable storage medium. The memory 405 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 405 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 405 may also be optionally at least one storage device located away from the aforementioned processor 401. AsFigure 4 As shown, the memory 405 as a computer storage medium can include an operating system, a network communication module, a user interface module and an application program.

[0090] In Figure 4 In the computer device 400 as shown, the user interface 403 is mainly used to provide an interface for user input, to obtain user input data; and the processor 401 can be used to call the application program stored in the memory 405, and specifically execute the method as shown in Figure 2 The specific process can refer to Figure 1 as shown, which will not be described here.

[0091] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by a computer program instructing related hardware. The program can be stored in a computer readable storage medium, and when the program is executed, it can include the processes of the above-mentioned embodiments. The storage medium can be a magnetic disc, an optical disc, a read-only memory or a random access memory, etc.

[0092] The above only describes the preferred embodiments of the present application, and of course cannot limit the scope of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope of the present application.

Claims

1. A method for detecting purple-fringe areas in an image, characterized in that: include: A sliding window is used to slide in the YUV image to traverse each pixel point, and if the central pixel point of the sliding window meets the first discrimination condition: the Y channel value is less than the threshold value Yt1 and there is at least one other pixel point in the sliding window with a Y channel value greater than the threshold value Yt2, the central pixel point is identified as a purple fringing candidate point; and a first purple fringing candidate region is generated based on all purple fringing pixels in the YUV image that meet the above Y channel discrimination condition; For each pixel in the YUV image, if the row-adjacent pixel (i-1, j) or the column-adjacent pixel (i, j-1) of the current pixel (i, j) is a purple fringing candidate point that meets the Y channel discrimination condition, the current pixel (i, j) is identified as a purple fringing candidate point, and the current pixel is added to the first purple fringing candidate area; Calculating the Y channel horizontal gradient and the Y channel vertical gradient of the current pixel in the YUV image, determining the edge direction of the current pixel based on the Y channel horizontal gradient, the Y channel vertical gradient, and a gradient threshold Gt1, calculating the U channel gradient and the V channel gradient of the current pixel in the edge direction, and identifying the current pixel as a purple fringing candidate point if the maximum value of the U channel gradient and the V channel gradient is greater than the gradient threshold Gt2; and generating a second purple fringing candidate region based on all purple fringing pixels in the YUV image that meet the above gradient discrimination conditions; Calculating the hue value and color saturation of a current pixel in the YUV image, and identifying the current pixel as a purple-fringe candidate point if the hue value is within a preset purple-fringe hue range and the color saturation is greater than a saturation threshold; and generating a third purple fringing candidate area according to all the purple fringing candidate points in the YUV image that meet the above hue and saturation discrimination conditions; The final target purple-fringe region is obtained by taking the intersection of the first purple-fringe candidate region, the second purple-fringe candidate region, and the third purple-fringe candidate region.

2. The method according to claim 1, characterized in that The formula for calculating hue value is: ; The formula for calculating color saturation is: ; Hue represents the hue value, (i, j) represents the pixel coordinates, arctan represents the inverse tangent operation, V(i, j) represents the brightness of the pixel coordinates, U(i, j) represents the chroma of the pixel coordinates; Sat represents the color saturation, and abs represents the absolute value operation.

3. The method according to claim 1, characterized in that The Sobel operator or Laplace algorithm is used for gradient calculation.

4. The method according to claim 1, wherein The size of the sliding window is 3×3.

5. The method according to claim 1, wherein A first purple fringing candidate region, a second purple fringing candidate region, and a third purple fringing candidate region are generated in parallel.

6. The method according to claim 1, characterized in that Determining the edge direction of the current pixel according to the Y channel horizontal gradient, the Y channel vertical gradient, and the gradient threshold Gt1 includes: If the Y channel horizontal gradient is greater than the Y channel vertical gradient, and the Y channel horizontal gradient is greater than the gradient threshold Gt1, then the edge direction of the current pixel is horizontal; or If the Y channel vertical gradient is greater than the Y channel horizontal gradient, and the Y channel vertical gradient is greater than the gradient threshold Gt1, the edge point of the current pixel is in the vertical direction.

7. The method according to claim 1, characterized in that Also includes: The U channel value and the V channel value of each purple-fringed pixel in the target purple-fringed area are replaced with 128.

8. A device for detecting purple-fringe areas in an image, characterized in that: include: a brightness discrimination module, configured to use a sliding window to slide through each pixel in the YUV image to be detected, identify the central pixel as a purple fringing candidate point if the central pixel of the sliding window satisfies a first discrimination condition: the Y channel value is less than a threshold value Yt1 and there is at least one other pixel in the sliding window with a Y channel value greater than a threshold value Yt2; and generate a first purple fringing candidate region based on all purple fringing pixels in the YUV image that meet the above Y channel discrimination condition; a neighboring discrimination module, configured to, for each pixel in the YUV image, identify the current pixel (i, j) as a purple fringing candidate point if the row-adjacent pixel (i-1, j) or the column-adjacent pixel (i, j-1) of the current pixel (i, j) is a purple fringing candidate point that meets the Y channel discrimination condition, and add the current pixel to the first purple fringing candidate area; a gradient discrimination module, configured to calculate the Y-channel horizontal gradient and the Y-channel vertical gradient of the current pixel in the YUV image, determine the edge direction of the current pixel based on the Y-channel horizontal gradient, the Y-channel vertical gradient, and a gradient threshold Gt1, calculate the U-channel gradient and the V-channel gradient of the current pixel in the edge direction, and identify the current pixel as a purple-fringing candidate point if the maximum value of the U-channel gradient and the V-channel gradient is greater than the gradient threshold Gt2; and generate a second purple-fringing candidate region based on all purple-fringed pixels in the YUV image that meet the above-mentioned gradient discrimination conditions; a color discrimination module, configured to calculate the hue value and color saturation of a current pixel in the YUV image, and identify the current pixel as a purple-fringe candidate if the hue value is within a preset purple-fringe hue range and the color saturation is greater than a saturation threshold; and generating a third purple fringing candidate area according to all the purple fringing candidate points in the YUV image that meet the above hue and saturation discrimination conditions; The merging module is configured to obtain a final target purple-fringe region by taking an intersection of the first purple-fringe candidate region, the second purple-fringe candidate region, and the third purple-fringe candidate region.

9. A computer storage medium, characterized in that The computer storage medium stores a plurality of instructions, which are suitable for being loaded by a processor and executing the method steps according to any one of claims 1 to 7.

10. A computer device, characterized in that: include: A processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the method steps according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method and device for removing purple edge of image, equipment and medium

    CN117635485A

  • Method and apparatus for cross-component prediction for video coding

    WO2023230152A1