WO2020119454A1 - Method and apparatus for color reproduction of image - Google Patents

Method and apparatus for color reproduction of image Download PDF

Info

Publication number
WO2020119454A1
WO2020119454A1 PCT/CN2019/121126 CN2019121126W WO2020119454A1 WO 2020119454 A1 WO2020119454 A1 WO 2020119454A1 CN 2019121126 W CN2019121126 W CN 2019121126W WO 2020119454 A1 WO2020119454 A1 WO 2020119454A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
area
pixels
saturation
color
Prior art date
Application number
PCT/CN2019/121126
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 WO2020119454A1 publication Critical patent/WO2020119454A1/en

Links

Images

Classifications

    • G06T5/77
    • G06T5/90
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/136Segmentation; Edge detection involving thresholding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/187Segmentation; Edge detection involving region growing; involving region merging; involving connected component labelling
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N1/00Scanning, transmission or reproduction of documents or the like, e.g. facsimile transmission; Details thereof
    • H04N1/46Colour picture communication systems
    • H04N1/56Processing of colour picture signals
    • H04N1/60Colour correction or control
    • 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/10016Video; Image sequence
    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30232Surveillance

Definitions

  • the present application relates to the field of image processing, and in particular to a method and device for color restoration of an image.
  • Image overexposure is a relatively common phenomenon, which may cause a series of problems.
  • a surveillance camera working in an electronic police mode can simultaneously capture red light signals and illegal vehicles as evidence for violations by illegal personnel.
  • background illumination such as dusk or night scenes
  • the surveillance camera takes a photo forensic against the signal red light
  • the camera often needs to increase the shutter, gain and aperture size. If the gain, shutter or aperture is increased too much, it will cause the traffic lights to be overexposed (for example, the red signal lights will become yellow or white), so that the captured images cannot be used as evidence of violations.
  • a camera with an ultra-wide dynamic range can be used to eliminate signal color distortion caused by strong light. This is because a camera with an ultra-wide dynamic range detects a large dynamic range of brightness, and can restore image details in a high-contrast brightness scene.
  • the ultra-wide dynamic camera is relatively expensive; on the other hand, because the signal light area generally accounts for a small proportion of the entire screen, the ultra-wide dynamic range camera has a limited effect on the color reproduction of the over-exposed signal light under low illumination.
  • Software method 1 You can identify the signal light area based on the red, green, blue (RGB) (color) space of the image, and then perform the color restoration of the signal light. However, the RGB color space does not reflect the brightness information of the signal light well, and may cause a discontinuous gradient phenomenon between the signal area after the color reproduction and the surrounding image.
  • Software method 2 Based on the method of deep learning, the signal lights in the image can be identified and the color can be enhanced. However, the method based on deep learning does not have a high accuracy in recognizing the contour of the signal light, so the color reproduction area of the signal light is prone to appear discontinuous with the surrounding image.
  • Embodiments of the present application provide an image processing method, which can accurately reproduce color of overexposed objects (for example, traffic lights) in an image. Furthermore, it can solve a series of problems caused by overexposure of objects in the image (for example, the problem of difficulty in obtaining evidence caused by overexposure of signal lights in the current electric police monitoring scene).
  • an embodiment of the present application provides a method for color restoration of an image, including: acquiring a first image to be processed, the first image including an overexposed first target object; and according to the saturation of the pixels of the first image And the brightness determine the first area of the first image, the saturation of the pixels in the first area is lower than the average value of the saturation of the pixels in the first image, and the brightness of the pixels in the first area is higher than the brightness of the pixels in the first image
  • the average value of the first area corresponds to the area of the first target object (where); the first area is binarized to obtain the binary image corresponding to the first area; the area of the binary image is determined to be greater than or equal to the first threshold
  • At least one connected area; the outline of at least one connected area corresponds to the outline of the first target object; the color of at least one connected area is restored.
  • the first area of the first image may be determined according to the saturation and brightness of the pixels of the first image (the first area may be used as the first target of overexposure) The area where the object is located), and then the first area can be binarized to obtain a binary image corresponding to the first area; and then determine at least one connected area (at least one connected area) in the binary image whose area is greater than or equal to the first threshold
  • the contour of the area corresponds to the contour of the first target object), and then, the color of the at least one connected area is restored (that is, the color of the over-exposed first target object is restored).
  • the method provided by the embodiments of the present application can accurately reproduce color of an over-exposed object in the image (that is, the first target object, for example, can be a traffic signal). Furthermore, it can solve a series of problems caused by overexposure of objects in the image (for example, the problem of difficulty in obtaining evidence caused by overexposure of signal lights in the current electric police monitoring scene).
  • the method before determining the first region of the first image according to the saturation and brightness of the first image, the method further includes: converting the first image from the first space to hue saturation and brightness (hue saturation) Value (HSV) space, the first space is any one of the brightness and chroma YUV space, RGB space or hue saturation brightness hue saturation brightness (HSL) space.
  • HSV hue saturation and brightness
  • the first space is any one of the brightness and chroma YUV space, RGB space or hue saturation brightness hue saturation brightness (HSL) space.
  • the first space may be YUV space or RGB space or HSL space.
  • you need to The first image is converted from the first space to the HSV space.
  • restoring the color of at least one connected area includes: acquiring color information of the traffic signal; when the traffic signal is red, the pixel of at least one connected area Adjust the hue to the red range, and increase and decrease the saturation and lightness of the pixels of at least one connected area; when the traffic signal is yellow, adjust the hue of the pixels of at least one connected area to the yellow range, and adjust at least one The saturation and brightness of pixels in the connected area are increased and decreased respectively; when the traffic signal is green, the hue of the pixels of at least one connected area is adjusted to the green range, and the saturation and brightness of the pixels of at least one connected area are respectively adjusted Perform ascent and descent.
  • increasing and decreasing the saturation and lightness of the pixels of at least one connected area may be linearly increasing and decreasing the saturation and lightness of the pixels of at least one connected area, respectively, or may be The saturation and lightness of the pixels of at least one connected area are nonlinearly improved and nonlinearly reduced, respectively.
  • restoring the color of at least one connected area includes: converting the at least one connected area to an RGB space; acquiring color information of the traffic signal; when the traffic signal is red , Adjust the red component of the pixels of at least one connected area to the first preset range, and reduce the blue and green components of the pixels of at least one connected area; when the traffic signal is yellow, change the red color of the pixels of at least one connected area And the green component are adjusted to the second preset range to reduce the blue component of pixels in at least one connected area; when the traffic signal is green, the green component of the pixels in at least one connected area is adjusted to the third preset range and reduced by at least The red and blue components of pixels in a connected area.
  • reducing the blue and green components of the pixels of at least one connected region may be a linear or non-linear reduction of the blue and green components of the pixels of at least one connected region.
  • the method before determining the first region of the first image according to the saturation and brightness of the first image, the method further includes: performing filtering processing on the saturation component and the brightness component of the pixels of the first image. In this way, the outline of the overexposed first object can be identified more stably and accurately.
  • acquiring the first image to be processed includes: using the second area selected by the user on the second image as the first image to be processed.
  • an embodiment of the present application provides an image processing device, including: an acquisition unit for acquiring a first image to be processed, the first image including an overexposed first target object; and a determination unit for The saturation and brightness of the pixels of the image determine the first area of the first image.
  • the saturation of the pixels of the first area is lower than the average value of the saturation of the pixels of the first image, and the brightness of the pixels of the first area is higher than the first
  • the average value of the lightness of pixels of an image the first area corresponds to the first target object area; the processing unit is used to binarize the first area to obtain a binary image corresponding to the first area; the determination unit also uses To determine at least one connected region whose area is greater than or equal to the first threshold in the binary image; the contour of the first target object corresponds to the contour of the at least one connected region; the processing unit is also used to restore the color of the at least one connected region.
  • the processing unit is further configured to: convert the first image from the first space to the HSV space, and the first space is any one of YUV space, RGB space, or HSL space.
  • the processing unit when the first target object is a traffic signal, is used to: obtain the color information of the traffic signal through the acquisition unit; when the traffic signal is red, change the hue of the pixels of at least one connected area Adjust to the red range, and increase and decrease the saturation and brightness of the pixels of at least one connected area; when the traffic signal is yellow, adjust the hue of the pixels of at least one connected area to the yellow range, and connect at least one The saturation and brightness of the pixels in the area are increased and decreased respectively; when the traffic signal is green, the hue of the pixels of at least one connected area is adjusted to the green range, and the saturation and brightness of the pixels of at least one connected area are respectively adjusted Raise and lower.
  • the processing unit when the first target object is a traffic signal, the processing unit is used to: convert at least one connected area to an RGB space; acquire the color information of the traffic signal through the acquisition unit; when the traffic signal is red , Adjust the red component of the pixels of the at least one connected area to the first preset range, and reduce the blue and green components of the pixels of the at least one connected area; when the traffic signal is yellow, the red sum of the pixels of the at least one connected area The green component is adjusted to the second preset range to reduce the blue component of pixels in at least one connected area; when the traffic signal is green, the green component of the pixels in at least one connected area is adjusted to the third preset range to reduce at least one The red and blue components of the pixels in the connected area.
  • the processing unit is further configured to filter the saturation component and the lightness component of the pixels of the first image.
  • the acquiring unit is configured to: use the second area selected by the user on the second image as the first image to be processed.
  • an embodiment of the present application provides an apparatus that exists in the form of a chip product.
  • the structure of the apparatus includes a processor and a memory, and the memory is used to couple with the processor to store necessary program instructions of the apparatus And data, the processor is used to execute the program instructions stored in the memory, so that the device performs the function of the image processing device in the above method.
  • an embodiment of the present application provides an image processing device that can implement the functions performed by the image processing device described above.
  • the functions can be implemented by hardware, or can be implemented by hardware executing corresponding software.
  • the hardware or software includes one or more modules corresponding to the above functions.
  • the structure of the image processing device includes a processor and a communication interface, and the processor is configured to support the image processing device to perform the corresponding function in the above method.
  • the communication interface is used to support communication between the image processing device and other devices (e.g., a signal light detector on traffic lights).
  • the image processing device may further include a memory for coupling with the processor, which stores necessary program instructions and data of the image processing device.
  • an embodiment of the present application provides a computer-readable storage medium, including instructions, which, when run on a computer, cause the computer to execute any method provided in the first aspect.
  • an embodiment of the present application provides a computer program product containing instructions, which when run on a computer, causes the computer to execute any method provided in the first aspect.
  • FIG. 1 is a schematic diagram of a system architecture suitable for a method for color restoration of an image provided by an embodiment of the present application
  • FIG. 2 is a schematic structural diagram of an image processing device according to an embodiment of the present application.
  • FIG. 3 is a schematic flowchart of a method suitable for color restoration of an image provided by an embodiment of the present application
  • FIG. 4 is a schematic diagram of a user selecting a first image to be processed provided by an embodiment of the present application
  • FIG. 5 is a schematic diagram of a first area provided by an embodiment of this application.
  • FIG. 6 is a schematic diagram of a binary image corresponding to a first area provided by an embodiment of the present application.
  • FIG. 7 is a schematic diagram of a connected area provided by an embodiment of the present application.
  • FIG. 8 is a schematic diagram of a first area, a binary image corresponding to the first area, and a connected area determined according to the binary image provided by an embodiment of the present application;
  • FIG. 9 is a schematic structural diagram of yet another image processing device provided by an embodiment of the present application.
  • Embodiments of the present application provide a method and device for color (color) restoration of an image, which are applied to a scene of color restoration of an overexposed image. It can be understood that the embodiments of the present application may also be applied to a scene where color restoration is performed on a video including one or more frames of overexposed images. Specifically, it can be applied to the process of color restoration of an overexposed object (or overexposed area) in an image. For example, in the process of color reproduction of overexposed traffic lights in images or videos taken by electronic police (cameras or monitors).
  • the embodiment of the present application takes the scene of an illegal image captured by an electronic police camera as an example.
  • FIG. 1 a schematic diagram of a system architecture suitable for a method for performing color restoration on an image (an illegal image captured by an electronic police camera), including electronic A police camera and an image processing device connected to the electronic police camera (the image processing device may also be integrated in the electronic police camera), the image processing device may perform color restoration processing on the image or video taken by the electronic police camera.
  • the image processing device can also be connected to a traffic signal lamp in order to obtain the (historical) color change of the signal lamp from the signal lamp detector on the traffic signal lamp.
  • the image processing device in FIG. 1 of the embodiment of the present application may be implemented by one device, or may be a functional module in a device, which is not specifically limited in the embodiment of the present application. It is understandable that the above-mentioned functions may be network elements in hardware devices, or software functions running on dedicated hardware, or virtualized functions instantiated on platforms (for example, cloud platforms), or chip systems. . In the embodiment of the present application, the chip system may be composed of a chip, or may include a chip and other discrete devices.
  • FIG. 2 is a schematic diagram of a hardware structure of an apparatus 200 provided by an embodiment of the present application.
  • the apparatus 200 includes at least one processor 201, which is used to implement the functions of the image processing device provided in the embodiments of the present application.
  • the device 200 may further include a bus 202 and at least one communication interface 204.
  • the device 200 may further include a memory 203.
  • the processor may be a central processing unit (central processing unit, CPU), a general-purpose processor, a network processor (NP), a digital signal processor (digital signal processing, DSP), or a micro processor Device, microcontroller, programmable logic device (PLD) or any combination of them.
  • the processor may also be any other device with a processing function, such as a circuit, a device, or a software module.
  • the bus 202 can be used to transfer information between the aforementioned components.
  • the communication interface 204 is used to communicate with other devices or communication networks, such as Ethernet, radio access network (RAN), wireless local area network (WLAN), etc.
  • the communication interface 204 may be an interface, a circuit, a transceiver, or other devices capable of implementing communication, and the application is not limited.
  • the communication interface 204 may be coupled with the processor 201.
  • the coupling in the embodiments of the present application is an indirect coupling or communication connection between devices, units or modules, which may be in electrical, mechanical or other forms, and is used for information interaction between devices, units or modules.
  • the memory may be read-only memory (read-only memory, ROM) or other types of static storage devices that can store static information and instructions, random access memory (random access memory, RAM), or may store Other types of dynamic storage devices for information and instructions can also be electrically erasable programmable read-only memory (electrically erasable programmable-read-only memory (EEPROM), compact-disc read-only memory (CD-ROM) or Other optical disc storage, optical disc storage (including compact discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), magnetic disk storage media or other magnetic storage devices, or can be used to carry or store desired data in the form of instructions or data structures Program code and any other medium that can be accessed by the computer, but not limited to this.
  • the memory may exist independently, or may be coupled with the processor, for example, through the bus 202.
  • the memory can also be integrated with the processor.
  • the memory 203 is used to store program instructions, and can be controlled and executed by the processor 201, so as to implement the method for color restoration of an image provided by the following embodiments of the present application.
  • the processor 201 is used to call and execute the instructions stored in the memory 203, so as to implement the method for color restoration of an image provided by the following embodiments of the present application.
  • the computer execution instructions in the embodiments of the present application may also be called application program codes, which are not specifically limited in the embodiments of the present application.
  • the memory 203 may be included in the processor 201.
  • the processor 201 may include one or more CPUs, such as CPU0 and CPU1 in FIG. 2.
  • the apparatus 200 may include multiple processors, such as the processor 201 and the processor 207 in FIG. 2. Each of these processors can be a single-core (single-CPU) processor or a multi-core (multi-CPU) processor.
  • the processor here may refer to one or more devices, circuits, and/or processing cores for processing data (eg, computer program instructions).
  • the apparatus 200 may further include an output device 205 and an input device 206.
  • the output device 205 and the processor 201 are coupled and can display information in various ways.
  • the output device 205 may be a liquid crystal display (LCD), a light emitting diode (LED) display device, a cathode ray tube (CRT) display device, or a projector. Wait.
  • the input device 206 and the processor 201 are coupled and can receive user input in various ways.
  • the input device 206 may be a camera, a mouse, a keyboard, a touch screen device, or a sensing device.
  • the above apparatus 200 may be a general-purpose device or a dedicated device.
  • the image processing device 200 may be a video camera, a camera, a monitor, a video display device, a desktop computer, a portable computer, a network server, a personal digital assistant (PDA), a mobile phone, a tablet computer, a wireless terminal device , Embedded devices or devices with a similar structure in Figure 2.
  • PDA personal digital assistant
  • the embodiment of the present application does not limit the type of the device 200.
  • Color space Color is usually described by three independent attributes. Three independent variables work together to form a space coordinate, that is, color space.
  • the color space can include RGB (color) space, YUV (color) space, HSV (color) space and HSL (color) space, etc.
  • RGB color
  • YUV color
  • HSV color
  • HSL color space
  • RGB space R represents the red component (red channel), G represents the green component (green channel), and B represents the blue component (blue channel).
  • RGB space R represents the red component (red channel)
  • G represents the green component (green channel)
  • B represents the blue component (blue channel).
  • Various colors are obtained by changing the three color channels of red, green and blue and superimposing them. In each component, the smaller the value, the lower the brightness, and the larger the value, the higher the brightness.
  • the brightness after mixing is equal to the sum of the brightness of the components.
  • YUV space Y represents brightness, that is, gray scale value.
  • U and V represent chroma, used to describe the image color and saturation, you can specify the color of the pixel. If there are only Y signal components and no U, V components, then the image represented in this way is a black and white grayscale image.
  • YUV space is mainly used to optimize the transmission of color video signals, making it backward compatible with old-fashioned black and white TVs.
  • HSV space HSV is a method of representing points in the RGB color space in an inverted cone.
  • H represents color information, that is, the position of the spectral color, which can be measured by angle, and the value range is 0° to 360°.
  • Red is 0°
  • green is 120°
  • blue is 240°.
  • V represents the brightness of the color, ranging from 0 to 1.
  • HSL space HSL is similar to HSV, and the first two parameters in this model are the same as HSV.
  • L represents the brightness of the color, and can be used to control the change of the light and dark of the color.
  • the value of L ranges from 0% to 100%. The smaller the value, the darker the color and the closer to black; the larger the value, the brighter the color and the closer to white.
  • an embodiment of the present application provides a method for color restoration of an image, including:
  • the first target object refers to one or more objects (or areas where the objects are located) that are overexposed in the first image.
  • the object may be, for example, traffic lights (of various shapes and colors), vehicles, traffic signs, and so on.
  • the second area selected by the user on the second image may be used as the first image to be processed.
  • the user when the user thinks that the traffic signal (first target object) in an image (second image) is overexposed, the user can use the input device (for example, mouse or touch screen) of the image processing device Perform the first operation on the second image.
  • the first operation is used to frame the area (second area) where the overexposed traffic signal light is located.
  • the image processing device may cut the second area from the second image according to the coordinate information of the second area selected by the user to obtain the third image and the first image to be processed.
  • the first image to be processed includes a second area
  • the third image includes other areas than the second area. That is, the first image to be processed includes the second area selected by the user on the second image.
  • the second image is an HSV format image, that is, the second image is in the HSV space
  • the first image to be processed is also in the HSV space, and the saturation component and the lightness component of the pixels of the first image can be directly
  • the filtering process is performed in order to more stably and accurately identify the outline of the overexposed first object (for example, the overexposed traffic signal light) in the subsequent steps.
  • the first image to be processed is also in the first space.
  • the first image needs to be converted from the first space to the HSV space. Then, the saturation component and the lightness component of the pixels of the first image are filtered, so as to identify the outline of the overexposed first object more stably and accurately in the subsequent steps.
  • the first area corresponds to the area of the first target object (where).
  • the area where the overexposed first target object (eg, overexposed traffic signal light) in the first image is located may be determined according to the saturation and lightness of the pixels of the first image.
  • the saturation component and the lightness component of the pixel of the first image after the filtering process may be analyzed to determine that the saturation component is lower than the average value of the saturation of the pixel of the first image, and the brightness component ratio
  • the area where the average value of the brightness of the pixels of the first image is high is the area where the first target object is located. That is, the saturation of the pixels in the first area is lower than the average of the saturation of the pixels in the first image, and the brightness of the pixels in the first area is higher than the average of the brightness of the pixels in the first image.
  • FIG. 5 it is a schematic diagram of a first area.
  • a binary image corresponding to the first area may be obtained.
  • the binary image corresponding to the first area may include three connected areas (a, b, and c, respectively).
  • the connected area a is the area where the signal lamp is located, and the connected areas b and c may be the area where the halo generated by the signal lamp is located.
  • the contour of the at least one connected region whose area is greater than or equal to the first threshold in the binary image corresponds to the contour of the first target object.
  • the contour of the at least one connected region with an area greater than or equal to the first threshold in the binary image may be used as the contour of the first target object.
  • the outline of the at least one connected area whose area is greater than or equal to the first threshold may be larger or smaller than the outline of the actual (real) first target object.
  • the at least one connected area may include not only the area where the signal light is, but also the area where the halo generated by the signal light is located, so
  • the outline of the at least one connected area whose area is greater than or equal to the first threshold may be larger than the outline of the actual signal lamp.
  • the at least one connected region may only include the region where the part where the signal lamp emits light. In this case, the outline of the at least one connected region is smaller than the actual signal lamp.
  • the first threshold may be determined according to the area of the connected area with the largest area in the binary image.
  • the first threshold may be equal to the area of the connected area with the largest area in the binary image, or the first threshold may be N% (eg, 30%) of the area of the connected area with the largest area in the binary image, N Is a positive number.
  • the binary image corresponding to the first area there are many connected areas with different areas.
  • the binary image corresponding to the first area may include three connected areas (a, b, and c, respectively). Based on the binary image, find all connected regions in the binary image. Sort all the connected regions found according to the size of the area (for example, arrange all connected regions in order from large to small).
  • connected areas with different sizes it is possible to filter out the connected areas with a smaller area, retain the connected areas with a larger area, and use at least one connected area with a larger area as the area of the first target object (such as a signal light) (for example, One connected area with the largest area may be used as the area where the signal lamp is located, or multiple connected areas with a larger area may be used as the area where the signal lamp is located).
  • the first target object such as a signal light
  • the outline of the connected area a corresponds to the outline of the first target object.
  • the value range of the parameter x may be 0-9, and the parameter x may be used to adjust the size of the first threshold.
  • the larger the value of x the less the connected areas with a smaller area are filtered out, that is, the more connected areas with a smaller area are retained, so that the outline of the first target object corresponds to the outline of more connected areas.
  • the first target object is a signal lamp
  • the area where the signal lamp is located spreads outward (that is, the area where the signal lamp is located includes not only the signal lamp but also the halo generated by the signal lamp).
  • the first target object is a signal lamp
  • the area where the signal lamp is located shrinks inward (that is, the area where the signal lamp is located includes only the signal lamp, not the halo generated by the signal lamp).
  • the image processing device determines that the first area of the first image is as shown in (a) in FIG. 8, and performs binarization processing on the first area
  • the binary image corresponding to the first area may include four connected areas (respectively d, e, f, and g), as shown in (c) of FIG. 8
  • at least one connected region with an area greater than or equal to the first threshold may be connected regions d and e. That is, the connected regions (f and g) are filtered out, and the connected regions d and e are retained.
  • the outline of the connected regions d and e can be used as the outline of the first target object.
  • restoring the color of at least one connected region may also be regarded as correcting the color of at least one connected region.
  • Restoring or correcting the color of at least one connected area means restoring or correcting the color of the overexposed first target object. For example, as shown in FIG. 7, restoring or correcting the color of the connected area a is restoring or correcting the color of the overexposed first target object.
  • the color information of the traffic signal light may be acquired based on a signal light detector externally connected to the signal light or based on an image recognition status light.
  • the color of at least one connected area can be restored in the HSV space.
  • the traffic signal is red, adjust the hue of the pixels of at least one connected area to the red range, and increase and decrease the saturation and brightness of the pixels of at least one connected area;
  • the traffic signal is yellow, adjust the hue of the pixels of at least one connected area to the yellow range, and increase and decrease the saturation and brightness of the pixels of at least one connected area;
  • the traffic signal is green, change The hue of the pixels of at least one connected area is adjusted to the green range, and the saturation and lightness of the pixels of at least one connected area are increased and decreased, respectively.
  • increasing and reducing the saturation and lightness of the pixels of at least one connected area may be linearly increasing and decreasing the saturation and lightness of the pixels of at least one connected area, respectively, or may be The saturation and lightness of the pixels of at least one connected area are nonlinearly improved and nonlinearly reduced, respectively.
  • Linearly increasing the saturation can increase the saturation of each pixel in the pixels in at least one connected area by the same amount (value); non-linearly increasing the saturation can change the difference in the pixels in at least one connected area
  • the saturation of the pixels is increased by different amounts (values).
  • Linearly reducing the brightness can reduce the brightness of each pixel in at least one connected region by the same amount (value); non-linearly reducing the brightness can reduce the brightness of different pixels in the pixels in at least one connected region Reduce different amounts (values). It should be noted that, after the saturation and lightness of pixels in at least one connected area are respectively increased and decreased, there is a strong correlation between the saturation and lightness of at least one connected area. Before the saturation and lightness of pixels in at least one connected area are increased and decreased respectively, there is no strong correlation between the saturation and lightness of at least one connected area.
  • the color of at least one connected area can be restored in RGB space. Specifically, when (determining) the traffic signal light is red, the red component of the pixel of the at least one connected area may be adjusted to the first preset range, and the blue and green components of the pixel of the at least one connected area may be reduced.
  • the value range of the parameter x can be 0-9, and the parameter x can be used to adjust the size of the R value.
  • reducing the blue and green components of the pixels of at least one connected region may be a linear or non-linear reduction of the blue and green components of the pixels of at least one connected region.
  • Linear reduction can reduce the blue and green components of each pixel in at least one connected region by the same amount (value); non-linear reduction can reduce the blue sum of different pixels in the pixels in at least one connected region The green component decreases by a different amount (value).
  • the traffic signal When (determine) the traffic signal is yellow, increase the red and green components of the pixels of at least one connected area, and reduce the blue component of the pixels of at least one connected area; when (determined) the traffic signal is green, increase at least one connected area
  • the green component of the pixel reduces the red and blue components of the pixel in at least one connected area.
  • the color-reduced first image can be re-converted from the HSV space to the first space, so that the first image and the third image (i.e. The two images cut out the remaining part of the first image) and merge to obtain a complete image (it can be considered that the complete image is the second image after color restoration). If the operation of converting the first image from the first space to the HSV space is not performed in step 302, the first image and the third image after color restoration can be directly merged to obtain a complete image.
  • the user can select the overexposed object before the video starts or when it is paused.
  • the user can use The method of the embodiment of the present application performs corresponding processing on each frame image of the video, thereby restoring the color of the over-exposed first target object in the entire video.
  • the first area of the first image may be determined according to the saturation and lightness of the pixels of the first image (the first area may be used as the overexposed first The area where the target object is located), and then binarize the first area to obtain the binary image corresponding to the first area; then determine at least one connected area in the binary image whose area is greater than or equal to the first threshold (you can use The outline of at least one connected area is taken as the outline of the first target object), and then, the color of the at least one connected area is restored (that is, the color of the over-exposed first target object is restored).
  • the method provided by the embodiments of the present application can accurately reproduce color of overexposed objects (for example, traffic lights) in the image. Furthermore, it can solve a series of problems caused by overexposure of objects in the image (for example, the problem of difficulty in obtaining evidence caused by overexposure of signal lights in the current electric police monitoring scene).
  • an ultra-wide dynamic range camera can be used to eliminate the color distortion of the signal light caused by strong light, and the ultra-wide dynamic camera is expensive and has a limited color reproduction effect on the over-exposed signal light under low illumination.
  • the method provided by the embodiment of the present application does not require additional equipment, is inexpensive, and can achieve the effect of color reproduction, and has high environmental adaptability, and can perform color reproduction of over-exposed signal lights under low illumination.
  • the color of the signal lights can be restored based on the RGB space of the image, or the area of the signal lights in the image can be identified and color enhanced based on the method of deep learning, but it may cause the color signal area and the surrounding image to be restored Discontinuous gradient phenomenon.
  • the method provided in the embodiment of the present application is based on the HSV space, and better reflects the brightness information of the physical signal lamp, so that the identification of the signal lamp area is more stable and accurate, and the signal lamp area after color restoration is more continuous with the surrounding image, and the naked eye effect More realistic.
  • the method provided by the embodiments of the present application is efficient and reliable, and can satisfy the color reproduction effect of the signal light in the video.
  • the image processing device includes a hardware structure and/or a software module corresponding to each function.
  • the present application can be implemented in the form of hardware or a combination of hardware and software. Whether a function is executed by hardware or software driven hardware depends on the specific application of the technical solution and design constraints. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
  • the image processing device may be divided into function modules according to the above method examples.
  • each function module may be divided corresponding to each function, or two or more functions may be integrated into one processing module.
  • the above integrated modules may be implemented in the form of hardware or software function modules. It should be noted that the division of the modules in the embodiments of the present application is schematic, and is only a division of logical functions. In actual implementation, there may be another division manner.
  • FIG. 9 shows a possible structural schematic diagram of the image processing device 9 involved in the above embodiment.
  • the image processing device includes: an acquisition unit 901, a determination unit 902, and Processing unit 903.
  • the acquiring unit 901 is used to support the image processing device to perform the process 301 in FIG. 3.
  • the determination unit 902 is used to support the image processing device to perform the processes 303 and 305 in FIG. 3.
  • the processing unit 903 is used to support the image processing device to perform steps 302, 304, and 306 in FIG. Wherein, all relevant content of each step involved in the above method embodiments can be referred to the function description of the corresponding function module, which will not be repeated here.
  • the steps of the method or algorithm described in conjunction with the disclosure of the present application may be implemented by hardware, or by a processor executing software instructions.
  • the software instructions may be composed of corresponding software modules, which may be stored in RAM, flash memory, ROM, EPROM, EEPROM, registers, hard disk, mobile hard disk, read-only optical disk, or any other form of storage medium well known in the art.
  • An exemplary storage medium is coupled to the processor, so that the processor can read information from the storage medium and can write information to the storage medium.
  • the storage medium may also be a component of the processor.
  • the processor and the storage medium may be located in an application specific integrated circuit (application specific integrated circuit, ASIC).
  • the ASIC may be located in the core network interface device.
  • the processor and the storage medium may also exist as discrete components in the core network interface device.
  • the image processing device readable medium includes an image processing device storage medium and a communication medium, where the communication medium includes any medium that facilitates transferring the image processing device program from one place to another place.
  • the storage medium may be any available medium that can be accessed by a general-purpose or special-purpose image processing device.

Abstract

The embodiments of the present application provide a method and an apparatus for color reproduction of an image, relating to the field of image processing, and being able to perform accurate color reproduction of an overexposed object (for example, a traffic signal lamp) in an image. Said method comprises: acquiring a first image to be processed, the first image comprising an overexposed first target object; according to the saturation and luminance of pixels of the first image, determining a first region of the first image; performing binarization processing on the first region, to obtain a binary image corresponding to the first region; determining, in the binary image, at least one connected region of which the area is greater than or equal to a first threshold, the contour of the at least one connected region corresponding to the contour of the first target object; and reproducing the color of the at least one connected region. The embodiments of the present application are applicable to situations where color reproduction is performed on an overexposed image.

Description

一种对图像进行颜色还原的方法和装置Method and device for color restoration of image 技术领域Technical field
本申请涉及图像处理领域,尤其涉及一种对图像进行颜色还原的方法和装置。The present application relates to the field of image processing, and in particular to a method and device for color restoration of an image.
背景技术Background technique
图像过曝是一个比较常见的现象,可能导致一系列的问题。举例来说,在交通视频监控系统中,工作在电子警察模式下的监控摄像机可以同时对红灯信号和违章车辆进行抓拍取证,作为违章人员的违章证据。但是,在背景环境光照度比较低的情况下(如黄昏或夜晚场景),当监控摄像机对着信号红灯进行拍照取证时,摄像机往往需要提高快门、增益和光圈大小。若增益、快门或者光圈的过分增大,就会导致拍摄到的交通信号灯过曝(例如,红色的信号灯会变成黄色或白色),从而导致抓拍的图像不能作为违章的证据。Image overexposure is a relatively common phenomenon, which may cause a series of problems. For example, in a traffic video surveillance system, a surveillance camera working in an electronic police mode can simultaneously capture red light signals and illegal vehicles as evidence for violations by illegal personnel. However, in the case of relatively low background illumination (such as dusk or night scenes), when the surveillance camera takes a photo forensic against the signal red light, the camera often needs to increase the shutter, gain and aperture size. If the gain, shutter or aperture is increased too much, it will cause the traffic lights to be overexposed (for example, the red signal lights will become yellow or white), so that the captured images cannot be used as evidence of violations.
目前,有以下几种实现信号灯色彩还原的方法,可以分为硬件方法和软件方法。硬件方法:可以采用具有超宽动态范围的摄像机消除强光造成的信号灯色彩失真。这是由于具有超宽动态范围的摄像机检测亮度动态范围大,能够还原出高反差亮度场景下的图像细节。但是,一方面,超宽动态摄像机价格比较昂贵;另一方面,由于通常信号灯区域占整个画面比例很小,导致超宽动态范围的摄像机对低照度下过曝信号灯的色彩还原效果有限。软件方法1:可以基于图像的红绿蓝(red、green、blue,RGB)(颜色)空间进行信号灯区域的识别,然后进行信号灯的色彩还原。但是,RGB色彩空间并不能很好地反映出信号灯的亮度信息,可能导致色彩还原后的信号灯区域与周围图像不连续的梯度现象。软件方法2:可以基于深度学习的方法对图像中的信号灯进行区域识别,并进行颜色增强。但是,基于深度学习的方法对信号灯的轮廓识别精度不高,因此信号灯色彩还原区域容易出现与周围图像不连续的现象。At present, there are several methods to realize the color restoration of signal lights, which can be divided into hardware methods and software methods. Hardware method: A camera with an ultra-wide dynamic range can be used to eliminate signal color distortion caused by strong light. This is because a camera with an ultra-wide dynamic range detects a large dynamic range of brightness, and can restore image details in a high-contrast brightness scene. However, on the one hand, the ultra-wide dynamic camera is relatively expensive; on the other hand, because the signal light area generally accounts for a small proportion of the entire screen, the ultra-wide dynamic range camera has a limited effect on the color reproduction of the over-exposed signal light under low illumination. Software method 1: You can identify the signal light area based on the red, green, blue (RGB) (color) space of the image, and then perform the color restoration of the signal light. However, the RGB color space does not reflect the brightness information of the signal light well, and may cause a discontinuous gradient phenomenon between the signal area after the color reproduction and the surrounding image. Software method 2: Based on the method of deep learning, the signal lights in the image can be identified and the color can be enhanced. However, the method based on deep learning does not have a high accuracy in recognizing the contour of the signal light, so the color reproduction area of the signal light is prone to appear discontinuous with the surrounding image.
因此,亟需一种更准确的对图像中的过曝物体(例如过曝的交通信号灯)进行色彩还原的方法。Therefore, there is a need for a more accurate method for color reproduction of overexposed objects (such as overexposed traffic lights) in images.
发明内容Summary of the invention
本申请实施例提供一种图像处理方法,能够对图像中过曝的物体(例如,交通信号灯)进行准确的色彩还原。进而,可以解决由于图像中的物体过曝导致的一系列问题(例如,当前电警监控场景下信号灯过曝造成的取证困难问题)。Embodiments of the present application provide an image processing method, which can accurately reproduce color of overexposed objects (for example, traffic lights) in an image. Furthermore, it can solve a series of problems caused by overexposure of objects in the image (for example, the problem of difficulty in obtaining evidence caused by overexposure of signal lights in the current electric police monitoring scene).
第一方面,本申请实施例提供一种对图像进行颜色还原的方法,包括:获取待处理的第一图像,第一图像包括过曝的第一目标对象;根据第一图像的像素的饱和度和明度确定第一图像的第一区域,第一区域的像素的饱和度低于第一图像的像素的饱和度的平均值,且第一区域的像素的明度高于第一图像的像素的明度的平均值;第一区域对应第一目标对象(所在的)区域;对第一区域进行二值化处理,得到第一区域对应的二值图像;确定二值图像中面积大于或等于第一阈值的至少一个连通区域;至少一个连通区域的轮廓对应第一目标对象的轮廓;还原至少一个连通区域的颜色。In a first aspect, an embodiment of the present application provides a method for color restoration of an image, including: acquiring a first image to be processed, the first image including an overexposed first target object; and according to the saturation of the pixels of the first image And the brightness determine the first area of the first image, the saturation of the pixels in the first area is lower than the average value of the saturation of the pixels in the first image, and the brightness of the pixels in the first area is higher than the brightness of the pixels in the first image The average value of the first area; the first area corresponds to the area of the first target object (where); the first area is binarized to obtain the binary image corresponding to the first area; the area of the binary image is determined to be greater than or equal to the first threshold At least one connected area; the outline of at least one connected area corresponds to the outline of the first target object; the color of at least one connected area is restored.
基于本申请实施例提供的方法,获取待处理的第一图像后,可以根据第一图像的像素的饱和度和明度确定第一图像的第一区域(第一区域可以作为过曝的第一目标对象所在的区域)而后,可以对第一区域进行二值化处理,得到第一区域对应的二值图像;再确定二值图像中面积大于或等于第一阈值的至少一个连通区域(至少一个连通区域的轮廓对应第一目标对象的轮廓),然后,还原该至少一个连通区域的颜色(即还原了过曝的第一目标对 象的颜色)。可见,本申请实施例提供的方法能够对图像中过曝的物体(即第一目标对象,例如可以是交通信号灯)进行准确的色彩还原。进而,可以解决由于图像中的物体过曝导致的一系列问题(例如,当前电警监控场景下信号灯过曝造成的取证困难问题)。Based on the method provided in the embodiments of the present application, after acquiring the first image to be processed, the first area of the first image may be determined according to the saturation and brightness of the pixels of the first image (the first area may be used as the first target of overexposure) The area where the object is located), and then the first area can be binarized to obtain a binary image corresponding to the first area; and then determine at least one connected area (at least one connected area) in the binary image whose area is greater than or equal to the first threshold The contour of the area corresponds to the contour of the first target object), and then, the color of the at least one connected area is restored (that is, the color of the over-exposed first target object is restored). It can be seen that the method provided by the embodiments of the present application can accurately reproduce color of an over-exposed object in the image (that is, the first target object, for example, can be a traffic signal). Furthermore, it can solve a series of problems caused by overexposure of objects in the image (for example, the problem of difficulty in obtaining evidence caused by overexposure of signal lights in the current electric police monitoring scene).
在一种可能的实现方式中,根据第一图像的饱和度和明度确定第一图像的第一区域之前,该方法还包括:将第一图像从第一空间转换到色调饱和度明度(hue saturation value,HSV)空间,第一空间为亮度色度YUV空间、RGB空间或色调饱和度亮度色调饱和度亮度(hue saturation lightness,HSL)空间中的任一种。也就是说,若待处理的第一图像处于第一空间,第一空间可以为YUV空间或者RGB空间或HSL空间,此时,为了得到第一图像的像素的饱和度分量和明度分量,需要将第一图像从第一空间转换到HSV空间。In a possible implementation, before determining the first region of the first image according to the saturation and brightness of the first image, the method further includes: converting the first image from the first space to hue saturation and brightness (hue saturation) Value (HSV) space, the first space is any one of the brightness and chroma YUV space, RGB space or hue saturation brightness hue saturation brightness (HSL) space. In other words, if the first image to be processed is in the first space, the first space may be YUV space or RGB space or HSL space. At this time, in order to obtain the saturation and lightness components of the pixels of the first image, you need to The first image is converted from the first space to the HSV space.
在一种可能的实现方式中,当第一目标对象为交通信号灯时,还原至少一个连通区域的颜色包括:获取交通信号灯的颜色信息;当交通信号灯为红色时,将至少一个连通区域的像素的色调调整至红色范围,并将至少一个连通区域的像素的饱和度和明度分别进行提升和降低;当交通信号灯为黄色时,将至少一个连通区域的像素的色调调整至黄色范围,并将至少一个连通区域的像素的饱和度和明度分别进行提升和降低;当交通信号灯为绿色时,将至少一个连通区域的像素的色调调整至绿色范围,并将至少一个连通区域的像素的饱和度和明度分别进行提升和降低。In a possible implementation manner, when the first target object is a traffic signal, restoring the color of at least one connected area includes: acquiring color information of the traffic signal; when the traffic signal is red, the pixel of at least one connected area Adjust the hue to the red range, and increase and decrease the saturation and lightness of the pixels of at least one connected area; when the traffic signal is yellow, adjust the hue of the pixels of at least one connected area to the yellow range, and adjust at least one The saturation and brightness of pixels in the connected area are increased and decreased respectively; when the traffic signal is green, the hue of the pixels of at least one connected area is adjusted to the green range, and the saturation and brightness of the pixels of at least one connected area are respectively adjusted Perform ascent and descent.
在本申请实施例中,将至少一个连通区域的像素的饱和度和明度分别进行提升和降低可以是将至少一个连通区域的像素的饱和度和明度分别进行线性提升和线性降低,或者可以是将至少一个连通区域的像素的饱和度和明度分别进行非线性提升和非线性降低。In the embodiment of the present application, increasing and decreasing the saturation and lightness of the pixels of at least one connected area may be linearly increasing and decreasing the saturation and lightness of the pixels of at least one connected area, respectively, or may be The saturation and lightness of the pixels of at least one connected area are nonlinearly improved and nonlinearly reduced, respectively.
在一种可能的实现方式中,当第一目标对象为交通信号灯时,还原至少一个连通区域的颜色包括:将至少一个连通区域转换到RGB空间;获取交通信号灯的颜色信息;当交通信号灯为红色时,将至少一个连通区域的像素的红色分量调整至第一预设范围,降低至少一个连通区域的像素的蓝色和绿色分量;当交通信号灯为黄色时,将至少一个连通区域的像素的红色和绿色分量调整至第二预设范围,降低至少一个连通区域的像素的蓝色分量;当交通信号灯为绿色时,将至少一个连通区域的像素的绿色分量调整至第三预设范围,降低至少一个连通区域的像素的红色和蓝色分量。In a possible implementation manner, when the first target object is a traffic signal, restoring the color of at least one connected area includes: converting the at least one connected area to an RGB space; acquiring color information of the traffic signal; when the traffic signal is red , Adjust the red component of the pixels of at least one connected area to the first preset range, and reduce the blue and green components of the pixels of at least one connected area; when the traffic signal is yellow, change the red color of the pixels of at least one connected area And the green component are adjusted to the second preset range to reduce the blue component of pixels in at least one connected area; when the traffic signal is green, the green component of the pixels in at least one connected area is adjusted to the third preset range and reduced by at least The red and blue components of pixels in a connected area.
其中,降低至少一个连通区域的像素的蓝色和绿色分量可以是对至少一个连通区域的像素的蓝色和绿色分量做线性降低或非线性降低。Wherein, reducing the blue and green components of the pixels of at least one connected region may be a linear or non-linear reduction of the blue and green components of the pixels of at least one connected region.
在一种可能的实现方式中,根据第一图像的饱和度和明度确定第一图像的第一区域之前,该方法还包括:对第一图像的像素的饱和度分量和明度分量进行滤波处理。这样一来,可以更稳定和准确地识别出过曝的第一对象的轮廓。In a possible implementation, before determining the first region of the first image according to the saturation and brightness of the first image, the method further includes: performing filtering processing on the saturation component and the brightness component of the pixels of the first image. In this way, the outline of the overexposed first object can be identified more stably and accurately.
在一种可能的实现方式中,获取待处理的第一图像包括:将用户在第二图像上选择的第二区域作为待处理的第一图像。In a possible implementation manner, acquiring the first image to be processed includes: using the second area selected by the user on the second image as the first image to be processed.
这样一来,相比直接对第二图像进行处理,从第二图像中选择出第一图像并仅对第一图像进行处理,一方面可以减小后续步骤中的运算量,另一方面可以提高第一目标对象(例如,信号灯)所在区域的识别精准度。In this way, compared to processing the second image directly, selecting the first image from the second image and processing only the first image, on the one hand, it can reduce the amount of calculation in the subsequent steps, on the other hand, it can improve The recognition accuracy of the area where the first target object (for example, a signal light) is located.
第二方面,本申请实施例提供一种图像处理设备,包括:获取单元,用于获取待处理 的第一图像,第一图像包括过曝的第一目标对象;确定单元,用于根据第一图像的像素的饱和度和明度确定第一图像的第一区域,第一区域的像素的饱和度低于第一图像的像素的饱和度的平均值,且第一区域的像素的明度高于第一图像的像素的明度的平均值;第一区域对应第一目标对象区域;处理单元,用于对第一区域进行二值化处理,得到第一区域对应的二值图像;确定单元,还用于确定二值图像中面积大于或等于第一阈值的至少一个连通区域;第一目标对象的轮廓对应该至少一个连通区域的轮廓;处理单元,还用于还原至少一个连通区域的颜色。In a second aspect, an embodiment of the present application provides an image processing device, including: an acquisition unit for acquiring a first image to be processed, the first image including an overexposed first target object; and a determination unit for The saturation and brightness of the pixels of the image determine the first area of the first image. The saturation of the pixels of the first area is lower than the average value of the saturation of the pixels of the first image, and the brightness of the pixels of the first area is higher than the first The average value of the lightness of pixels of an image; the first area corresponds to the first target object area; the processing unit is used to binarize the first area to obtain a binary image corresponding to the first area; the determination unit also uses To determine at least one connected region whose area is greater than or equal to the first threshold in the binary image; the contour of the first target object corresponds to the contour of the at least one connected region; the processing unit is also used to restore the color of the at least one connected region.
在一种可能的实现方式中,处理单元还用于:将第一图像从第一空间转换到HSV空间,第一空间为YUV空间、RGB空间或HSL空间中的任一种。In a possible implementation manner, the processing unit is further configured to: convert the first image from the first space to the HSV space, and the first space is any one of YUV space, RGB space, or HSL space.
在一种可能的实现方式中,当第一目标对象为交通信号灯时,处理单元用于:通过获取单元获取交通信号灯的颜色信息;当交通信号灯为红色时,将至少一个连通区域的像素的色调调整至红色范围,并将至少一个连通区域的像素的饱和度和明度分别进行提升和降低;当交通信号灯为黄色时,将至少一个连通区域的像素的色调调整至黄色范围,并将至少一个连通区域的像素的饱和度和明度分别进行提升和降低;当交通信号灯为绿色时,将至少一个连通区域的像素的色调调整至绿色范围,并将至少一个连通区域的像素的饱和度和明度分别进行提升和降低。In a possible implementation, when the first target object is a traffic signal, the processing unit is used to: obtain the color information of the traffic signal through the acquisition unit; when the traffic signal is red, change the hue of the pixels of at least one connected area Adjust to the red range, and increase and decrease the saturation and brightness of the pixels of at least one connected area; when the traffic signal is yellow, adjust the hue of the pixels of at least one connected area to the yellow range, and connect at least one The saturation and brightness of the pixels in the area are increased and decreased respectively; when the traffic signal is green, the hue of the pixels of at least one connected area is adjusted to the green range, and the saturation and brightness of the pixels of at least one connected area are respectively adjusted Raise and lower.
在一种可能的实现方式中,当第一目标对象为交通信号灯时,处理单元用于:将至少一个连通区域转换到RGB空间;通过获取单元获取交通信号灯的颜色信息;当交通信号灯为红色时,将至少一个连通区域的像素的红色分量调整至第一预设范围,降低至少一个连通区域的像素的蓝色和绿色分量;当交通信号灯为黄色时,将至少一个连通区域的像素的红色和绿色分量调整至第二预设范围,降低至少一个连通区域的像素的蓝色分量;当交通信号灯为绿色时,将至少一个连通区域的像素的绿色分量调整至第三预设范围,降低至少一个连通区域的像素的红色和蓝色分量。In a possible implementation manner, when the first target object is a traffic signal, the processing unit is used to: convert at least one connected area to an RGB space; acquire the color information of the traffic signal through the acquisition unit; when the traffic signal is red , Adjust the red component of the pixels of the at least one connected area to the first preset range, and reduce the blue and green components of the pixels of the at least one connected area; when the traffic signal is yellow, the red sum of the pixels of the at least one connected area The green component is adjusted to the second preset range to reduce the blue component of pixels in at least one connected area; when the traffic signal is green, the green component of the pixels in at least one connected area is adjusted to the third preset range to reduce at least one The red and blue components of the pixels in the connected area.
在一种可能的实现方式中,处理单元还用于:对第一图像的像素的饱和度分量和明度分量进行滤波处理。In a possible implementation manner, the processing unit is further configured to filter the saturation component and the lightness component of the pixels of the first image.
在一种可能的实现方式中,获取单元用于:将用户在第二图像上选择的第二区域作为待处理的第一图像。In a possible implementation manner, the acquiring unit is configured to: use the second area selected by the user on the second image as the first image to be processed.
第二方面及其各种可能的实现方式的技术效果可以参见第一方面及其各种可能的实现方式的技术效果,此处不再赘述。For the technical effects of the second aspect and its various possible implementation manners, refer to the technical effects of the first aspect and its various possible implementation manners, and details are not described herein again.
第三方面,本申请实施例提供了一种装置,该装置以芯片的产品形态存在,该装置的结构中包括处理器和存储器,该存储器用于与处理器耦合,保存该装置必要的程序指令和数据,该处理器用于执行存储器中存储的程序指令,使得该装置执行上述方法中图像处理设备的功能。In a third aspect, an embodiment of the present application provides an apparatus that exists in the form of a chip product. The structure of the apparatus includes a processor and a memory, and the memory is used to couple with the processor to store necessary program instructions of the apparatus And data, the processor is used to execute the program instructions stored in the memory, so that the device performs the function of the image processing device in the above method.
第四方面,本申请实施例提供了一种图像处理设备,该图像处理设备可以实现上述图像处理设备所执行的功能,功能可以通过硬件实现,也可以通过硬件执行相应的软件实现。硬件或软件包括一个或多个上述功能相应的模块。According to a fourth aspect, an embodiment of the present application provides an image processing device that can implement the functions performed by the image processing device described above. The functions can be implemented by hardware, or can be implemented by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions.
在一种可能的设计中,该图像处理设备的结构中包括处理器和通信接口,该处理器被配置为支持该图像处理设备执行上述方法中相应的功能。该通信接口用于支持该图像处理 设备与其他设备(例如交通信号灯上的信号灯检测器)之间的通信。该图像处理设备还可以包括存储器,该存储器用于与处理器耦合,其保存该图像处理设备必要的程序指令和数据。In a possible design, the structure of the image processing device includes a processor and a communication interface, and the processor is configured to support the image processing device to perform the corresponding function in the above method. The communication interface is used to support communication between the image processing device and other devices (e.g., a signal light detector on traffic lights). The image processing device may further include a memory for coupling with the processor, which stores necessary program instructions and data of the image processing device.
第五方面,本申请实施例提供一种计算机可读存储介质,包括指令,当其在计算机上运行时,使得计算机执行第一方面提供的任意一种方法。According to a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, including instructions, which, when run on a computer, cause the computer to execute any method provided in the first aspect.
第六方面,本申请实施例提供了一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行第一方面提供的任意一种方法。According to a sixth aspect, an embodiment of the present application provides a computer program product containing instructions, which when run on a computer, causes the computer to execute any method provided in the first aspect.
附图说明BRIEF DESCRIPTION
图1为本申请实施例提供的一种适用于对图像进行颜色还原的方法的系统架构示意图;FIG. 1 is a schematic diagram of a system architecture suitable for a method for color restoration of an image provided by an embodiment of the present application;
图2为本申请实施例提供的一种图像处理设备的结构示意图;2 is a schematic structural diagram of an image processing device according to an embodiment of the present application;
图3为本申请实施例提供的一种适用于对图像进行颜色还原的方法的流程示意图;FIG. 3 is a schematic flowchart of a method suitable for color restoration of an image provided by an embodiment of the present application;
图4为本申请实施例提供的一种用户选择待处理的第一图像的示意图;4 is a schematic diagram of a user selecting a first image to be processed provided by an embodiment of the present application;
图5为本申请实施例提供的一种第一区域的示意图;5 is a schematic diagram of a first area provided by an embodiment of this application;
图6为本申请实施例提供的一种第一区域对应的二值图像的示意图;6 is a schematic diagram of a binary image corresponding to a first area provided by an embodiment of the present application;
图7为本申请实施例提供的一种连通区域的示意图;7 is a schematic diagram of a connected area provided by an embodiment of the present application;
图8为本申请实施例提供的一种第一区域、第一区域对应的二值图像以及根据该二值图像确定的连通区域的示意图;8 is a schematic diagram of a first area, a binary image corresponding to the first area, and a connected area determined according to the binary image provided by an embodiment of the present application;
图9为本申请实施例提供的又一种图像处理设备的结构示意图。9 is a schematic structural diagram of yet another image processing device provided by an embodiment of the present application.
具体实施方式detailed description
本申请实施例提供一种对图像进行颜色(色彩)还原的方法和装置,应用于对过曝的图像进行色彩还原的场景。可以理解的是,本申请实施例也可以应用于对包括一帧或多帧过曝图像的视频进行色彩还原的场景。具体的,可以应用于对图像中的过曝的对象(或过曝的区域)进行色彩还原的过程中。例如,对电子警察(摄像机或监控器)拍摄的图像或视频中的过曝的交通信号灯进行色彩还原的过程中。Embodiments of the present application provide a method and device for color (color) restoration of an image, which are applied to a scene of color restoration of an overexposed image. It can be understood that the embodiments of the present application may also be applied to a scene where color restoration is performed on a video including one or more frames of overexposed images. Specifically, it can be applied to the process of color restoration of an overexposed object (or overexposed area) in an image. For example, in the process of color reproduction of overexposed traffic lights in images or videos taken by electronic police (cameras or monitors).
本申请实施例以电子警察摄像机拍摄违章图像的场景为例,如图1所示,提供一种适用于对图像(电子警察摄像机拍摄的违章图像)进行颜色还原的方法的系统架构示意图,包括电子警察摄像机和与电子警察摄像机连接的图像处理设备(该图像处理设备也可以集成在电子警察摄像机中),该图像处理设备可以对电子警察摄像机拍摄的图像或视频进行颜色还原的处理。该图像处理设备还可以与交通信号灯连接,以便从交通信号灯上的信号灯检测器获取信号灯的(历史)颜色变化情况。The embodiment of the present application takes the scene of an illegal image captured by an electronic police camera as an example. As shown in FIG. 1, a schematic diagram of a system architecture suitable for a method for performing color restoration on an image (an illegal image captured by an electronic police camera), including electronic A police camera and an image processing device connected to the electronic police camera (the image processing device may also be integrated in the electronic police camera), the image processing device may perform color restoration processing on the image or video taken by the electronic police camera. The image processing device can also be connected to a traffic signal lamp in order to obtain the (historical) color change of the signal lamp from the signal lamp detector on the traffic signal lamp.
本申请实施例图1中的图像处理设备,可以由一个设备实现,也可以是一个设备内的一个功能模块,本申请实施例对此不作具体限定。可以理解的是,上述功能既可以是硬件设备中的网络元件,也可以是在专用硬件上运行的软件功能,或者是平台(例如,云平台)上实例化的虚拟化功能,或者是芯片系统。本申请实施例中,芯片系统可以由芯片构成,也可以包含芯片和其他分立器件。The image processing device in FIG. 1 of the embodiment of the present application may be implemented by one device, or may be a functional module in a device, which is not specifically limited in the embodiment of the present application. It is understandable that the above-mentioned functions may be network elements in hardware devices, or software functions running on dedicated hardware, or virtualized functions instantiated on platforms (for example, cloud platforms), or chip systems. . In the embodiment of the present application, the chip system may be composed of a chip, or may include a chip and other discrete devices.
例如,用于实现本申请实施例提供的图像处理设备的功能的装置可以通过图2中的装置200来实现。图2所示为本申请实施例提供的装置200的硬件结构示意图。该装置200中包括至少一个处理器201,用于实现本申请实施例提供的图像处理设备的功能。装置200中还可以包括总线202以及至少一个通信接口204。装置200中还可以包括存储器203。For example, the apparatus for implementing the functions of the image processing apparatus provided by the embodiments of the present application may be implemented by the apparatus 200 in FIG. 2. FIG. 2 is a schematic diagram of a hardware structure of an apparatus 200 provided by an embodiment of the present application. The apparatus 200 includes at least one processor 201, which is used to implement the functions of the image processing device provided in the embodiments of the present application. The device 200 may further include a bus 202 and at least one communication interface 204. The device 200 may further include a memory 203.
在本申请实施例中,处理器可以是中央处理器(central processing unit,CPU),通用处理器、网络处理器(network processor,NP)、数字信号处理器(digital signal processing,DSP)、微处理器、微控制器、可编程逻辑器件(programmable logic device,PLD)或它们的任意组合。处理器还可以是其它任意具有处理功能的装置,例如电路、器件或软件模块。In the embodiment of the present application, the processor may be a central processing unit (central processing unit, CPU), a general-purpose processor, a network processor (NP), a digital signal processor (digital signal processing, DSP), or a micro processor Device, microcontroller, programmable logic device (PLD) or any combination of them. The processor may also be any other device with a processing function, such as a circuit, a device, or a software module.
总线202可用于在上述组件之间传送信息。The bus 202 can be used to transfer information between the aforementioned components.
通信接口204,用于与其他设备或通信网络通信,如以太网,无线接入网(radio access network,RAN),无线局域网(wireless local area networks,WLAN)等。通信接口204可以是接口、电路、收发器或者其它能够实现通信的装置,本申请不做限制。通信接口204可以和处理器201耦合。本申请实施例中的耦合是装置、单元或模块之间的间接耦合或通信连接,可以是电性,机械或其它的形式,用于装置、单元或模块之间的信息交互。The communication interface 204 is used to communicate with other devices or communication networks, such as Ethernet, radio access network (RAN), wireless local area network (WLAN), etc. The communication interface 204 may be an interface, a circuit, a transceiver, or other devices capable of implementing communication, and the application is not limited. The communication interface 204 may be coupled with the processor 201. The coupling in the embodiments of the present application is an indirect coupling or communication connection between devices, units or modules, which may be in electrical, mechanical or other forms, and is used for information interaction between devices, units or modules.
在本申请实施例中,存储器可以是只读存储器(read-only memory,ROM)或可存储静态信息和指令的其他类型的静态存储设备,随机存取存储器(random access memory,RAM)或者可存储信息和指令的其他类型的动态存储设备,也可以是电可擦可编程只读存储器(electrically erasable programmable read-only memory,EEPROM)、只读光盘(compact disc read-only memory,CD-ROM)或其他光盘存储、光碟存储(包括压缩光碟、激光碟、光碟、数字通用光碟、蓝光光碟等)、磁盘存储介质或者其他磁存储设备、或者能够用于携带或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的任何其他介质,但不限于此。存储器可以是独立存在,也可以与处理器耦合,例如通过总线202。存储器也可以和处理器集成在一起。In the embodiments of the present application, the memory may be read-only memory (read-only memory, ROM) or other types of static storage devices that can store static information and instructions, random access memory (random access memory, RAM), or may store Other types of dynamic storage devices for information and instructions can also be electrically erasable programmable read-only memory (electrically erasable programmable-read-only memory (EEPROM), compact-disc read-only memory (CD-ROM) or Other optical disc storage, optical disc storage (including compact discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), magnetic disk storage media or other magnetic storage devices, or can be used to carry or store desired data in the form of instructions or data structures Program code and any other medium that can be accessed by the computer, but not limited to this. The memory may exist independently, or may be coupled with the processor, for example, through the bus 202. The memory can also be integrated with the processor.
其中,存储器203用于存储程序指令,并可以由处理器201来控制执行,从而实现本申请下述实施例提供的对图像进行颜色还原的方法。处理器201用于调用并执行存储器203中存储的指令,从而实现本申请下述实施例提供的对图像进行颜色还原的方法。The memory 203 is used to store program instructions, and can be controlled and executed by the processor 201, so as to implement the method for color restoration of an image provided by the following embodiments of the present application. The processor 201 is used to call and execute the instructions stored in the memory 203, so as to implement the method for color restoration of an image provided by the following embodiments of the present application.
可选的,本申请实施例中的计算机执行指令也可以称之为应用程序代码,本申请实施例对此不作具体限定。Optionally, the computer execution instructions in the embodiments of the present application may also be called application program codes, which are not specifically limited in the embodiments of the present application.
可选地,存储器203可以包括于处理器201中。Alternatively, the memory 203 may be included in the processor 201.
在具体实现中,作为一种实施例,处理器201可以包括一个或多个CPU,例如图2中的CPU0和CPU1。In a specific implementation, as an embodiment, the processor 201 may include one or more CPUs, such as CPU0 and CPU1 in FIG. 2.
在具体实现中,作为一种实施例,装置200可以包括多个处理器,例如图2中的处理器201和处理器207。这些处理器中的每一个可以是一个单核(single-CPU)处理器,也可以是一个多核(multi-CPU)处理器。这里的处理器可以指一个或多个设备、电路、和/或用于处理数据(例如计算机程序指令)的处理核。In a specific implementation, as an embodiment, the apparatus 200 may include multiple processors, such as the processor 201 and the processor 207 in FIG. 2. Each of these processors can be a single-core (single-CPU) processor or a multi-core (multi-CPU) processor. The processor here may refer to one or more devices, circuits, and/or processing cores for processing data (eg, computer program instructions).
在具体实现中,作为一种实施例,装置200还可以包括输出设备205和输入设备206。输出设备205和处理器201耦合,可以以多种方式来显示信息。例如,输出设备205可以是液晶显示器(liquid crystal display,LCD),发光二级管(light emitting diode,LED)显示设备,阴极射线管(cathode ray tube,CRT)显示设备,或投影仪(projector)等。输入设备206和处理器201耦合,可以以多种方式接收用户的输入。例如,输入设备206可以是摄像头、鼠标、键盘、触摸屏设备或传感设备等。In a specific implementation, as an embodiment, the apparatus 200 may further include an output device 205 and an input device 206. The output device 205 and the processor 201 are coupled and can display information in various ways. For example, the output device 205 may be a liquid crystal display (LCD), a light emitting diode (LED) display device, a cathode ray tube (CRT) display device, or a projector. Wait. The input device 206 and the processor 201 are coupled and can receive user input in various ways. For example, the input device 206 may be a camera, a mouse, a keyboard, a touch screen device, or a sensing device.
上述的装置200可以是一个通用设备或者是一个专用设备。在具体实现中,图像处理设备200可以是摄像机、照相机、监控器、视频显示设备、台式机、便携式电脑、网络服 务器、掌上电脑(personal digital assistant,PDA)、移动手机、平板电脑、无线终端设备、嵌入式设备或有图2中类似结构的设备。本申请实施例不限定装置200的类型。The above apparatus 200 may be a general-purpose device or a dedicated device. In a specific implementation, the image processing device 200 may be a video camera, a camera, a monitor, a video display device, a desktop computer, a portable computer, a network server, a personal digital assistant (PDA), a mobile phone, a tablet computer, a wireless terminal device , Embedded devices or devices with a similar structure in Figure 2. The embodiment of the present application does not limit the type of the device 200.
为了下述各实施例的描述清楚简洁,首先给出相关概念或技术的简要介绍:In order to describe the following embodiments clearly and concisely, a brief introduction of related concepts or technologies is first given:
颜色空间:颜色通常用三个独立的属性来描述,三个独立变量综合作用,构成一个空间坐标,即颜色空间。颜色空间可以包括RGB(颜色)空间、YUV(颜色)空间、HSV(颜色)空间和HSL(颜色)空间等,不同颜色空间可以从不同的角度去衡量同一个对象的颜色。在不同的处理过程中,对颜色处理的侧重点不同,因此各种颜色空间可以相互转换以满足不同的处理要求。其中:Color space: Color is usually described by three independent attributes. Three independent variables work together to form a space coordinate, that is, color space. The color space can include RGB (color) space, YUV (color) space, HSV (color) space and HSL (color) space, etc. Different color spaces can measure the color of the same object from different angles. In different processing processes, the emphasis on color processing is different, so various color spaces can be converted to meet different processing requirements. among them:
RGB空间:R代表红色分量(红色通道),G代表绿色分量(绿色通道),B代表蓝色分量(蓝色通道)。通过对红、绿、蓝三个颜色通道的变化以及它们相互之间的叠加来得到各种颜色。各分量中,数值越小,亮度越低,数值越大,亮度越高。当各分量相混时,混合后的亮度却等于各分量的亮度总和。RGB space: R represents the red component (red channel), G represents the green component (green channel), and B represents the blue component (blue channel). Various colors are obtained by changing the three color channels of red, green and blue and superimposing them. In each component, the smaller the value, the lower the brightness, and the larger the value, the higher the brightness. When the components are mixed, the brightness after mixing is equal to the sum of the brightness of the components.
YUV空间:Y表示明亮度,也就是灰阶值。U和V表示色度,用于描述影像色彩及饱和度,可以指定像素的颜色。如果只有Y信号分量而没有U、V分量,那么这样表示的图像就是黑白灰度图像。YUV空间主要用于优化彩色视频信号的传输,使其向后相容老式黑白电视。YUV space: Y represents brightness, that is, gray scale value. U and V represent chroma, used to describe the image color and saturation, you can specify the color of the pixel. If there are only Y signal components and no U, V components, then the image represented in this way is a black and white grayscale image. YUV space is mainly used to optimize the transmission of color video signals, making it backward compatible with old-fashioned black and white TVs.
HSV空间:HSV是一种将RGB色彩空间中的点在倒圆锥体中的表示方法。其中,H表示色彩信息,即所处的光谱颜色的位置,可以用角度度量,取值范围为0°~360°。红色为0°,绿色为120°,蓝色为240°。S表示成所选颜色的饱和度和该颜色最大的饱和度之间的比率,范围从0到1。当S=0时,只有灰度。V表示色彩的明亮程度,范围从0到1。HSV space: HSV is a method of representing points in the RGB color space in an inverted cone. Among them, H represents color information, that is, the position of the spectral color, which can be measured by angle, and the value range is 0° to 360°. Red is 0°, green is 120°, and blue is 240°. S is expressed as the ratio between the saturation of the selected color and the maximum saturation of the color, ranging from 0 to 1. When S=0, there is only grayscale. V represents the brightness of the color, ranging from 0 to 1.
HSL空间:HSL类似于HSV,该模型中前两个参数和HSV一样。L表示色彩的亮度,可以用于控制色彩的明暗变化。L的取值范围为0%至100%,数值越小,色彩越暗,越接近于黑色;数值越大,色彩越亮,越接近于白色。HSL space: HSL is similar to HSV, and the first two parameters in this model are the same as HSV. L represents the brightness of the color, and can be used to control the change of the light and dark of the color. The value of L ranges from 0% to 100%. The smaller the value, the darker the color and the closer to black; the larger the value, the brighter the color and the closer to white.
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行描述。其中,在本申请的描述中,除非另有说明,“至少一个”是指一个或多个,“多个”是指两个或多于两个。另外,为了便于清楚描述本申请实施例的技术方案,在本申请的实施例中,采用了“第一”、“第二”等字样对功能和作用基本相同的相同项或相似项进行区分。本领域技术人员可以理解“第一”、“第二”等字样并不对数量和执行次序进行限定,并且“第一”、“第二”等字样也并不限定一定不同。The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application. In the description of the present application, unless otherwise stated, “at least one” refers to one or more, and “plurality” refers to two or more than two. In addition, in order to facilitate a clear description of the technical solutions of the embodiments of the present application, in the embodiments of the present application, the words "first" and "second" are used to distinguish the same or similar items that have substantially the same functions and functions. Those skilled in the art may understand that the words "first" and "second" do not limit the number and execution order, and the words "first" and "second" do not necessarily mean different.
为了便于理解,以下结合附图对本申请实施例提供的对图像进行颜色还原的方法进行具体介绍。For ease of understanding, the method for color restoration of an image provided by embodiments of the present application will be specifically described below with reference to the drawings.
如图3所示,本申请实施例提供一种对图像进行颜色还原的方法,包括:As shown in FIG. 3, an embodiment of the present application provides a method for color restoration of an image, including:
301、获取待处理的第一图像,第一图像包括过曝的第一目标对象。301: Acquire a first image to be processed, the first image including an overexposed first target object.
其中,第一目标对象是指第一图像中过曝的一个或多个物体(或物体所在的区域)。其中,物体例如可以是(各种不同形状不同颜色的)交通指示灯、车辆、交通指示牌等等。The first target object refers to one or more objects (or areas where the objects are located) that are overexposed in the first image. Among them, the object may be, for example, traffic lights (of various shapes and colors), vehicles, traffic signs, and so on.
在一种可能的设计中,可以将用户在第二图像上框选的第二区域作为待处理的第一图像。示例性的,如图4所示,当用户认为某一图像(第二图像)中的交通信号灯(第一目标对象)过曝,用户可以通过图像处理设备的输入设备(例如,鼠标或触摸屏)对第二图像进行第一操作,第一操作用于将该过曝的交通信号灯所在的区域(第二区域)框选出来。 图像处理设备识别到用户对第二图像的第一操作后,可以根据用户框选的第二区域的坐标信息从第二图像剪切第二区域,得到第三图像和待处理的第一图像。其中,待处理的第一图像包括第二区域,第三图像包括除第二区域的其他区域。也就是说,待处理的第一图像包括用户在第二图像上选择的第二区域。In a possible design, the second area selected by the user on the second image may be used as the first image to be processed. Exemplarily, as shown in FIG. 4, when the user thinks that the traffic signal (first target object) in an image (second image) is overexposed, the user can use the input device (for example, mouse or touch screen) of the image processing device Perform the first operation on the second image. The first operation is used to frame the area (second area) where the overexposed traffic signal light is located. After recognizing the first operation of the second image by the user, the image processing device may cut the second area from the second image according to the coordinate information of the second area selected by the user to obtain the third image and the first image to be processed. The first image to be processed includes a second area, and the third image includes other areas than the second area. That is, the first image to be processed includes the second area selected by the user on the second image.
这样一来,相比直接对第二图像进行处理,从第二图像中选择出第一图像并仅对第一图像进行处理,一方面可以减小后续步骤中的运算量,另一方面可以提高第一目标对象(例如,交通信号灯)所在区域的识别精准度。In this way, compared to processing the second image directly, selecting the first image from the second image and processing only the first image, on the one hand, it can reduce the amount of calculation in the subsequent steps, on the other hand, it can improve The recognition accuracy of the area where the first target object (for example, a traffic signal) is located.
302、可选的,对第一图像的像素的饱和度分量和明度分量进行滤波处理。302. Optionally, perform filtering processing on the saturation component and the lightness component of the pixels of the first image.
需要说明的是,若第二图像为HSV格式的图像,即第二图像处于HSV空间,那么待处理的第一图像也处于HSV空间,可以直接对第一图像的像素的饱和度分量和明度分量进行滤波处理,以便在后续步骤中更稳定和准确地识别出过曝的第一对象(例如,过曝的交通信号灯)的轮廓。It should be noted that if the second image is an HSV format image, that is, the second image is in the HSV space, then the first image to be processed is also in the HSV space, and the saturation component and the lightness component of the pixels of the first image can be directly The filtering process is performed in order to more stably and accurately identify the outline of the overexposed first object (for example, the overexposed traffic signal light) in the subsequent steps.
若第二图像处于第一空间,第一空间可以为YUV空间或者RGB空间或HSL空间,那么待处理的第一图像也处于第一空间。此时,为了得到第一图像的像素的饱和度分量和明度分量,需要将第一图像从第一空间转换到HSV空间。而后,再对第一图像的像素的饱和度分量和明度分量进行滤波处理,以便在后续步骤中更稳定和准确地识别出过曝的第一对象的轮廓。If the second image is in the first space, and the first space may be YUV space or RGB space or HSL space, then the first image to be processed is also in the first space. At this time, in order to obtain the saturation component and the lightness component of the pixels of the first image, the first image needs to be converted from the first space to the HSV space. Then, the saturation component and the lightness component of the pixels of the first image are filtered, so as to identify the outline of the overexposed first object more stably and accurately in the subsequent steps.
303、根据第一图像的像素的饱和度和明度确定第一图像的第一区域。303. Determine the first area of the first image according to the saturation and lightness of the pixels of the first image.
本申请实施例中,第一区域对应第一目标对象(所在)的区域。可以根据第一图像的像素的饱和度和明度确定第一图像中过曝的第一目标对象(例如,过曝的交通信号灯)所在的区域。In the embodiment of the present application, the first area corresponds to the area of the first target object (where). The area where the overexposed first target object (eg, overexposed traffic signal light) in the first image is located may be determined according to the saturation and lightness of the pixels of the first image.
在一种可能的设计中,可以对滤波处理后的第一图像的像素的饱和度分量和明度分量进行分析,确定饱和度分量比第一图像的像素的饱和度的平均值低、明度分量比第一图像的像素的明度的平均值高的区域为第一目标对象所在的区域。即第一区域的像素的饱和度低于第一图像的像素的饱和度的平均值,且第一区域的像素的明度高于第一图像的像素的明度的平均值。如图5所示,为一种第一区域的示意图。In a possible design, the saturation component and the lightness component of the pixel of the first image after the filtering process may be analyzed to determine that the saturation component is lower than the average value of the saturation of the pixel of the first image, and the brightness component ratio The area where the average value of the brightness of the pixels of the first image is high is the area where the first target object is located. That is, the saturation of the pixels in the first area is lower than the average of the saturation of the pixels in the first image, and the brightness of the pixels in the first area is higher than the average of the brightness of the pixels in the first image. As shown in FIG. 5, it is a schematic diagram of a first area.
304、对第一区域进行二值化处理,得到第一区域对应的二值图像。304. Perform binarization processing on the first area to obtain a binary image corresponding to the first area.
示例性的,如图6所示,对图5所示的第一区域进行二值化处理后,可以得到第一区域对应的二值图像。第一区域对应的二值图像中可以包括三个连通区域(分别为a、b和c)。连通区域a是信号灯所在的区域,连通区域b和c可以是信号灯产生的光晕所在的区域。Exemplarily, as shown in FIG. 6, after performing binarization processing on the first area shown in FIG. 5, a binary image corresponding to the first area may be obtained. The binary image corresponding to the first area may include three connected areas (a, b, and c, respectively). The connected area a is the area where the signal lamp is located, and the connected areas b and c may be the area where the halo generated by the signal lamp is located.
305、确定二值图像中面积大于或等于第一阈值的至少一个连通区域。305. Determine at least one connected region whose area in the binary image is greater than or equal to the first threshold.
在一种可能的设计中,上述二值图像中面积大于或等于第一阈值的至少一个连通区域的轮廓对应第一目标对象的轮廓。可以将上述二值图像中面积大于或等于第一阈值的至少一个连通区域的轮廓作为第一目标对象的轮廓。需要说明的是,上述面积大于或等于第一阈值的至少一个连通区域的轮廓可能比实际的(真实的)第一目标对象的轮廓大一些或小一些。例如,当第一目标对象是信号灯时,由于(亮着的)信号灯会产生光晕,可能导致上述至少一个连通区域不仅包括信号灯本身所在的区域,还包括信号灯产生的光晕所在的区域,因此上述面积大于或等于第一阈值的至少一个连通区域的轮廓可以比实际的信号灯的轮廓大一些。又例如,若信号灯的一部分损坏无法发光,上述至少一个连通区域可能仅 包括信号灯发光的部分所在的区域,此时,上述至少一个连通区域的轮廓比实际的信号灯的轮廓小一些。In a possible design, the contour of the at least one connected region whose area is greater than or equal to the first threshold in the binary image corresponds to the contour of the first target object. The contour of the at least one connected region with an area greater than or equal to the first threshold in the binary image may be used as the contour of the first target object. It should be noted that the outline of the at least one connected area whose area is greater than or equal to the first threshold may be larger or smaller than the outline of the actual (real) first target object. For example, when the first target object is a signal light, since the (lit) signal light generates halos, the at least one connected area may include not only the area where the signal light is, but also the area where the halo generated by the signal light is located, so The outline of the at least one connected area whose area is greater than or equal to the first threshold may be larger than the outline of the actual signal lamp. For another example, if a part of the signal lamp is damaged and cannot emit light, the at least one connected region may only include the region where the part where the signal lamp emits light. In this case, the outline of the at least one connected region is smaller than the actual signal lamp.
其中,第一阈值可以是根据该二值图像中面积最大的连通区域的面积确定的。例如,第一阈值可以等于该二值图像中面积最大的连通区域的面积,或者,第一阈值可以为该二值图像中面积最大的连通区域的面积的N%(例如,30%),N为正数。The first threshold may be determined according to the area of the connected area with the largest area in the binary image. For example, the first threshold may be equal to the area of the connected area with the largest area in the binary image, or the first threshold may be N% (eg, 30%) of the area of the connected area with the largest area in the binary image, N Is a positive number.
第一区域对应的二值图像中存在许多面积大小不等的连通区域。例如,如图6所示,第一区域对应的二值图像中可以包括三个连通区域(分别为a、b和c)。基于该二值图像,查找该二值图像其中所有的连通区域。根据面积的大小对查找到的全部连通区域进行排序(例如将全部连通区域进行面积由大到小的顺序排列)。在这些大小不同的连通区域中,可以过滤掉面积较小的连通区域,保留面积较大的连通区域,将面积较大的至少一个连通区域作为第一目标对象(例如信号灯)的区域(例如,可以将面积最大的一个连通区域作为信号灯的所在的区域,或者,可以将面积较大的多个连通区域作为信号灯的所在的区域)。In the binary image corresponding to the first area, there are many connected areas with different areas. For example, as shown in FIG. 6, the binary image corresponding to the first area may include three connected areas (a, b, and c, respectively). Based on the binary image, find all connected regions in the binary image. Sort all the connected regions found according to the size of the area (for example, arrange all connected regions in order from large to small). Among these connected areas with different sizes, it is possible to filter out the connected areas with a smaller area, retain the connected areas with a larger area, and use at least one connected area with a larger area as the area of the first target object (such as a signal light) (for example, One connected area with the largest area may be used as the area where the signal lamp is located, or multiple connected areas with a larger area may be used as the area where the signal lamp is located).
举例来说,可以先筛选出二值图像中面积最大的连通区域,假设其面积为max,可以设置第一阈值为max/(x+2),以过滤掉面积小于max/(x+2)的连通区域。例如,如图7所示,可以过滤掉连通区域(b和c),保留连通区域a。连通区域a的轮廓对应第一目标对象的轮廓。For example, you can first filter out the connected area with the largest area in the binary image. Assuming its area is max, you can set the first threshold to max/(x+2) to filter out the area less than max/(x+2) Connected area. For example, as shown in FIG. 7, the connected regions (b and c) can be filtered out, and the connected region a is retained. The outline of the connected area a corresponds to the outline of the first target object.
其中,参数x的取值范围可以为0-9,参数x可以用于调整第一阈值的大小。x的取值越大,过滤掉的面积较小的连通区域越少,即保留下来的面积较小的连通区域越多,从而第一目标对象的轮廓对应越多的连通区域的轮廓。举例来说,若第一目标对象为信号灯,则信号灯所在的区域越向外扩散(即信号灯所在的区域不仅包括信号灯,还可以包括信号灯产生的光晕)。x的取值越小,过滤掉的面积较小的连通区域越多,即保留下来的面积较小的连通区域越少,从而第一目标对象的轮廓对应越少的连通区域的轮廓。举例来说,若第一目标对象为信号灯,则信号灯所在的区域越向内收缩(即信号灯所在的区域仅包括信号灯,不包括信号灯产生的光晕)。The value range of the parameter x may be 0-9, and the parameter x may be used to adjust the size of the first threshold. The larger the value of x, the less the connected areas with a smaller area are filtered out, that is, the more connected areas with a smaller area are retained, so that the outline of the first target object corresponds to the outline of more connected areas. For example, if the first target object is a signal lamp, the area where the signal lamp is located spreads outward (that is, the area where the signal lamp is located includes not only the signal lamp but also the halo generated by the signal lamp). The smaller the value of x, the more connected areas with a smaller area are filtered out, that is, the fewer connected areas with a smaller area are retained, so that the outline of the first target object corresponds to the outline of the fewer connected areas. For example, if the first target object is a signal lamp, the area where the signal lamp is located shrinks inward (that is, the area where the signal lamp is located includes only the signal lamp, not the halo generated by the signal lamp).
再例如,若待处理的第一图像包括箭头形状的指示灯,图像处理设备确定该第一图像的第一区域如图8中的(a)所示,对该第一区域进行二值化处理后,如图8中的(b)所示,第一区域对应的二值图像中可以包括四个连通区域(分别为d、e、f和g),如图8中的(c)所示,该二值图像中面积大于或等于第一阈值的至少一个连通区域可以为连通区域d和e。即过滤掉连通区域(f和g),保留连通区域d和e。可以将连通区域d和e的轮廓作为第一目标对象的轮廓。For another example, if the first image to be processed includes an indicator light in the shape of an arrow, the image processing device determines that the first area of the first image is as shown in (a) in FIG. 8, and performs binarization processing on the first area After that, as shown in (b) of FIG. 8, the binary image corresponding to the first area may include four connected areas (respectively d, e, f, and g), as shown in (c) of FIG. 8 In this binary image, at least one connected region with an area greater than or equal to the first threshold may be connected regions d and e. That is, the connected regions (f and g) are filtered out, and the connected regions d and e are retained. The outline of the connected regions d and e can be used as the outline of the first target object.
306、还原至少一个连通区域的颜色。306. Restore the color of at least one connected area.
在本申请实施例中,还原至少一个连通区域的颜色也可以认为是修正至少一个连通区域的颜色。还原或修正至少一个连通区域的颜色即还原或修正过曝的第一目标对象的颜色。例如,如图7所示,还原或修正连通区域a的颜色即还原或修正过曝的第一目标对象的颜色。In the embodiment of the present application, restoring the color of at least one connected region may also be regarded as correcting the color of at least one connected region. Restoring or correcting the color of at least one connected area means restoring or correcting the color of the overexposed first target object. For example, as shown in FIG. 7, restoring or correcting the color of the connected area a is restoring or correcting the color of the overexposed first target object.
示例性的,当第一目标对象为交通信号灯时,可以先基于信号灯上外接的信号灯检测器或基于图像识别状态灯获取交通信号灯的颜色信息。Exemplarily, when the first target object is a traffic signal light, the color information of the traffic signal light may be acquired based on a signal light detector externally connected to the signal light or based on an image recognition status light.
在一种可能的设计中,可以在HSV空间还原至少一个连通区域的颜色。具体的,当(确定)交通信号灯为红色时,将至少一个连通区域的像素的色调调整至红色范围,并将至少一个连通区域的像素的饱和度和明度分别进行提升和降低;当(确定)交通信号灯为黄色 时,将至少一个连通区域的像素的色调调整至黄色范围,并将至少一个连通区域的像素的饱和度和明度分别进行提升和降低;当(确定)交通信号灯为绿色时,将至少一个连通区域的像素的色调调整至绿色范围,并将至少一个连通区域的像素的饱和度和明度分别进行提升和降低。In a possible design, the color of at least one connected area can be restored in the HSV space. Specifically, when (determine) the traffic signal is red, adjust the hue of the pixels of at least one connected area to the red range, and increase and decrease the saturation and brightness of the pixels of at least one connected area; when (OK) When the traffic signal is yellow, adjust the hue of the pixels of at least one connected area to the yellow range, and increase and decrease the saturation and brightness of the pixels of at least one connected area; when (OK) the traffic signal is green, change The hue of the pixels of at least one connected area is adjusted to the green range, and the saturation and lightness of the pixels of at least one connected area are increased and decreased, respectively.
在本申请实施例中,将至少一个连通区域的像素的饱和度和明度分别进行提升和降低可以是将至少一个连通区域的像素的饱和度和明度分别进行线性提升和线性降低,或者可以是将至少一个连通区域的像素的饱和度和明度分别进行非线性提升和非线性降低。对饱和度进行线性提升可以对至少一个连通区域中的像素中的每个像素的饱和度提升相同的量(值);对饱和度进行非线性提升可以对至少一个连通区域中的像素中的不同像素的饱和度提升不同的量(值)。对明度进行线性降低可以对至少一个连通区域中的像素中的每个像素的明度降低相同的量(值);对明度进行非线性降低可以对至少一个连通区域中的像素中的不同像素的明度降低不同的量(值)。需要说明的是,将至少一个连通区域的像素的饱和度和明度分别进行提升和降低之后,至少一个连通区域的饱和度和明度会存在强相关关系。而将至少一个连通区域的像素的饱和度和明度分别进行提升和降低之前,至少一个连通区域的饱和度和明度不存在强相关关系。In the embodiment of the present application, increasing and reducing the saturation and lightness of the pixels of at least one connected area may be linearly increasing and decreasing the saturation and lightness of the pixels of at least one connected area, respectively, or may be The saturation and lightness of the pixels of at least one connected area are nonlinearly improved and nonlinearly reduced, respectively. Linearly increasing the saturation can increase the saturation of each pixel in the pixels in at least one connected area by the same amount (value); non-linearly increasing the saturation can change the difference in the pixels in at least one connected area The saturation of the pixels is increased by different amounts (values). Linearly reducing the brightness can reduce the brightness of each pixel in at least one connected region by the same amount (value); non-linearly reducing the brightness can reduce the brightness of different pixels in the pixels in at least one connected region Reduce different amounts (values). It should be noted that, after the saturation and lightness of pixels in at least one connected area are respectively increased and decreased, there is a strong correlation between the saturation and lightness of at least one connected area. Before the saturation and lightness of pixels in at least one connected area are increased and decreased respectively, there is no strong correlation between the saturation and lightness of at least one connected area.
在另一种可能的设计中,可以在RGB空间还原至少一个连通区域的颜色。具体的,当(确定)交通信号灯为红色时,可以将所述至少一个连通区域的像素的红色分量调整至第一预设范围,降低至少一个连通区域的像素的蓝色和绿色分量。In another possible design, the color of at least one connected area can be restored in RGB space. Specifically, when (determining) the traffic signal light is red, the red component of the pixel of the at least one connected area may be adjusted to the first preset range, and the blue and green components of the pixel of the at least one connected area may be reduced.
举例来说,假设对8位编码的RGB图像进行颜色还原,若其中一点像素的红色分量(R值)为Rx,则可以将该点像素的R值调整为R=(200+55*x/9+Rx)/2(第一预设范围)。其中,参数x的取值范围可以为0-9,参数x可以用于调整R值的大小。For example, assuming color restoration of an 8-bit encoded RGB image, if the red component (R value) of a pixel is Rx, the R value of the pixel can be adjusted to R=(200+55*x/ 9+Rx)/2 (the first preset range). The value range of the parameter x can be 0-9, and the parameter x can be used to adjust the size of the R value.
其中,降低至少一个连通区域的像素的蓝色和绿色分量可以是对至少一个连通区域的像素的蓝色和绿色分量做线性降低或非线性降低。线性降低可以对至少一个连通区域中的像素中的每个像素的蓝色和绿色分量降低相同的量(值);非线性降低可以对至少一个连通区域中的像素中的不同像素的蓝色和绿色分量降低不同的量(值)。Wherein, reducing the blue and green components of the pixels of at least one connected region may be a linear or non-linear reduction of the blue and green components of the pixels of at least one connected region. Linear reduction can reduce the blue and green components of each pixel in at least one connected region by the same amount (value); non-linear reduction can reduce the blue sum of different pixels in the pixels in at least one connected region The green component decreases by a different amount (value).
当(确定)交通信号灯为黄色时,提高至少一个连通区域的像素的红色和绿色分量,降低至少一个连通区域的像素的蓝色分量;当(确定)交通信号灯为绿色时,提高至少一个连通区域的像素的绿色分量,降低至少一个连通区域的像素的红色和蓝色分量。具体过程可以参考上文对于交通信号灯为红色时的相关处理过程,在此不做赘述。When (determine) the traffic signal is yellow, increase the red and green components of the pixels of at least one connected area, and reduce the blue component of the pixels of at least one connected area; when (determined) the traffic signal is green, increase at least one connected area The green component of the pixel reduces the red and blue components of the pixel in at least one connected area. For the specific process, reference may be made to the above related processing process when the traffic signal light is red, and details are not described here.
307、将第一图像和第三图像合并。307: Combine the first image and the third image.
若在步骤302将第一图像从第一空间转换到了HSV空间,则可以将颜色还原后的第一图像从HSV空间重新转换到第一空间,以便将第一图像和第三图像(即从第二图像剪切掉第一图像后的剩余部分)合并起来得到完整的图像(可以认为该完整的图像是经过颜色还原后的第二图像)。若在步骤302未执行将第一图像从第一空间转换到了HSV空间的操作,可以直接将还原颜色后的第一图像和第三图像合并得到完整的图像。If the first image is converted from the first space to the HSV space in step 302, the color-reduced first image can be re-converted from the HSV space to the first space, so that the first image and the third image (i.e. The two images cut out the remaining part of the first image) and merge to obtain a complete image (it can be considered that the complete image is the second image after color restoration). If the operation of converting the first image from the first space to the HSV space is not performed in step 302, the first image and the third image after color restoration can be directly merged to obtain a complete image.
在一种可能的设计中,在对视频中过曝的第一目标对象进行颜色还原的过程中,用户可以在视频开始前或暂停时选择过曝对象,在后续视频的播放过程中,可以采用本申请实施例的方法对该视频的每一帧图像进行相应的处理,从而还原整个视频中过曝的第一目标对象的颜色。In a possible design, during the color restoration of the first target object that is overexposed in the video, the user can select the overexposed object before the video starts or when it is paused. In the subsequent video playback process, the user can use The method of the embodiment of the present application performs corresponding processing on each frame image of the video, thereby restoring the color of the over-exposed first target object in the entire video.
基于本申请实施例提供的方法,获取待处理的第一图像后,可以根据第一图像的像素的饱和度和明度确定第一图像的第一区域(可以将第一区域作为过曝的第一目标对象所在的区域)而后,对第一区域进行二值化处理,得到第一区域对应的二值图像;再确定二值图像中面积大于或等于第一阈值的至少一个连通区域(可以将该至少一个连通区域的轮廓作为第一目标对象的轮廓),然后,还原该至少一个连通区域的颜色(即还原了过曝的第一目标对象的颜色)。可见,本申请实施例提供的方法能够对图像中过曝的物体(例如,交通信号灯)进行准确的色彩还原。进而,可以解决由于图像中的物体过曝导致的一系列问题(例如,当前电警监控场景下信号灯过曝造成的取证困难问题)。Based on the method provided in the embodiments of the present application, after acquiring the first image to be processed, the first area of the first image may be determined according to the saturation and lightness of the pixels of the first image (the first area may be used as the overexposed first The area where the target object is located), and then binarize the first area to obtain the binary image corresponding to the first area; then determine at least one connected area in the binary image whose area is greater than or equal to the first threshold (you can use The outline of at least one connected area is taken as the outline of the first target object), and then, the color of the at least one connected area is restored (that is, the color of the over-exposed first target object is restored). It can be seen that the method provided by the embodiments of the present application can accurately reproduce color of overexposed objects (for example, traffic lights) in the image. Furthermore, it can solve a series of problems caused by overexposure of objects in the image (for example, the problem of difficulty in obtaining evidence caused by overexposure of signal lights in the current electric police monitoring scene).
现有技术中,可以采用超宽动态范围的摄像机消除强光造成的信号灯色彩失真,而超宽动态摄像机价格昂贵,且对低照度下过曝信号灯的色彩还原效果有限。本申请实施例提供的方法不需要增添额外的设备,价格低廉,且能达到颜色还原的效果,并且环境适应性高,能够进行低照度下过曝信号灯的色彩还原。现有技术中,也可以基于图像的RGB空间进行信号灯的色彩还原,或者可以基于深度学习的方法对图像中的信号灯进行区域识别并进行颜色增强,但可能导致色彩还原后的信号灯区域与周围图像不连续的梯度现象。本申请实施例提供的方法是基于HSV空间进行的,更好的反映出实体信号灯的亮度信息,从而对信号灯区域识别更稳定且准确,且色彩还原后的信号灯区域与周围图像更连续,肉眼效果更逼真。另外,本申请实施例提供的方法高效可靠,可以满足视频中信号灯色彩还原效果。In the prior art, an ultra-wide dynamic range camera can be used to eliminate the color distortion of the signal light caused by strong light, and the ultra-wide dynamic camera is expensive and has a limited color reproduction effect on the over-exposed signal light under low illumination. The method provided by the embodiment of the present application does not require additional equipment, is inexpensive, and can achieve the effect of color reproduction, and has high environmental adaptability, and can perform color reproduction of over-exposed signal lights under low illumination. In the prior art, the color of the signal lights can be restored based on the RGB space of the image, or the area of the signal lights in the image can be identified and color enhanced based on the method of deep learning, but it may cause the color signal area and the surrounding image to be restored Discontinuous gradient phenomenon. The method provided in the embodiment of the present application is based on the HSV space, and better reflects the brightness information of the physical signal lamp, so that the identification of the signal lamp area is more stable and accurate, and the signal lamp area after color restoration is more continuous with the surrounding image, and the naked eye effect More realistic. In addition, the method provided by the embodiments of the present application is efficient and reliable, and can satisfy the color reproduction effect of the signal light in the video.
上述主要从图像处理设备的角度对本申请实施例提供的方案进行了介绍。可以理解的是,图像处理设备为了实现上述功能,其包括了执行各个功能相应的硬件结构和/或软件模块。本领域技术人员应该很容易意识到,结合本文中所公开的实施例描述的算法步骤,本申请能够以硬件或硬件和软件的结合形式来实现。某个功能究竟以硬件还是软件驱动硬件的方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。The above mainly introduces the solutions provided by the embodiments of the present application from the perspective of the image processing device. It can be understood that, in order to realize the above-mentioned functions, the image processing device includes a hardware structure and/or a software module corresponding to each function. Those skilled in the art should easily realize that, in conjunction with the algorithm steps described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and software. Whether a function is executed by hardware or software driven hardware depends on the specific application of the technical solution and design constraints. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
本申请实施例可以根据上述方法示例对图像处理设备进行功能模块的划分,例如,可以对应各个功能划分各个功能模块,也可以将两个或两个以上的功能集成在一个处理模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。需要说明的是,本申请实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。In the embodiments of the present application, the image processing device may be divided into function modules according to the above method examples. For example, each function module may be divided corresponding to each function, or two or more functions may be integrated into one processing module. The above integrated modules may be implemented in the form of hardware or software function modules. It should be noted that the division of the modules in the embodiments of the present application is schematic, and is only a division of logical functions. In actual implementation, there may be another division manner.
在采用对应各个功能划分各个功能模块的情况下,图9示出了上述实施例中所涉及的图像处理设备9的一种可能的结构示意图,图像处理设备包括:获取单元901、确定单元902和处理单元903。获取单元901用于支持图像处理设备执行图3中的过程301。确定单元902用于支持图像处理设备执行图3中的过程303和305。处理单元903用于支持图像处理设备执行图3中的过302、304和306。其中,上述方法实施例涉及的各步骤的所有相关内容均可以援引到对应功能模块的功能描述,在此不再赘述。In the case where each functional module is divided corresponding to each function, FIG. 9 shows a possible structural schematic diagram of the image processing device 9 involved in the above embodiment. The image processing device includes: an acquisition unit 901, a determination unit 902, and Processing unit 903. The acquiring unit 901 is used to support the image processing device to perform the process 301 in FIG. 3. The determination unit 902 is used to support the image processing device to perform the processes 303 and 305 in FIG. 3. The processing unit 903 is used to support the image processing device to perform steps 302, 304, and 306 in FIG. Wherein, all relevant content of each step involved in the above method embodiments can be referred to the function description of the corresponding function module, which will not be repeated here.
结合本申请公开内容所描述的方法或者算法的步骤可以硬件的方式来实现,也可以是由处理器执行软件指令的方式来实现。软件指令可以由相应的软件模块组成,软件模块可以被存放于RAM、闪存、ROM、EPROM、EEPROM、寄存器、硬盘、移动硬盘、只读光盘或者本领域熟知的任何其它形式的存储介质中。一种示例性的存储介质耦合至处理器, 从而使处理器能够从该存储介质读取信息,且可向该存储介质写入信息。当然,存储介质也可以是处理器的组成部分。处理器和存储介质可以位于专用集成电路(application specific integrated circuit,ASIC)中。另外,该ASIC可以位于核心网接口设备中。当然,处理器和存储介质也可以作为分立组件存在于核心网接口设备中。The steps of the method or algorithm described in conjunction with the disclosure of the present application may be implemented by hardware, or by a processor executing software instructions. The software instructions may be composed of corresponding software modules, which may be stored in RAM, flash memory, ROM, EPROM, EEPROM, registers, hard disk, mobile hard disk, read-only optical disk, or any other form of storage medium well known in the art. An exemplary storage medium is coupled to the processor, so that the processor can read information from the storage medium and can write information to the storage medium. Of course, the storage medium may also be a component of the processor. The processor and the storage medium may be located in an application specific integrated circuit (application specific integrated circuit, ASIC). In addition, the ASIC may be located in the core network interface device. Of course, the processor and the storage medium may also exist as discrete components in the core network interface device.
本领域技术人员应该可以意识到,在上述一个或多个示例中,本申请所描述的功能可以用硬件、软件、固件或它们的任意组合来实现。当使用软件实现时,可以将这些功能存储在图像处理设备可读介质中或者作为图像处理设备可读介质上的一个或多个指令或代码进行传输。图像处理设备可读介质包括图像处理设备存储介质和通信介质,其中通信介质包括便于从一个地方向另一个地方传送图像处理设备程序的任何介质。存储介质可以是通用或专用图像处理设备能够存取的任何可用介质。Those skilled in the art should realize that in one or more of the above examples, the functions described in this application may be implemented by hardware, software, firmware, or any combination thereof. When implemented using software, these functions may be stored in the image processing device readable medium or transmitted as one or more instructions or codes on the image processing device readable medium. The image processing device readable medium includes an image processing device storage medium and a communication medium, where the communication medium includes any medium that facilitates transferring the image processing device program from one place to another place. The storage medium may be any available medium that can be accessed by a general-purpose or special-purpose image processing device.
以上所述的具体实施方式,对本申请的目的、技术方案和有益效果进行了进一步详细说明,所应理解的是,以上所述仅为本申请的具体实施方式而已,并不用于限定本申请的保护范围,凡在本申请的技术方案的基础之上,所做的任何修改、等同替换、改进等,均应包括在本申请的保护范围之内。The specific embodiments described above further describe the purpose, technical solutions, and beneficial effects of this application in detail. It should be understood that the above descriptions are only specific implementations of this application, and are not intended to limit the scope of this application. The scope of protection, any modifications, equivalent replacements, improvements, etc. made on the basis of the technical solutions of this application, shall be included in the scope of protection of this application.

Claims (12)

  1. 一种对图像进行颜色还原的方法,其特征在于,包括:A method for color restoration of an image, characterized in that it includes:
    获取待处理的第一图像,所述第一图像包括过曝的第一目标对象;Acquiring a first image to be processed, the first image including an overexposed first target object;
    根据所述第一图像的像素的饱和度和明度确定所述第一图像的第一区域,所述第一区域的像素的饱和度低于所述第一图像的像素的饱和度的平均值,且所述第一区域的像素的明度高于所述第一图像的像素的明度的平均值;所述第一区域对应所述第一目标对象的区域;Determining the first area of the first image according to the saturation and lightness of the pixels of the first image, the saturation of the pixels of the first area is lower than the average value of the saturation of the pixels of the first image, And the brightness of the pixels of the first area is higher than the average value of the brightness of the pixels of the first image; the first area corresponds to the area of the first target object;
    对所述第一区域进行二值化处理,得到所述第一区域对应的二值图像;Performing binary processing on the first area to obtain a binary image corresponding to the first area;
    确定所述二值图像中面积大于或等于第一阈值的至少一个连通区域;所述至少一个连通区域的轮廓对应所述第一目标对象的轮廓;Determining at least one connected region in the binary image whose area is greater than or equal to a first threshold; the contour of the at least one connected region corresponds to the contour of the first target object;
    还原所述至少一个连通区域的颜色。The color of the at least one connected area is restored.
  2. 根据权利要求1所述的对图像进行颜色还原的方法,其特征在于,所述根据所述第一图像的饱和度和明度确定所述第一图像的第一区域之前,所述方法还包括:The method for color restoring an image according to claim 1, wherein before determining the first area of the first image according to the saturation and lightness of the first image, the method further comprises:
    将所述第一图像从第一空间转换到色调饱和度明度HSV空间,所述第一空间为亮度色度YUV空间、红绿蓝RGB空间或色调饱和度亮度HSL空间中的任一种。Converting the first image from a first space to a hue saturation lightness HSV space, the first space is any one of a luma hue YUV space, a red-green-blue RGB space, or a hue saturation lightness HSL space.
  3. 根据权利要求1或2所述的对图像进行颜色还原的方法,其特征在于,当所述第一目标对象为交通信号灯时,所述还原所述至少一个连通区域的颜色包括:The method for color restoring an image according to claim 1 or 2, wherein when the first target object is a traffic signal light, the restoring the color of the at least one connected area includes:
    获取所述交通信号灯的颜色信息;Acquiring color information of the traffic signal light;
    当所述交通信号灯为红色时,将所述至少一个连通区域的像素的色调调整至红色范围,并将所述至少一个连通区域的像素的饱和度和明度分别进行提升和降低;When the traffic signal light is red, adjust the hue of the pixels of the at least one connected area to the red range, and respectively increase and decrease the saturation and brightness of the pixels of the at least one connected area;
    当所述交通信号灯为黄色时,将所述至少一个连通区域的像素的色调调整至黄色范围,并将所述至少一个连通区域的像素的饱和度和明度分别进行提升和降低;When the traffic signal light is yellow, adjust the hue of the pixels of the at least one connected area to a yellow range, and increase and decrease the saturation and brightness of the pixels of the at least one connected area, respectively;
    当所述交通信号灯为绿色时,将所述至少一个连通区域的像素的色调调整至绿色范围,并将所述至少一个连通区域的像素的饱和度和明度分别进行提升和降低。When the traffic light is green, adjust the hue of the pixels of the at least one connected area to the green range, and increase and decrease the saturation and brightness of the pixels of the at least one connected area, respectively.
  4. 根据权利要求1或2所述的对图像进行颜色还原的方法,其特征在于,当所述第一目标对象为交通信号灯时,所述还原所述至少一个连通区域的颜色包括:The method for color restoring an image according to claim 1 or 2, wherein when the first target object is a traffic signal light, the restoring the color of the at least one connected area includes:
    将所述至少一个连通区域转换到RGB空间;Convert the at least one connected region to RGB space;
    获取所述交通信号灯的颜色信息;Acquiring color information of the traffic signal light;
    当所述交通信号灯为红色时,将所述至少一个连通区域的像素的红色分量调整至第一预设范围,降低所述至少一个连通区域的像素的蓝色和绿色分量;When the traffic signal light is red, adjust the red component of the pixels of the at least one connected area to the first preset range, and reduce the blue and green components of the pixels of the at least one connected area;
    当所述交通信号灯为黄色时,将所述至少一个连通区域的像素的红色和绿色分量调整至第二预设范围,降低所述至少一个连通区域的像素的蓝色分量;When the traffic signal light is yellow, adjust the red and green components of the pixels of the at least one connected area to a second preset range, and reduce the blue component of the pixels of the at least one connected area;
    当所述交通信号灯为绿色时,将所述至少一个连通区域的像素的绿色分量调整至第三预设范围,降低所述至少一个连通区域的像素的红色和蓝色分量。When the traffic signal light is green, adjust the green component of the pixels of the at least one connected area to a third preset range, and reduce the red and blue components of the pixels of the at least one connected area.
  5. 根据权利要求1-4任一项所述的对图像进行颜色还原的方法,其特征在于,所述根据所述第一图像的饱和度和明度确定所述第一图像的第一区域之前,所述方 法还包括:The method for color restoring an image according to any one of claims 1 to 4, wherein before determining the first area of the first image according to the saturation and lightness of the first image, all The method also includes:
    对所述第一图像的像素的饱和度分量和明度分量进行滤波处理。Performing filtering processing on the saturation component and the lightness component of the pixels of the first image.
  6. 根据权利要求1-5任一项所述的对图像进行颜色还原的方法,其特征在于,所述获取待处理的第一图像包括:The method for color restoring an image according to any one of claims 1 to 5, wherein the acquiring the first image to be processed includes:
    将用户在第二图像上选择的第二区域作为所述待处理的第一图像。The second area selected by the user on the second image is used as the first image to be processed.
  7. 一种图像处理设备,其特征在于,包括:An image processing device, characterized in that it includes:
    获取单元,用于获取待处理的第一图像,所述第一图像包括过曝的第一目标对象;An obtaining unit, configured to obtain a first image to be processed, the first image including an overexposed first target object;
    确定单元,用于根据所述第一图像的像素的饱和度和明度确定所述第一图像的第一区域,所述第一区域的像素的饱和度低于所述第一图像的像素的饱和度的平均值,且所述第一区域的像素的明度高于所述第一图像的像素的明度的平均值;所述第一区域对应所述第一目标对象的区域;A determining unit for determining the first area of the first image according to the saturation and lightness of the pixels of the first image, the saturation of the pixels of the first area is lower than the saturation of the pixels of the first image An average value of degrees, and the brightness of the pixels of the first area is higher than the average value of the brightness of the pixels of the first image; the first area corresponds to the area of the first target object;
    处理单元,用于对所述第一区域进行二值化处理,得到所述第一区域对应的二值图像;A processing unit, configured to perform binarization processing on the first area to obtain a binary image corresponding to the first area;
    所述确定单元,还用于确定所述二值图像中面积大于或等于第一阈值的至少一个连通区域;所述至少一个连通区域的轮廓对应所述第一目标对象的轮廓;The determining unit is further configured to determine at least one connected region whose area in the binary image is greater than or equal to a first threshold; the contour of the at least one connected region corresponds to the contour of the first target object;
    所述处理单元,还用于还原所述至少一个连通区域的颜色。The processing unit is also used to restore the color of the at least one connected area.
  8. 根据权利要求7所述的图像处理设备,其特征在于,所述处理单元还用于:The image processing apparatus according to claim 7, wherein the processing unit is further configured to:
    将所述第一图像从第一空间转换到色调饱和度明度HSV空间,所述第一空间为亮度色度YUV空间、红绿蓝RGB空间或色调饱和度亮度HSL空间中的任一种。Converting the first image from a first space to a hue saturation lightness HSV space, the first space is any one of a luma hue YUV space, a red-green-blue RGB space, or a hue saturation lightness HSL space.
  9. 根据权利要求7或8所述的图像处理设备,其特征在于,当所述第一目标对象为交通信号灯时,所述处理单元用于:The image processing device according to claim 7 or 8, wherein when the first target object is a traffic signal, the processing unit is configured to:
    通过所述获取单元获取所述交通信号灯的颜色信息;Acquiring the color information of the traffic signal light through the acquiring unit;
    当所述交通信号灯为红色时,将所述至少一个连通区域的像素的色调调整至红色范围,并将所述至少一个连通区域的像素的饱和度和明度分别进行提升和降低;When the traffic signal light is red, adjust the hue of the pixels of the at least one connected area to the red range, and respectively increase and decrease the saturation and brightness of the pixels of the at least one connected area;
    当所述交通信号灯为黄色时,将所述至少一个连通区域的像素的色调调整至黄色范围,并将所述至少一个连通区域的像素的饱和度和明度分别进行提升和降低;When the traffic signal light is yellow, adjust the hue of the pixels of the at least one connected area to a yellow range, and increase and decrease the saturation and brightness of the pixels of the at least one connected area, respectively;
    当所述交通信号灯为绿色时,将所述至少一个连通区域的像素的色调调整至绿色范围,并将所述至少一个连通区域的像素的饱和度和明度分别进行提升和降低。When the traffic light is green, adjust the hue of the pixels of the at least one connected area to the green range, and increase and decrease the saturation and brightness of the pixels of the at least one connected area, respectively.
  10. 根据权利要求7或8所述的图像处理设备,其特征在于,当所述第一目标对象为交通信号灯时,所述处理单元用于:The image processing device according to claim 7 or 8, wherein when the first target object is a traffic signal, the processing unit is configured to:
    将所述至少一个连通区域转换到RGB空间;Convert the at least one connected region to RGB space;
    通过所述获取单元获取所述交通信号灯的颜色信息;Acquiring the color information of the traffic signal light through the acquiring unit;
    当所述交通信号灯为红色时,将所述至少一个连通区域的像素的红色分量调整至第一预设范围,降低所述至少一个连通区域的像素的蓝色和绿色分量;When the traffic signal light is red, adjust the red component of the pixels of the at least one connected area to the first preset range, and reduce the blue and green components of the pixels of the at least one connected area;
    当所述交通信号灯为黄色时,将所述至少一个连通区域的像素的红色和绿色分 量调整至第二预设范围,降低所述至少一个连通区域的像素的蓝色分量;When the traffic light is yellow, adjust the red and green components of the pixels of the at least one connected area to a second preset range, and reduce the blue component of the pixels of the at least one connected area;
    当所述交通信号灯为绿色时,将所述至少一个连通区域的像素的绿色分量调整至第三预设范围,降低所述至少一个连通区域的像素的红色和蓝色分量。When the traffic signal light is green, adjust the green component of the pixels of the at least one connected area to a third preset range, and reduce the red and blue components of the pixels of the at least one connected area.
  11. 根据权利要求7-10任一项所述的图像处理设备,其特征在于,所述处理单元还用于:The image processing apparatus according to any one of claims 7-10, wherein the processing unit is further configured to:
    对所述第一图像的像素的饱和度分量和明度分量进行滤波处理。Performing filtering processing on the saturation component and the lightness component of the pixels of the first image.
  12. 根据权利要求7-11任一项所述的图像处理设备,其特征在于,所述获取单元用于:The image processing device according to any one of claims 7-11, wherein the acquisition unit is configured to:
    将用户在第二图像上选择的第二区域作为所述待处理的第一图像。13、一种计算机可读存储介质,包括指令,其特征在于,当所述指令在计算机上运行时,使得计算机执行权利要求1至6任一项所述的对图像进行颜色还原的方法。The second area selected by the user on the second image is used as the first image to be processed. 13. A computer-readable storage medium, including instructions, characterized in that, when the instructions are run on a computer, the computer is caused to perform the method for color restoration of an image according to any one of claims 1 to 6.
PCT/CN2019/121126 2018-12-12 2019-11-27 Method and apparatus for color reproduction of image WO2020119454A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201811517272.3 2018-12-12
CN201811517272.3A CN111311500A (en) 2018-12-12 2018-12-12 Method and device for carrying out color restoration on image

Publications (1)

Publication Number Publication Date
WO2020119454A1 true WO2020119454A1 (en) 2020-06-18

Family

ID=71076231

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/121126 WO2020119454A1 (en) 2018-12-12 2019-11-27 Method and apparatus for color reproduction of image

Country Status (2)

Country Link
CN (1) CN111311500A (en)
WO (1) WO2020119454A1 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112200747B (en) * 2020-10-16 2022-06-21 展讯通信(上海)有限公司 Image processing method and device and computer readable storage medium
CN113436126B (en) * 2021-07-13 2022-06-10 上海艾为电子技术股份有限公司 Image saturation enhancement method and system and electronic equipment
CN114783192A (en) * 2022-03-24 2022-07-22 杭州海康威视数字技术股份有限公司 Signal lamp color processing method and device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130194504A1 (en) * 2011-12-06 2013-08-01 Michael Donvig Joensson Image processing method for recovering details in overexposed digital video footage or digital still images
CN104301621A (en) * 2014-09-28 2015-01-21 北京凌云光技术有限责任公司 Image processing method, device and terminal
JP2016001782A (en) * 2014-06-11 2016-01-07 キヤノン株式会社 Image processing system, imaging device, image processing method, program, and storage medium
CN106507079A (en) * 2016-11-03 2017-03-15 浙江宇视科技有限公司 A kind of color rendition method and device
CN106504217A (en) * 2016-11-29 2017-03-15 广东欧珀移动通信有限公司 Image processing method, image processing apparatus, imaging device and electronic installation

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130194504A1 (en) * 2011-12-06 2013-08-01 Michael Donvig Joensson Image processing method for recovering details in overexposed digital video footage or digital still images
JP2016001782A (en) * 2014-06-11 2016-01-07 キヤノン株式会社 Image processing system, imaging device, image processing method, program, and storage medium
CN104301621A (en) * 2014-09-28 2015-01-21 北京凌云光技术有限责任公司 Image processing method, device and terminal
CN106507079A (en) * 2016-11-03 2017-03-15 浙江宇视科技有限公司 A kind of color rendition method and device
CN106504217A (en) * 2016-11-29 2017-03-15 广东欧珀移动通信有限公司 Image processing method, image processing apparatus, imaging device and electronic installation

Also Published As

Publication number Publication date
CN111311500A (en) 2020-06-19

Similar Documents

Publication Publication Date Title
CN109274985B (en) Video transcoding method and device, computer equipment and storage medium
US9813635B2 (en) Method and apparatus for auto exposure value detection for high dynamic range imaging
WO2019148912A1 (en) Image processing method, apparatus, electronic device and storage medium
WO2020119454A1 (en) Method and apparatus for color reproduction of image
WO2018149253A1 (en) Image processing method and device
CN110572637B (en) Image anomaly detection method, terminal device and storage medium
JP7359521B2 (en) Image processing method and device
CN112073703B (en) Method and device for adjusting color correction matrix, terminal equipment and medium
CN103646392B (en) Backlighting detecting and equipment
US20190313071A1 (en) Dynamic chroma key for video background replacement
US10438376B2 (en) Image processing apparatus replacing color of portion in image into single color, image processing method, and storage medium
WO2021073304A1 (en) Image processing method and apparatus
CN112218065B (en) Image white balance method, system, terminal device and storage medium
CN115496668A (en) Image processing method, image processing device, electronic equipment and storage medium
CN111523551A (en) Binarization method, device and equipment for blue object
CN110807735A (en) Image processing method, image processing device, terminal equipment and computer readable storage medium
JPH1166301A (en) Method and device for classifying color image and record medium recorded with this method
CN112200747B (en) Image processing method and device and computer readable storage medium
CN113727085A (en) White balance processing method and electronic equipment
CN111970501A (en) Pure color scene AE color processing method and device, electronic equipment and storage medium
WO2023123601A1 (en) Image color processing method and apparatus, and electronic device
US11509797B2 (en) Image processing apparatus, image processing method, and storage medium
WO2022032666A1 (en) Image processing method and related apparatus
CN112215237B (en) Image processing method and device, electronic equipment and computer readable storage medium
CN113473101B (en) Color correction method, device, electronic equipment and storage medium

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: 19896628

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: 19896628

Country of ref document: EP

Kind code of ref document: A1