WO2022257396A1 - Method and apparatus for determining color fringe pixel point in image and computer device - Google Patents

Method and apparatus for determining color fringe pixel point in image and computer device Download PDF

Info

Publication number
WO2022257396A1
WO2022257396A1 PCT/CN2021/136744 CN2021136744W WO2022257396A1 WO 2022257396 A1 WO2022257396 A1 WO 2022257396A1 CN 2021136744 W CN2021136744 W CN 2021136744W WO 2022257396 A1 WO2022257396 A1 WO 2022257396A1
Authority
WO
WIPO (PCT)
Prior art keywords
color
value
target
pixel
preset
Prior art date
Application number
PCT/CN2021/136744
Other languages
French (fr)
Chinese (zh)
Inventor
王艳龙
Original Assignee
爱芯元智半导体(上海)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 爱芯元智半导体(上海)有限公司 filed Critical 爱芯元智半导体(上海)有限公司
Publication of WO2022257396A1 publication Critical patent/WO2022257396A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10024Color image

Definitions

  • the present application relates to the field of image processing, in particular, to a method, device and computer equipment for determining color fringe pixels in an image.
  • High-quality lenses generally add ultra-low dispersion lenses to correct or eliminate purple fringing, but the price is also much higher, and in many cases it cannot be completely eliminated, so it is still necessary to use algorithms to correct purple fringing.
  • the traditional purple fringing algorithm is relatively simple for purple recognition, and the purple recognition accuracy is low.
  • the present application proposes a determination method, determination device and computer equipment of color fringe pixels in an image capable of better identifying color fringe pixels.
  • the present application provides a method for determining color fringe pixels in an image, which may include:
  • the color value may include a red value, a green value and a blue value
  • the color fringe pixels are pixels in the color fringe in the target image.
  • the method for determining the color edge pixels in the above image after determining the color value of the pixel point, can also determine the red-green difference value and the blue-green difference value according to the color value, compared with simply determining the pixel point according to the color value In this way, reddish colors and bluish colors can be identified, which makes the identification of colors more flexible and avoids the omission of color edge pixels to a certain extent.
  • reddish colors and bluish colors can be identified, which makes the identification of colors more flexible and avoids the omission of color edge pixels to a certain extent.
  • the determining whether the target pixel is a color edge pixel in the target image according to the gradient values of the target pixel in multiple preset directions may include: judging that the target Whether the gradient value of the pixel point in the corresponding preset direction is valid; determine whether the target pixel point is a color edge pixel in the target image according to whether the gradient value of the target pixel point in multiple preset directions is valid point.
  • the above-mentioned embodiment provides a method for determining the color edge pixel point, judging whether the gradient value of the pixel point in the corresponding preset direction is valid according to the gradient value, and if it is valid, it is considered that there is a highlighted pixel in the preset direction point, so that whether the pixel point is a color edge pixel point can be determined according to whether the gradient values in multiple preset directions are valid.
  • the judging whether the gradient value of the target pixel point in the corresponding preset direction is valid may include: acquiring a plurality of gradient groups, the gradient groups including preset gradient values and preset brightness Value; compare the gradient value of the target pixel point in the target preset direction with the preset gradient value in the target gradient group to obtain the gradient of the target pixel point in the target gradient group in the target preset direction
  • the target gradient group may be a gradient group to be compared in the plurality of gradient groups
  • the target preset direction may be a preset direction to be compared in the plurality of preset directions
  • Comparing the brightness value of the target pixel point with the preset brightness value in the target gradient group to obtain the brightness comparison result of the target pixel point in the target gradient group in the target preset direction; according to the The gradient comparison results and brightness comparison results of the plurality of gradient groups of the target pixel in the target preset direction determine whether the gradient value of the target pixel in the target preset direction is valid.
  • the actual pixel point to be corrected (the pixel point in the center of the detection window, that is, the target pixel point)
  • the brightness may be relatively low, and the pixel to be corrected is between the bright area and the dark area (the area where the target is located, and the brightness of this area is relatively low), so theoretically, the brightness of the pixel to be corrected is different. will be very low, therefore, combining the brightness to judge whether the gradient value is valid will get a more accurate judgment result.
  • the target pixel after determining whether the target pixel is a color fringe pixel in the target image according to the gradient values of the target pixel in multiple preset directions, it may further include: when When the target pixel is a color edge pixel in the target image, the color value of the target pixel is corrected.
  • the target pixel when the target pixel is a color edge pixel, the target pixel can also be corrected, so that the corrected target image is more realistic.
  • the correcting the color value of the target pixel may include: searching for the corrected pixel corresponding to the target pixel according to the gradient values of the target pixel in multiple preset directions ; Correcting the color value of the target pixel according to the color value of the corrected pixel corresponding to the target pixel.
  • the correction of the color edge pixels is realized through the color value, so that the color of the corrected target pixel is similar to the color of the corrected pixel, so that the corrected target image is more realistic.
  • the correcting the color value of the target pixel according to the color value of the corrected pixel corresponding to the target pixel may include: determining the target color component, the first remaining color component and the second The remaining color component, the target color component, the first remaining color component and the second remaining color component can be one of the red component, green component and blue component respectively; calculate the target in the corrected pixel The difference between the color component value corresponding to the color component and the color component value corresponding to the first remaining color component in the corrected pixel to obtain the first difference; calculate the color component corresponding to the target color component in the corrected pixel value and the color component value corresponding to the second remaining color component in the corrected pixel point to obtain the second difference value; calculate the color component value corresponding to the target color component of the target pixel point and the first difference Value difference, to obtain the color component value corresponding to the first remaining color component of the target pixel point; calculate the difference value between the color component value corresponding to the target color component of the target pixel point and the second difference value, to obtain The color component value
  • the target color component is first determined, and then the color component value corresponding to the target color component of the target pixel is kept unchanged during the process of correcting the color value of the target pixel, that is, the brightness of the pixel is guaranteed to remain unchanged , and then correct the color component values corresponding to the first remaining color component and the second remaining color component of the pixel, so that the brightness of the pixel after correction will not be too different from the brightness before correction, so that the correction There will be no obvious brightness difference area in the color fringe (considering that it is impossible to identify all the color fringe pixels in the color fringe, that is, the recognition of color fringe pixels may be missed, then, if the correction pixel is directly The color value of the point is corrected as the color value of the pixel to be corrected.
  • the searching for the correction pixel corresponding to the target pixel according to the gradient values of the target pixel in multiple preset directions may include: according to the target pixel in multiple preset directions Whether the gradient value in the direction is effective determines the search direction of the corrected pixel corresponding to the target pixel; search for the corrected pixel corresponding to the target pixel within a preset pixel range in the search direction.
  • the above embodiment provides a search method for corrected pixel points. Firstly, the search direction is determined according to whether the gradient value is valid, and then the corrected pixel points are searched in the search direction. Since whether the gradient value is effective or not reflects whether there is a highlighted pixel point in the corresponding preset direction, the search direction of the corrected pixel point can be determined based on whether the gradient value is valid or not.
  • the searching for the corrected pixel corresponding to the pixel within the preset pixel range in the search direction may include: first appearing in the preset pixel range in the search direction A pixel point whose color is a non-color edge color is determined as a corrected pixel point corresponding to the pixel point.
  • the advantage of determining the first-appearing pixel that is a non-color edge color as the corrected pixel corresponding to the pixel is to reduce the amount of calculation and improve the correction accuracy. It can be understood that the closer the pixel is to the color edge The pixels of the color edge should be more similar to the color edge pixels, and the farther away from the color edge pixels, the less similar to the color edge pixels. Therefore, when a pixel with a color other than a color edge color appears for the first time, directly Set to rectify pixels, which can reduce the amount of calculation and improve the accuracy of correction.
  • the target pixel before determining whether the target pixel is a color fringe pixel in the target image according to the gradient values of the target pixel in multiple preset directions, it may further include: according to calculating the brightness value of the target pixel from the color value of the target pixel; obtaining a preset brightness value and a maximum brightness value of the target pixel in each preset direction in the plurality of preset directions; Comparing the maximum luminance value of the target pixel point in each of the multiple preset directions with the preset luminance value to obtain the maximum brightness value of the target pixel point in the multiple preset directions Gradient weights in each preset direction; comparing the maximum brightness value of the target pixel point in each preset direction in the plurality of preset directions with the brightness value of the target pixel point, Obtaining the preliminary gradient value of the target pixel point in each preset direction in the plurality of preset directions; The gradient weight is multiplied by the preliminary gradient value of the target pixel point in the corresponding preset direction to obtain the gradient value of the target pixel point
  • the above embodiment provides a method for calculating the gradient value of a pixel point in each preset direction. Since the color fringe usually appears at the junction where the brightness difference is large, the gradient value can be calculated based on the brightness of the pixel to improve the accuracy of the color fringe pixel judgment.
  • the determining the color of the pixel according to the color value of the pixel, the difference between red and green, and the difference between blue and green may include: obtaining a plurality of color groups, and the color groups include preset Set the blue value, the preset red-green difference value and the preset blue-green difference value; compare the blue value of the pixel with the preset blue value in the target color group to obtain the corresponding value of the target color group Blue comparison result, the target color group is a color group to be compared in the plurality of color groups; the red-green difference value of the pixel point and the preset red-green difference value in the target color group Comparing to obtain the red-green comparison result corresponding to the target color group; comparing the blue-green difference value of the pixel with the preset blue-green difference value in the target color group to obtain the corresponding The blue-green comparison result; determine the color of the pixel according to the blue comparison result, red-green comparison result and blue-green comparison result corresponding to the plurality of color groups.
  • a plurality of color groups can be preset, and the color of the pixel point can be determined according to the blue comparison results, red-green comparison results, and blue-green comparison results corresponding to the plurality of color groups, and the same color with different brightness can be compared, and , to identify reddish or bluish colors, which improves the color recognition rate.
  • the present application provides a device for determining color fringe pixels in an image, which may include:
  • An acquisition module configured to acquire the color value of the target pixel in the target image, the color value may include a red value, a green value and a blue value;
  • the calculation module may be configured to calculate the difference between the red value and the green value of the target pixel to obtain the red-green difference, and calculate the difference between the blue value and the green value of the target pixel , get the blue-green difference;
  • the determining module may be configured to determine the color of the pixel point according to the color value, red-green difference value and blue-green difference value of the target pixel point;
  • the color fringe module may be configured to determine whether the target pixel is the target according to gradient values of the target pixel in multiple preset directions when the color of the target pixel is a color fringe color A color fringe pixel in the image, the color fringe pixel being a pixel in the color fringe in the target image.
  • the color fringing module may be configured to: determine whether the gradient value of the target pixel point in the corresponding preset direction is valid; Whether the gradient value of is valid determines whether the target pixel is a color edge pixel in the target image.
  • the color fringing module can be configured to: obtain a plurality of gradient groups, and the gradient groups include preset gradient values and preset brightness values; The gradient value in the direction is compared with the preset gradient value in the target gradient group to obtain the gradient comparison result of the target gradient group of the target pixel point in the target preset direction, and the target gradient group is the multiple A gradient group to be compared in a gradient group, the target preset direction is a preset direction to be compared in the plurality of preset directions; the brightness value of the target pixel point is compared with the target gradient The preset brightness values in the group are compared to obtain the brightness comparison result of the target gradient group of the target pixel point in the target preset direction; according to the target pixel point in the target preset direction The gradient comparison results and brightness comparison results of the multiple gradient groups determine whether the gradient value of the target pixel point in the target preset direction is valid.
  • the determining device further includes: a correction module configured to correct the color value of the target pixel when the target pixel is a color edge pixel in the target image Make corrections.
  • the correction module may be configured to: search for the corrected pixel corresponding to the target pixel according to the gradient values of the target pixel in multiple preset directions; The color value of the corrected pixel point corresponding to the point corrects the color value of the target pixel point.
  • the correction module may be configured to: determine the target color component, the first remaining color component and the second remaining color component, the target color component, the first remaining color component and the The second remaining color components are respectively one of the red component, the green component and the blue component; calculating the color component value corresponding to the target color component in the corrected pixel corresponds to the first remaining color component in the corrected pixel The difference value of the color component value of the first difference value is obtained; the difference between the color component value corresponding to the target color component in the corrected pixel point and the color component value corresponding to the second remaining color component in the corrected pixel point is calculated value to obtain the second difference; calculate the difference between the color component value corresponding to the target color component of the target pixel and the first difference, and obtain the color component corresponding to the first remaining color component of the target pixel value; calculating the difference between the color component value corresponding to the target color component of the target pixel point and the second difference value, to obtain the color component value corresponding to the second remaining color component of the target pixel point.
  • the correction module may be configured to: determine the search direction of the corrected pixel corresponding to the target pixel according to whether the gradient values of the target pixel in multiple preset directions are valid; The corrected pixel corresponding to the target pixel is searched within a preset pixel range in the search direction.
  • the rectification module may be configured to: determine the first pixel in the preset pixel range in the search direction that is a non-color edge color as the pixel corresponding to the pixel. Correct the pixels.
  • the determination device may further include: a gradient value determination module configured to: calculate the brightness value of the target pixel point according to the color value of the target pixel point; obtain a preset brightness value and the determined The maximum brightness value of the target pixel point in each preset direction in the plurality of preset directions; the maximum brightness value of the target pixel point in each preset direction in the plurality of preset directions Value is compared with the preset brightness value to obtain the gradient weight of the target pixel point in each preset direction in the multiple preset directions; the target pixel point in the multiple preset directions Comparing the maximum brightness value in each preset direction in the direction with the brightness value of the target pixel to obtain a preliminary gradient of the target pixel in each preset direction in the plurality of preset directions value; multiply the gradient weight of the target pixel point in each preset direction in the plurality of preset directions by the preliminary gradient value of the target pixel point in the corresponding preset direction to obtain the A gradient value of the target pixel point in each preset direction in the plurality of
  • the gradient value determining module can be configured to: obtain a plurality of color groups, the color groups include a preset blue value, a preset red-green difference value and a preset blue-green difference value ; Comparing the blue value of the pixel with the preset blue value in the target color group to obtain a blue comparison result corresponding to the target color group, the target color group being one of the plurality of color groups A color group to be compared; compare the red-green difference value of the pixel with the preset red-green difference value in the target color group to obtain the red-green comparison result corresponding to the target color group; The blue-green difference value of the pixel is compared with the preset blue-green difference value in the target color group to obtain the blue-green comparison result corresponding to the target color group; according to the blue comparison results corresponding to the plurality of color groups The result, the red-green comparison result and the blue-green comparison result determine the color of the pixel.
  • the present application provides a computer device, which is characterized in that it may include a memory, a processor, and a computer program stored in the memory and operable on the processor, the processor
  • the method for determining color fringe pixels in an image as described above can be implemented when the computer program is executed.
  • the present application provides a computer-readable storage medium, where computer program instructions may be stored in the computer-readable storage medium, and when the computer program instructions are read and executed by a processor, The method for determining color fringe pixels in an image as described above may be performed.
  • Fig. 1 is a schematic diagram of the implementation process of the method for determining the color edge pixels in the image in the embodiment of the present application;
  • Fig. 2 is the schematic diagram of color fringe in the embodiment of the present application.
  • FIG. 3 is a schematic diagram of a pixel search range in an embodiment of the present application.
  • Fig. 4 is the schematic diagram of the search window in the embodiment of the present application.
  • FIG. 5 is a schematic diagram of the composition and structure of the device for determining the color fringe pixels in the image in the embodiment of the present application;
  • FIG. 6 is a block diagram of an internal structure of a computer device in an embodiment of the present application.
  • a method for determining color fringe pixels in an image is provided.
  • the executor of the method for determining color fringe pixels in an image described in the embodiment of the present application is a computer device capable of implementing the method for determining color fringe pixels in an image described in the embodiment of the present application.
  • the computer device may include but Not limited to terminals and servers.
  • terminals include desktop terminals and mobile terminals
  • desktop terminals include but not limited to desktop computers and vehicle-mounted computers
  • mobile terminals include but not limited to mobile phones, tablets, laptops, smart watches and cameras.
  • Servers include high-performance computers and high-performance computer clusters.
  • the color model adopted is the RGB model, but it should be pointed out that the embodiment of the present application does not limit the color model, that is, when other color models also adopt the inventive concept of the embodiment of the present application , it should also fall within the protection scope of the embodiments of the present application. Specifically, as long as other color models also adopt the scheme of calculating the color difference value according to the color value, and then determining the color of the pixel point according to the color value and the color difference value, All should fall within the protection scope of the embodiments of the present application.
  • a method for determining color fringe pixels in an image including:
  • Step 100 acquiring color values of target pixels in the target image, where the color values include red values, green values and blue values.
  • the target image is the image that needs to be processed currently, that is, the image to be determined whether it contains color fringes. If the target image contains color fringe pixels, the target image is an image that contains color fringes. On the contrary, if the pixels in the target image are If it is not a color fringe pixel, then the target image is an image that does not contain color fringe, that is to say, the method for determining the color fringe pixel in the image provided by the embodiment of the present application can not only determine whether the image contains color fringe pixels, but also It can be determined at the same time whether the image is an image including color fringing.
  • the target pixel is the pixel in the target image.
  • the target pixel point may be any pixel point among all the pixel points in the target image; the target pixel point may also be a pixel point in a target area in the target image, wherein the target area may be an area determined according to a preset area determination rule , can also be an area determined according to the user's interactive operation on the target image, for example, the area circled by the user in the target image, or an area recognized by image recognition technology, for example, the image recognition technology
  • the technology of identifying the edge area, so as to identify the area containing the color edge, and the identified area containing the color edge is the target area.
  • the color edge is the edge of a certain color that appears at the junction of the target with a large brightness difference, such as the color edge marked by the black dotted line shown in Figure 2, and the color edge marked by the black dotted line appears next to the building.
  • the target may be a human, an animal, or a plant, which is not specifically limited here.
  • the target image is a color image, and each pixel in the target image contains a color value.
  • the color value includes a red value, a green value, and a blue value. Since the red value, green value, and blue value of each pixel point Different, so each pixel presents a different color.
  • Color value which is the color component value corresponding to the color component.
  • the color components in the target image include red, green and blue components.
  • the red value is the red component value corresponding to the red component
  • the green value is the green component value corresponding to the green component
  • the blue value is the blue component value corresponding to the blue component.
  • the red component is represented by R
  • the value of the red component is 128, that is, the red value is 128.
  • the step 100 of obtaining the color value of the target pixel in the target image includes:
  • Step 101 for a target pixel in a target image, obtain a preliminary color value of the target pixel.
  • the color value of the target pixel in the target image is the preliminary color value.
  • the color space of the target image is YUV space
  • the target pixel in the target The color values of the pixels are the brightness value Y, the first color difference value U and the second color difference value V.
  • Step 102 performing color space conversion on the preliminary color value of the target pixel to obtain the color value of the target pixel.
  • the target pixel The preliminary color value is transformed into the color space to obtain the color value of the target pixel.
  • the target image since the target image may not be an RGB image, the preliminary color value of the target image is obtained, and then the preliminary color value is converted according to the conversion relationship of the color space to obtain the color value of the target pixel.
  • Step 200 calculating the difference between the red value and the green value of the target pixel to obtain the red-green difference, and calculating the difference between the blue value and the green value of the target pixel to obtain the blue-green difference value.
  • Step 300 Determine the color of the pixel according to the color value of the target pixel, the difference between red and green, and the difference between blue and green.
  • the color of the target pixel can be determined according to the color value, red-green difference, and blue-green difference of the target pixel.
  • this method can also identify reddish or bluish colors. For example, to identify purple, relying solely on the color value to identify purple may only identify pure purple. For example, when the red value is in a certain range, the green value is in a certain range, and the blue value is in a certain range, it is considered to be purple. The recognition accuracy of such a recognition method for purple is not high.
  • the method for determining the color edge pixels in the image provided in the embodiment of the present application combines the difference between red and green and the difference between blue and green to recognize purple, so that the reddish purple The bluish purple is also recognized, which makes the recognition of purple more flexible and avoids the omission of color edge pixels to a certain extent.
  • Step 400 when the color of the target pixel is a color fringe color, determine whether the target pixel is a color fringe pixel in the target image according to the gradient values of the target pixel in multiple preset directions point, the color fringe pixel point is a pixel point in the color fringe in the target image.
  • Color edge color is the color of the color edge.
  • the pixels in the color edge usually show a relatively consistent color. For example, if the color edge is purple, the color edge color is purple, that is, the pixels in the color edge are basically all purple; For example, if the color edge is blue, the color edge color is blue.
  • the preset direction is the preset direction.
  • the preset directions are 0° direction, 90° direction, 180° direction and 270° direction.
  • the gradient value in the preset direction reflects the magnitude of the gradient in the preset direction.
  • the method for determining the color edge pixel in the above image after determining the color value of the pixel, also determines the red-green difference and the blue-green difference according to the color value, compared to determining the pixel point simply based on the color value
  • the way of color this way can identify the reddish color and the bluish color, which makes the color recognition more flexible, and avoids the omission of color edge pixels to a certain extent.
  • the color edge appears in the At the junction where the brightness difference is large, there must be a certain gradient at these positions. Therefore, after determining that the color of the pixel point is the color edge color, it is further determined whether the pixel point is a color edge color according to the gradient values of multiple preset directions. Pixels, to a certain extent, improve the recognition rate of color edge pixels.
  • determining whether the target pixel is a color fringe pixel in the target image according to the gradient values of the target pixel in multiple preset directions in step 400 includes:
  • Step 40A judging whether the gradient value of the target pixel point in the corresponding preset direction is valid.
  • the purpose of judging whether the gradient value in a preset direction is valid is to judge whether there is a highlighted pixel in the preset direction, so as to determine whether the target pixel is a color fringe according to the judging result of the highlighted pixel pixel, and, when the target pixel is a color edge pixel, determine the search direction of the corrected pixel corresponding to the target pixel.
  • a method for determining whether the gradient value is valid including: obtaining a threshold gradient value; for each preset direction, comparing the gradient value of the preset direction with the threshold gradient value; if the preset direction If the gradient value is greater than or equal to the threshold gradient value, it is determined that the gradient value in the preset direction is valid, that is, there are highlighted pixels in the preset direction; if the gradient value in the preset direction is smaller than the threshold gradient value, it is determined that the gradient value in the preset direction is The gradient value in the preset direction is invalid, that is, there are no highlighted pixels in the preset direction.
  • Step 40B determining whether the target pixel is a color fringe pixel in the target image according to whether the gradient values of the target pixel in multiple preset directions are valid.
  • the target pixel is a color edge pixel in the target image.
  • ⁇ d_x indicates that the preset direction is that the gradient value in the x direction is invalid;
  • d_x indicates that the preset direction is that the gradient value in the x direction is valid; when "&&" and "
  • the gradient values of the four preset directions around the target pixel are valid, and the target pixel is considered to be surrounded by a highlighted area, not a color edge pixel; for the second to thirteenth cases, multiple In the preset directions, not all the gradient values of the preset directions are valid, and the color edge pixels are pixels at the junction of large brightness differences. Therefore, when there are multiple preset directions, not all preset When the gradient values in both directions are valid, the target pixel is considered to be a color edge pixel located in the color edge.
  • the above-mentioned embodiment provides a method for determining the color edge pixel point, judging whether the gradient value of the pixel point in the corresponding preset direction is valid according to the gradient value, and if it is valid, it is considered that there is a highlighted pixel in the preset direction point, so as to determine whether the pixel point is a color edge pixel point according to whether the gradient values in multiple preset directions are valid.
  • the determination in step 40A whether the gradient value of the target pixel point in the corresponding preset direction is valid includes:
  • step 40A1 a plurality of gradient groups are obtained, and the gradient groups include preset gradient values and preset brightness values.
  • the preset gradient value is a preset gradient value; the preset brightness value is a preset brightness value.
  • T i (t i , L i ) represents the i-th gradient group among multiple gradient groups, where t i represents the preset gradient value in the i -th gradient group, and Li represents the i-th gradient group Preset brightness value in gradient group.
  • Each of the multiple gradient groups includes preset gradient values and preset brightness values, and the preset gradient values and preset brightness values included in each gradient group are different.
  • the purpose of setting the gradient group in advance is to compare the gradient value of the target pixel point in a preset direction and the brightness value of the target pixel point with the preset gradient value and preset brightness value in the gradient group, so as to determine by comparison Whether the gradient value in the preset direction is valid.
  • Step 40A2 comparing the gradient value of the target pixel point in the target preset direction with the preset gradient value in the target gradient group to obtain the target gradient value of the target pixel point in the target preset direction
  • the target gradient group is a gradient group to be compared among the plurality of gradient groups
  • the preset target direction is a preset direction to be compared among the plurality of preset directions.
  • the gradient group to be compared refers to the gradient group that has not yet participated in the comparison among the multiple gradient groups when judging whether the gradient value in the target preset direction is valid according to the gradient group. For example, set up three gradient groups, T 1 (t 1 ,L 1 ), T 2 (t 2 ,L 2 ) and T 3 (t 3 ,L 3 ), where T 1 (t 1 ,L 1 ) has completed the comparison, so the gradient groups to be compared are T 2 (t 2 , L 2 ) and T 3 (t 3 , L 3 ), and T 2 (t 2 , L 2 ) and T 3 (t 3 , L 3 ), for example, T 2 (t 2 , L 2 ) as the target gradient group.
  • the preset direction to be compared is a preset direction that has not participated in the comparison among the multiple preset directions.
  • the multiple preset directions are 0° direction, 90° direction, 180° direction and 270° direction, wherein, the 0° direction and 90° direction have been compared, and the preset direction to be compared is 180° ° direction and 270° direction, therefore, one of the 180° direction and the 270° direction, for example, the 270° direction is used as the target preset direction.
  • Step 40A3 comparing the brightness value of the target pixel point with the preset brightness value in the target gradient group to obtain a comparison result of the brightness of the target pixel point in the target gradient group in the target preset direction.
  • Brightness comparison result which is the comparison result of the brightness value.
  • Step 40A4 determine whether the gradient value of the target pixel point in the target preset direction is determined according to the gradient comparison results and brightness comparison results of the plurality of gradient groups in the target preset direction efficient.
  • the preset direction of the target is 90°
  • the gradient value of the target pixel point in the 90° direction is 43
  • the brightness value of the target pixel point is 167.
  • the gradient comparison result of gradient group T 1 is 43>20
  • the brightness comparison result is 167 ⁇ 200
  • the gradient comparison result of gradient group T 2 is 43>20
  • the brightness comparison result is 167>200.
  • the gradient value of the pixel point in the target preset direction can be determined according to the gradient comparison result and brightness comparison result of the target gradient group If it is valid, the remaining gradient groups to be compared in the multiple gradient groups will not be compared.
  • the preset direction of the target is 90°
  • the gradient value of the target pixel in the 90° direction is 43
  • the brightness value of the target pixel is 207.
  • T 1 (20,200) and T 2 (40,160) There are two gradient groups in total, namely T 1 (20,200) and T 2 (40,160), the gradient comparison result of the gradient group T 1 is 43>20, and the brightness comparison result is 207>200, so the gradient of the target pixel point in the 90° direction can be judged according to the first gradient group T 1
  • the value is valid, no need to judge the gradient group T2.
  • the actual pixel point to be corrected (the pixel point in the center of the detection window, that is, the target pixel point)
  • the brightness may be relatively low, and the pixel to be corrected is between the bright area and the dark area (the area where the target is located, and the brightness of this area is relatively low), so theoretically, the brightness of the pixel to be corrected is different. will be very low, therefore, judging whether the gradient value is valid in combination with the brightness will get a more accurate judgment result.
  • step 400 after determining whether the target pixel is a color fringe pixel in the target image according to the gradient values of the target pixel in a plurality of preset directions in step 400, it further includes:
  • Step 500 when the target pixel is a color edge pixel in the target image, correct the color value of the target pixel.
  • the target pixel is a color edge pixel
  • the target pixel is also corrected, so that the corrected target image is more realistic.
  • correcting the color value of the target pixel in step 500 includes:
  • Step 501 according to the gradient values of the target pixel in multiple preset directions, search for the corrected pixel corresponding to the target pixel.
  • the corrected pixel corresponding to the target pixel is a pixel used to correct the target pixel in the target image. It can be understood that the target pixel points are different, and the corrected pixel points corresponding to the target pixel points may be the same or different.
  • Step 502 correcting the color value of the target pixel according to the color value of the corrected pixel corresponding to the target pixel.
  • the color value of the corrected pixel point corresponding to the pixel point can be directly used as the color value of the pixel point, so as to restore the pixel point of the edge of the target.
  • the target pixel point is ps
  • the corrected pixel point corresponding to the target pixel point ps is p2
  • the red value, green value and blue value of p2 are directly used as the red value, green value and blue value of the target pixel point ps .
  • the correction of the color edge pixels is realized through the color value, so that the color of the corrected target pixel is similar to the color of the corrected pixel, so that the corrected target image is more realistic. .
  • step 400 after determining whether the target pixel is a color fringe pixel in the target image according to the gradient values of the target pixel in a plurality of preset directions in step 400, it further includes:
  • the target pixel is not a color fringe pixel in the target image
  • search the remaining pixels in the target image to determine whether the remaining pixel is a color fringe pixel in the target image point.
  • the remaining pixels are pixels that have not been searched in the target image, that is, pixels that have not been searched to determine whether they are color edge pixels.
  • correcting the color value of the target pixel according to the color value of the corrected pixel corresponding to the target pixel in step 502 includes:
  • Step 502A determine the target color component, the first remaining color component and the second remaining color component, the target color component, the first remaining color component and the second remaining color component are red component, green component and blue component respectively One of the color components.
  • the target color component is one of the red component, the green component and the blue component; the first remaining color component is a color component except the target color component among the red component, the green component and the blue component; the second remaining color component is is the color component except the target color component and the first remaining color component among the red component, the green component and the blue component.
  • the purpose of determining the target color component is to ensure that the brightness of the target pixel after correction will not change greatly compared with the brightness before correction.
  • any one of the red component, green component, and blue component can be used as the basis of the target color component because the color edge usually appears at the junction of a large difference in brightness, and then covers the edge of a darker target.
  • the brightness is darker, so the values of the red component, green component and blue component of the pixel in the target will not be very large, so no matter which one of the red component, green component and blue component is used as the target color component,
  • the difference between the calculated first difference and the second difference will not be very large, and then based on the first difference and the second difference, the first remaining color component and the second remaining color component of the color edge pixel are Correction, so that the brightness of the corrected color fringe pixels will not change greatly, so as not to change the brightness too much, so that the color fringe cannot make a smooth transition between the highlight area and the target area, resulting in a gap between the highlight area and the target area. areas where there is a noticeable change in brightness.
  • Step 502B calculating the difference between the color component value corresponding to the target color component in the corrected pixel point and the color component value corresponding to the first remaining color component in the corrected pixel point, to obtain a first difference value.
  • the first difference is the difference between the target color component in the corrected pixel and the color component value corresponding to the first remaining color component. For example, if the target color component is a red component, and the first remaining color component is a blue component, then the color component value corresponding to the red component of the corrected pixel point (assumed to be 60) and the color component value corresponding to the blue component (assumed to be 45) has a difference of 15, that is, the first difference is 15.
  • Step 502C calculating the difference between the color component value corresponding to the target color component in the corrected pixel point and the color component value corresponding to the second remaining color component in the corrected pixel point, to obtain a second difference value.
  • the second difference is the difference between the target color component in the corrected pixel and the color component value corresponding to the second remaining color component. For example, if the second remaining color component is the green component, then the difference between the color component value corresponding to the red component of the corrected pixel point (assumed to be 60) and the color component value corresponding to the green component (assumed to be 40) is calculated to be 20, namely The second difference is 20.
  • Step 502D calculating the difference between the color component value corresponding to the target color component of the target pixel point and the first difference value, to obtain the color component value corresponding to the first remaining color component of the target pixel point.
  • the first remaining color component of the pixel to be corrected is corrected. For example, if the color component value corresponding to the target color component (red component) of the pixel to be corrected is 70, and the first difference value is 15, then after correction, the color corresponding to the first remaining color component (blue component) of the pixel point The component value is 55.
  • the color value ranges from 0 to 255, if the calculated color component value corresponding to the first remaining color component of the pixel is greater than 255, set the color component value corresponding to the first remaining color component of the pixel to 255 ; If the calculated color component value corresponding to the first remaining color component of the pixel is less than 0, set the color component value corresponding to the first remaining color component of the pixel to 0.
  • Step 502E calculating the difference between the color component value corresponding to the target color component of the target pixel point and the second difference value, to obtain the color component value corresponding to the second remaining color component of the target pixel point.
  • the second remaining color component of the pixel to be corrected is corrected. For example, if the color component value corresponding to the target color component (red component) of the pixel to be corrected is 70, and the second difference is 20, then after correction, the color component value corresponding to the second remaining color component (green component) of the pixel point for 50.
  • the color component value corresponding to the second remaining color component of the pixel is set to 255; if the calculated second remaining color of the pixel If the color component value corresponding to the component is less than 0, then the color component value corresponding to the second remaining color component of the pixel is set to 0.
  • the color component value corresponding to the target color component of the pixel to be corrected is 70, then the color component value corresponding to the red component of the pixel is 70 before and after correction.
  • the target color component is first determined, and then the color component value corresponding to the target color component of the target pixel is kept unchanged during the process of correcting the color value of the target pixel, that is, the brightness of the pixel is guaranteed to remain unchanged , and then correct the color component values corresponding to the first remaining color component and the second remaining color component of the pixel, so that the brightness of the pixel after correction will not be too different from the brightness before correction, so that the correction There will be no obvious brightness difference area in the color fringe (considering that it is impossible to identify all the color fringe pixels in the color fringe, that is, the recognition of color fringe pixels may be missed, then, if the correction pixel is directly The color value of the point is corrected as the color value of the pixel to be corrected.
  • step 501 searching for the corrected pixel corresponding to the target pixel according to the gradient values of the target pixel in multiple preset directions includes:
  • Step 501A determine the search direction of the correction pixel corresponding to the target pixel according to whether the gradient values of the target pixel in multiple preset directions are valid.
  • the reverse direction of the preset direction where the gradient value is valid is determined as the search for the corrected pixel direction. Specifically, as shown in Table 1.
  • Step 501B searching for the correction pixel corresponding to the target pixel within the preset pixel range in the search direction.
  • Preset pixel range is the preset pixel range.
  • the pixel range refers to the number of pixels. For example, if the preset pixel range is 5, and the search direction is 0° direction, then search and correct pixel points within the range of 5 pixels in the 0° direction.
  • the above embodiment provides a search method for corrected pixel points. Firstly, the search direction is determined according to whether the gradient value is valid, and then the corrected pixel points are searched in the search direction. Since whether the gradient value is effective or not reflects whether there is a highlighted pixel point in the corresponding preset direction, the search direction of the corrected pixel point can be determined based on whether the gradient value is valid or not.
  • the step 501B of searching for the corrected pixel corresponding to the pixel within the preset pixel range in the search direction includes:
  • a pixel point whose color is a non-color edge color that appears for the first time within the preset pixel range in the search direction is determined as the corrected pixel point corresponding to the pixel point.
  • the color fringe pixel to be corrected is ps
  • the search direction is the 0° direction
  • the preset pixel range is 5
  • the pixel that appears for the first time in the 0° direction is a non-color fringe color is pixel P2 , so P2 is taken as the corrected pixel corresponding to the target pixel ps.
  • the pixels whose color is not the color fringe color are not color fringe pixels, and can be used to correct the color fringe pixels.
  • the advantage of determining the first-appearing pixel that is a non-color edge color as the corrected pixel corresponding to the pixel is to reduce the amount of calculation and improve the correction accuracy. It can be understood that the closer the pixel is to the color edge The pixels of the color edge should be more similar to the color edge pixels, and the farther away from the color edge pixels, the less similar to the color edge pixels. Therefore, when a pixel with a color other than a color edge color appears for the first time, directly Set to rectify pixels, which can reduce the amount of calculation and improve the accuracy of correction.
  • step 400 before determining whether the target pixel is a color fringe pixel in the target image according to the gradient values of the target pixel in multiple preset directions in step 400, it further includes:
  • Step 600 calculating the brightness value of the target pixel point according to the color value of the target pixel point.
  • the brightness value reflects the brightness of the target pixel point.
  • a method for calculating the brightness value of a target pixel including: obtaining a red weight, a green weight, and a blue weight, wherein the sum of the red weight, the green weight, and the blue weight is 1; combining the red weight with Multiply the red value of the target pixel to obtain the red brightness; multiply the green weight by the green value of the target pixel to obtain the green brightness; multiply the blue weight by the blue value of the target pixel to obtain the blue brightness; The red brightness, green brightness and blue brightness are summed to obtain the brightness value of the target pixel.
  • the values of w1, w2 and w3 are all 1/3, that is, the brightness value is obtained by averaging the red value, the green value and the blue value.
  • Step 700 acquiring a preset brightness value and a maximum brightness value of the target pixel point in each preset direction in the plurality of preset directions.
  • the preset brightness value is a preset brightness value. Because the color fringe appears at the boundary where the brightness difference is large, therefore, a brightness value is set in advance to check whether there are pixels with higher brightness around the target pixel, and then judge whether the target pixel is a color fringe pixel. Since there is a region with higher brightness around the color edge, the preset brightness value can be set relatively larger.
  • a method for determining a preset brightness value including: acquiring multiple images of a target scene captured by a camera; acquiring the color values of pixels in a highlighted area around the color fringe in each image; The color value of the pixel point in the highlighted area around the color edge in the image to obtain the preset brightness value.
  • the above-mentioned method for determining the preset brightness value obtains multiple images for the target scene, and then calculates the preset brightness value based on the multiple images, which can obtain the preset brightness values of the same camera in different target scenes, and improve the performance of the same camera in different target scenes. Accuracy of determination of preset brightness values under different target scenes.
  • multiple preset directions are 0° direction, 45° direction, 90° direction, 135° direction, 180° direction, 225° direction, 270° direction, 315° direction, compared to simple setting 4
  • the maximum brightness value in the preset direction is the maximum value of brightness values in the preset direction.
  • the brightness value of each pixel point in the preset direction is calculated to obtain the brightness value of each pixel point in the preset direction.
  • set a larger detection window such as a detection window with a size of 11 ⁇ 11, with the pixel point whose color is the color edge color as the center, and then detect the pixel points in each preset direction covered by the detection window
  • the luminance value is calculated to obtain the maximum luminance value in each preset direction.
  • a method for determining the size of the detection window including: acquiring multiple images of the target scene captured by the camera; determining the pixel width of the color fringe in each image; Get the size of the detection window.
  • determining the pixel width of the color fringe in each image includes: for each image, determining the maximum pixel width and the minimum pixel width of the color fringe; multiplying the first width weight by the maximum pixel width to obtain the first pixel width; The second width weight is multiplied by the minimum pixel width to obtain the second pixel width; the first pixel width and the second pixel width are summed to obtain the summation result; the pixel width of the color edge in the image is obtained according to the summation result, wherein, The sum of the first width weight and the second width weight is one.
  • the maximum pixel width and the minimum pixel width are 5 and 3 respectively
  • the weight of the first width is 0.6
  • the weight of the second width is 0.4
  • the summation result of the first width and the second width is 4.2
  • the summation result is rounded to obtain the pixel width of the color fringe as 4.
  • the size of the detection window is obtained according to the pixel width of the color fringe in the multiple images, including: calculating the average value of the pixel width of the color fringe in the multiple images, and obtaining the size of the detection window according to the average value of the pixel width of the color fringe in the multiple images .
  • obtaining the size of the detection window according to the average value of the pixel width of the color fringe in the multiple images includes: multiplying the average value of the pixel width of the color fringe in the multiple images by 2 and adding 1 to obtain the size of the detection window.
  • Step 800 comparing the maximum luminance value of the target pixel point in each preset direction in the plurality of preset directions with the preset luminance value to obtain the target pixel point in the plurality of preset directions. Gradient weights in each of the preset directions.
  • the maximum brightness value of the target pixel point in the preset direction is greater than or equal to the preset brightness value, then determine the gradient weight of the target pixel point in the preset direction as the first weight; if the target If the maximum brightness value of the pixel point in the preset direction is smaller than the preset brightness value, then it is determined that the gradient weight of the target pixel point in the preset direction is the second weight.
  • the first weight is greater than the second weight, for example, the first weight is 0.9, and the second weight is 0.1; for another example, the first weight is 1, and the second weight is 0, that is, when the maximum brightness value is less than the preset brightness value , thinking that no highlighted pixel can be found in the preset direction.
  • Step 9000 comparing the maximum luminance value of the target pixel point in each preset direction in the plurality of preset directions with the luminance value of the target pixel point to obtain the target pixel point in the Preliminary gradient values in each of the plurality of preset directions.
  • the brightness value of the target pixel point is subtracted from the maximum brightness value of the target pixel point in the preset direction to obtain a preliminary gradient value of the target pixel point in the preset direction.
  • Step 1000 Multiply the gradient weight of the target pixel point in each preset direction in the plurality of preset directions by the preliminary gradient value of the target pixel point in the corresponding preset direction to obtain the The gradient value of the target pixel point in each preset direction in the plurality of preset directions.
  • compare is to compare p_max and grad_det_I.
  • p_max is greater than or equal to grad_det_I
  • the output of compare is the first weight.
  • p_max is less than grad_det_I
  • the output of compare is the second weight.
  • the above embodiment provides a method for calculating the gradient value of a pixel point in each preset direction. Since the color fringe usually appears at the junction where there is a large difference in brightness, the gradient value is calculated based on the brightness of the pixel to improve the accuracy of judging the color fringe pixel.
  • determining the color of the pixel according to the color value, the red-green difference value and the blue-green difference value of the pixel point in step 300 includes:
  • step 301 a plurality of color groups are obtained, and the color groups include a preset blue value, a preset red-green difference value, and a preset blue-green difference value.
  • the preset blue value is the preset blue value; the preset red-green difference value is the preset red-green difference value; the preset blue-green difference value is the preset blue-green difference value.
  • Y i (BL i , RG i , BG i ) represents the i-th color group among the multiple color groups, where BL i represents the preset blue value in the i-th color group, and RG i Indicates the preset red-green difference value in the i-th color group, and BG i represents the preset blue-green difference value in the i-th color group.
  • set 6 color groups namely: Y 1 (BL 1 ,RG 1 ,BG 1 ), Y 2 (BL 2 ,RG 2 ,BG 2 ), Y 3 (BL 3 ,RG 3 , BG 3 ), Y 4 (BL 4 , RG 4 , BG 4 ), Y 5 (BL 5 , RG 5 , BG 5 ), Y 6 (BL 6 , RG 6 , BG 6 ).
  • Step 302 comparing the blue value of the pixel with the preset blue value in the target color group to obtain a blue comparison result corresponding to the target color group, the target color group being the plurality of colors A color group in the group to be compared.
  • the color group to be compared is a color group that has not participated in the comparison among the multiple color groups.
  • the color groups that have not participated in the comparison are Y 5 (BL 5 , RG 5 , BG 5 ) and Y 6 (BL 6 , RG 6 , BG 6 ), so the color group to be compared is Y 5 (BL 5 , RG 5 , BG 5 ), Y 6 (BL 6 , RG 6 , BG 6 ), use one of the color groups to be compared, for example, Y 5 (BL 5 , RG 5 , BG 5 ), as Target color group.
  • the blue comparison result is the comparison result of the blue value.
  • Step 303 comparing the red-green difference value of the pixel with the preset red-green difference value in the target color group to obtain a red-green comparison result corresponding to the target color group.
  • the red-green comparison result is the comparison result of the difference between red and green.
  • Step 304 comparing the blue-green difference value of the pixel with the preset blue-green difference value in the target color group to obtain a blue-green comparison result corresponding to the target color group.
  • the blue-green comparison result is the comparison result of the blue-green difference.
  • Step 305 Determine the color of the pixel according to the blue comparison results, red-green comparison results, and blue-green comparison results corresponding to the plurality of color groups.
  • the blue value of a pixel is represented by b
  • the red-green difference of a pixel is represented by rg
  • the blue-green difference of a pixel is represented by bg
  • BL 4 BL 1
  • BG 4 BG 1
  • BL 5 BL 2
  • BG 5 BG 2
  • BL 6 BL 3
  • BG 6 BG 3
  • Three levels are set, and two levels are set for the difference between red and green, so as to obtain 6 color groups, so:
  • the 6 color groups are set as follows:
  • set the red-green difference RG 1 , RG 2 and RG 3 in the color group to be larger, so that the color group can detect the reddish purple color edge, the larger the RG 1 , RG 2 and RG 3 , the more Prefer to detect reddish purple color edges, for example, set RG 1 , RG 2 and RG 3 to 0; or, set the red-green difference in the color group RG 4 , RG 5 and RG 6 to be smaller, Enables the color group to detect bluish purple color edges, the smaller the RG 4 , RG 5 and RG 6 , the more inclined to detect bluish purple color edges, for example, set RG 4 , RG 5 and RG 6 to 200 Or 255.
  • multiple color groups are preset, and the color of the pixel is determined according to the blue comparison results, red-green comparison results, and blue-green comparison results corresponding to the multiple color groups. Red or bluish colors are recognized, which improves the color recognition rate.
  • determining the color of the pixel according to the blue comparison results, red-green comparison results, and blue-green comparison results corresponding to the multiple color groups in step 305 includes:
  • the blue comparison result corresponding to the target color group meets the first condition
  • the red-green comparison result corresponding to the target color group meets the second condition
  • the blue-green comparison result corresponding to the target color group meets the third condition
  • the first condition is the condition that the blue comparison result in the target color group should meet;
  • the second condition is the condition that the red-green comparison result in the target color group should meet;
  • the third condition is the target color A condition that the blue-green comparison result in the group should satisfy. Therefore, the target color groups are different, and the first condition, the second condition and the third condition corresponding to the target color groups may be different.
  • the target color group is Y 1 (BL 1 , RG 1 , BG 1 ), RG 1 is an integer between h3 and h4, so the first condition is: the blue value of the target pixel is greater than the target The preset blue value in the color group; the second condition is: the red-green difference of the target pixel is greater than the preset red-green difference in the target color group; the third condition is: the blue-green difference of the target pixel is greater than The preset blue-green delta value in the target color group.
  • the target color group is Y 6 (BL 6 , RG 6 , BG 6 ), where RG 6 is an integer between h1 and h2, h3>0, h4>0, h3 ⁇ h4, h4 ⁇ h1, Therefore, the first condition is: the blue value of the target pixel is greater than the preset blue value in the target color group; the second condition is: the red-green difference of the target pixel is greater than the preset red-green difference in the target color group value; the third condition is: the blue-green difference value of the target pixel is smaller than the preset blue-green difference value in the target color group.
  • a device 5 for determining color fringe pixels in an image including:
  • the obtaining module 51 may be configured to obtain the color value of the target pixel in the target image, the color value including a red value, a green value and a blue value;
  • the calculation module 52 may be configured to calculate the difference between the red value and the green value of the target pixel to obtain the red-green difference, and calculate the difference between the blue value and the green value of the target pixel value, get the blue-green difference;
  • the determination module 53 may be configured to determine the color of the pixel point according to the color value, red-green difference value and blue-green difference value of the target pixel point;
  • the color fringe module 54 may be configured to determine whether the target pixel is the color fringe color according to the gradient values of the target pixel in multiple preset directions when the color of the target pixel is A color fringe pixel in the target image, the color fringe pixel being a pixel in the color fringe in the target image.
  • the above-mentioned device for determining the color edge pixel in the image after determining the color value of the pixel, also determines the difference between red and green and the difference between blue and green according to the color value, compared with determining the pixel point simply based on the color value
  • the way of color this way can identify the reddish color and the bluish color, which makes the color recognition more flexible, and avoids the omission of color edge pixels to a certain extent.
  • the color edge appears in the At the junction where the brightness difference is large, there must be a certain gradient at these positions. Therefore, after determining that the color of the pixel point is the color edge color, it is further determined whether the pixel point is a color edge color according to the gradient values of multiple preset directions. Pixels, to a certain extent, improve the recognition rate of color edge pixels.
  • the color fringing module 54 can be configured to: determine whether the gradient value of the target pixel point in the corresponding preset direction is valid; Whether the gradient value above is valid determines whether the target pixel is a color edge pixel in the target image.
  • the color fringing module 54 can be configured to: obtain a plurality of gradient groups, and the gradient groups include preset gradient values and preset brightness values; Comparing the gradient value in the set direction with the preset gradient value in the target gradient group to obtain the gradient comparison result of the target gradient group of the target pixel point in the target preset direction, the target gradient group is the A gradient group to be compared in a plurality of gradient groups, the target preset direction is a preset direction to be compared in the plurality of preset directions; the brightness value of the target pixel point is compared with the target The preset brightness values in the gradient group are compared to obtain the brightness comparison result of the target gradient group of the target pixel point in the target preset direction; according to the target pixel point in the target preset direction The gradient comparison results and the brightness comparison results of the plurality of gradient groups determine whether the gradient value of the target pixel point in the target preset direction is valid.
  • the device 5 further includes: a correction module, configured to correct the color value of the target pixel when the target pixel is a color edge pixel in the target image Make corrections.
  • a correction module configured to correct the color value of the target pixel when the target pixel is a color edge pixel in the target image Make corrections.
  • the correction module may be configured to: search for the corrected pixel corresponding to the target pixel according to the gradient values of the target pixel in multiple preset directions; The color value of the corrected pixel point corresponding to the point corrects the color value of the target pixel point.
  • the correction module may be configured to: determine the target color component, the first remaining color component and the second remaining color component, the target color component, the first remaining color component and the The second remaining color components are respectively one of the red component, the green component and the blue component; calculating the color component value corresponding to the target color component in the corrected pixel corresponds to the first remaining color component in the corrected pixel The difference value of the color component value of the first difference value is obtained; the difference between the color component value corresponding to the target color component in the corrected pixel point and the color component value corresponding to the second remaining color component in the corrected pixel point is calculated value to obtain the second difference; calculate the difference between the color component value corresponding to the target color component of the target pixel and the first difference, and obtain the color component corresponding to the first remaining color component of the target pixel value; calculating the difference between the color component value corresponding to the target color component of the target pixel point and the second difference value, to obtain the color component value corresponding to the second remaining color component of the target pixel point.
  • the correction module may be configured to: determine the search direction of the corrected pixel corresponding to the target pixel according to whether the gradient values of the target pixel in multiple preset directions are valid; The corrected pixel corresponding to the target pixel is searched within a preset pixel range in the search direction.
  • the rectification module may be configured to: determine the first pixel in the preset pixel range in the search direction that is a non-color edge color as the pixel corresponding to the pixel. Correct the pixels.
  • the device 5 further includes: a gradient value determination module, which may be configured to: calculate the brightness value of the target pixel point according to the color value of the target pixel point; obtain a preset brightness value and The maximum brightness value of the target pixel point in each preset direction of the multiple preset directions; the maximum brightness value of the target pixel point in each preset direction of the multiple preset directions Comparing the luminance value with the preset luminance value to obtain the gradient weight of the target pixel point in each of the multiple preset directions; Comparing the maximum luminance value in each preset direction in the set direction with the luminance value of the target pixel to obtain a preliminary Gradient value; multiply the gradient weight of the target pixel point in each preset direction in the plurality of preset directions and the preliminary gradient value of the target pixel point in the corresponding preset direction to obtain the The gradient value of the target pixel point in each preset direction in the plurality of preset directions.
  • a gradient value determination module which may be configured to: calculate the brightness value of the target pixel point according to the
  • the gradient value determining module can be configured to: obtain a plurality of color groups, the color groups include a preset blue value, a preset red-green difference value and a preset blue-green difference value ; Comparing the blue value of the pixel with the preset blue value in the target color group to obtain a blue comparison result corresponding to the target color group, the target color group being one of the plurality of color groups A color group to be compared; compare the red-green difference value of the pixel with the preset red-green difference value in the target color group to obtain the red-green comparison result corresponding to the target color group; The blue-green difference value of the pixel is compared with the preset blue-green difference value in the target color group to obtain the blue-green comparison result corresponding to the target color group; according to the blue comparison results corresponding to the plurality of color groups The result, the red-green comparison result and the blue-green comparison result determine the color of the pixel.
  • a computer device is provided, and the computer device may specifically be a terminal or a server.
  • the computer device includes a processor, a memory and a network interface connected through a system bus, the memory includes a non-volatile storage medium and an internal memory, and the non-volatile storage medium of the computer device stores an operating system and also stores a computer program
  • the processor can realize the method for determining color fringe pixels in the image.
  • Nonvolatile memory can include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
  • Volatile memory can include random access memory (RAM) or external cache memory.
  • RAM random access memory
  • RAM is available in many forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Chain Synchlink DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
  • a computer program may also be stored in the internal memory, and when the computer program is executed by the processor, the processor may execute the method for determining color fringe pixels in the image.
  • FIG. 6 is only a block diagram of a part of the structure related to the solution of this application, and does not constitute a limitation on the computer equipment to which the solution of this application is applied.
  • the specific computer equipment can be More or fewer components than shown in the figures may be included, or some components may be combined, or have a different arrangement of components.
  • the method for determining color fringe pixels in an image provided in this application can be implemented in the form of a computer program, and the computer program can be run on a computer device as shown in FIG. 6 .
  • Various program templates constituting the means for determining the color fringe pixels in the image can be stored in the memory of the computer equipment. For example, an acquisition module 51 , a calculation module 52 and a determination module 53 .
  • a computer device comprising a memory and a processor
  • the memory stores a computer program
  • the processor performs the following steps:
  • the color value of the target pixel in the target image comprising a red value, a green value and a blue value
  • the color fringe pixels are pixels in the color fringe in the target image.
  • a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the processor is made to perform the following steps:
  • the color value of the target pixel in the target image comprising a red value, a green value and a blue value
  • the color fringe pixels are pixels in the color fringe in the target image.
  • the method for determining the color fringe pixels in the image, the device for determining the color fringe pixels in the image, the computer equipment, and the computer-readable storage medium belong to a general inventive concept, and the color fringe pixels in the image
  • the content in the embodiments of the method for determining, the device for determining color fringe pixels in an image, the computer equipment, and the computer-readable storage medium are applicable to each other.
  • the disclosed devices and methods may be implemented in other ways.
  • the device embodiments described above are only illustrative.
  • the division of the units is only a logical function division.
  • multiple units or components can be combined or May be integrated into another system, or some features may be ignored, or not implemented.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be through some communication interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.
  • a unit described as a separate component may or may not be physically separated, and a component displayed as a unit may or may not be a physical unit, that is, it may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • each functional module in each embodiment of the present application may be integrated to form an independent part, each module may exist independently, or two or more modules may be integrated to form an independent part.
  • the present application provides a method for determining color edge pixels in an image, a determining device, and computer equipment.
  • the method includes: acquiring the color value of the target pixel in the target image; calculating the red value of the target pixel and the difference between the green value to obtain the red-green difference, and calculate the difference between the blue value and the green value of the target pixel to obtain the blue-green difference; according to the color value of the target pixel, The red-green difference value and the blue-green difference value determine the color of the pixel point; when the color of the target pixel point is a color edge color, the gradient value of the target pixel point in multiple preset directions is used to determine the Whether the target pixel is a color fringe pixel in the target image, and the color fringe pixel is a pixel in the color fringe in the target image.
  • the method, device and computer equipment for determining color fringe pixels in an image of the present application are reproducible and can be used in various industrial applications.
  • the method for determining color fringe pixels in an image, the determining device and the computer equipment of the present application can be used in the field of image processing.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Facsimile Image Signal Circuits (AREA)
  • Image Processing (AREA)
  • Image Analysis (AREA)

Abstract

A method and apparatus for determining a color fringe pixel point in an image and a computer device. The method comprises: obtaining a color value of a target pixel point in a target image (S100); calculating a difference between a red value and a green value of the target pixel point to obtain a red-green difference, and calculating a difference between a blue value and the green value of the target pixel point to obtain a blue-green difference (S200); determining the color of the pixel point according to the color value, the red-green difference, and the blue-green difference of the target pixel point (S300); and when the color of the target pixel point is a color fringe color, determining, according to gradient values of the target pixel point in multiple preset directions, whether the target pixel point is a color fringe pixel point in the target image or not, the color fringe pixel point being a pixel point in a color fringe in the target image (S400). By means of the method, color identification is more flexible, and omission of color fringe pixel points is avoided to a certain extent.

Description

图像中的色边像素点的确定方法、确定装置和计算机设备Determination method, determination device and computer equipment of color fringe pixels in image
相关申请的交叉引用Cross References to Related Applications
本申请要求于2021年06月10日提交中国国家知识产权局的申请号为202110650968.9、名称为“图像中的色边像素点的确定方法、装置和计算机设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application with the application number 202110650968.9 and titled "Method, Device and Computer Equipment for Determining Color Edge Pixels in Images" submitted to the State Intellectual Property Office of China on June 10, 2021. The entire contents are incorporated by reference in this application.
技术领域technical field
本申请涉及图像处理领域,具体而言,涉及一种图像中的色边像素点的确定方法、确定装置和计算机设备。The present application relates to the field of image processing, in particular, to a method, device and computer equipment for determining color fringe pixels in an image.
背景技术Background technique
数码相机在拍摄目标的过程中,目标在亮度差异较大的交界处容易出现紫色边缘的现象,这个现象的产生与RGB波长差异导致的进入镜头的折射率、图像传感器色彩插值算法及图像传感器本身的属性有关。When a digital camera shoots a target, the target is prone to purple edges at the junction of large brightness differences. This phenomenon is related to the refractive index entering the lens caused by the RGB wavelength difference, the image sensor color interpolation algorithm and the image sensor itself. properties are related.
高素质镜头一般都加入超低色散镜片来校正或者消除紫色边缘,但价格也高出许多,并且很多时候也不能百分百消除,所以仍然有必要利用算法去校正紫边现象。High-quality lenses generally add ultra-low dispersion lenses to correct or eliminate purple fringing, but the price is also much higher, and in many cases it cannot be completely eliminated, so it is still necessary to use algorithms to correct purple fringing.
传统的紫边算法对紫色识别比较单一,紫色识别精度较低。The traditional purple fringing algorithm is relatively simple for purple recognition, and the purple recognition accuracy is low.
发明内容Contents of the invention
本申请提出一种能够较好的识别色边像素点的图像中的色边像素点的确定方法、确定装置和计算机设备。The present application proposes a determination method, determination device and computer equipment of color fringe pixels in an image capable of better identifying color fringe pixels.
在一些实施方式中,本申请提供了一种图像中的色边像素点的确定方法,可以包括:In some implementations, the present application provides a method for determining color fringe pixels in an image, which may include:
获取目标图像中的目标像素点的颜色值,所述颜色值可以包括红色值、绿色值和蓝色值;Acquiring the color value of the target pixel in the target image, the color value may include a red value, a green value and a blue value;
计算所述目标像素点的红色值和绿色值之间的差值,得到红绿差值,计算所述目标像素点的蓝色值和绿色值之间的差值,得到蓝绿差值;calculating the difference between the red value and the green value of the target pixel to obtain a red-green difference, and calculating the difference between the blue and green values of the target pixel to obtain a blue-green difference;
根据所述目标像素点的颜色值、红绿差值和蓝绿差值确定所述像素点的颜色;determining the color of the pixel according to the color value of the target pixel, the difference between red and green, and the difference between blue and green;
当所述目标像素点的颜色为色边颜色时,根据所述目标像素点在多个预设方向上的梯度值确定所述目标像素点是否是所述目标图像中的色边像素点,所述色边像素点为所述目标图像中的色边中的像素点。When the color of the target pixel is a color fringe color, determine whether the target pixel is a color fringe pixel in the target image according to gradient values of the target pixel in a plurality of preset directions, The color fringe pixels are pixels in the color fringe in the target image.
上述图像中的色边像素点的确定方法,在确定像素点的颜色值之后,还可以根据颜色值确定了红绿差值和蓝绿差值,相较于单纯的根据颜色值来确定像素点的颜色的方式,这样的方式能够识别出偏红的颜色和偏蓝的颜色,使得对颜色的识别更加的灵活,在一定程度上避免了色边像素点的遗漏,最后考虑到色边是出现在亮度差异较大的交界处,这些位置必然存在一定的梯度,因此,在确定像素点的颜色为色边颜色之后,还可以根据多个预设方向的梯度值来进一步确定该像素点是否是色边像素点,在一定程度上提高了色边像素点的识别率。The method for determining the color edge pixels in the above image, after determining the color value of the pixel point, can also determine the red-green difference value and the blue-green difference value according to the color value, compared with simply determining the pixel point according to the color value In this way, reddish colors and bluish colors can be identified, which makes the identification of colors more flexible and avoids the omission of color edge pixels to a certain extent. Finally, considering the appearance of color edges At the junction where the brightness difference is large, there must be a certain gradient at these positions. Therefore, after determining that the color of the pixel point is the color edge color, it can be further determined whether the pixel point is Color edge pixels improve the recognition rate of color edge pixels to a certain extent.
在一个实施例中,所述根据所述目标像素点在多个预设方向上的梯度值确定所述目标像素点是否是所述目标图像中的色边像素点,可以包括:判断所述目标像素点在相应的预设方向上的梯度值是否有效;根据所述目标像素点在多个预设方向上的梯度值是否有效确定所述目标像素点是否是所述目标图像中的色边像素点。In one embodiment, the determining whether the target pixel is a color edge pixel in the target image according to the gradient values of the target pixel in multiple preset directions may include: judging that the target Whether the gradient value of the pixel point in the corresponding preset direction is valid; determine whether the target pixel point is a color edge pixel in the target image according to whether the gradient value of the target pixel point in multiple preset directions is valid point.
上述实施例,提供了一种确定色边像素点的方法,根据梯度值判断像素点在相应的预设方向上的梯度值是否有效,如果有效,则认为该预设方向上存在高亮的像素点,从而可以根据多个预设方向上的梯度值是否有效来确定像素点是否是色边像素点。The above-mentioned embodiment provides a method for determining the color edge pixel point, judging whether the gradient value of the pixel point in the corresponding preset direction is valid according to the gradient value, and if it is valid, it is considered that there is a highlighted pixel in the preset direction point, so that whether the pixel point is a color edge pixel point can be determined according to whether the gradient values in multiple preset directions are valid.
在一个实施例中,所述判断所述目标像素点在相应的预设方向上的梯度值是否有效,可以包括:获取多个梯度组,所述梯度组中包括预设梯度值和预设亮度值;将所述目标像素点在目标预设方向上的梯度值与目标梯度组中的预设梯度值进行比较,得到所述目标像素点在所述目标预设方向上的目标梯度组的梯度比较结果,所述目标梯度组可以为所述多个梯度组中的一个待比对梯度组,所述目标预设方向可以为所述多个预设方向中的一个待比对预设方向;将所述目标像素点的亮度值与所述目标梯度组中的预设亮度值进行比较,得到所述目标像素点在所述目标预设方向上的目标梯度组的亮度比较结果;根据所述目标像素点在所述目标预设方向上的所述多个梯度组的梯度比较结果和亮度比较结果确定所述目标像素点在所述目标预设方向上的梯度值是否有效。In one embodiment, the judging whether the gradient value of the target pixel point in the corresponding preset direction is valid may include: acquiring a plurality of gradient groups, the gradient groups including preset gradient values and preset brightness Value; compare the gradient value of the target pixel point in the target preset direction with the preset gradient value in the target gradient group to obtain the gradient of the target pixel point in the target gradient group in the target preset direction As a result of the comparison, the target gradient group may be a gradient group to be compared in the plurality of gradient groups, and the target preset direction may be a preset direction to be compared in the plurality of preset directions; Comparing the brightness value of the target pixel point with the preset brightness value in the target gradient group to obtain the brightness comparison result of the target pixel point in the target gradient group in the target preset direction; according to the The gradient comparison results and brightness comparison results of the plurality of gradient groups of the target pixel in the target preset direction determine whether the gradient value of the target pixel in the target preset direction is valid.
上述实施例,单纯的依靠梯度值来判断相应的预设方向上的梯度值是否有效可能并不准确,因为,实际的待矫正的像素点(检测窗口中心的像素点,即目标像素点)的亮度可能比较低,而待矫正的像素点是介于高亮区域和暗区域(目标所在的区域,该区域的亮度相对较低)之间的,所以理论上,待矫正的像素点的亮度不会很低,因此,结合亮度来判断梯度值是否有效将得到更加准确的判断结。In the above embodiment, it may not be accurate to simply rely on the gradient value to determine whether the gradient value in the corresponding preset direction is valid, because the actual pixel point to be corrected (the pixel point in the center of the detection window, that is, the target pixel point) The brightness may be relatively low, and the pixel to be corrected is between the bright area and the dark area (the area where the target is located, and the brightness of this area is relatively low), so theoretically, the brightness of the pixel to be corrected is different. will be very low, therefore, combining the brightness to judge whether the gradient value is valid will get a more accurate judgment result.
在一个实施例中,在所述根据所述目标像素点在多个预设方向上的梯度值确定所述目标像素点是否是所述目标图像中的色边像素点之后,还可以包括:当所述目标像素点是所述目标图像中的色边像素点时,对所述目标像素点的颜色值进行矫正。In one embodiment, after determining whether the target pixel is a color fringe pixel in the target image according to the gradient values of the target pixel in multiple preset directions, it may further include: when When the target pixel is a color edge pixel in the target image, the color value of the target pixel is corrected.
上述实施例,在目标像素点是色边像素点的时候,还可以对该目标像素点进行了矫正,使得矫正后的目标图像更加的真实。In the above embodiment, when the target pixel is a color edge pixel, the target pixel can also be corrected, so that the corrected target image is more realistic.
在一个实施例中,所述对所述目标像素点的颜色值进行矫正,可以包括:根据所述目标像素点在多个预设方向上的梯度值查找所述目标像素点对应的矫正像素点;根据所述目标像素点对应的矫正像素点的颜色值对所述目标像素点的颜色值进行矫正。In one embodiment, the correcting the color value of the target pixel may include: searching for the corrected pixel corresponding to the target pixel according to the gradient values of the target pixel in multiple preset directions ; Correcting the color value of the target pixel according to the color value of the corrected pixel corresponding to the target pixel.
上述实施例,通过颜色值实现了色边像素点的矫正,使得矫正后的目标像素点的颜色和矫正像素点颜色相似,从而使得矫正后的目标图像更加的真实。In the above embodiment, the correction of the color edge pixels is realized through the color value, so that the color of the corrected target pixel is similar to the color of the corrected pixel, so that the corrected target image is more realistic.
在一个实施例中,所述根据所述目标像素点对应的矫正像素点的颜色值对所述目标像素点的颜色值进行矫正,可以包括:确定目标颜色分量,第一剩余颜色分量和第二剩余颜色分量,所述目标颜色分量,所述第一剩余颜色分量和所述第二剩余颜色分量分别可以为红色分量、绿色分量以及蓝色分量中的一个;计算所述矫正像素点中的目标颜色分量对应的颜色分量值与所述矫正像素点中的第一剩余颜色分量对应的颜色分量值的差值,得到第一差值;计算所述矫正像素点中的目标颜色分量对应的颜色分量值与所述矫正像素点中的第二剩余颜色分量对应的颜色分量值的差值,得到第二差值;计算所述目标像素点的目标颜色分量对应的颜色分量值与所述第一差值的差值,得到所述目标像素点的第一剩余颜色分量对应的颜色分量值;计算所述目标像素点的目标颜色分量对应的颜色分量值与所述第二差值的差值,得到所述目标像素点的第二剩余颜色分量对应的颜色分量值。In one embodiment, the correcting the color value of the target pixel according to the color value of the corrected pixel corresponding to the target pixel may include: determining the target color component, the first remaining color component and the second The remaining color component, the target color component, the first remaining color component and the second remaining color component can be one of the red component, green component and blue component respectively; calculate the target in the corrected pixel The difference between the color component value corresponding to the color component and the color component value corresponding to the first remaining color component in the corrected pixel to obtain the first difference; calculate the color component corresponding to the target color component in the corrected pixel value and the color component value corresponding to the second remaining color component in the corrected pixel point to obtain the second difference value; calculate the color component value corresponding to the target color component of the target pixel point and the first difference Value difference, to obtain the color component value corresponding to the first remaining color component of the target pixel point; calculate the difference value between the color component value corresponding to the target color component of the target pixel point and the second difference value, to obtain The color component value corresponding to the second remaining color component of the target pixel.
上述实施例,首先确定了目标颜色分量,然后在对目标像素点的颜色值进行矫正的过程中,保持目标像素点的目标颜色分量对应的颜色分量值不变,即保证像素点的亮度不变,然后再对像素点的第一剩余颜色分量和第二剩余颜色分量对应的颜色分量值进行矫正,使得像素点在矫正后的亮度与矫正前的亮度不会出现过大的差异,进而使得矫正后的色边中不会出现明显的亮度差异区域(考虑到不可能将色边中的全部色边像素点都识别出来,即色边像素点的识别可能出现遗漏,那么,如果直接将矫正像素点的颜色值作为待矫正的像素点的颜色值来矫正,那么矫正后,如果还有未矫正的色边像素点,必然和矫正后的色边像素点出现明显的颜色差异,即色边仍然存在,因此,可以保持未矫正的色边像素点和矫正后的色边像素点的亮度差异不会太大,从而即使无法对所有的色边像素点进行矫正,也不会出现很大的亮度改变,从视觉上来看,色边在一定程度上被消除)。In the above-mentioned embodiment, the target color component is first determined, and then the color component value corresponding to the target color component of the target pixel is kept unchanged during the process of correcting the color value of the target pixel, that is, the brightness of the pixel is guaranteed to remain unchanged , and then correct the color component values corresponding to the first remaining color component and the second remaining color component of the pixel, so that the brightness of the pixel after correction will not be too different from the brightness before correction, so that the correction There will be no obvious brightness difference area in the color fringe (considering that it is impossible to identify all the color fringe pixels in the color fringe, that is, the recognition of color fringe pixels may be missed, then, if the correction pixel is directly The color value of the point is corrected as the color value of the pixel to be corrected. After correction, if there are still uncorrected color edge pixels, there must be obvious color differences from the corrected color edge pixels, that is, the color edge remains Therefore, the brightness difference between the uncorrected color fringe pixels and the corrected color fringe pixels will not be too large, so that even if all the color fringe pixels cannot be corrected, there will not be a large brightness change, from a visual point of view, the color fringing is eliminated to some extent).
在一个实施例中,所述根据所述目标像素点在多个预设方向上的梯度值查找所述目标像素点对应的矫正像素点,可以包括:根据所述目标像素点在多个预设方向上的梯度值是否有效确定所述目标像素点对应的矫正像素点的查找方向;在所述查找方向上的预设像素范围内查找所述目标像素点对应的矫正像素点。In one embodiment, the searching for the correction pixel corresponding to the target pixel according to the gradient values of the target pixel in multiple preset directions may include: according to the target pixel in multiple preset directions Whether the gradient value in the direction is effective determines the search direction of the corrected pixel corresponding to the target pixel; search for the corrected pixel corresponding to the target pixel within a preset pixel range in the search direction.
上述实施例,提供了一种矫正像素点的查找方法,首先根据梯度值是否有效确定查找方向,然后在该查找方向上查找矫正像素点。由于梯度值是否有效反映的是相应的预设方向上是否存在高亮像素点,因此,基于梯度值是否有效可以确定矫正像素点的查找方向。The above embodiment provides a search method for corrected pixel points. Firstly, the search direction is determined according to whether the gradient value is valid, and then the corrected pixel points are searched in the search direction. Since whether the gradient value is effective or not reflects whether there is a highlighted pixel point in the corresponding preset direction, the search direction of the corrected pixel point can be determined based on whether the gradient value is valid or not.
在一个实施例中,所述在所述查找方向上的预设像素范围内查找所述像素点对应的矫正像素点,可以包括:将在所述查找方向上的预设像素范围内首次出现的颜色为非色边颜色的像素点确定为所述像素点对应的矫正像素点。In an embodiment, the searching for the corrected pixel corresponding to the pixel within the preset pixel range in the search direction may include: first appearing in the preset pixel range in the search direction A pixel point whose color is a non-color edge color is determined as a corrected pixel point corresponding to the pixel point.
上述实施例,将首次出现的颜色为非色边颜色的像素点确定为像素点对应的矫正像素点的优势是减少计算量并且提高矫正准确率,可以理解的是,距离色边像素点越近的像素点与色边像素点应当更相似,距离色边像素点越远的像素点与色边像素点越不相似,因此,在首次出现颜色为非色边颜色的像素点时,直接将其设置为矫正像素点,减少计算量的同时还可以提高矫正准确率。In the above-mentioned embodiment, the advantage of determining the first-appearing pixel that is a non-color edge color as the corrected pixel corresponding to the pixel is to reduce the amount of calculation and improve the correction accuracy. It can be understood that the closer the pixel is to the color edge The pixels of the color edge should be more similar to the color edge pixels, and the farther away from the color edge pixels, the less similar to the color edge pixels. Therefore, when a pixel with a color other than a color edge color appears for the first time, directly Set to rectify pixels, which can reduce the amount of calculation and improve the accuracy of correction.
在一个实施例中,在所述根据所述目标像素点在多个预设方向上的梯度值确定所述目标像素点是否是所述目标图像中的色边像素点之前,还可以包括:根据所述目标像素点的颜色值计算所述目标像素点的亮度值;获取预设亮度值和所述目标像素点在所述多个预设方向中的每个预设方向上的最大亮度值;将所述目标像素点在所述多个预设方向中的每个预设方向上的最大亮度值与所述预设亮度值进行比较,得到所述目标像素点在所述多个预设方向中的每个预设方向上的梯度权重;将所述目标像素点在所述多个预设方向中的每个预设方向上的最大亮度值与所述目标像素点的亮度值进行比较,得到所述目标像素点在所述多个预设方向中的每个预设方向上的初步梯度值;将所述目标像素点在所述多个预设方向中的每个预设方向上的梯度权重和所述目标像素点在相应的预设方向上的初步梯度值相乘,得到所述目标像素点在所述多个预设方向中的每个预设方向上的梯度值。In one embodiment, before determining whether the target pixel is a color fringe pixel in the target image according to the gradient values of the target pixel in multiple preset directions, it may further include: according to calculating the brightness value of the target pixel from the color value of the target pixel; obtaining a preset brightness value and a maximum brightness value of the target pixel in each preset direction in the plurality of preset directions; Comparing the maximum luminance value of the target pixel point in each of the multiple preset directions with the preset luminance value to obtain the maximum brightness value of the target pixel point in the multiple preset directions Gradient weights in each preset direction; comparing the maximum brightness value of the target pixel point in each preset direction in the plurality of preset directions with the brightness value of the target pixel point, Obtaining the preliminary gradient value of the target pixel point in each preset direction in the plurality of preset directions; The gradient weight is multiplied by the preliminary gradient value of the target pixel point in the corresponding preset direction to obtain the gradient value of the target pixel point in each preset direction in the plurality of preset directions.
上述实施例,提供了一种计算像素点在各个预设方向上的梯度值的方法。由于色边通常出现在亮度差异较大的交界处,因此,可以基于像素点的亮度来计算梯度值,以提高色边像素点判断的准确率。The above embodiment provides a method for calculating the gradient value of a pixel point in each preset direction. Since the color fringe usually appears at the junction where the brightness difference is large, the gradient value can be calculated based on the brightness of the pixel to improve the accuracy of the color fringe pixel judgment.
在一个实施例中,所述根据所述像素点的颜色值、红绿差值和蓝绿差值确定所述像素点的颜色,可以包括:获取多个颜色组,所述颜色组中包括预设蓝色值、预设红绿差值和预设蓝绿差值;将所述像素点的蓝色值与目标颜色组中的预设蓝色值进行比较,得到所述目标颜色组对应的蓝色比较结果,所述目标颜色组为所述多个颜色组中的一个待比对颜色组;将所述像素点的红绿差值与所述目标颜色组中的预设红绿差值进行比较,得到所述目标颜色组对应的红绿比较结果;将所述像素点的蓝绿差值与所述目标颜色组中的预设蓝绿差值进行比较,得到所述目标颜色组对应的蓝绿比较结果;根据所述多个颜色组对应的蓝色比较结果、红绿比较结果和蓝绿比较结果确定所述像素点的颜色。In one embodiment, the determining the color of the pixel according to the color value of the pixel, the difference between red and green, and the difference between blue and green may include: obtaining a plurality of color groups, and the color groups include preset Set the blue value, the preset red-green difference value and the preset blue-green difference value; compare the blue value of the pixel with the preset blue value in the target color group to obtain the corresponding value of the target color group Blue comparison result, the target color group is a color group to be compared in the plurality of color groups; the red-green difference value of the pixel point and the preset red-green difference value in the target color group Comparing to obtain the red-green comparison result corresponding to the target color group; comparing the blue-green difference value of the pixel with the preset blue-green difference value in the target color group to obtain the corresponding The blue-green comparison result; determine the color of the pixel according to the blue comparison result, red-green comparison result and blue-green comparison result corresponding to the plurality of color groups.
上述实施例,可以预先设置多个颜色组,并且可以根据多个颜色组对应的蓝色比较结果、红绿比较结果和蓝绿比较结果确定像素点的颜色,能够对不同亮度的相同颜色,以及,偏红或者偏蓝的颜色进行识别,提高了颜色的识别率。In the above embodiment, a plurality of color groups can be preset, and the color of the pixel point can be determined according to the blue comparison results, red-green comparison results, and blue-green comparison results corresponding to the plurality of color groups, and the same color with different brightness can be compared, and , to identify reddish or bluish colors, which improves the color recognition rate.
在另一实施方式中,本申请提供了一种图像中的色边像素点的确定装置,可以包括:In another embodiment, the present application provides a device for determining color fringe pixels in an image, which may include:
获取模块,用于获取目标图像中的目标像素点的颜色值,所述颜色值可以包括红色值、绿色值和蓝色值;An acquisition module, configured to acquire the color value of the target pixel in the target image, the color value may include a red value, a green value and a blue value;
计算模块,可以配置成用于计算所述目标像素点的红色值和绿色值之间的差值,得到红绿差值,计算所述目标像素点的蓝色值和绿色值之间的差值,得到蓝绿差值;The calculation module may be configured to calculate the difference between the red value and the green value of the target pixel to obtain the red-green difference, and calculate the difference between the blue value and the green value of the target pixel , get the blue-green difference;
确定模块,可以配置成用于根据所述目标像素点的颜色值、红绿差值和蓝绿差值确定所述像素点的颜色;The determining module may be configured to determine the color of the pixel point according to the color value, red-green difference value and blue-green difference value of the target pixel point;
色边模块,可以配置成用于当所述目标像素点的颜色为色边颜色时,根据所述目标像素点在多个预设方向上的梯度值确定所述目标像素点是否是所述目标图像中的色边像素点,所述色边像素点为所述目标图像中的色边中的像素点。The color fringe module may be configured to determine whether the target pixel is the target according to gradient values of the target pixel in multiple preset directions when the color of the target pixel is a color fringe color A color fringe pixel in the image, the color fringe pixel being a pixel in the color fringe in the target image.
在一个实施例中,所述色边模块,可以配置成用于:判断所述目标像素点在相应的预设方向上的梯度值是否有效;根据所述目标像素点在多个预设方向上的梯度值是否有效确定所述目标像素点是否是所述目标图像中的色边像素点。In one embodiment, the color fringing module may be configured to: determine whether the gradient value of the target pixel point in the corresponding preset direction is valid; Whether the gradient value of is valid determines whether the target pixel is a color edge pixel in the target image.
在一个实施例中,所述色边模块,可以配置成用于:获取多个梯度组,所述梯度组中包括预设梯度值和预设亮度值;将所述目标像素点在目标预设方向上的梯度值与目标梯度组中的预设梯度值进行比较,得到所述目标像素点在所述目标预设方向上的目标梯度组的梯度比较结果,所述目标梯度组为所述多个梯度组中的一个待比对梯度组,所述目标预设方向为所述多个预设方向中的一个待比对预设方向;将所述目标像素点的亮度值与所述目标梯度组中的预设亮度值进行比较,得到所述目标像素点在所述目标预设方向上的目标梯度组的亮度比较结果;根据所述目标像素点在所述目标预设方向上的所述多个梯度组的梯度比较结果和亮度比较结果确定所述目标像素点在所述目标预设方向上的梯度值是否有效。In one embodiment, the color fringing module can be configured to: obtain a plurality of gradient groups, and the gradient groups include preset gradient values and preset brightness values; The gradient value in the direction is compared with the preset gradient value in the target gradient group to obtain the gradient comparison result of the target gradient group of the target pixel point in the target preset direction, and the target gradient group is the multiple A gradient group to be compared in a gradient group, the target preset direction is a preset direction to be compared in the plurality of preset directions; the brightness value of the target pixel point is compared with the target gradient The preset brightness values in the group are compared to obtain the brightness comparison result of the target gradient group of the target pixel point in the target preset direction; according to the target pixel point in the target preset direction The gradient comparison results and brightness comparison results of the multiple gradient groups determine whether the gradient value of the target pixel point in the target preset direction is valid.
在一个实施例中,所述确定装置,还包括:矫正模块,可以配置成用于当所述目标像素点是所述目标图像中的色边像素点时,对所述目标像素点的颜色值进行矫正。In one embodiment, the determining device further includes: a correction module configured to correct the color value of the target pixel when the target pixel is a color edge pixel in the target image Make corrections.
在一个实施例中,所述矫正模块,可以配置成用于:根据所述目标像素点在多个预设方向上的梯度值查找所述目标像素点对应的矫正像素点;根据所述目标像素点对应的矫正像素点的颜色值对所述目标像素点的颜色值进行矫正。In one embodiment, the correction module may be configured to: search for the corrected pixel corresponding to the target pixel according to the gradient values of the target pixel in multiple preset directions; The color value of the corrected pixel point corresponding to the point corrects the color value of the target pixel point.
在一个实施例中,所述矫正模块,可以配置成用于:确定目标颜色分量,第一剩余颜色分量和第二剩余颜色分量,所述目标颜色分量,所述第一剩余颜色分量和所述第二剩余颜色分量分别为红色分量、绿色分量以及蓝色分量中的一个;计算所述矫正像素点中的目标颜色分量对应的颜色分量值与所述矫正像素点中的第一剩余颜色分量对应的颜色分量值的差值,得到第一差值;计算所述矫正像素点中的目标颜色分量对应的颜色分量值与所述矫正像素点中的第二剩余颜色分量对应的颜色分量值的差值,得到第二差值;计算所述目标像素点的目标颜色分量对应的颜色分量值与所述第一差值的差值,得到所述目标像素点的第一剩余颜色分量对应的颜色分量值;计算所述目标像素点的目标颜色分量对应的颜色分量值与所述第二差值的差值,得到所述目标像素点的第二剩余颜色分量对应的颜色分量值。In one embodiment, the correction module may be configured to: determine the target color component, the first remaining color component and the second remaining color component, the target color component, the first remaining color component and the The second remaining color components are respectively one of the red component, the green component and the blue component; calculating the color component value corresponding to the target color component in the corrected pixel corresponds to the first remaining color component in the corrected pixel The difference value of the color component value of the first difference value is obtained; the difference between the color component value corresponding to the target color component in the corrected pixel point and the color component value corresponding to the second remaining color component in the corrected pixel point is calculated value to obtain the second difference; calculate the difference between the color component value corresponding to the target color component of the target pixel and the first difference, and obtain the color component corresponding to the first remaining color component of the target pixel value; calculating the difference between the color component value corresponding to the target color component of the target pixel point and the second difference value, to obtain the color component value corresponding to the second remaining color component of the target pixel point.
在一个实施例中,所述矫正模块,可以配置成用于:根据所述目标像素点在多个预设方向上的梯度值是否有效确定所述目标像素点对应的矫正像素点的查找方向;在所述查找方向上的预设像素范围内查找所述目标像素点对应的矫正像素点。In one embodiment, the correction module may be configured to: determine the search direction of the corrected pixel corresponding to the target pixel according to whether the gradient values of the target pixel in multiple preset directions are valid; The corrected pixel corresponding to the target pixel is searched within a preset pixel range in the search direction.
在一个实施例中,所述矫正模块,可以配置成用于:将在所述查找方向上的预设像素范围内首次出现的颜色为非色边颜色的像素点确定为所述像素点对应的矫正像素点。In one embodiment, the rectification module may be configured to: determine the first pixel in the preset pixel range in the search direction that is a non-color edge color as the pixel corresponding to the pixel. Correct the pixels.
在一个实施例中,所述确定装置还可以包括:梯度值确定模块,配置成用于:根据所述目标像素点的颜色值计算所述目标像素点的亮度值;获取预设亮度值和所述目标像素点在所述多个预设方向中的每个预设方向上的最大亮度值;将所述目标像素点在所述多个预设方向中的每个预设方向上的最大亮度值与所述预设亮度值进行比较,得到所述目标像素点在所述多个预设方向中的每个预设方向上的梯度权重;将所述目标像素点在所述多个预设方向中的每个预设方向上的最大亮度值与所述目标像素点的亮度值进行比较,得到所述目标像素点在所述多个预设方向中的每个预设方向上的初步梯度值;将所述目标像素点在所述多个预设方向中的每个预设方向上的梯度权重和所述目标像素点在相应的预设方向上的初 步梯度值相乘,得到所述目标像素点在所述多个预设方向中的每个预设方向上的梯度值。In an embodiment, the determination device may further include: a gradient value determination module configured to: calculate the brightness value of the target pixel point according to the color value of the target pixel point; obtain a preset brightness value and the determined The maximum brightness value of the target pixel point in each preset direction in the plurality of preset directions; the maximum brightness value of the target pixel point in each preset direction in the plurality of preset directions Value is compared with the preset brightness value to obtain the gradient weight of the target pixel point in each preset direction in the multiple preset directions; the target pixel point in the multiple preset directions Comparing the maximum brightness value in each preset direction in the direction with the brightness value of the target pixel to obtain a preliminary gradient of the target pixel in each preset direction in the plurality of preset directions value; multiply the gradient weight of the target pixel point in each preset direction in the plurality of preset directions by the preliminary gradient value of the target pixel point in the corresponding preset direction to obtain the A gradient value of the target pixel point in each preset direction in the plurality of preset directions.
在一个实施例中,所述梯度值确定模块,可以配置成用于:获取多个颜色组,所述颜色组中包括预设蓝色值、预设红绿差值和预设蓝绿差值;将所述像素点的蓝色值与目标颜色组中的预设蓝色值进行比较,得到所述目标颜色组对应的蓝色比较结果,所述目标颜色组为所述多个颜色组中的一个待比对颜色组;将所述像素点的红绿差值与所述目标颜色组中的预设红绿差值进行比较,得到所述目标颜色组对应的红绿比较结果;将所述像素点的蓝绿差值与所述目标颜色组中的预设蓝绿差值进行比较,得到所述目标颜色组对应的蓝绿比较结果;根据所述多个颜色组对应的蓝色比较结果、红绿比较结果和蓝绿比较结果确定所述像素点的颜色。In one embodiment, the gradient value determining module can be configured to: obtain a plurality of color groups, the color groups include a preset blue value, a preset red-green difference value and a preset blue-green difference value ; Comparing the blue value of the pixel with the preset blue value in the target color group to obtain a blue comparison result corresponding to the target color group, the target color group being one of the plurality of color groups A color group to be compared; compare the red-green difference value of the pixel with the preset red-green difference value in the target color group to obtain the red-green comparison result corresponding to the target color group; The blue-green difference value of the pixel is compared with the preset blue-green difference value in the target color group to obtain the blue-green comparison result corresponding to the target color group; according to the blue comparison results corresponding to the plurality of color groups The result, the red-green comparison result and the blue-green comparison result determine the color of the pixel.
在又一些实施方式中,本申请提供了一种计算机设备,其特征在于,可以包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,所述处理器在执行所述计算机程序时可以实现如上所述图像中的色边像素点的确定方法。In still other embodiments, the present application provides a computer device, which is characterized in that it may include a memory, a processor, and a computer program stored in the memory and operable on the processor, the processor The method for determining color fringe pixels in an image as described above can be implemented when the computer program is executed.
在再一些实施方式中,本申请提供了一种计算机可读存储介质,所述计算机可读取存储介质中可以存储有计算机程序指令,所述计算机程序指令在被处理器读取并运行时,可以执行如上所述图像中的色边像素点的确定方法。In some other implementations, the present application provides a computer-readable storage medium, where computer program instructions may be stored in the computer-readable storage medium, and when the computer program instructions are read and executed by a processor, The method for determining color fringe pixels in an image as described above may be performed.
附图说明Description of drawings
为了更清楚地说明本申请实施例的技术方案,下面将对本申请实施例中所需要使用的附图作简单地介绍,应当理解,以下附图仅示出了本申请的某些实施例,因此不应被看作是对范围的限定,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他相关的附图。In order to more clearly illustrate the technical solutions of the embodiments of the present application, the accompanying drawings that need to be used in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present application, so It should not be regarded as a limitation on the scope, and those skilled in the art can also obtain other related drawings according to these drawings without creative work.
图1为本申请实施例中图像中的色边像素点的确定方法的实现流程示意图;Fig. 1 is a schematic diagram of the implementation process of the method for determining the color edge pixels in the image in the embodiment of the present application;
图2为本申请实施例中色边的示意图;Fig. 2 is the schematic diagram of color fringe in the embodiment of the present application;
图3为本申请实施例中像素搜索范围的示意图;FIG. 3 is a schematic diagram of a pixel search range in an embodiment of the present application;
图4为本申请实施例中检索窗口的示意图;Fig. 4 is the schematic diagram of the search window in the embodiment of the present application;
图5为本申请实施例中图像中的色边像素点的确定装置的组成结构示意图;FIG. 5 is a schematic diagram of the composition and structure of the device for determining the color fringe pixels in the image in the embodiment of the present application;
图6为本申请实施例中计算机设备的内部结构框图。FIG. 6 is a block diagram of an internal structure of a computer device in an embodiment of the present application.
具体实施方式Detailed ways
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the application with reference to the drawings in the embodiments of the application. Apparently, the described embodiments are only some of the embodiments of the application, not all of them. Based on the embodiments in this application, all other embodiments obtained by persons of ordinary skill in the art without creative efforts fall within the protection scope of this application.
在一个实施例中,提供了一种图像中的色边像素点的确定方法。本申请实施例所述的图像中的色边像素点的确定方法的执行主体为能够实现本申请实施例所述的图像中的色边像素点的确定方法的计算机设备,该计算机设备可以包括但不限于终端和服务器。其中,终端包括台式终端和移动终端,台式终端包括但不限于台式电脑和车载电脑;移动终端包括但不限于手机、平板、笔记本电脑、智能手表和相机。服务器包括高性能计算机和高性能计算机集群。In one embodiment, a method for determining color fringe pixels in an image is provided. The executor of the method for determining color fringe pixels in an image described in the embodiment of the present application is a computer device capable of implementing the method for determining color fringe pixels in an image described in the embodiment of the present application. The computer device may include but Not limited to terminals and servers. Among them, terminals include desktop terminals and mobile terminals, desktop terminals include but not limited to desktop computers and vehicle-mounted computers; mobile terminals include but not limited to mobile phones, tablets, laptops, smart watches and cameras. Servers include high-performance computers and high-performance computer clusters.
需要指出的是,在本申请实施例中,以紫色色边为例对本申请实施例进行详细说明。It should be noted that, in the embodiment of the present application, the embodiment of the present application is described in detail by taking the purple color border as an example.
在本申请实施例中,采用的色彩模型是RGB模型,但需要指出的是,本申请实施例并不会对色彩模型进行限制,即当其他的色彩模型也采用了本申请实施例的发明构思时,也应当落入本申请实施例所要保护的范围,具体来说,只要其他的色彩模型也采用了根据颜色值计算颜色差值,然后根据颜色值和颜色差值确定像素点颜色的方案,都应当落入本申请实施例所要保护的范围。In the embodiment of the present application, the color model adopted is the RGB model, but it should be pointed out that the embodiment of the present application does not limit the color model, that is, when other color models also adopt the inventive concept of the embodiment of the present application , it should also fall within the protection scope of the embodiments of the present application. Specifically, as long as other color models also adopt the scheme of calculating the color difference value according to the color value, and then determining the color of the pixel point according to the color value and the color difference value, All should fall within the protection scope of the embodiments of the present application.
在一个实施例中,如图1所示,提供了一种图像中的色边像素点的确定方法,包括:In one embodiment, as shown in Figure 1, a method for determining color fringe pixels in an image is provided, including:
步骤100,获取目标图像中的目标像素点的颜色值,所述颜色值包括红色值、绿色值和蓝色值。Step 100, acquiring color values of target pixels in the target image, where the color values include red values, green values and blue values.
目标图像,为当前需要处理的图像,即待确定是否包含色边的图像,如果目标图像中包含色边像素点,则目标图像是包含色边的图像,相反,如果目标图像中的像素点均不是色边像素点,则目标图像是不包含色边的图像,也就是说,通过本申请实施例提供的图像中的色边像素点的确定方法不仅可以确定图像是否包含色边像素点,还能同时确定该图像是否是包含色边的图像。The target image is the image that needs to be processed currently, that is, the image to be determined whether it contains color fringes. If the target image contains color fringe pixels, the target image is an image that contains color fringes. On the contrary, if the pixels in the target image are If it is not a color fringe pixel, then the target image is an image that does not contain color fringe, that is to say, the method for determining the color fringe pixel in the image provided by the embodiment of the present application can not only determine whether the image contains color fringe pixels, but also It can be determined at the same time whether the image is an image including color fringing.
目标像素点,为目标图像中的像素点。目标像素点可以是目标图像中所有像素点中的任一像素点;目标像素点也可以是目标图像中的目标区域的像素点,其中,目标区域可以是根据预置的区域确定规则确定的区域,也可以是根据用户对目标图像的交互操作确定的区域,例如,用户在目标图像中圈起来的区域,还可以是通过图像识别技术识别出来的一个区域,例如,图像识别技术为对包含色边的区域进行识别的技术,从而将包含色边的区域识别出来,该识别出来的包含色边的区域即为目标区域。The target pixel is the pixel in the target image. The target pixel point may be any pixel point among all the pixel points in the target image; the target pixel point may also be a pixel point in a target area in the target image, wherein the target area may be an area determined according to a preset area determination rule , can also be an area determined according to the user's interactive operation on the target image, for example, the area circled by the user in the target image, or an area recognized by image recognition technology, for example, the image recognition technology The technology of identifying the edge area, so as to identify the area containing the color edge, and the identified area containing the color edge is the target area.
其中,色边,为目标在亮度差异较大的交界处出现的某种颜色的边缘,如图2所示的黑色虚线标记的色边,黑色虚线标记的色边出现在建筑物旁边。其中,目标可以是人,动物,也可以是植物,在此不做具体的限定。Among them, the color edge is the edge of a certain color that appears at the junction of the target with a large brightness difference, such as the color edge marked by the black dotted line shown in Figure 2, and the color edge marked by the black dotted line appears next to the building. Wherein, the target may be a human, an animal, or a plant, which is not specifically limited here.
目标图像是彩色图像,目标图像中的每个像素点都包含颜色值,具体的,颜色值包括红色值、绿色值和蓝色值,由于每个像素点的红色值、绿色值和蓝色值不同,所以每个像素点呈现的颜色不同。The target image is a color image, and each pixel in the target image contains a color value. Specifically, the color value includes a red value, a green value, and a blue value. Since the red value, green value, and blue value of each pixel point Different, so each pixel presents a different color.
颜色值,为颜色分量对应的颜色分量值。目标图像中的颜色分量包括红色分量、绿色分量和蓝色分量。红色值为红色分量对应的红色分量值,绿色值为绿色分量对应的绿色分量值,蓝色值为蓝色分量对应的蓝色分量值。例如,红色分量用R表示,红色分量值为128,即红色值为128。Color value, which is the color component value corresponding to the color component. The color components in the target image include red, green and blue components. The red value is the red component value corresponding to the red component, the green value is the green component value corresponding to the green component, and the blue value is the blue component value corresponding to the blue component. For example, the red component is represented by R, and the value of the red component is 128, that is, the red value is 128.
在一个实施例中,步骤100所述获取目标图像中的目标像素点的颜色值,包括:In one embodiment, the step 100 of obtaining the color value of the target pixel in the target image includes:
步骤101,对目标图像中的目标像素点,获取所述目标像素点的初步颜色值。Step 101, for a target pixel in a target image, obtain a preliminary color value of the target pixel.
初步颜色值,在目标图像的颜色空间是初步颜色空间的时候,目标图像中的目标像素点的颜色值为初步颜色值,例如,目标图像的颜色空间是YUV空间,则目标像素点中的目标像素点的颜色值为亮度值Y,第一色差值U和第二色差值V。Preliminary color value. When the color space of the target image is the preliminary color space, the color value of the target pixel in the target image is the preliminary color value. For example, if the color space of the target image is YUV space, the target pixel in the target The color values of the pixels are the brightness value Y, the first color difference value U and the second color difference value V.
步骤102,对所述目标像素点的初步颜色值进行颜色空间的转换,得到所述目标像素点的颜色值。Step 102, performing color space conversion on the preliminary color value of the target pixel to obtain the color value of the target pixel.
再如上例子,假设转换公式为:红色值=Y+w 1×V,绿色值=Y-w 2×U-w 3×V,蓝色值=Y+w 4×U,根据转换公式,对目标像素点的初步颜色值进行颜色空间的转换,得到目标像素点的颜色值。 As in the example above, suppose the conversion formula is: red value=Y+w 1 ×V, green value=Yw 2 ×Uw 3 ×V, blue value=Y+w 4 ×U, according to the conversion formula, the target pixel The preliminary color value is transformed into the color space to obtain the color value of the target pixel.
上述实施例,由于目标图像可能并不是RGB图像,因此,获取目标图像的初步颜色值,然后根据颜色空间的转换关系对初步颜色值进行转换,得到目标像素点的颜色值。In the above embodiment, since the target image may not be an RGB image, the preliminary color value of the target image is obtained, and then the preliminary color value is converted according to the conversion relationship of the color space to obtain the color value of the target pixel.
步骤200,计算所述目标像素点的红色值和绿色值之间的差值,得到红绿差值,计算所述目标像素点的蓝色值和绿色值之间的差值,得到蓝绿差值。Step 200, calculating the difference between the red value and the green value of the target pixel to obtain the red-green difference, and calculating the difference between the blue value and the green value of the target pixel to obtain the blue-green difference value.
红绿差值,为红色值减去绿色值后得到的值;蓝绿差值为蓝色值减去绿色值后得到的值。例如,红色值为92,绿色值为80,蓝色值为160,则红绿差值为92-80=12,蓝绿差值为160-80=80。The difference between red and green is the value obtained by subtracting the green value from the red value; the difference between blue and green is the value obtained by subtracting the green value from the blue value. For example, if the red value is 92, the green value is 80, and the blue value is 160, then the difference between red and green is 92-80=12, and the difference between blue and green is 160-80=80.
步骤300,根据所述目标像素点的颜色值、红绿差值和蓝绿差值确定所述像素点的颜色。Step 300: Determine the color of the pixel according to the color value of the target pixel, the difference between red and green, and the difference between blue and green.
由于已经知晓了目标像素点的颜色值、红绿差值和蓝绿差值,因此,可以根据目标像素点的颜色值、红绿差值和蓝绿差值来确定该目标像素点的颜色,相较于单纯的根据目标像素点的颜色值来确定目标像素点的颜色的方式,这样的方式能够把偏红或者偏蓝的颜色也识别出来。例如,识别紫色,单纯的依靠颜色值来识别紫色可能只能识别纯紫色,比如,当红色值在某个区间,绿色值在某个区间,蓝色值在某个区间,则认为是紫色,这样的识别方法对于紫色的识别精度并不高,本申请实施例提供的图像中的色边像素点的确定方法结合红绿差值和蓝绿差值来识别紫色,便可以把偏红的紫色还有偏蓝的紫色也都识别出来,使得紫色的识别更加的灵活,在一定程度上避免了色边像素点的遗漏。Since the color value, red-green difference, and blue-green difference of the target pixel are known, the color of the target pixel can be determined according to the color value, red-green difference, and blue-green difference of the target pixel, Compared with the method of simply determining the color of the target pixel according to the color value of the target pixel, this method can also identify reddish or bluish colors. For example, to identify purple, relying solely on the color value to identify purple may only identify pure purple. For example, when the red value is in a certain range, the green value is in a certain range, and the blue value is in a certain range, it is considered to be purple. The recognition accuracy of such a recognition method for purple is not high. The method for determining the color edge pixels in the image provided in the embodiment of the present application combines the difference between red and green and the difference between blue and green to recognize purple, so that the reddish purple The bluish purple is also recognized, which makes the recognition of purple more flexible and avoids the omission of color edge pixels to a certain extent.
步骤400,当所述目标像素点的颜色为色边颜色时,根据所述目标像素点在多个预设方向上的梯度 值确定所述目标像素点是否是所述目标图像中的色边像素点,所述色边像素点为所述目标图像中的色边中的像素点。Step 400, when the color of the target pixel is a color fringe color, determine whether the target pixel is a color fringe pixel in the target image according to the gradient values of the target pixel in multiple preset directions point, the color fringe pixel point is a pixel point in the color fringe in the target image.
色边颜色,为色边的颜色,色边中的像素点通常会呈现比较一致的颜色,例如,紫色色边,则色边颜色为紫色,即色边中的像素点基本全为紫色;再如,蓝色色边,则色边颜色为蓝色。Color edge color is the color of the color edge. The pixels in the color edge usually show a relatively consistent color. For example, if the color edge is purple, the color edge color is purple, that is, the pixels in the color edge are basically all purple; For example, if the color edge is blue, the color edge color is blue.
预设方向,为预先设置的方向。例如,预设方向为0°方向,90°方向,180度方向和270°方向。The preset direction is the preset direction. For example, the preset directions are 0° direction, 90° direction, 180° direction and 270° direction.
预设方向上的梯度值,反映该预设方向上梯度的大小。The gradient value in the preset direction reflects the magnitude of the gradient in the preset direction.
由于色边是出现在亮度差异较大的交界处,所以交界处必然存在一定的梯度,因此,在判断一个像素点的颜色是色边颜色之后,需要再结合梯度值来进一步判断该像素点是否是色边中的像素点。Since the color fringe appears at the junction where the brightness difference is large, there must be a certain gradient at the junction. Therefore, after judging that the color of a pixel is the color fringe color, it is necessary to combine the gradient value to further judge whether the pixel is is the pixel in the color fringe.
上述图像中的色边像素点的确定方法,在确定像素点的颜色值之后,还根据颜色值确定了红绿差值和蓝绿差值,相较于单纯的根据颜色值来确定像素点的颜色的方式,这样的方式能够识别出偏红的颜色和偏蓝的颜色,使得对颜色的识别更加的灵活,在一定程度上避免了色边像素点的遗漏,最后考虑到色边是出现在亮度差异较大的交界处,这些位置必然存在一定的梯度,因此,在确定像素点的颜色为色边颜色之后,还根据多个预设方向的梯度值来进一步确定该像素点是否是色边像素点,在一定程度上提高了色边像素点的识别率。The method for determining the color edge pixel in the above image, after determining the color value of the pixel, also determines the red-green difference and the blue-green difference according to the color value, compared to determining the pixel point simply based on the color value The way of color, this way can identify the reddish color and the bluish color, which makes the color recognition more flexible, and avoids the omission of color edge pixels to a certain extent. Finally, considering that the color edge appears in the At the junction where the brightness difference is large, there must be a certain gradient at these positions. Therefore, after determining that the color of the pixel point is the color edge color, it is further determined whether the pixel point is a color edge color according to the gradient values of multiple preset directions. Pixels, to a certain extent, improve the recognition rate of color edge pixels.
在一个实施例中,步骤400所述根据所述目标像素点在多个预设方向上的梯度值确定所述目标像素点是否是所述目标图像中的色边像素点,包括:In one embodiment, determining whether the target pixel is a color fringe pixel in the target image according to the gradient values of the target pixel in multiple preset directions in step 400 includes:
步骤40A,判断所述目标像素点在相应的预设方向上的梯度值是否有效。Step 40A, judging whether the gradient value of the target pixel point in the corresponding preset direction is valid.
判断某个预设方向上的梯度值是否有效的目的是:判断在该预设方向上是否存在高亮的像素点,从而根据高亮的像素点的判断结果确定该目标像素点是否是色边像素点,以及,在该目标像素点是色边像素点的同时,确定该目标像素点对应的矫正像素点的搜索方向。The purpose of judging whether the gradient value in a preset direction is valid is to judge whether there is a highlighted pixel in the preset direction, so as to determine whether the target pixel is a color fringe according to the judging result of the highlighted pixel pixel, and, when the target pixel is a color edge pixel, determine the search direction of the corrected pixel corresponding to the target pixel.
示例性的,提供一种确定梯度值是否有效的方法,包括:获取门限梯度值;对每个预设方向,将该预设方向的梯度值与门限梯度值进行比较;若该预设方向的梯度值大于或等于门限梯度值,则确定该预设方向上的梯度值有效,即该预设方向上存在高亮的像素点;若该预设方向的梯度值小于门限梯度值,则确定该预设方向上的梯度值无效,即该预设方向上不存在高亮的像素点。Exemplarily, a method for determining whether the gradient value is valid is provided, including: obtaining a threshold gradient value; for each preset direction, comparing the gradient value of the preset direction with the threshold gradient value; if the preset direction If the gradient value is greater than or equal to the threshold gradient value, it is determined that the gradient value in the preset direction is valid, that is, there are highlighted pixels in the preset direction; if the gradient value in the preset direction is smaller than the threshold gradient value, it is determined that the gradient value in the preset direction is The gradient value in the preset direction is invalid, that is, there are no highlighted pixels in the preset direction.
步骤40B,根据所述目标像素点在多个预设方向上的梯度值是否有效确定所述目标像素点是否是所述目标图像中的色边像素点。Step 40B, determining whether the target pixel is a color fringe pixel in the target image according to whether the gradient values of the target pixel in multiple preset directions are valid.
具体的,根据下式判断目标像素点是否是所述目标图像中的色边像素点。Specifically, it is judged according to the following formula whether the target pixel is a color edge pixel in the target image.
Figure PCTCN2021136744-appb-000001
Figure PCTCN2021136744-appb-000001
其中,“~d_x”表示预设方向为x方向上的梯度值无效;“d_x”表示预设方向为x方向上的梯度值有效;当“&&”和“||”同时出现时,先计算“&&”;上式中的数字0到13是指第0到第13种情况,即数字i表示第i种情况。Among them, "~d_x" indicates that the preset direction is that the gradient value in the x direction is invalid; "d_x" indicates that the preset direction is that the gradient value in the x direction is valid; when "&&" and "||" appear at the same time, calculate first "&&"; the numbers 0 to 13 in the above formula refer to the 0th to 13th cases, that is, the number i represents the i-th case.
对于第1种情况,目标像素点前后左右四个预设方向的梯度值均有效,认为目标像素点被高亮区域包围,不是色边像素点;对于第2种到第13种情况,多个预设方向中并不是所有的预设方向的梯度值均有效,而色边像素点是处于亮度差异较大的交界处的像素点,因此,当多个预设方向中并不是所有的预设方向的梯度值均有效时,认为该目标像素点是位于色边中的色边像素点。For the first case, the gradient values of the four preset directions around the target pixel are valid, and the target pixel is considered to be surrounded by a highlighted area, not a color edge pixel; for the second to thirteenth cases, multiple In the preset directions, not all the gradient values of the preset directions are valid, and the color edge pixels are pixels at the junction of large brightness differences. Therefore, when there are multiple preset directions, not all preset When the gradient values in both directions are valid, the target pixel is considered to be a color edge pixel located in the color edge.
上述实施例,提供了一种确定色边像素点的方法,根据梯度值判断像素点在相应的预设方向上的梯度值是否有效,如果有效,则认为该预设方向上存在高亮的像素点,从而根据多个预设方向上的梯度值是否有效来确定像素点是否是色边像素点。The above-mentioned embodiment provides a method for determining the color edge pixel point, judging whether the gradient value of the pixel point in the corresponding preset direction is valid according to the gradient value, and if it is valid, it is considered that there is a highlighted pixel in the preset direction point, so as to determine whether the pixel point is a color edge pixel point according to whether the gradient values in multiple preset directions are valid.
在一个实施例中,步骤40A所述判断所述目标像素点在相应的预设方向上的梯度值是否有效,包括:In one embodiment, the determination in step 40A whether the gradient value of the target pixel point in the corresponding preset direction is valid includes:
步骤40A1,获取多个梯度组,所述梯度组中包括预设梯度值和预设亮度值。In step 40A1, a plurality of gradient groups are obtained, and the gradient groups include preset gradient values and preset brightness values.
预设梯度值,为预先设置的梯度值;预设亮度值,为预先设置的亮度值。示例性的,用T i(t i,L i)表示多个梯度组中的第i个梯度组,其中,t i表示第i个梯度组中的预设梯度值,L i表示第i个梯度组中的预设亮度值。多个梯度组中的每个梯度组中都包括预设梯度值和预设亮度值,每个梯度组中包括的预设梯度值和预设亮度值不同。 The preset gradient value is a preset gradient value; the preset brightness value is a preset brightness value. Exemplarily, T i (t i , L i ) represents the i-th gradient group among multiple gradient groups, where t i represents the preset gradient value in the i -th gradient group, and Li represents the i-th gradient group Preset brightness value in gradient group. Each of the multiple gradient groups includes preset gradient values and preset brightness values, and the preset gradient values and preset brightness values included in each gradient group are different.
预先设置梯度组的目的是:将目标像素点在某个预设方向的梯度值和目标像素点的亮度值与梯度组中的预设梯度值和预设亮度值进行比较,以通过比较来确定该预设方向上的梯度值是否有效。The purpose of setting the gradient group in advance is to compare the gradient value of the target pixel point in a preset direction and the brightness value of the target pixel point with the preset gradient value and preset brightness value in the gradient group, so as to determine by comparison Whether the gradient value in the preset direction is valid.
预先设置多个梯度组的目的:由于应用场景不同,在色边,以及,色边周围的高亮区域和目标区域的明暗程度也将不同,因此,如果只设置一个梯度组,可能无法对所有应用场景进行较好的判断,因此,设置多个梯度组以提高对不同应用场景的判断的准确率。The purpose of setting multiple gradient groups in advance: due to different application scenarios, the brightness of the color edge and the highlight area around the color edge and the target area will also be different. Therefore, if only one gradient group is set, it may not be possible for all Therefore, multiple gradient groups are set to improve the accuracy of judgment on different application scenarios.
步骤40A2,将所述目标像素点在目标预设方向上的梯度值与目标梯度组中的预设梯度值进行比较,得到所述目标像素点在所述目标预设方向上的目标梯度组的梯度比较结果,所述目标梯度组为所述多个梯度组中的一个待比对梯度组,所述目标预设方向为所述多个预设方向中的一个待比对预设方向。Step 40A2, comparing the gradient value of the target pixel point in the target preset direction with the preset gradient value in the target gradient group to obtain the target gradient value of the target pixel point in the target preset direction As for the gradient comparison result, the target gradient group is a gradient group to be compared among the plurality of gradient groups, and the preset target direction is a preset direction to be compared among the plurality of preset directions.
待比对梯度组,为在根据梯度组判断目标预设方向上的梯度值是否有效时,多个梯度组中还未参与比对的梯度组。例如,设置3个梯度组,分别为T 1(t 1,L 1),T 2(t 2,L 2)和T 3(t 3,L 3),其中,T 1(t 1,L 1)已经完成了比对,于是,待比对梯度组为T 2(t 2,L 2)和T 3(t 3,L 3),将T 2(t 2,L 2)和T 3(t 3,L 3)中的一个,例如,T 2(t 2,L 2)作为目标梯度组。 The gradient group to be compared refers to the gradient group that has not yet participated in the comparison among the multiple gradient groups when judging whether the gradient value in the target preset direction is valid according to the gradient group. For example, set up three gradient groups, T 1 (t 1 ,L 1 ), T 2 (t 2 ,L 2 ) and T 3 (t 3 ,L 3 ), where T 1 (t 1 ,L 1 ) has completed the comparison, so the gradient groups to be compared are T 2 (t 2 , L 2 ) and T 3 (t 3 , L 3 ), and T 2 (t 2 , L 2 ) and T 3 (t 3 , L 3 ), for example, T 2 (t 2 , L 2 ) as the target gradient group.
梯度比较结果,为梯度值的比较结果。Gradient comparison result, which is the comparison result of the gradient value.
待比对预设方向,为多个预设方向中还未参与比对的预设方向。例如,多个预设方向为0°方向、90°方向、180度°方向和270°方向,其中,0°方向、90°方向已经完成了比对,则待比对预设方向为180度°方向和270°方向,于是,将180度°方向和270°方向中的一个,例如,270°方向作为目标预设方向。The preset direction to be compared is a preset direction that has not participated in the comparison among the multiple preset directions. For example, the multiple preset directions are 0° direction, 90° direction, 180° direction and 270° direction, wherein, the 0° direction and 90° direction have been compared, and the preset direction to be compared is 180° ° direction and 270° direction, therefore, one of the 180° direction and the 270° direction, for example, the 270° direction is used as the target preset direction.
步骤40A3,将所述目标像素点的亮度值与所述目标梯度组中的预设亮度值进行比较,得到所述目标像素点在所述目标预设方向上的目标梯度组的亮度比较结果。Step 40A3, comparing the brightness value of the target pixel point with the preset brightness value in the target gradient group to obtain a comparison result of the brightness of the target pixel point in the target gradient group in the target preset direction.
亮度比较结果,为亮度值的比较结果。Brightness comparison result, which is the comparison result of the brightness value.
步骤40A4,根据所述目标像素点在所述目标预设方向上的所述多个梯度组的梯度比较结果和亮度比较结果确定所述目标像素点在所述目标预设方向上的梯度值是否有效。Step 40A4, determine whether the gradient value of the target pixel point in the target preset direction is determined according to the gradient comparison results and brightness comparison results of the plurality of gradient groups in the target preset direction efficient.
根据多个梯度组的梯度比较结果和亮度比较结果来判断像素点在目标预设方向上的梯度值是否有效。According to the gradient comparison results and brightness comparison results of multiple gradient groups, it is judged whether the gradient value of the pixel point in the target preset direction is valid.
例如,目标预设方向为90°方向,目标像素点在90°方向上的梯度值为43,目标像素点的亮度值为 167,总共有2个梯度组,分别为T 1(20,200)和T 2(40,160),梯度组T 1的梯度比较结果为43>20,亮度比较结果为167<200;梯度组T 2的梯度比较结果为43>20,亮度比较结果为167>200。根据梯度组T 2的比较结果可以看出,由于目标像素点自身的亮度就比较高为167,并且目标预设方向上还存在比目标像素点亮度更高的像素点(亮度值为167+43=210),因此,认为目标预设方向(90°方向)为高亮像素点所在的方向,因此,判定目标像素点在目标预设方向(90°方向)上的梯度值有效。 For example, the preset direction of the target is 90°, the gradient value of the target pixel point in the 90° direction is 43, and the brightness value of the target pixel point is 167. There are two gradient groups in total, namely T 1 (20,200) and T 2 (40,160), the gradient comparison result of gradient group T 1 is 43>20, and the brightness comparison result is 167<200; the gradient comparison result of gradient group T 2 is 43>20, and the brightness comparison result is 167>200. According to the comparison results of the gradient group T2, it can be seen that the brightness of the target pixel itself is relatively high at 167, and there are pixels with higher brightness than the target pixel in the preset direction of the target (the brightness value is 167+43 =210), therefore, it is considered that the target preset direction (90° direction) is the direction where the highlighted pixel is located, therefore, it is determined that the gradient value of the target pixel point in the target preset direction (90° direction) is valid.
为了提高比对效率,在判断像素点在目标预设方向上的梯度值是否有效时,若根据目标梯度组的梯度比较结果和亮度比较结果即可确定像素点在目标预设方向上的梯度值有效,则不再对多个梯度组中剩余的其他待比对梯度组进行比较。In order to improve the comparison efficiency, when judging whether the gradient value of the pixel point in the target preset direction is valid, the gradient value of the pixel point in the target preset direction can be determined according to the gradient comparison result and brightness comparison result of the target gradient group If it is valid, the remaining gradient groups to be compared in the multiple gradient groups will not be compared.
例如,目标预设方向为90°方向,目标像素点在90°方向上的梯度值为43,目标像素点的亮度值为207,总共有2个梯度组,分别为T 1(20,200)和T 2(40,160),梯度组T 1的梯度比较结果为43>20,亮度比较结果为207>200,于是,根据第1个梯度组T 1即可判断出目标像素点在90°方向上的梯度值有效,不必再进行梯度组T 2的判断。 For example, the preset direction of the target is 90°, the gradient value of the target pixel in the 90° direction is 43, and the brightness value of the target pixel is 207. There are two gradient groups in total, namely T 1 (20,200) and T 2 (40,160), the gradient comparison result of the gradient group T 1 is 43>20, and the brightness comparison result is 207>200, so the gradient of the target pixel point in the 90° direction can be judged according to the first gradient group T 1 The value is valid, no need to judge the gradient group T2.
上述实施例,单纯的依靠梯度值来判断相应的预设方向上的梯度值是否有效可能并不准确,因为,实际的待矫正的像素点(检测窗口中心的像素点,即目标像素点)的亮度可能比较低,而待矫正的像素点是介于高亮区域和暗区域(目标所在的区域,该区域的亮度相对较低)之间的,所以理论上,待矫正的像素点的亮度不会很低,因此,结合亮度来判断梯度值是否有效将得到更加准确的判断结果。In the above embodiment, it may not be accurate to simply rely on the gradient value to determine whether the gradient value in the corresponding preset direction is valid, because the actual pixel point to be corrected (the pixel point in the center of the detection window, that is, the target pixel point) The brightness may be relatively low, and the pixel to be corrected is between the bright area and the dark area (the area where the target is located, and the brightness of this area is relatively low), so theoretically, the brightness of the pixel to be corrected is different. will be very low, therefore, judging whether the gradient value is valid in combination with the brightness will get a more accurate judgment result.
在一个实施例中,在步骤400所述根据所述目标像素点在多个预设方向上的梯度值确定所述目标像素点是否是所述目标图像中的色边像素点之后,还包括:In one embodiment, after determining whether the target pixel is a color fringe pixel in the target image according to the gradient values of the target pixel in a plurality of preset directions in step 400, it further includes:
步骤500,当所述目标像素点是所述目标图像中的色边像素点时,对所述目标像素点的颜色值进行矫正。Step 500, when the target pixel is a color edge pixel in the target image, correct the color value of the target pixel.
上述实施例,在目标像素点是色边像素点的时候,还对该目标像素点进行了矫正,使得矫正后的目标图像更加的真实。In the above embodiment, when the target pixel is a color edge pixel, the target pixel is also corrected, so that the corrected target image is more realistic.
在一个实施例中,步骤500所述对所述目标像素点的颜色值进行校正,包括:In one embodiment, correcting the color value of the target pixel in step 500 includes:
步骤501,根据所述目标像素点在多个预设方向上的梯度值查找所述目标像素点对应的矫正像素点。Step 501 , according to the gradient values of the target pixel in multiple preset directions, search for the corrected pixel corresponding to the target pixel.
目标像素点对应的矫正像素点,为目标图像中用于对该目标像素点进行矫正的像素点。可以理解的是,目标像素点不同,该目标像素点对应的矫正像素点可能相同也可能不同。The corrected pixel corresponding to the target pixel is a pixel used to correct the target pixel in the target image. It can be understood that the target pixel points are different, and the corrected pixel points corresponding to the target pixel points may be the same or different.
由于色边出现在亮度差异较大的交界处,这些位置必然存在一定的梯度,那么在梯度相反的方向,很大可能会出现矫正像素点,因此,可以根据目标像素点在多个预设方向上的梯度值查找该像素点对应的矫正像素点。Since the color fringe appears at the junction where the brightness difference is large, there must be a certain gradient at these positions, then in the direction opposite to the gradient, it is very likely that the correction pixel will appear. Therefore, according to the target pixel, it can be in multiple preset directions The gradient value above finds the corrected pixel corresponding to the pixel.
步骤502,根据所述目标像素点对应的矫正像素点的颜色值对所述目标像素点的颜色值进行矫正。Step 502 , correcting the color value of the target pixel according to the color value of the corrected pixel corresponding to the target pixel.
由于色边通常出现在亮度差异较大的交界处,然后在亮度较暗的目标的边缘出现,即色边实际上是覆盖在目标边缘的某种颜色的像素点,因此,当找到矫正像素点之后,可以直接将像素点对应的矫正像素点的颜色值作为该像素点的颜色值,从而还原目标的边缘的像素点。例如,目标像素点为ps,目标像素点ps对应的矫正像素点为p2,于是,直接把p2的红色值、绿色值和蓝色值作为目标像素点ps的红色值、绿色值和蓝色值。Since the color fringe usually appears at the junction where the brightness difference is large, and then appears at the edge of the object with darker brightness, that is, the color fringe is actually a pixel of a certain color covering the edge of the object, so when the correction pixel is found After that, the color value of the corrected pixel point corresponding to the pixel point can be directly used as the color value of the pixel point, so as to restore the pixel point of the edge of the target. For example, the target pixel point is ps, and the corrected pixel point corresponding to the target pixel point ps is p2, so the red value, green value and blue value of p2 are directly used as the red value, green value and blue value of the target pixel point ps .
上述实施例,通过颜色值实现了色边像素点的矫正,使得矫正后的目标像素点的颜色和矫正像素点颜色相似,从而使得矫正后的目标图像更加的真实。。In the above embodiment, the correction of the color edge pixels is realized through the color value, so that the color of the corrected target pixel is similar to the color of the corrected pixel, so that the corrected target image is more realistic. .
在一个实施例中,在步骤400所述根据所述目标像素点在多个预设方向上的梯度值确定所述目标像素点是否是所述目标图像中的色边像素点之后,还包括:In one embodiment, after determining whether the target pixel is a color fringe pixel in the target image according to the gradient values of the target pixel in a plurality of preset directions in step 400, it further includes:
当所述目标像素点不是所述目标图像中的色边像素点时,对所述目标图像中的剩余像素点进行查找, 以确定所述剩余像素点是否是所述目标图像中的色边像素点。When the target pixel is not a color fringe pixel in the target image, search the remaining pixels in the target image to determine whether the remaining pixel is a color fringe pixel in the target image point.
其中,剩余像素点,为目标图像中还未查找的像素点,即还未通过查找以确定是否是色边像素点的像素点。Wherein, the remaining pixels are pixels that have not been searched in the target image, that is, pixels that have not been searched to determine whether they are color edge pixels.
在一个实施例中,步骤502所述根据所述目标像素点对应的矫正像素点的颜色值对所述目标像素点的颜色值进行矫正,包括:In one embodiment, correcting the color value of the target pixel according to the color value of the corrected pixel corresponding to the target pixel in step 502 includes:
步骤502A,确定目标颜色分量,第一剩余颜色分量和第二剩余颜色分量,所述目标颜色分量,所述第一剩余颜色分量和所述第二剩余颜色分量分别为红色分量、绿色分量以及蓝色分量中的一个。Step 502A, determine the target color component, the first remaining color component and the second remaining color component, the target color component, the first remaining color component and the second remaining color component are red component, green component and blue component respectively One of the color components.
目标颜色分量,为红色分量、绿色分量以及蓝色分量中的一个;第一剩余颜色分量,为红色分量、绿色分量以及蓝色分量中除去目标颜色分量的一个颜色分量;第二剩余颜色分量,为红色分量、绿色分量以及蓝色分量中除去目标颜色分量和第一剩余颜色分量的颜色分量。The target color component is one of the red component, the green component and the blue component; the first remaining color component is a color component except the target color component among the red component, the green component and the blue component; the second remaining color component is is the color component except the target color component and the first remaining color component among the red component, the green component and the blue component.
确定目标颜色分量的目的是要保证目标像素点矫正后的亮度相较于矫正前的亮度不会出现很大的变化。The purpose of determining the target color component is to ensure that the brightness of the target pixel after correction will not change greatly compared with the brightness before correction.
红色分量、绿色分量以及蓝色分量中的任意一个都能作为目标颜色分量的基础是:色边通常出现在亮度差异较大的交界处,然后覆盖在亮度较暗的目标的边缘,由于目标的亮度较暗,因此,目标中的像素点的红色分量、绿色分量以及蓝色分量的值都不会很大,所以不管将红色分量、绿色分量以及蓝色分量中的哪一个作为目标颜色分量,计算得到的第一差值、第二差值的差异都不会很大,然后再基于第一差值、第二差值对色边像素点的第一剩余颜色分量和第二剩余颜色分量进行矫正,使得矫正后的色边像素点的亮度不会出现很大的改变,以免亮度改变过大,使得色边无法在高亮区域以及目标区域进行平缓的过渡,导致高亮区域以及目标区域之间出现明显的亮度改变的区域。Any one of the red component, green component, and blue component can be used as the basis of the target color component because the color edge usually appears at the junction of a large difference in brightness, and then covers the edge of a darker target. The brightness is darker, so the values of the red component, green component and blue component of the pixel in the target will not be very large, so no matter which one of the red component, green component and blue component is used as the target color component, The difference between the calculated first difference and the second difference will not be very large, and then based on the first difference and the second difference, the first remaining color component and the second remaining color component of the color edge pixel are Correction, so that the brightness of the corrected color fringe pixels will not change greatly, so as not to change the brightness too much, so that the color fringe cannot make a smooth transition between the highlight area and the target area, resulting in a gap between the highlight area and the target area. areas where there is a noticeable change in brightness.
步骤502B,计算所述矫正像素点中的目标颜色分量对应的颜色分量值与所述矫正像素点中的第一剩余颜色分量对应的颜色分量值的差值,得到第一差值。Step 502B, calculating the difference between the color component value corresponding to the target color component in the corrected pixel point and the color component value corresponding to the first remaining color component in the corrected pixel point, to obtain a first difference value.
第一差值,为矫正像素点中的目标颜色分量和第一剩余颜色分量对应的颜色分量值的差值。例如,目标颜色分量为红色分量,第一剩余颜色分量为蓝色分量,则计算得到矫正像素点的红色分量对应的颜色分量值(假设为60)与蓝色分量对应的颜色分量值(假设为45)的差值为15,即第一差值为15。The first difference is the difference between the target color component in the corrected pixel and the color component value corresponding to the first remaining color component. For example, if the target color component is a red component, and the first remaining color component is a blue component, then the color component value corresponding to the red component of the corrected pixel point (assumed to be 60) and the color component value corresponding to the blue component (assumed to be 45) has a difference of 15, that is, the first difference is 15.
步骤502C,计算所述矫正像素点中的目标颜色分量对应的颜色分量值与所述矫正像素点中的第二剩余颜色分量对应的颜色分量值的差值,得到第二差值。Step 502C, calculating the difference between the color component value corresponding to the target color component in the corrected pixel point and the color component value corresponding to the second remaining color component in the corrected pixel point, to obtain a second difference value.
第二差值,为矫正像素点中的目标颜色分量和第二剩余颜色分量对应的颜色分量值的差值。例如,第二剩余颜色分量为绿色分量,则计算得到矫正像素点的红色分量对应的颜色分量值(假设为60)与绿色分量对应的颜色分量值(假设为40)的差值为20,即第二差值为20。The second difference is the difference between the target color component in the corrected pixel and the color component value corresponding to the second remaining color component. For example, if the second remaining color component is the green component, then the difference between the color component value corresponding to the red component of the corrected pixel point (assumed to be 60) and the color component value corresponding to the green component (assumed to be 40) is calculated to be 20, namely The second difference is 20.
步骤502D,计算所述目标像素点的目标颜色分量对应的颜色分量值与所述第一差值的差值,得到所述目标像素点的第一剩余颜色分量对应的颜色分量值。Step 502D, calculating the difference between the color component value corresponding to the target color component of the target pixel point and the first difference value, to obtain the color component value corresponding to the first remaining color component of the target pixel point.
对待矫正的像素点的第一剩余颜色分量进行矫正。例如,待矫正的像素点的目标颜色分量(红色分量)对应的颜色分量值为70,第一差值为15,则矫正后,像素点的第一剩余颜色分量(蓝色分量)对应的颜色分量值为55。The first remaining color component of the pixel to be corrected is corrected. For example, if the color component value corresponding to the target color component (red component) of the pixel to be corrected is 70, and the first difference value is 15, then after correction, the color corresponding to the first remaining color component (blue component) of the pixel point The component value is 55.
由于颜色值的范围是0到255,因此,如果计算得到的像素点的第一剩余颜色分量对应的颜色分量值大于255,则将像素点的第一剩余颜色分量对应的颜色分量值设置为255;如果计算得到的像素点的第一剩余颜色分量对应的颜色分量值小于0,则将像素点的第一剩余颜色分量对应的颜色分量值设置为0。Since the color value ranges from 0 to 255, if the calculated color component value corresponding to the first remaining color component of the pixel is greater than 255, set the color component value corresponding to the first remaining color component of the pixel to 255 ; If the calculated color component value corresponding to the first remaining color component of the pixel is less than 0, set the color component value corresponding to the first remaining color component of the pixel to 0.
步骤502E,计算所述目标像素点的目标颜色分量对应的颜色分量值与所述第二差值的差值,得到所述目标像素点的第二剩余颜色分量对应的颜色分量值。Step 502E, calculating the difference between the color component value corresponding to the target color component of the target pixel point and the second difference value, to obtain the color component value corresponding to the second remaining color component of the target pixel point.
对待矫正的像素点的第二剩余颜色分量进行矫正。例如,待矫正的像素点的目标颜色分量(红色分量)对应的颜色分量值为70,第二差值为20则矫正后,像素点的第二剩余颜色分量(绿色分量)对应的颜色分量值为50。The second remaining color component of the pixel to be corrected is corrected. For example, if the color component value corresponding to the target color component (red component) of the pixel to be corrected is 70, and the second difference is 20, then after correction, the color component value corresponding to the second remaining color component (green component) of the pixel point for 50.
如果计算得到的像素点的第二剩余颜色分量对应的颜色分量值大于255,则将像素点的第二剩余颜色分量对应的颜色分量值设置为255;如果计算得到的像素点的第二剩余颜色分量对应的颜色分量值小于0,则将像素点的第二剩余颜色分量对应的颜色分量值设置为0。If the calculated color component value corresponding to the second remaining color component of the pixel is greater than 255, then set the color component value corresponding to the second remaining color component of the pixel to 255; if the calculated second remaining color of the pixel If the color component value corresponding to the component is less than 0, then the color component value corresponding to the second remaining color component of the pixel is set to 0.
最后,保持待矫正的像素点的目标颜色分量对应的颜色分量值不变,以保证待矫正像素点的亮度不变。例如,待矫正的像素点的红色分量对应的颜色分量值为70,则矫正前后,该像素点的红色分量对应的颜色分量值均为70。Finally, keep the color component value corresponding to the target color component of the pixel to be corrected unchanged, so as to ensure that the brightness of the pixel to be corrected remains unchanged. For example, if the color component value corresponding to the red component of the pixel to be corrected is 70, then the color component value corresponding to the red component of the pixel is 70 before and after correction.
上述实施例,首先确定了目标颜色分量,然后在对目标像素点的颜色值进行矫正的过程中,保持目标像素点的目标颜色分量对应的颜色分量值不变,即保证像素点的亮度不变,然后再对像素点的第一剩余颜色分量和第二剩余颜色分量对应的颜色分量值进行矫正,使得像素点在矫正后的亮度与矫正前的亮度不会出现过大的差异,进而使得矫正后的色边中不会出现明显的亮度差异区域(考虑到不可能将色边中的全部色边像素点都识别出来,即色边像素点的识别可能出现遗漏,那么,如果直接将矫正像素点的颜色值作为待矫正的像素点的颜色值来矫正,那么矫正后,如果还有未矫正的色边像素点,必然和矫正后的色边像素点出现明显的颜色差异,即色边仍然存在,因此,保持未矫正的色边像素点和矫正后的色边像素点的亮度差异不会太大,从而即使无法对所有的色边像素点进行矫正,也不会出现很大的亮度改变,从视觉上来看,色边在一定程度上被消除)。In the above-mentioned embodiment, the target color component is first determined, and then the color component value corresponding to the target color component of the target pixel is kept unchanged during the process of correcting the color value of the target pixel, that is, the brightness of the pixel is guaranteed to remain unchanged , and then correct the color component values corresponding to the first remaining color component and the second remaining color component of the pixel, so that the brightness of the pixel after correction will not be too different from the brightness before correction, so that the correction There will be no obvious brightness difference area in the color fringe (considering that it is impossible to identify all the color fringe pixels in the color fringe, that is, the recognition of color fringe pixels may be missed, then, if the correction pixel is directly The color value of the point is corrected as the color value of the pixel to be corrected. After correction, if there are still uncorrected color edge pixels, there must be obvious color differences from the corrected color edge pixels, that is, the color edge remains Therefore, the brightness difference between the uncorrected color fringe pixels and the corrected color fringe pixels will not be too large, so even if all the color fringe pixels cannot be corrected, there will not be a large brightness change , visually, the color fringing is eliminated to some extent).
在一个实施例中,步骤501所述根据所述目标像素点在多个预设方向上的梯度值查找所述目标像素点对应的矫正像素点,包括:In one embodiment, step 501, searching for the corrected pixel corresponding to the target pixel according to the gradient values of the target pixel in multiple preset directions includes:
步骤501A,根据所述目标像素点在多个预设方向上的梯度值是否有效确定所述目标像素点对应的矫正像素点的查找方向。Step 501A, determine the search direction of the correction pixel corresponding to the target pixel according to whether the gradient values of the target pixel in multiple preset directions are valid.
当目标像素点是目标图像中的色边像素点时,根据目标像素点在多个预设方向上的梯度值是否有效,将梯度值有效的预设方向的反方向确定为矫正像素点的查找方向。具体的,如表1所示。When the target pixel is a color edge pixel in the target image, according to whether the gradient values of the target pixel in multiple preset directions are valid, the reverse direction of the preset direction where the gradient value is valid is determined as the search for the corrected pixel direction. Specifically, as shown in Table 1.
表1Table 1
Figure PCTCN2021136744-appb-000002
Figure PCTCN2021136744-appb-000002
步骤501B,在所述查找方向上的预设像素范围内查找所述目标像素点对应的矫正像素点。Step 501B, searching for the correction pixel corresponding to the target pixel within the preset pixel range in the search direction.
预设像素范围,为预先设置的像素范围。其中,像素范围,指像素点的个数。例如,预设像素范围为5,查找方向为0°方向,则在0°方向上的5个像素范围内查找矫正像素点。Preset pixel range is the preset pixel range. Wherein, the pixel range refers to the number of pixels. For example, if the preset pixel range is 5, and the search direction is 0° direction, then search and correct pixel points within the range of 5 pixels in the 0° direction.
上述实施例,提供了一种矫正像素点的查找方法,首先根据梯度值是否有效确定查找方向,然后在该查找方向上查找矫正像素点。由于梯度值是否有效反映的是相应的预设方向上是否存在高亮像素点,因此,基于梯度值是否有效可以确定矫正像素点的查找方向。The above embodiment provides a search method for corrected pixel points. Firstly, the search direction is determined according to whether the gradient value is valid, and then the corrected pixel points are searched in the search direction. Since whether the gradient value is effective or not reflects whether there is a highlighted pixel point in the corresponding preset direction, the search direction of the corrected pixel point can be determined based on whether the gradient value is valid or not.
在一个实施例中,步骤501B所述在所述查找方向上的预设像素范围内查找所述像素点对应的矫正像素点,包括:In one embodiment, the step 501B of searching for the corrected pixel corresponding to the pixel within the preset pixel range in the search direction includes:
将在所述查找方向上的预设像素范围内首次出现的颜色为非色边颜色的像素点确定为所述像素点对应的矫正像素点。A pixel point whose color is a non-color edge color that appears for the first time within the preset pixel range in the search direction is determined as the corrected pixel point corresponding to the pixel point.
如图3所示,待矫正的色边像素点为ps,查找方向为0°方向,预设像素范围为5,在0°方向首次出现的颜色为非色边颜色的像素点为像素点P2,于是,将P2作为目标像素点ps对应的矫正像素点。As shown in Figure 3, the color fringe pixel to be corrected is ps, the search direction is the 0° direction, the preset pixel range is 5, and the pixel that appears for the first time in the 0° direction is a non-color fringe color is pixel P2 , so P2 is taken as the corrected pixel corresponding to the target pixel ps.
需要说明的是,如果在查找方向上的预设像素范围内无法查找到颜色为非色边颜色的像素点(矫正像素点),则不对待矫正的像素点ps进行矫正。It should be noted that if no pixel (corrected pixel) can be found within the preset pixel range in the search direction, the pixel to be corrected will not be corrected.
由于色边像素点的颜色是色边颜色,因此,颜色为非色边颜色的像素点不是色边像素点,可以用来对色边像素点进行矫正。Since the color of the color fringe pixels is the color fringe color, the pixels whose color is not the color fringe color are not color fringe pixels, and can be used to correct the color fringe pixels.
上述实施例,将首次出现的颜色为非色边颜色的像素点确定为像素点对应的矫正像素点的优势是减少计算量并且提高矫正准确率,可以理解的是,距离色边像素点越近的像素点与色边像素点应当更相似,距离色边像素点越远的像素点与色边像素点越不相似,因此,在首次出现颜色为非色边颜色的像素点时,直接将其设置为矫正像素点,减少计算量的同时还可以提高矫正准确率。In the above-mentioned embodiment, the advantage of determining the first-appearing pixel that is a non-color edge color as the corrected pixel corresponding to the pixel is to reduce the amount of calculation and improve the correction accuracy. It can be understood that the closer the pixel is to the color edge The pixels of the color edge should be more similar to the color edge pixels, and the farther away from the color edge pixels, the less similar to the color edge pixels. Therefore, when a pixel with a color other than a color edge color appears for the first time, directly Set to rectify pixels, which can reduce the amount of calculation and improve the accuracy of correction.
在一个实施例中,在步骤400所述根据所述目标像素点在多个预设方向上的梯度值确定所述目标像素点是否是所述目标图像中的色边像素点之前,还包括:In one embodiment, before determining whether the target pixel is a color fringe pixel in the target image according to the gradient values of the target pixel in multiple preset directions in step 400, it further includes:
步骤600,根据所述目标像素点的颜色值计算所述目标像素点的亮度值。Step 600, calculating the brightness value of the target pixel point according to the color value of the target pixel point.
亮度值,反映目标像素点的亮度的大小,亮度值越大,目标像素点的亮度越大,亮度值越小,目标像素点的亮度越小。The brightness value reflects the brightness of the target pixel point. The larger the brightness value, the larger the brightness of the target pixel point, and the smaller the brightness value, the smaller the brightness of the target pixel point.
示例性的,提供一种计算目标像素点的亮度值的方法,包括:获取红色权重、绿色权重和蓝色权重,其中,红色权重、绿色权重和蓝色权重的和为1;将红色权重与目标像素点的红色值相乘,得到红色亮度;将绿色权重与目标像素点的绿色值相乘,得到绿色亮度;将蓝色权重与目标像素点的蓝色值相乘,得到蓝色亮度;将红色亮度、绿色亮度和蓝色亮度求和,得到目标像素点的亮度值。例如,红色权重、绿色权重和蓝色权重分别为w1、w2和w3,红色值、绿色值和蓝色值分别为R、G和B,于是,亮度值=w1×R+w2×G+w3×B。在一个实施例中,w1、w2和w3的值均为1/3,即通过对红色值、绿色值和蓝色值求均值得到亮度值。Exemplarily, a method for calculating the brightness value of a target pixel is provided, including: obtaining a red weight, a green weight, and a blue weight, wherein the sum of the red weight, the green weight, and the blue weight is 1; combining the red weight with Multiply the red value of the target pixel to obtain the red brightness; multiply the green weight by the green value of the target pixel to obtain the green brightness; multiply the blue weight by the blue value of the target pixel to obtain the blue brightness; The red brightness, green brightness and blue brightness are summed to obtain the brightness value of the target pixel. For example, the red weight, green weight and blue weight are w1, w2 and w3 respectively, and the red value, green value and blue value are R, G and B respectively, so the brightness value=w1×R+w2×G+w3 ×B. In one embodiment, the values of w1, w2 and w3 are all 1/3, that is, the brightness value is obtained by averaging the red value, the green value and the blue value.
步骤700,获取预设亮度值和所述目标像素点在所述多个预设方向中的每个预设方向上的最大亮度值。Step 700, acquiring a preset brightness value and a maximum brightness value of the target pixel point in each preset direction in the plurality of preset directions.
预设亮度值,为预先设置的亮度值。因为色边出现在亮度差异较大的边界处,因此,预先设置一个亮度值,以查看目标像素点周围是否存在亮度较高的像素点,进而判断目标像素点是否是色边像素点。由于色边周围存在亮度较大的区域,因此,可以将预设亮度值设置的相对较大一些。The preset brightness value is a preset brightness value. Because the color fringe appears at the boundary where the brightness difference is large, therefore, a brightness value is set in advance to check whether there are pixels with higher brightness around the target pixel, and then judge whether the target pixel is a color fringe pixel. Since there is a region with higher brightness around the color edge, the preset brightness value can be set relatively larger.
示例性的,提供一种确定预设亮度值的方法,包括:获取相机拍摄得到的目标场景的多张图像;获取每张图像中色边周围的高亮区域的像素点的颜色值;根据多张图像中色边周围的高亮区域的像素点的颜色值得到预设亮度值。Exemplarily, a method for determining a preset brightness value is provided, including: acquiring multiple images of a target scene captured by a camera; acquiring the color values of pixels in a highlighted area around the color fringe in each image; The color value of the pixel point in the highlighted area around the color edge in the image to obtain the preset brightness value.
上述确定预设亮度值的方法,针对目标场景获取多张图像,然后根据该多张图像计算得到预设亮度 值,能够得到同一相机在不同的目标场景下的预设亮度值,提高同一相机在不同的目标场景下的预设亮度值的确定的准确率。The above-mentioned method for determining the preset brightness value obtains multiple images for the target scene, and then calculates the preset brightness value based on the multiple images, which can obtain the preset brightness values of the same camera in different target scenes, and improve the performance of the same camera in different target scenes. Accuracy of determination of preset brightness values under different target scenes.
示例性的,多个预设方向,为0°方向、45°方向、90°方向、135°方向、180°方向、225°方向、270°方向、315°方向,相较于简单的设置4个预设方向,设置8个预设方向能够提高查找色边像素点的准确率。Exemplarily, multiple preset directions are 0° direction, 45° direction, 90° direction, 135° direction, 180° direction, 225° direction, 270° direction, 315° direction, compared to simple setting 4 There are 8 preset directions, and setting 8 preset directions can improve the accuracy of finding color edge pixels.
预设方向上的最大亮度值,为该预设方向上的亮度值的最大值。The maximum brightness value in the preset direction is the maximum value of brightness values in the preset direction.
对预设方向上的各个像素点的亮度值进行计算,得到该预设方向上的各个像素点的亮度值。如图4所示,以颜色为色边颜色的像素点为中心,设置一个较大的检测窗口,例如尺寸为11×11的检测窗口,然后对检测窗口覆盖的各个预设方向上的像素点的亮度值进行计算,从而得到各个预设方向上的最大亮度值。The brightness value of each pixel point in the preset direction is calculated to obtain the brightness value of each pixel point in the preset direction. As shown in Figure 4, set a larger detection window, such as a detection window with a size of 11×11, with the pixel point whose color is the color edge color as the center, and then detect the pixel points in each preset direction covered by the detection window The luminance value is calculated to obtain the maximum luminance value in each preset direction.
示例性的,提供一种确定检测窗口的尺寸的方法,包括:获取相机拍摄得到的目标场景的多张图像;确定每张图像中色边的像素宽度;根据多张图像中色边的像素宽度得到检测窗口的尺寸。Exemplarily, a method for determining the size of the detection window is provided, including: acquiring multiple images of the target scene captured by the camera; determining the pixel width of the color fringe in each image; Get the size of the detection window.
其中,确定每张图像中色边的像素宽度,包括:对每张图像,确定色边的最大像素宽度和最小像素宽度;将第一宽度权重乘以最大像素宽度,得到第一像素宽度;将第二宽度权重乘以最小像素宽度,得到第二像素宽度;将第一像素宽度和第二像素宽度求和,得到求和结果;根据求和结果得到该图像中色边的像素宽度,其中,第一宽度权重和第二宽度权重的和为1。Wherein, determining the pixel width of the color fringe in each image includes: for each image, determining the maximum pixel width and the minimum pixel width of the color fringe; multiplying the first width weight by the maximum pixel width to obtain the first pixel width; The second width weight is multiplied by the minimum pixel width to obtain the second pixel width; the first pixel width and the second pixel width are summed to obtain the summation result; the pixel width of the color edge in the image is obtained according to the summation result, wherein, The sum of the first width weight and the second width weight is one.
例如,最大像素宽度和最小像素宽度分别为5和3,第一宽度权重为0.6,第二宽度权重为0.4,于是,第一宽度为:5×0.6=3,第二宽度为:3×0.4=1.2,将第一宽度和第二宽度求和得到求和结果为4.2,于是,对求和结果取整,得到色边的像素宽度为4。For example, the maximum pixel width and the minimum pixel width are 5 and 3 respectively, the weight of the first width is 0.6, and the weight of the second width is 0.4, so the first width is: 5×0.6=3, and the second width is: 3×0.4 =1.2, the summation result of the first width and the second width is 4.2, and the summation result is rounded to obtain the pixel width of the color fringe as 4.
其中,根据多张图像中色边的像素宽度得到检测窗口的尺寸,包括:计算多张图像中色边的像素宽度的均值,根据多张图像中色边的像素宽度的均值得到检测窗口的尺寸。Wherein, the size of the detection window is obtained according to the pixel width of the color fringe in the multiple images, including: calculating the average value of the pixel width of the color fringe in the multiple images, and obtaining the size of the detection window according to the average value of the pixel width of the color fringe in the multiple images .
其中,根据多张图像中色边的像素宽度的均值得到检测窗口的尺寸,包括:将多张图像中色边的像素宽度的均值乘以2再加1,得到检测窗口的尺寸。Wherein, obtaining the size of the detection window according to the average value of the pixel width of the color fringe in the multiple images includes: multiplying the average value of the pixel width of the color fringe in the multiple images by 2 and adding 1 to obtain the size of the detection window.
例如,有3张图像,3张图像中色边的像素宽度分别为4、5和6,于是,均值为5,于是确定检测窗口的尺寸为:5×2+1=11。For example, there are 3 images, and the pixel widths of the color fringes in the 3 images are 4, 5 and 6 respectively, so the average value is 5, so the size of the detection window is determined to be: 5×2+1=11.
步骤800,将所述目标像素点在所述多个预设方向中的每个预设方向上的最大亮度值与所述预设亮度值进行比较,得到所述目标像素点在所述多个预设方向中的每个预设方向上的梯度权重。Step 800, comparing the maximum luminance value of the target pixel point in each preset direction in the plurality of preset directions with the preset luminance value to obtain the target pixel point in the plurality of preset directions. Gradient weights in each of the preset directions.
对某个预设方向,若目标像素点在该预设方向上的最大亮度值大于或等于预设亮度值,则确定目标像素点在该预设方向上的梯度权重为第一权重;若目标像素点在该预设方向上的最大亮度值小于预设亮度值,则确定目标像素点在该预设方向上的梯度权重为第二权重。其中,第一权重大于第二权重,例如,第一权重为0.9,第二权重为0.1;再如,第一权重为1,第二权重为0,即当最大亮度值小于预设亮度值时,认为该预设方向上找不到高亮的像素点。For a preset direction, if the maximum brightness value of the target pixel point in the preset direction is greater than or equal to the preset brightness value, then determine the gradient weight of the target pixel point in the preset direction as the first weight; if the target If the maximum brightness value of the pixel point in the preset direction is smaller than the preset brightness value, then it is determined that the gradient weight of the target pixel point in the preset direction is the second weight. Wherein, the first weight is greater than the second weight, for example, the first weight is 0.9, and the second weight is 0.1; for another example, the first weight is 1, and the second weight is 0, that is, when the maximum brightness value is less than the preset brightness value , thinking that no highlighted pixel can be found in the preset direction.
步骤9000,将所述目标像素点在所述多个预设方向中的每个预设方向上的最大亮度值与所述目标像素点的亮度值进行比较,得到所述目标像素点在所述多个预设方向中的每个预设方向上的初步梯度值。Step 9000, comparing the maximum luminance value of the target pixel point in each preset direction in the plurality of preset directions with the luminance value of the target pixel point to obtain the target pixel point in the Preliminary gradient values in each of the plurality of preset directions.
对某个预设方向,将目标像素点在该预设方向上的最大亮度值减去该目标像素点的亮度值,得到目标像素点在该预设方向上的初步梯度值。For a preset direction, the brightness value of the target pixel point is subtracted from the maximum brightness value of the target pixel point in the preset direction to obtain a preliminary gradient value of the target pixel point in the preset direction.
步骤1000,将所述目标像素点在所述多个预设方向中的每个预设方向上的梯度权重和所述目标像素点在相应的预设方向上的初步梯度值相乘,得到所述目标像素点在所述多个预设方向中的每个预设方向上的梯度值。Step 1000: Multiply the gradient weight of the target pixel point in each preset direction in the plurality of preset directions by the preliminary gradient value of the target pixel point in the corresponding preset direction to obtain the The gradient value of the target pixel point in each preset direction in the plurality of preset directions.
假设目标像素点的亮度值为p_center,预设亮度值为grad_det_I,则对某个预设方向,获取该预设方 向上的最大亮度值,假设为p_max,则目标像素点在该预设方向上的梯度值为:Assuming that the brightness value of the target pixel is p_center, and the preset brightness value is grad_det_I, then for a preset direction, obtain the maximum brightness value in the preset direction, assuming it is p_max, then the target pixel point is in the preset direction The gradient value of is:
(p_max-p_center)×compare(p_max,grad_det_I),(p_max-p_center)×compare(p_max,grad_det_I),
其中,compare为对p_max和grad_det_I进行比较,当p_max大于或等于grad_det_I,compare的输出为第一权重,当p_max小于grad_det_I,compare的输出为第二权重。Among them, compare is to compare p_max and grad_det_I. When p_max is greater than or equal to grad_det_I, the output of compare is the first weight. When p_max is less than grad_det_I, the output of compare is the second weight.
上述实施例,提供了一种计算像素点在各个预设方向上的梯度值的方法。由于色边通常出现在亮度差异较大的交界处,因此,基于像素点的亮度来计算梯度值,以提高色边像素点判断的准确率。The above embodiment provides a method for calculating the gradient value of a pixel point in each preset direction. Since the color fringe usually appears at the junction where there is a large difference in brightness, the gradient value is calculated based on the brightness of the pixel to improve the accuracy of judging the color fringe pixel.
在一个实施例中,步骤300所述根据所述像素点的颜色值、红绿差值和蓝绿差值确定所述像素点的颜色,包括:In one embodiment, determining the color of the pixel according to the color value, the red-green difference value and the blue-green difference value of the pixel point in step 300 includes:
步骤301,获取多个颜色组,所述颜色组中包括预设蓝色值、预设红绿差值和预设蓝绿差值。In step 301, a plurality of color groups are obtained, and the color groups include a preset blue value, a preset red-green difference value, and a preset blue-green difference value.
预设蓝色值,为预先设置的蓝色值;预设红绿差值,为预先设置的红绿差值;预设蓝绿差值,为预先设置的蓝绿差值。The preset blue value is the preset blue value; the preset red-green difference value is the preset red-green difference value; the preset blue-green difference value is the preset blue-green difference value.
示例性的,用Y i(BL i,RG i,BG i)表示多个颜色组中的第i个颜色组,其中,BL i表示第i个颜色组中的预设蓝色值,RG i表示第i个颜色组中的预设红绿差值,BG i表示第i个颜色组中的预设蓝绿差值。 Exemplarily, Y i (BL i , RG i , BG i ) represents the i-th color group among the multiple color groups, where BL i represents the preset blue value in the i-th color group, and RG i Indicates the preset red-green difference value in the i-th color group, and BG i represents the preset blue-green difference value in the i-th color group.
以紫色色边为例,设置6个颜色组,分别为:Y 1(BL 1,RG 1,BG 1),Y 2(BL 2,RG 2,BG 2),Y 3(BL 3,RG 3,BG 3),Y 4(BL 4,RG 4,BG 4),Y 5(BL 5,RG 5,BG 5),Y 6(BL 6,RG 6,BG 6)。 Taking the purple color border as an example, set 6 color groups, namely: Y 1 (BL 1 ,RG 1 ,BG 1 ), Y 2 (BL 2 ,RG 2 ,BG 2 ), Y 3 (BL 3 ,RG 3 , BG 3 ), Y 4 (BL 4 , RG 4 , BG 4 ), Y 5 (BL 5 , RG 5 , BG 5 ), Y 6 (BL 6 , RG 6 , BG 6 ).
预先设置多个颜色组的目的:即使是同样的颜色,由于光照强度不同,即亮度不同,其颜色值也有差异,因此,为了区分不同亮度的颜色值,同时区分偏蓝或者偏红的颜色,选择设置多个颜色组。The purpose of setting multiple color groups in advance: Even for the same color, due to different light intensity, that is, different brightness, its color value is also different. Therefore, in order to distinguish color values of different brightness, and at the same time distinguish bluish or reddish colors, Select to set multiple color groups.
步骤302,将所述像素点的蓝色值与目标颜色组中的预设蓝色值进行比较,得到所述目标颜色组对应的蓝色比较结果,所述目标颜色组为所述多个颜色组中的一个待比对颜色组。Step 302, comparing the blue value of the pixel with the preset blue value in the target color group to obtain a blue comparison result corresponding to the target color group, the target color group being the plurality of colors A color group in the group to be compared.
待比对颜色组,为多个颜色组中还未参与比对的颜色组。再如上例子,假设还未参与比对的颜色组为Y 5(BL 5,RG 5,BG 5)和Y 6(BL 6,RG 6,BG 6),于是,待比对颜色组为Y 5(BL 5,RG 5,BG 5),Y 6(BL 6,RG 6,BG 6),将待比对颜色组中的一个,例如,Y 5(BL 5,RG 5,BG 5),作为目标颜色组。 The color group to be compared is a color group that has not participated in the comparison among the multiple color groups. As in the example above, assume that the color groups that have not participated in the comparison are Y 5 (BL 5 , RG 5 , BG 5 ) and Y 6 (BL 6 , RG 6 , BG 6 ), so the color group to be compared is Y 5 (BL 5 , RG 5 , BG 5 ), Y 6 (BL 6 , RG 6 , BG 6 ), use one of the color groups to be compared, for example, Y 5 (BL 5 , RG 5 , BG 5 ), as Target color group.
蓝色比较结果,为蓝色值的比较结果。The blue comparison result is the comparison result of the blue value.
步骤303,将所述像素点的红绿差值与所述目标颜色组中的预设红绿差值进行比较,得到所述目标颜色组对应的红绿比较结果。Step 303 , comparing the red-green difference value of the pixel with the preset red-green difference value in the target color group to obtain a red-green comparison result corresponding to the target color group.
红绿比较结果,为红绿差值的比较结果。The red-green comparison result is the comparison result of the difference between red and green.
步骤304,将所述像素点的蓝绿差值与所述目标颜色组中的预设蓝绿差值进行比较,得到所述目标颜色组对应的蓝绿比较结果。Step 304, comparing the blue-green difference value of the pixel with the preset blue-green difference value in the target color group to obtain a blue-green comparison result corresponding to the target color group.
蓝绿比较结果,为蓝绿差值的比较结果。The blue-green comparison result is the comparison result of the blue-green difference.
步骤305,根据所述多个颜色组对应的蓝色比较结果、红绿比较结果和蓝绿比较结果确定所述像素点的颜色。Step 305: Determine the color of the pixel according to the blue comparison results, red-green comparison results, and blue-green comparison results corresponding to the plurality of color groups.
假设像素点的蓝色值用b表示,像素点的红绿差值用r-g表示,像素点的蓝绿差值用b-g表示,BL 4=BL 1,BG 4=BG 1,BL 5=BL 2,BG 5=BG 2,BL 6=BL 3,BG 6=BG 3,RG 4,RG 5和RG 6相同(假设为k1)且为h1到h2之间的一个整数,h1<h2,RG 1,RG 2和RG 3相同(假设为k2)且为h3到h4之间的一个整数,h3>0,h4>0,h3<h4,h4<h1,即对蓝色值和蓝绿差值设置了三个等级,对红绿差值设置了两个等级,从而得到6个颜色组,于是: Suppose the blue value of a pixel is represented by b, the red-green difference of a pixel is represented by rg, the blue-green difference of a pixel is represented by bg, BL 4 =BL 1 , BG 4 =BG 1 , BL 5 =BL 2 , BG 5 =BG 2 , BL 6 =BL 3 , BG 6 =BG 3 , RG 4 , RG 5 and RG 6 are the same (assumed to be k1) and are an integer between h1 and h2, h1<h2, RG 1 , RG 2 and RG 3 are the same (assumed to be k2) and are an integer between h3 and h4, h3>0, h4>0, h3<h4, h4<h1, that is, set the blue value and the blue-green difference Three levels are set, and two levels are set for the difference between red and green, so as to obtain 6 color groups, so:
Figure PCTCN2021136744-appb-000003
Figure PCTCN2021136744-appb-000003
其中,“1”表示像素点的颜色为色边颜色;“0”表示颜色点的颜色不是色边颜色。Among them, "1" indicates that the color of the pixel point is the color edge color; "0" indicates that the color of the color point is not the color edge color.
示例性的,对于紫色色边,6个颜色组设置如下:Exemplarily, for the purple color edge, the 6 color groups are set as follows:
BL 4=BL 1=230,BG 4=BG 1=5,BL 5=BL 2=160,BG 5=BG 2=30,BL 6=BL 3=80,BG 6=BG 3=40,RG 4=RG 5=RG 6=200,RG 1=RG 2=RG 3=0,即6个颜色组为:Y 1(230,0,5),Y 2(160,0,30),Y 3(80,0,40),Y 4(230,200,5),Y 5(160,200,30),Y 6(80,200,40)。 BL 4 =BL 1 =230, BG 4 =BG 1 =5, BL 5 =BL 2 =160, BG 5 =BG 2 =30, BL 6 =BL 3 =80, BG 6 =BG 3 =40, RG 4 =RG 5 =RG 6 =200, RG 1 =RG 2 =RG 3 =0, that is, the 6 color groups are: Y 1 (230,0,5), Y 2 (160,0,30), Y 3 ( 80,0,40), Y 4 (230,200,5), Y 5 (160,200,30), Y 6 (80,200,40).
继续如上例子,将颜色组中的红绿差值RG 1,RG 2和RG 3设置得大一些,使得颜色组能够检测偏红的紫色色边,RG 1,RG 2和RG 3越大,越偏向于检测偏红的紫色色边,例如,将RG 1,RG 2和RG 3全部设置为0;或者,将颜色组中的红绿差值RG 4,RG 5和RG 6设置得小一些,使得颜色组能够检测偏蓝的紫色色边,RG 4,RG 5和RG 6越小,越偏向于检测偏蓝的紫色色边,,例如,将RG 4,RG 5和RG 6全部设置为200或者255。 Continuing with the above example, set the red-green difference RG 1 , RG 2 and RG 3 in the color group to be larger, so that the color group can detect the reddish purple color edge, the larger the RG 1 , RG 2 and RG 3 , the more Prefer to detect reddish purple color edges, for example, set RG 1 , RG 2 and RG 3 to 0; or, set the red-green difference in the color group RG 4 , RG 5 and RG 6 to be smaller, Enables the color group to detect bluish purple color edges, the smaller the RG 4 , RG 5 and RG 6 , the more inclined to detect bluish purple color edges, for example, set RG 4 , RG 5 and RG 6 to 200 Or 255.
上述实施例,预先设置多个颜色组,并根据多个颜色组对应的蓝色比较结果、红绿比较结果和蓝绿比较结果确定像素点的颜色,能够对不同亮度的相同颜色,以及,偏红或者偏蓝的颜色进行识别,提高了颜色的识别率。In the above embodiment, multiple color groups are preset, and the color of the pixel is determined according to the blue comparison results, red-green comparison results, and blue-green comparison results corresponding to the multiple color groups. Red or bluish colors are recognized, which improves the color recognition rate.
在一个实施例中,步骤305所述根据所述多个颜色组对应的蓝色比较结果、红绿比较结果和蓝绿比较结果确定所述像素点的颜色,包括:In one embodiment, determining the color of the pixel according to the blue comparison results, red-green comparison results, and blue-green comparison results corresponding to the multiple color groups in step 305 includes:
若所述目标颜色组对应的蓝色比较结果满足第一条件,所述目标颜色组对应的红绿比较结果满足第二条件,所述目标颜色组对应的蓝绿比较结果满足第三条件,则确定所述目标像素点的颜色为色边颜色。If the blue comparison result corresponding to the target color group meets the first condition, the red-green comparison result corresponding to the target color group meets the second condition, and the blue-green comparison result corresponding to the target color group meets the third condition, then Determine the color of the target pixel point as the color edge color.
其中,第一条件,为该目标颜色组中的蓝色比较结果应该满足的条件;第二条件,为该目标颜色组中的红绿比较结果应该满足的条件;第三条件,为该目标颜色组中的蓝绿比较结果应该满足的条件。因此,目标颜色组不同,该目标颜色组对应的第一条件、第二条件和第三条件可能不同。Among them, the first condition is the condition that the blue comparison result in the target color group should meet; the second condition is the condition that the red-green comparison result in the target color group should meet; the third condition is the target color A condition that the blue-green comparison result in the group should satisfy. Therefore, the target color groups are different, and the first condition, the second condition and the third condition corresponding to the target color groups may be different.
继续如上例子,假设目标颜色组为Y 1(BL 1,RG 1,BG 1),RG 1为h3到h4之间的一个整数,于是,第一条件为:目标像素点的蓝色值大于目标颜色组中的预设蓝色值;第二条件为:目标像素点的红绿差值大于目标颜色组中的预设红绿差值;第三条件为:目标像素点的蓝绿差值大于目标颜色组中的预设蓝绿差值。再如,目标颜色组为Y 6(BL 6,RG 6,BG 6),其中,RG 6为h1到h2之间的一个整数,h3>0,h4>0,h3<h4,h4<h1,于是,第一条件为:目标像素点的蓝色值大于目标颜色组中的预设蓝色值;第二条件为:目标像素点的红绿差值大于目标颜色组中的预设红绿差值;第三条件为:目标像素点的蓝绿差值小于目标颜色组中的预设蓝绿差值。 Continuing with the above example, assuming that the target color group is Y 1 (BL 1 , RG 1 , BG 1 ), RG 1 is an integer between h3 and h4, so the first condition is: the blue value of the target pixel is greater than the target The preset blue value in the color group; the second condition is: the red-green difference of the target pixel is greater than the preset red-green difference in the target color group; the third condition is: the blue-green difference of the target pixel is greater than The preset blue-green delta value in the target color group. For another example, the target color group is Y 6 (BL 6 , RG 6 , BG 6 ), where RG 6 is an integer between h1 and h2, h3>0, h4>0, h3<h4, h4<h1, Therefore, the first condition is: the blue value of the target pixel is greater than the preset blue value in the target color group; the second condition is: the red-green difference of the target pixel is greater than the preset red-green difference in the target color group value; the third condition is: the blue-green difference value of the target pixel is smaller than the preset blue-green difference value in the target color group.
上述实施例,在目标颜色组对应的比较结果满足条件的时候,便不再对其他待比对颜色组进行比对,减少了确定像素点颜色的计算量,提高了像素点的颜色的确定效率。In the above-mentioned embodiment, when the comparison result corresponding to the target color group satisfies the conditions, no comparison is made to other color groups to be compared, which reduces the amount of calculation for determining the color of the pixel and improves the efficiency of determining the color of the pixel .
在一个实施例中,如图5所示,提供了一种图像中的色边像素点的确定装置5,包括:In one embodiment, as shown in FIG. 5, a device 5 for determining color fringe pixels in an image is provided, including:
获取模块51,可以配置成用于获取目标图像中的目标像素点的颜色值,所述颜色值包括红色值、绿色值和蓝色值;The obtaining module 51 may be configured to obtain the color value of the target pixel in the target image, the color value including a red value, a green value and a blue value;
计算模块52,可以配置成用于计算所述目标像素点的红色值和绿色值之间的差值,得到红绿差值, 计算所述目标像素点的蓝色值和绿色值之间的差值,得到蓝绿差值;The calculation module 52 may be configured to calculate the difference between the red value and the green value of the target pixel to obtain the red-green difference, and calculate the difference between the blue value and the green value of the target pixel value, get the blue-green difference;
确定模块53,可以配置成用于根据所述目标像素点的颜色值、红绿差值和蓝绿差值确定所述像素点的颜色;The determination module 53 may be configured to determine the color of the pixel point according to the color value, red-green difference value and blue-green difference value of the target pixel point;
色边模块54,可以配置成用于当所述目标像素点的颜色为色边颜色时,根据所述目标像素点在多个预设方向上的梯度值确定所述目标像素点是否是所述目标图像中的色边像素点,所述色边像素点为所述目标图像中的色边中的像素点。The color fringe module 54 may be configured to determine whether the target pixel is the color fringe color according to the gradient values of the target pixel in multiple preset directions when the color of the target pixel is A color fringe pixel in the target image, the color fringe pixel being a pixel in the color fringe in the target image.
上述图像中的色边像素点的确定装置,在确定像素点的颜色值之后,还根据颜色值确定了红绿差值和蓝绿差值,相较于单纯的根据颜色值来确定像素点的颜色的方式,这样的方式能够识别出偏红的颜色和偏蓝的颜色,使得对颜色的识别更加的灵活,在一定程度上避免了色边像素点的遗漏,最后考虑到色边是出现在亮度差异较大的交界处,这些位置必然存在一定的梯度,因此,在确定像素点的颜色为色边颜色之后,还根据多个预设方向的梯度值来进一步确定该像素点是否是色边像素点,在一定程度上提高了色边像素点的识别率。The above-mentioned device for determining the color edge pixel in the image, after determining the color value of the pixel, also determines the difference between red and green and the difference between blue and green according to the color value, compared with determining the pixel point simply based on the color value The way of color, this way can identify the reddish color and the bluish color, which makes the color recognition more flexible, and avoids the omission of color edge pixels to a certain extent. Finally, considering that the color edge appears in the At the junction where the brightness difference is large, there must be a certain gradient at these positions. Therefore, after determining that the color of the pixel point is the color edge color, it is further determined whether the pixel point is a color edge color according to the gradient values of multiple preset directions. Pixels, to a certain extent, improve the recognition rate of color edge pixels.
在一个实施例中,所述色边模块54,可以配置成用于:判断所述目标像素点在相应的预设方向上的梯度值是否有效;根据所述目标像素点在多个预设方向上的梯度值是否有效确定所述目标像素点是否是所述目标图像中的色边像素点。In one embodiment, the color fringing module 54 can be configured to: determine whether the gradient value of the target pixel point in the corresponding preset direction is valid; Whether the gradient value above is valid determines whether the target pixel is a color edge pixel in the target image.
在一个实施例中,所述色边模块54,可以配置成用于:获取多个梯度组,所述梯度组中包括预设梯度值和预设亮度值;将所述目标像素点在目标预设方向上的梯度值与目标梯度组中的预设梯度值进行比较,得到所述目标像素点在所述目标预设方向上的目标梯度组的梯度比较结果,所述目标梯度组为所述多个梯度组中的一个待比对梯度组,所述目标预设方向为所述多个预设方向中的一个待比对预设方向;将所述目标像素点的亮度值与所述目标梯度组中的预设亮度值进行比较,得到所述目标像素点在所述目标预设方向上的目标梯度组的亮度比较结果;根据所述目标像素点在所述目标预设方向上的所述多个梯度组的梯度比较结果和亮度比较结果确定所述目标像素点在所述目标预设方向上的梯度值是否有效。In one embodiment, the color fringing module 54 can be configured to: obtain a plurality of gradient groups, and the gradient groups include preset gradient values and preset brightness values; Comparing the gradient value in the set direction with the preset gradient value in the target gradient group to obtain the gradient comparison result of the target gradient group of the target pixel point in the target preset direction, the target gradient group is the A gradient group to be compared in a plurality of gradient groups, the target preset direction is a preset direction to be compared in the plurality of preset directions; the brightness value of the target pixel point is compared with the target The preset brightness values in the gradient group are compared to obtain the brightness comparison result of the target gradient group of the target pixel point in the target preset direction; according to the target pixel point in the target preset direction The gradient comparison results and the brightness comparison results of the plurality of gradient groups determine whether the gradient value of the target pixel point in the target preset direction is valid.
在一个实施例中,所述装置5,还包括:矫正模块,可以配置成用于当所述目标像素点是所述目标图像中的色边像素点时,对所述目标像素点的颜色值进行矫正。In one embodiment, the device 5 further includes: a correction module, configured to correct the color value of the target pixel when the target pixel is a color edge pixel in the target image Make corrections.
在一个实施例中,所述矫正模块,可以配置成用于:根据所述目标像素点在多个预设方向上的梯度值查找所述目标像素点对应的矫正像素点;根据所述目标像素点对应的矫正像素点的颜色值对所述目标像素点的颜色值进行矫正。In one embodiment, the correction module may be configured to: search for the corrected pixel corresponding to the target pixel according to the gradient values of the target pixel in multiple preset directions; The color value of the corrected pixel point corresponding to the point corrects the color value of the target pixel point.
在一个实施例中,所述矫正模块,可以配置成用于:确定目标颜色分量,第一剩余颜色分量和第二剩余颜色分量,所述目标颜色分量,所述第一剩余颜色分量和所述第二剩余颜色分量分别为红色分量、绿色分量以及蓝色分量中的一个;计算所述矫正像素点中的目标颜色分量对应的颜色分量值与所述矫正像素点中的第一剩余颜色分量对应的颜色分量值的差值,得到第一差值;计算所述矫正像素点中的目标颜色分量对应的颜色分量值与所述矫正像素点中的第二剩余颜色分量对应的颜色分量值的差值,得到第二差值;计算所述目标像素点的目标颜色分量对应的颜色分量值与所述第一差值的差值,得到所述目标像素点的第一剩余颜色分量对应的颜色分量值;计算所述目标像素点的目标颜色分量对应的颜色分量值与所述第二差值的差值,得到所述目标像素点的第二剩余颜色分量对应的颜色分量值。In one embodiment, the correction module may be configured to: determine the target color component, the first remaining color component and the second remaining color component, the target color component, the first remaining color component and the The second remaining color components are respectively one of the red component, the green component and the blue component; calculating the color component value corresponding to the target color component in the corrected pixel corresponds to the first remaining color component in the corrected pixel The difference value of the color component value of the first difference value is obtained; the difference between the color component value corresponding to the target color component in the corrected pixel point and the color component value corresponding to the second remaining color component in the corrected pixel point is calculated value to obtain the second difference; calculate the difference between the color component value corresponding to the target color component of the target pixel and the first difference, and obtain the color component corresponding to the first remaining color component of the target pixel value; calculating the difference between the color component value corresponding to the target color component of the target pixel point and the second difference value, to obtain the color component value corresponding to the second remaining color component of the target pixel point.
在一个实施例中,所述矫正模块,可以配置成用于:根据所述目标像素点在多个预设方向上的梯度值是否有效确定所述目标像素点对应的矫正像素点的查找方向;在所述查找方向上的预设像素范围内查找所述目标像素点对应的矫正像素点。In one embodiment, the correction module may be configured to: determine the search direction of the corrected pixel corresponding to the target pixel according to whether the gradient values of the target pixel in multiple preset directions are valid; The corrected pixel corresponding to the target pixel is searched within a preset pixel range in the search direction.
在一个实施例中,所述矫正模块,可以配置成用于:将在所述查找方向上的预设像素范围内首次出现的颜色为非色边颜色的像素点确定为所述像素点对应的矫正像素点。In one embodiment, the rectification module may be configured to: determine the first pixel in the preset pixel range in the search direction that is a non-color edge color as the pixel corresponding to the pixel. Correct the pixels.
在一个实施例中,所述装置5,还包括:梯度值确定模块,可以配置成用于:根据所述目标像素点的颜色值计算所述目标像素点的亮度值;获取预设亮度值和所述目标像素点在所述多个预设方向中的每个预设方向上的最大亮度值;将所述目标像素点在所述多个预设方向中的每个预设方向上的最大亮度值与所述预设亮度值进行比较,得到所述目标像素点在所述多个预设方向中的每个预设方向上的梯度权重;将所述目标像素点在所述多个预设方向中的每个预设方向上的最大亮度值与所述目标像素点的亮度值进行比较,得到所述目标像素点在所述多个预设方向中的每个预设方向上的初步梯度值;将所述目标像素点在所述多个预设方向中的每个预设方向上的梯度权重和所述目标像素点在相应的预设方向上的初步梯度值相乘,得到所述目标像素点在所述多个预设方向中的每个预设方向上的梯度值。In one embodiment, the device 5 further includes: a gradient value determination module, which may be configured to: calculate the brightness value of the target pixel point according to the color value of the target pixel point; obtain a preset brightness value and The maximum brightness value of the target pixel point in each preset direction of the multiple preset directions; the maximum brightness value of the target pixel point in each preset direction of the multiple preset directions Comparing the luminance value with the preset luminance value to obtain the gradient weight of the target pixel point in each of the multiple preset directions; Comparing the maximum luminance value in each preset direction in the set direction with the luminance value of the target pixel to obtain a preliminary Gradient value; multiply the gradient weight of the target pixel point in each preset direction in the plurality of preset directions and the preliminary gradient value of the target pixel point in the corresponding preset direction to obtain the The gradient value of the target pixel point in each preset direction in the plurality of preset directions.
在一个实施例中,所述梯度值确定模块,可以配置成用于:获取多个颜色组,所述颜色组中包括预设蓝色值、预设红绿差值和预设蓝绿差值;将所述像素点的蓝色值与目标颜色组中的预设蓝色值进行比较,得到所述目标颜色组对应的蓝色比较结果,所述目标颜色组为所述多个颜色组中的一个待比对颜色组;将所述像素点的红绿差值与所述目标颜色组中的预设红绿差值进行比较,得到所述目标颜色组对应的红绿比较结果;将所述像素点的蓝绿差值与所述目标颜色组中的预设蓝绿差值进行比较,得到所述目标颜色组对应的蓝绿比较结果;根据所述多个颜色组对应的蓝色比较结果、红绿比较结果和蓝绿比较结果确定所述像素点的颜色。In one embodiment, the gradient value determining module can be configured to: obtain a plurality of color groups, the color groups include a preset blue value, a preset red-green difference value and a preset blue-green difference value ; Comparing the blue value of the pixel with the preset blue value in the target color group to obtain a blue comparison result corresponding to the target color group, the target color group being one of the plurality of color groups A color group to be compared; compare the red-green difference value of the pixel with the preset red-green difference value in the target color group to obtain the red-green comparison result corresponding to the target color group; The blue-green difference value of the pixel is compared with the preset blue-green difference value in the target color group to obtain the blue-green comparison result corresponding to the target color group; according to the blue comparison results corresponding to the plurality of color groups The result, the red-green comparison result and the blue-green comparison result determine the color of the pixel.
在一个实施例中,如图6所示,提供了一种计算机设备,该计算机设备具体可以是终端或服务器。该计算机设备包括通过系统总线连接的处理器、存储器和网络接口,存储器包括非易失性存储介质和内存储器,该计算机设备的非易失性存储介质存储有操作系统,还可存储有计算机程序,该计算机程序被处理器执行时,可使得处理器实现图像中的色边像素点的确定方法。非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。该内存储器中也可储存有计算机程序,该计算机程序被处理器执行时,可使得处理器执行图像中的色边像素点的确定方法。本领域技术人员可以理解,图6中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定,具体的计算机设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。In one embodiment, as shown in FIG. 6 , a computer device is provided, and the computer device may specifically be a terminal or a server. The computer device includes a processor, a memory and a network interface connected through a system bus, the memory includes a non-volatile storage medium and an internal memory, and the non-volatile storage medium of the computer device stores an operating system and also stores a computer program When the computer program is executed by the processor, the processor can realize the method for determining color fringe pixels in the image. Nonvolatile memory can include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Chain Synchlink DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc. A computer program may also be stored in the internal memory, and when the computer program is executed by the processor, the processor may execute the method for determining color fringe pixels in the image. Those skilled in the art can understand that the structure shown in FIG. 6 is only a block diagram of a part of the structure related to the solution of this application, and does not constitute a limitation on the computer equipment to which the solution of this application is applied. The specific computer equipment can be More or fewer components than shown in the figures may be included, or some components may be combined, or have a different arrangement of components.
本申请提供的图像中的色边像素点的确定方法可以实现为一种计算机程序的形式,计算机程序可在如图6所示的计算机设备上运行。计算机设备的存储器中可存储组成图像中的色边像素点的确定装置的各个程序模板。比如,获取模块51、计算模块52和确定模块53。The method for determining color fringe pixels in an image provided in this application can be implemented in the form of a computer program, and the computer program can be run on a computer device as shown in FIG. 6 . Various program templates constituting the means for determining the color fringe pixels in the image can be stored in the memory of the computer equipment. For example, an acquisition module 51 , a calculation module 52 and a determination module 53 .
一种计算机设备,包括存储器和处理器,所述存储器存储有计算机程序,所述计算机程序被所述处理器执行时,使得所述处理器执行如下步骤:A computer device, comprising a memory and a processor, the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the following steps:
获取目标图像中的目标像素点的颜色值,所述颜色值包括红色值、绿色值和蓝色值;Acquiring the color value of the target pixel in the target image, the color value comprising a red value, a green value and a blue value;
计算所述目标像素点的红色值和绿色值之间的差值,得到红绿差值,计算所述目标像素点的蓝色值和绿色值之间的差值,得到蓝绿差值;calculating the difference between the red value and the green value of the target pixel to obtain a red-green difference, and calculating the difference between the blue and green values of the target pixel to obtain a blue-green difference;
根据所述目标像素点的颜色值、红绿差值和蓝绿差值确定所述像素点的颜色;determining the color of the pixel according to the color value of the target pixel, the difference between red and green, and the difference between blue and green;
当所述目标像素点的颜色为色边颜色时,根据所述目标像素点在多个预设方向上的梯度值确定所述目标像素点是否是所述目标图像中的色边像素点,所述色边像素点为所述目标图像中的色边中的像素点。When the color of the target pixel is a color fringe color, determine whether the target pixel is a color fringe pixel in the target image according to gradient values of the target pixel in a plurality of preset directions, The color fringe pixels are pixels in the color fringe in the target image.
在一个实施例中,提供了一种计算机可读存储介质,存储有计算机程序,所述计算机程序被处理器 执行时,使得所述处理器执行以下步骤:In one embodiment, a computer-readable storage medium is provided, storing a computer program, and when the computer program is executed by a processor, the processor is made to perform the following steps:
获取目标图像中的目标像素点的颜色值,所述颜色值包括红色值、绿色值和蓝色值;Acquiring the color value of the target pixel in the target image, the color value comprising a red value, a green value and a blue value;
计算所述目标像素点的红色值和绿色值之间的差值,得到红绿差值,计算所述目标像素点的蓝色值和绿色值之间的差值,得到蓝绿差值;calculating the difference between the red value and the green value of the target pixel to obtain a red-green difference, and calculating the difference between the blue and green values of the target pixel to obtain a blue-green difference;
根据所述目标像素点的颜色值、红绿差值和蓝绿差值确定所述像素点的颜色;determining the color of the pixel according to the color value of the target pixel, the difference between red and green, and the difference between blue and green;
当所述目标像素点的颜色为色边颜色时,根据所述目标像素点在多个预设方向上的梯度值确定所述目标像素点是否是所述目标图像中的色边像素点,所述色边像素点为所述目标图像中的色边中的像素点。When the color of the target pixel is a color fringe color, determine whether the target pixel is a color fringe pixel in the target image according to gradient values of the target pixel in a plurality of preset directions, The color fringe pixels are pixels in the color fringe in the target image.
需要说明的是,上述图像中的色边像素点的确定方法、图像中的色边像素点的确定装置、计算机设备及计算机可读存储介质属于一个总的发明构思,图像中的色边像素点的确定方法、图像中的色边像素点的确定装置、计算机设备及计算机可读存储介质实施例中的内容可相互适用。It should be noted that the method for determining the color fringe pixels in the image, the device for determining the color fringe pixels in the image, the computer equipment, and the computer-readable storage medium belong to a general inventive concept, and the color fringe pixels in the image The content in the embodiments of the method for determining, the device for determining color fringe pixels in an image, the computer equipment, and the computer-readable storage medium are applicable to each other.
在本申请所提供的实施例中,应该理解到,所揭露装置和方法,可以通过其它的方式实现。以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,又例如,多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些通信接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the embodiments provided in this application, it should be understood that the disclosed devices and methods may be implemented in other ways. The device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or May be integrated into another system, or some features may be ignored, or not implemented. In another point, the mutual coupling or direct coupling or communication connection shown or discussed may be through some communication interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.
另外,作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。In addition, a unit described as a separate component may or may not be physically separated, and a component displayed as a unit may or may not be a physical unit, that is, it may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
再者,在本申请各个实施例中的各功能模块可以集成在一起形成一个独立的部分,也可以是各个模块单独存在,也可以两个或两个以上模块集成形成一个独立的部分。Furthermore, each functional module in each embodiment of the present application may be integrated to form an independent part, each module may exist independently, or two or more modules may be integrated to form an independent part.
在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。In this document, relational terms such as first and second etc. are used only to distinguish one entity or operation from another without necessarily requiring or implying any such relationship between these entities or operations. Actual relationship or sequence.
以上所述仅为本申请的实施例而已,并不用于限制本申请的保护范围,对于本领域的技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。The above descriptions are only examples of the present application, and are not intended to limit the scope of protection of the present application. For those skilled in the art, various modifications and changes may be made to the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of this application shall be included within the protection scope of this application.
工业实用性Industrial Applicability
本申请提供了一种图像中的色边像素点的确定方法、确定装置和计算机设备,所述方法,包括:获取目标图像中的目标像素点的颜色值;计算所述目标像素点的红色值和绿色值之间的差值,得到红绿差值,计算所述目标像素点的蓝色值和绿色值之间的差值,得到蓝绿差值;根据所述目标像素点的颜色值、红绿差值和蓝绿差值确定所述像素点的颜色;当所述目标像素点的颜色为色边颜色时,根据所述目标像素点在多个预设方向上的梯度值确定所述目标像素点是否是所述目标图像中的色边像素点,所述色边像素点为所述目标图像中的色边中的像素点。通过上述方法,对颜色的识别更加的灵活,在一定程度上避免了色边像素点的遗漏。The present application provides a method for determining color edge pixels in an image, a determining device, and computer equipment. The method includes: acquiring the color value of the target pixel in the target image; calculating the red value of the target pixel and the difference between the green value to obtain the red-green difference, and calculate the difference between the blue value and the green value of the target pixel to obtain the blue-green difference; according to the color value of the target pixel, The red-green difference value and the blue-green difference value determine the color of the pixel point; when the color of the target pixel point is a color edge color, the gradient value of the target pixel point in multiple preset directions is used to determine the Whether the target pixel is a color fringe pixel in the target image, and the color fringe pixel is a pixel in the color fringe in the target image. Through the above method, the recognition of the color is more flexible, and the omission of color edge pixels is avoided to a certain extent.
此外,可以理解的是,本申请的图像中的色边像素点的确定方法、确定装置和计算机设备是可以重现的,并且可以用在多种工业应用中。例如,本申请的图像中的色边像素点的确定方法、确定装置和计算机设备可以用于图像处理领域。In addition, it can be understood that the method, device and computer equipment for determining color fringe pixels in an image of the present application are reproducible and can be used in various industrial applications. For example, the method for determining color fringe pixels in an image, the determining device and the computer equipment of the present application can be used in the field of image processing.

Claims (20)

  1. 一种图像中的色边像素点的确定方法,其特征在于,包括:A method for determining color fringe pixels in an image, comprising:
    获取目标图像中的目标像素点的颜色值,所述颜色值包括红色值、绿色值和蓝色值;Acquiring the color value of the target pixel in the target image, the color value comprising a red value, a green value and a blue value;
    计算所述目标像素点的红色值和绿色值之间的差值,得到红绿差值,计算所述目标像素点的蓝色值和绿色值之间的差值,得到蓝绿差值;calculating the difference between the red value and the green value of the target pixel to obtain a red-green difference, and calculating the difference between the blue and green values of the target pixel to obtain a blue-green difference;
    根据所述目标像素点的颜色值、红绿差值和蓝绿差值确定所述像素点的颜色;determining the color of the pixel according to the color value of the target pixel, the difference between red and green, and the difference between blue and green;
    当所述目标像素点的颜色为色边颜色时,根据所述目标像素点在多个预设方向上的梯度值确定所述目标像素点是否是所述目标图像中的色边像素点,所述色边像素点为所述目标图像中的色边中的像素点。When the color of the target pixel is a color fringe color, determine whether the target pixel is a color fringe pixel in the target image according to gradient values of the target pixel in a plurality of preset directions, The color fringe pixels are pixels in the color fringe in the target image.
  2. 根据权利要求1所述的确定方法,其特征在于,所述根据所述目标像素点在多个预设方向上的梯度值确定所述目标像素点是否是所述目标图像中的色边像素点,包括:The determination method according to claim 1, characterized in that, according to the gradient values of the target pixel in a plurality of preset directions, it is determined whether the target pixel is a color edge pixel in the target image ,include:
    判断所述目标像素点在相应的预设方向上的梯度值是否有效;judging whether the gradient value of the target pixel point in the corresponding preset direction is valid;
    根据所述目标像素点在多个预设方向上的梯度值是否有效确定所述目标像素点是否是所述目标图像中的色边像素点。Whether the target pixel is a color fringe pixel in the target image is determined according to whether the gradient values of the target pixel in multiple preset directions are valid.
  3. 根据权利要求2所述的确定方法,其特征在于,所述判断所述目标像素点在相应的预设方向上的梯度值是否有效,包括:The determination method according to claim 2, wherein the judging whether the gradient value of the target pixel point in the corresponding preset direction is valid comprises:
    获取多个梯度组,所述梯度组中包括预设梯度值和预设亮度值;Obtaining multiple gradient groups, the gradient groups include preset gradient values and preset brightness values;
    将所述目标像素点在目标预设方向上的梯度值与目标梯度组中的预设梯度值进行比较,得到所述目标像素点在所述目标预设方向上的目标梯度组的梯度比较结果,所述目标梯度组为所述多个梯度组中的一个待比对梯度组,所述目标预设方向为所述多个预设方向中的一个待比对预设方向;Comparing the gradient value of the target pixel point in the target preset direction with the preset gradient value in the target gradient group to obtain a gradient comparison result of the target pixel point in the target gradient group in the target preset direction , the target gradient group is a gradient group to be compared among the plurality of gradient groups, and the preset target direction is a preset direction to be compared among the plurality of preset directions;
    将所述目标像素点的亮度值与所述目标梯度组中的预设亮度值进行比较,得到所述目标像素点在所述目标预设方向上的目标梯度组的亮度比较结果;Comparing the luminance value of the target pixel point with the preset luminance value in the target gradient group to obtain a brightness comparison result of the target pixel point in the target gradient group in the target preset direction;
    根据所述目标像素点在所述目标预设方向上的所述多个梯度组的梯度比较结果和亮度比较结果确定所述目标像素点在所述目标预设方向上的梯度值是否有效。Determine whether the gradient value of the target pixel point in the target preset direction is valid according to the gradient comparison results and brightness comparison results of the plurality of gradient groups of the target pixel point in the target preset direction.
  4. 根据权利要求1至3中的任一项所述的确定方法,其特征在于,在所述根据所述目标像素点在多个预设方向上的梯度值确定所述目标像素点是否是所述目标图像中的色边像素点之后,还包括:The determination method according to any one of claims 1 to 3, characterized in that, in the step of determining whether the target pixel is the target pixel according to the gradient values of the target pixel in a plurality of preset directions After the color fringe pixels in the target image, it also includes:
    当所述目标像素点是所述目标图像中的色边像素点时,对所述目标像素点的颜色值进行矫正。When the target pixel is a color edge pixel in the target image, the color value of the target pixel is corrected.
  5. 根据权利要求4所述的方法,其特征在于,所述对所述目标像素点的颜色值进行校正,包括:The method according to claim 4, wherein the correcting the color value of the target pixel comprises:
    根据所述目标像素点在多个预设方向上的梯度值查找所述目标像素点对应的矫正像素点;Finding the correction pixel corresponding to the target pixel according to the gradient values of the target pixel in multiple preset directions;
    根据所述目标像素点对应的矫正像素点的颜色值对所述目标像素点的颜色值进行矫正。The color value of the target pixel is corrected according to the color value of the corrected pixel corresponding to the target pixel.
  6. 根据权利要求5所述的确定方法,其特征在于,所述根据所述目标像素点对应的矫正像素点的颜色值对所述目标像素点的颜色值进行矫正,包括:The determination method according to claim 5, wherein the correcting the color value of the target pixel according to the color value of the corrected pixel corresponding to the target pixel includes:
    确定目标颜色分量,第一剩余颜色分量和第二剩余颜色分量,所述目标颜色分量,所述第一剩余颜色分量和所述第二剩余颜色分量分别为红色分量、绿色分量以及蓝色分量中的一个;Determine the target color component, the first remaining color component and the second remaining color component, the target color component, the first remaining color component and the second remaining color component are the red component, the green component and the blue component respectively one of;
    计算所述矫正像素点中的目标颜色分量对应的颜色分量值与所述矫正像素点中的第一剩余颜色分量对应的颜色分量值的差值,得到第一差值;calculating the difference between the color component value corresponding to the target color component in the corrected pixel and the color component value corresponding to the first remaining color component in the corrected pixel, to obtain a first difference;
    计算所述矫正像素点中的目标颜色分量对应的颜色分量值与所述矫正像素点中的第二剩余颜色分量对应的颜色分量值的差值,得到第二差值;calculating the difference between the color component value corresponding to the target color component in the corrected pixel and the color component value corresponding to the second remaining color component in the corrected pixel, to obtain a second difference;
    计算所述目标像素点的目标颜色分量对应的颜色分量值与所述第一差值的差值,得到所述目标像素点的第一剩余颜色分量对应的颜色分量值;calculating the difference between the color component value corresponding to the target color component of the target pixel point and the first difference value, to obtain the color component value corresponding to the first remaining color component of the target pixel point;
    计算所述目标像素点的目标颜色分量对应的颜色分量值与所述第二差值的差值,得到所述目标像素点的第二剩余颜色分量对应的颜色分量值。calculating the difference between the color component value corresponding to the target color component of the target pixel and the second difference value, to obtain the color component value corresponding to the second remaining color component of the target pixel.
  7. 根据权利要求5或6所述的确定方法,其特征在于,所述根据所述目标像素点在多个预设方向上的梯度值查找所述目标像素点对应的矫正像素点,包括:The determination method according to claim 5 or 6, wherein the searching for the correction pixel corresponding to the target pixel according to the gradient values of the target pixel in multiple preset directions comprises:
    根据所述目标像素点在多个预设方向上的梯度值是否有效确定所述目标像素点对应的矫正像素点的查找方向;Determine the search direction of the corrected pixel corresponding to the target pixel according to whether the gradient values of the target pixel in multiple preset directions are valid;
    在所述查找方向上的预设像素范围内查找所述目标像素点对应的矫正像素点。The corrected pixel corresponding to the target pixel is searched within a preset pixel range in the search direction.
  8. 根据权利要求7所述的确定方法,其特征在于,所述在所述查找方向上的预设像素范围内查找所述像素点对应的矫正像素点,包括:The determination method according to claim 7, wherein the searching for the correction pixel corresponding to the pixel within the preset pixel range in the search direction comprises:
    将在所述查找方向上的预设像素范围内首次出现的颜色为非色边颜色的像素点确定为所述像素点对应的矫正像素点。A pixel point whose color is a non-color edge color that appears for the first time within the preset pixel range in the search direction is determined as the corrected pixel point corresponding to the pixel point.
  9. 根据权利要求1至8中的任一项所述的确定方法,其特征在于,在所述根据所述目标像素点在多个预设方向上的梯度值确定所述目标像素点是否是所述目标图像中的色边像素点之前,还包括:The determination method according to any one of claims 1 to 8, characterized in that, in the step of determining whether the target pixel is the target pixel according to the gradient values of the target pixel in a plurality of preset directions Before the color fringe pixels in the target image, it also includes:
    根据所述目标像素点的颜色值计算所述目标像素点的亮度值;calculating the brightness value of the target pixel according to the color value of the target pixel;
    获取预设亮度值和所述目标像素点在所述多个预设方向中的每个预设方向上的最大亮度值;Obtaining a preset brightness value and a maximum brightness value of the target pixel point in each preset direction in the plurality of preset directions;
    将所述目标像素点在所述多个预设方向中的每个预设方向上的最大亮度值与所述预设亮度值进行比较,得到所述目标像素点在所述多个预设方向中的每个预设方向上的梯度权重;Comparing the maximum luminance value of the target pixel point in each of the multiple preset directions with the preset luminance value to obtain the maximum brightness value of the target pixel point in the multiple preset directions Gradient weights in each preset direction in ;
    将所述目标像素点在所述多个预设方向中的每个预设方向上的最大亮度值与所述目标像素点的亮度值进行比较,得到所述目标像素点在所述多个预设方向中的每个预设方向上的初步梯度值;Comparing the maximum luminance value of the target pixel point in each preset direction in the multiple preset directions with the luminance value of the target pixel point to obtain the target pixel point in the multiple preset directions Preliminary gradient values in each preset direction in the set direction;
    将所述目标像素点在所述多个预设方向中的每个预设方向上的梯度权重和所述目标像素点在相应的预设方向上的初步梯度值相乘,得到所述目标像素点在所述多个预设方向中的每个预设方向上的梯度值。multiplying the gradient weight of the target pixel point in each preset direction in the plurality of preset directions by the preliminary gradient value of the target pixel point in the corresponding preset direction to obtain the target pixel A gradient value of a point in each preset direction in the plurality of preset directions.
  10. 根据权利要求1至9中的任一项所述的确定方法,其特征在于,所述根据所述像素点的颜色值、红绿差值和蓝绿差值确定所述像素点的颜色,包括:The determination method according to any one of claims 1 to 9, wherein the determining the color of the pixel according to the color value of the pixel, the difference between red and green and the difference between blue and green includes :
    获取多个颜色组,所述颜色组中包括预设蓝色值、预设红绿差值和预设蓝绿差值;Obtaining multiple color groups, the color groups include preset blue value, preset red-green difference value and preset blue-green difference value;
    将所述像素点的蓝色值与目标颜色组中的预设蓝色值进行比较,得到所述目标颜色组对应的蓝色比较结果,所述目标颜色组为所述多个颜色组中的一个待比对颜色组;Comparing the blue value of the pixel with the preset blue value in the target color group to obtain a blue comparison result corresponding to the target color group, the target color group being one of the plurality of color groups A color group to be compared;
    将所述像素点的红绿差值与所述目标颜色组中的预设红绿差值进行比较,得到所述目标颜色组对应的红绿比较结果;Comparing the red-green difference value of the pixel with the preset red-green difference value in the target color group to obtain a red-green comparison result corresponding to the target color group;
    将所述像素点的蓝绿差值与所述目标颜色组中的预设蓝绿差值进行比较,得到所述目标颜色组对应的蓝绿比较结果;Comparing the blue-green difference value of the pixel with the preset blue-green difference value in the target color group to obtain a blue-green comparison result corresponding to the target color group;
    根据所述多个颜色组对应的蓝色比较结果、红绿比较结果和蓝绿比较结果确定所述像素点的颜色。The color of the pixel is determined according to the blue comparison result, the red-green comparison result and the blue-green comparison result corresponding to the plurality of color groups.
  11. 一种图像中的色边像素点的确定装置,其特征在于,包括:A device for determining color fringe pixels in an image, comprising:
    获取模块,配置成用于获取目标图像中的目标像素点的颜色值,所述颜色值包括红色值、绿色值和蓝色值;An acquisition module configured to acquire a color value of a target pixel in the target image, the color value including a red value, a green value and a blue value;
    计算模块,配置成用于计算所述目标像素点的红色值和绿色值之间的差值,得到红绿差值,计算所述目标像素点的蓝色值和绿色值之间的差值,得到蓝绿差值;A calculation module configured to calculate the difference between the red value and the green value of the target pixel to obtain the red-green difference, and calculate the difference between the blue value and the green value of the target pixel, Get the difference between blue and green;
    确定模块,配置成用于根据所述目标像素点的颜色值、红绿差值和蓝绿差值确定所述像素点的颜色;A determining module, configured to determine the color of the pixel point according to the color value, the red-green difference value and the blue-green difference value of the target pixel point;
    色边模块,配置成用于当所述目标像素点的颜色为色边颜色时,根据所述目标像素点在多个预设方向上的梯度值确定所述目标像素点是否是所述目标图像中的色边像素点,所述色边像素点为所述目标图 像中的色边中的像素点。A color fringe module, configured to determine whether the target pixel is the target image according to gradient values of the target pixel in multiple preset directions when the color of the target pixel is a color fringe color The color fringe pixels in the color fringe are pixels in the color fringe in the target image.
  12. 根据权利要求11所述的确定装置,其特征在于,所述色边模块还配置成用于:The determining device according to claim 11, wherein the color edge module is further configured to:
    判断所述目标像素点在相应的预设方向上的梯度值是否有效;judging whether the gradient value of the target pixel point in the corresponding preset direction is valid;
    根据所述目标像素点在多个预设方向上的梯度值是否有效确定所述目标像素点是否是所述目标图像中的色边像素点。Whether the target pixel is a color fringe pixel in the target image is determined according to whether the gradient values of the target pixel in multiple preset directions are valid.
  13. 根据权利要求12所述的确定装置,其特征在于,所述色边模块还配置成用于:The determining device according to claim 12, wherein the color edge module is further configured to:
    获取多个梯度组,所述梯度组中包括预设梯度值和预设亮度值;Obtaining multiple gradient groups, the gradient groups include preset gradient values and preset brightness values;
    将所述目标像素点在目标预设方向上的梯度值与目标梯度组中的预设梯度值进行比较,得到所述目标像素点在所述目标预设方向上的目标梯度组的梯度比较结果,所述目标梯度组为所述多个梯度组中的一个待比对梯度组,所述目标预设方向为所述多个预设方向中的一个待比对预设方向;Comparing the gradient value of the target pixel point in the target preset direction with the preset gradient value in the target gradient group to obtain a gradient comparison result of the target pixel point in the target gradient group in the target preset direction , the target gradient group is a gradient group to be compared among the plurality of gradient groups, and the preset target direction is a preset direction to be compared among the plurality of preset directions;
    将所述目标像素点的亮度值与所述目标梯度组中的预设亮度值进行比较,得到所述目标像素点在所述目标预设方向上的目标梯度组的亮度比较结果;Comparing the luminance value of the target pixel point with the preset luminance value in the target gradient group to obtain a brightness comparison result of the target pixel point in the target gradient group in the target preset direction;
    根据所述目标像素点在所述目标预设方向上的所述多个梯度组的梯度比较结果和亮度比较结果确定所述目标像素点在所述目标预设方向上的梯度值是否有效。Determine whether the gradient value of the target pixel point in the target preset direction is valid according to the gradient comparison results and brightness comparison results of the plurality of gradient groups of the target pixel point in the target preset direction.
  14. 根据权利要求11至13任一项所述的确定装置,其特征在于,所述确定装置还包括矫正模块,所述矫正模块配置成用于:The determining device according to any one of claims 11 to 13, characterized in that the determining device further comprises a correcting module, and the correcting module is configured to:
    当所述目标像素点是所述目标图像中的色边像素点时,对所述目标像素点的颜色值进行矫正。When the target pixel is a color edge pixel in the target image, the color value of the target pixel is corrected.
  15. 根据权利要求14所述的确定装置,其特征在于,所述矫正模块还配置成用于:The determining device according to claim 14, wherein the correction module is further configured to:
    根据所述目标像素点在多个预设方向上的梯度值查找所述目标像素点对应的矫正像素点;以及Finding corrected pixel points corresponding to the target pixel points according to the gradient values of the target pixel points in multiple preset directions; and
    根据所述目标像素点对应的矫正像素点的颜色值对所述目标像素点的颜色值进行矫正。The color value of the target pixel is corrected according to the color value of the corrected pixel corresponding to the target pixel.
  16. 根据权利要求14或15所述的确定装置,其特征在于,所述矫正模块还配置成用于:The determining device according to claim 14 or 15, wherein the correction module is further configured to:
    将在所述查找方向上的预设像素范围内首次出现的颜色为非色边颜色的像素点确定为所述像素点对应的矫正像素点。A pixel point whose color is a non-color edge color that appears for the first time within the preset pixel range in the search direction is determined as the corrected pixel point corresponding to the pixel point.
  17. 根据权利要求11至16中的任一项所述的确定装置,其特征在于,所述确定装置还包括梯度值确定模块,所述括梯度值确定模块配置成用于:The determining device according to any one of claims 11 to 16, wherein the determining device further comprises a gradient value determining module, and the gradient value determining module is configured to:
    根据所述目标像素点的颜色值计算所述目标像素点的亮度值;calculating the brightness value of the target pixel according to the color value of the target pixel;
    获取预设亮度值和所述目标像素点在所述多个预设方向中的每个预设方向上的最大亮度值;Obtaining a preset brightness value and a maximum brightness value of the target pixel point in each preset direction in the plurality of preset directions;
    将所述目标像素点在所述多个预设方向中的每个预设方向上的最大亮度值与所述预设亮度值进行比较,得到所述目标像素点在所述多个预设方向中的每个预设方向上的梯度权重;Comparing the maximum luminance value of the target pixel point in each of the multiple preset directions with the preset luminance value to obtain the maximum brightness value of the target pixel point in the multiple preset directions Gradient weights in each preset direction in ;
    将所述目标像素点在所述多个预设方向中的每个预设方向上的最大亮度值与所述目标像素点的亮度值进行比较,得到所述目标像素点在所述多个预设方向中的每个预设方向上的初步梯度值;Comparing the maximum luminance value of the target pixel point in each preset direction in the multiple preset directions with the luminance value of the target pixel point to obtain the target pixel point in the multiple preset directions Preliminary gradient values in each preset direction in the set direction;
    将所述目标像素点在所述多个预设方向中的每个预设方向上的梯度权重和所述目标像素点在相应的预设方向上的初步梯度值相乘,得到所述目标像素点在所述多个预设方向中的每个预设方向上的梯度值。multiplying the gradient weight of the target pixel point in each preset direction in the plurality of preset directions by the preliminary gradient value of the target pixel point in the corresponding preset direction to obtain the target pixel A gradient value of a point in each preset direction in the plurality of preset directions.
  18. 根据权利要求11至17中的任一项所述的确定装置,其特征在于,所述梯度值确定模块还配置成用于:The determining device according to any one of claims 11 to 17, wherein the gradient value determining module is further configured to:
    获取多个颜色组,所述颜色组中包括预设蓝色值、预设红绿差值和预设蓝绿差值;Obtaining multiple color groups, the color groups include preset blue value, preset red-green difference value and preset blue-green difference value;
    将所述像素点的蓝色值与目标颜色组中的预设蓝色值进行比较,得到所述目标颜色组对应的蓝色比较结果,所述目标颜色组为所述多个颜色组中的一个待比对颜色组;Comparing the blue value of the pixel with the preset blue value in the target color group to obtain a blue comparison result corresponding to the target color group, the target color group being one of the plurality of color groups A color group to be compared;
    将所述像素点的红绿差值与所述目标颜色组中的预设红绿差值进行比较,得到所述目标颜色组对应 的红绿比较结果;Comparing the red-green difference value of the pixel with the preset red-green difference value in the target color group to obtain the red-green comparison result corresponding to the target color group;
    将所述像素点的蓝绿差值与所述目标颜色组中的预设蓝绿差值进行比较,得到所述目标颜色组对应的蓝绿比较结果;Comparing the blue-green difference value of the pixel with the preset blue-green difference value in the target color group to obtain a blue-green comparison result corresponding to the target color group;
    根据所述多个颜色组对应的蓝色比较结果、红绿比较结果和蓝绿比较结果确定所述像素点的颜色。The color of the pixel is determined according to the blue comparison result, the red-green comparison result and the blue-green comparison result corresponding to the plurality of color groups.
  19. 一种计算机设备,其特征在于,包括存储器、处理器以及存储在所述存储器中并且能够在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现根据权利要求1至10中的任一项所述的图像中的色边像素点的确定方法。A computer device, characterized by comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, when the processor executes the computer program, the computer program according to claims 1 to 1 is implemented. The method for determining color fringe pixels in an image described in any one of 10.
  20. 一种计算机可读存储介质,其特征在于,所述计算机可读取存储介质中存储有计算机程序指令,所述计算机程序指令在被处理器读取并运行时,执行根据权利要求1至10中的任一项所述的图像中的色边像素点的确定方法。A computer-readable storage medium, wherein computer program instructions are stored in the computer-readable storage medium, and when the computer program instructions are read and executed by a processor, the computer program instructions according to claims 1 to 10 are executed. A method for determining color fringe pixels in an image according to any one of the above.
PCT/CN2021/136744 2021-06-10 2021-12-09 Method and apparatus for determining color fringe pixel point in image and computer device WO2022257396A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110650968.9A CN113393540B (en) 2021-06-10 2021-06-10 Method and device for determining color edge pixel points in image and computer equipment
CN202110650968.9 2021-06-10

Publications (1)

Publication Number Publication Date
WO2022257396A1 true WO2022257396A1 (en) 2022-12-15

Family

ID=77620453

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/136744 WO2022257396A1 (en) 2021-06-10 2021-12-09 Method and apparatus for determining color fringe pixel point in image and computer device

Country Status (2)

Country Link
CN (1) CN113393540B (en)
WO (1) WO2022257396A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115760884A (en) * 2023-01-06 2023-03-07 山东恩信特种车辆制造有限公司 Semitrailer surface welding slag optimization segmentation method based on image processing
CN116993643A (en) * 2023-09-27 2023-11-03 山东建筑大学 Unmanned aerial vehicle photogrammetry image correction method based on artificial intelligence

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113393540B (en) * 2021-06-10 2023-10-27 爱芯元智半导体(宁波)有限公司 Method and device for determining color edge pixel points in image and computer equipment
US11863916B2 (en) 2022-01-27 2024-01-02 Altek Semiconductor Corporation Color correction method and image correction apparatus
CN117710489A (en) * 2023-05-18 2024-03-15 荣耀终端有限公司 Image color edge quantization method, apparatus, storage medium, and program product

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140307963A1 (en) * 2013-04-15 2014-10-16 Apple Inc. Defringing RAW Images
CN106657946A (en) * 2017-01-12 2017-05-10 深圳岚锋创视网络科技有限公司 System and method for eliminating purple boundary of image
CN109978961A (en) * 2019-03-15 2019-07-05 湖南国科微电子股份有限公司 A kind of pattern colour side removing method, device and electronic equipment
CN112446830A (en) * 2019-08-27 2021-03-05 浙江宇视科技有限公司 Image color edge processing method and device, storage medium and electronic equipment
CN112887693A (en) * 2021-01-12 2021-06-01 浙江大华技术股份有限公司 Image purple border elimination method, equipment and storage medium
CN113393540A (en) * 2021-06-10 2021-09-14 上海智砹芯半导体科技有限公司 Method and device for determining color edge pixel points in image and computer equipment

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102938843B (en) * 2012-11-22 2014-12-03 华为技术有限公司 Image processing method, image processing device and imaging device
CN110335257A (en) * 2019-06-20 2019-10-15 东莞理工学院 A kind of image color detection method and mobile terminal

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140307963A1 (en) * 2013-04-15 2014-10-16 Apple Inc. Defringing RAW Images
CN106657946A (en) * 2017-01-12 2017-05-10 深圳岚锋创视网络科技有限公司 System and method for eliminating purple boundary of image
CN109978961A (en) * 2019-03-15 2019-07-05 湖南国科微电子股份有限公司 A kind of pattern colour side removing method, device and electronic equipment
CN112446830A (en) * 2019-08-27 2021-03-05 浙江宇视科技有限公司 Image color edge processing method and device, storage medium and electronic equipment
CN112887693A (en) * 2021-01-12 2021-06-01 浙江大华技术股份有限公司 Image purple border elimination method, equipment and storage medium
CN113393540A (en) * 2021-06-10 2021-09-14 上海智砹芯半导体科技有限公司 Method and device for determining color edge pixel points in image and computer equipment

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115760884A (en) * 2023-01-06 2023-03-07 山东恩信特种车辆制造有限公司 Semitrailer surface welding slag optimization segmentation method based on image processing
CN116993643A (en) * 2023-09-27 2023-11-03 山东建筑大学 Unmanned aerial vehicle photogrammetry image correction method based on artificial intelligence
CN116993643B (en) * 2023-09-27 2023-12-12 山东建筑大学 Unmanned aerial vehicle photogrammetry image correction method based on artificial intelligence

Also Published As

Publication number Publication date
CN113393540A (en) 2021-09-14
CN113393540B (en) 2023-10-27

Similar Documents

Publication Publication Date Title
WO2022257396A1 (en) Method and apparatus for determining color fringe pixel point in image and computer device
US8564687B2 (en) Efficient determination of an illuminant of a scene
US9386289B2 (en) Automatic white balancing with chromaticity measure of raw image data
US7949185B2 (en) Method of performing robust auto white balance
US8199202B2 (en) Image processing device, storage medium storing image processing program, and image pickup apparatus
TWI532385B (en) White balance method and apparatus thereof
CN113301318B (en) Image white balance processing method and device, storage medium and terminal
US9378564B2 (en) Methods for color correcting digital images and devices thereof
CN109587466B (en) Method and apparatus for color shading correction
WO2021218603A1 (en) Image processing method and projection system
US10224004B2 (en) Automatic white balance based on surface reflection decomposition
WO2020093653A1 (en) Color adjustment method, color adjustment device, electronic device and computer-readable storage medium
GB2453891A (en) Pupil color correction device and program
CN112669758A (en) Display screen correction method, device, system and computer readable storage medium
TW202107411A (en) Image sensing device and method for auto white balance therefor
CN116158087A (en) Multi-camera color consistency correction method and device
US8565523B2 (en) Image content-based color balancing
US20180176528A1 (en) Light locus generation for automatic white balance
JP6573798B2 (en) Image processing apparatus and image processing method
CN114945087B (en) Image processing method, device, equipment and storage medium based on face characteristics
WO2023151210A1 (en) Image processing method, electronic device and computer-readable storage medium
WO2023123601A1 (en) Image color processing method and apparatus, and electronic device
US8189067B2 (en) Determining the illuminant in a captured scene
CN116233381A (en) Color correction method and device, electronic equipment and storage medium
CN105407340B (en) A kind of white balancing treatment method and terminal

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21944892

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21944892

Country of ref document: EP

Kind code of ref document: A1