An image color processing method and device, electronic equipment and storage medium
Patent Information
- Application Number
- CN202111165849.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-30
- Publication Date
- 2026-10-16
- Estimated Expiration
- 2041-09-30
AI Technical Summary
[0018] The technical solution provided in this disclosure has at least the following advantages compared with the prior art:
Smart Images

Figure CN115908862B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of information technology, and in particular to an image color processing method, apparatus, electronic device, and storage medium. Background Technology
[0002] Color degradation is a common problem in images. Machine learning models can typically be used to detect the degree of color degradation in an image. To achieve high detection accuracy, a certain number of training samples are needed; that is, a certain number of color-degraded images are required as training samples for the machine learning model.
[0003] Therefore, obtaining images whose color degradation effect closely approximates the natural color degradation effect is the foundation for enabling machine learning models to achieve high detection accuracy. Summary of the Invention
[0004] To solve the above-mentioned technical problems, or at least partially solve them, embodiments of this disclosure provide an image color processing method, apparatus, electronic device, and storage medium, which realizes the purposeful degradation processing of image colors and can obtain a more realistic color degradation effect.
[0005] In a first aspect, embodiments of this disclosure provide an image color processing method, the method comprising:
[0006] Determine the color distribution information of the original image in the first color space;
[0007] Based on the color distribution information, the color categories of the original image are reduced according to preset rules to perform local color degradation processing on the original image and obtain an intermediate image;
[0008] The intermediate image is converted from the first color space to the second color space, and the colors of the intermediate image are further processed in the second color space to perform overall color degradation processing on the original image, thereby obtaining a target image whose colors meet preset conditions.
[0009] Secondly, embodiments of this disclosure also provide an image color processing apparatus, the apparatus comprising:
[0010] The determination module is used to determine the color distribution information of the original image in the first color space;
[0011] The first degradation module is used to reduce the color categories of the original image according to the color distribution information and based on preset rules, so as to perform local color degradation processing on the original image and obtain an intermediate image;
[0012] The second degradation module is used to convert the intermediate image from the first color space to the second color space, and to further process the colors of the intermediate image in the second color space to perform overall color degradation processing on the original image, so as to obtain a target image whose colors meet the preset conditions.
[0013] Thirdly, embodiments of this disclosure also provide an electronic device, the electronic device comprising:
[0014] One or more processors;
[0015] Storage device for storing one or more programs;
[0016] When the one or more programs are executed by the one or more processors, the one or more processors implement the image color processing method as described above.
[0017] Fourthly, embodiments of this disclosure also provide a computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the image color processing method described above.
[0018] The technical solution provided in this disclosure has at least the following advantages compared with the prior art:
[0019] The image color processing method provided in this disclosure involves determining the color distribution information of an original image in a first color space; reducing the color categories of the original image based on the color distribution information and a preset rule to perform local color degradation processing on the original image to obtain an intermediate image; converting the intermediate image from the first color space to a second color space; and further processing the colors of the intermediate image in the second color space to perform overall color degradation processing on the original image to obtain a target image whose colors meet preset conditions. This method achieves targeted color degradation processing of images and can obtain a more realistic color degradation effect. Attached Figure Description
[0020] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale.
[0021] Figure 1 This is a flowchart of an image color processing method according to an embodiment of the present disclosure;
[0022] Figure 2 This is a flowchart of an image color processing method according to an embodiment of the present disclosure;
[0023] Figure 3 This is a flowchart of an image color processing method according to an embodiment of the present disclosure;
[0024] Figure 4 This is a schematic diagram illustrating a linear reduction of the first distance in an embodiment of this disclosure;
[0025] Figure 5 This is a flowchart of an image color processing method according to an embodiment of the present disclosure;
[0026] Figure 6 This is a schematic diagram of the structure of an image color processing device according to an embodiment of the present disclosure;
[0027] Figure 7 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present disclosure. Detailed Implementation
[0028] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.
[0029] It should be understood that the steps described in the method embodiments of this disclosure may be performed in different orders and in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this disclosure is not limited in this respect.
[0030] The term "comprising" and its variations as used herein are open-ended inclusions, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below.
[0031] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are used only to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.
[0032] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".
[0033] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
[0034] Figure 1 This is a flowchart illustrating an image color processing method according to an embodiment of the present disclosure. The method can be executed by an image color processing device, which can be implemented in software and / or hardware. This device can be configured in an electronic device, such as a display terminal or server. The display terminal specifically includes, but is not limited to, smartphones, PDAs, tablets, portable wearable devices, smart home devices (e.g., table lamps), and other electronic devices equipped with a display screen.
[0035] like Figure 1 As shown, the method may specifically include the following steps:
[0036] Step 110: Determine the color distribution information of the original image in the first color space.
[0037] The original image refers to the image captured by a camera (e.g., a sensor camera). Color distribution information refers to the color categories included in the original image, and the number of pixels within each color category. It can be understood that the more color categories the original image includes, the more vibrant the visual effect.
[0038] The first color space can be the Lab color space, the HSV (Hue Saturation Value) color space, or the RGB color space, etc. This embodiment uses the Lab color space as an example. Specifically, in the Lab color space, a three-dimensional color histogram of the original image is determined. Based on the three-dimensional color histogram, the number of pixels at each brightness level is counted. Each pixel includes two components, a and b, where a is the component from green to red and b is the component from blue to yellow. The horizontal axis of the three-dimensional color histogram represents brightness, and the vertical axis represents the number of pixels. The pixel at each brightness level includes two components, a and b. Based on the pixels at each brightness level, a two-dimensional color histogram of the original image is determined. The horizontal and vertical axes of the two-dimensional color histogram represent the a and b components, respectively. The color distribution information of the original image in the Lab color space is determined based on the two-dimensional color histogram.
[0039] Furthermore, in some embodiments, determining the color distribution information of the original image in the Lab color space based on the two-dimensional color histogram includes: inputting the pixels at each brightness level into a preset clustering algorithm to obtain at least two cluster centers and pixel clusters belonging to the at least two cluster centers respectively; the at least two cluster centers and pixel clusters belonging to the at least two cluster centers constitute the color distribution information of the original image in the Lab color space.
[0040] Optionally, determining the color distribution information of the original image in the first color space can also be achieved by identifying the color categories in the original image and the pixels under each category based on a machine learning model; or by matching with a preset image template to determine the color distribution information of the image.
[0041] Step 120: Based on the color distribution information, reduce the color categories of the original image according to preset rules to perform local color degradation processing on the original image and obtain an intermediate image.
[0042] Specifically, local color degradation of the original image can involve reducing the number of color categories in the original image, with the aim of making the colors of the original image darker, achieving a natural color degradation effect. This color degradation of the original image can simulate, or in other words, reproduce, a real low-quality image.
[0043] In some embodiments, based on color distribution information and a preset rule, the number of color categories in the original image is reduced to perform local color degradation processing on the original image to obtain an intermediate image. This includes: determining pixel pairs with a color distance less than a threshold based on the color distribution information, where the color distance characterizes the degree of color similarity between two pixels in a pixel pair; reducing the distance between pixel pairs to reduce the number of color categories in the original image; and assembling the intermediate image based on the pixel pairs with reduced distance. Pixel pairs with a color distance less than the threshold are pixels with relatively similar colors, such as pink and magenta. By shortening the distance between such pixels, color merging can be achieved, thereby reducing the number of color categories and decreasing the color richness of the image.
[0044] Step 130: Convert the intermediate image from the first color space to the second color space, and continue to process the colors of the intermediate image in the second color space to perform overall color degradation processing on the original image, so as to obtain a target image whose colors meet the preset conditions.
[0045] To further improve the realism of the color degradation effect and ensure that the color degradation effect obtained by the algorithm is consistent with the natural color degradation effect, after performing local color degradation processing on the original image, a global color degradation processing is then performed on the original image. Specifically, the intermediate image is converted from a first color space to a second color space, and the colors of the intermediate image are further processed in the second color space. Wherein, when the first color space is the Lab color space, the second color space can be either the HSV color space or the RGB color space; the first color space and the second color space simply need to be different. This embodiment uses the Lab color space as the first color space and the HSV color space as an example for illustrative purposes.
[0046] For example, converting an intermediate image from a first color space to a second color space, and further processing the colors of the intermediate image in the second color space to perform overall color degradation on the original image to obtain a target image whose colors meet preset conditions, includes: converting the intermediate image from the Lab color space to the HSV color space; and linearly adjusting the saturation component in the HSV color space according to preset conditions to perform overall color degradation on the original image. Specifically, in the HSV color space, the saturation component s of the intermediate image is adjusted. The adjustment rule can be s' = s * thr, where thr = a value between 1.4 and 0.4, and the range of thr is determined based on business experience. Here, s represents the saturation component before adjustment, s' represents the saturation component after adjustment, and thr represents the adjustment parameter, which can be determined according to preset conditions, i.e., according to the specified degree of color degradation.
[0047] The image color processing method provided in this embodiment determines the color distribution information of the original image in a first color space, performs local color degradation processing on the original image based on the color distribution information to obtain an intermediate image, and then converts the intermediate image from the first color space to a second color space. The colors of the intermediate image are further processed in the second color space to perform overall color degradation processing on the original image. This achieves targeted color degradation processing of the original image and can obtain a more realistic color degradation effect.
[0048] Based on the above embodiments, by simulating color-degraded images, a large amount of color-degraded image data can be generated. This simulated large amount of color-degraded image data can then be used as training samples to train a color-degraded detection model. Based on the trained color-degraded detection model, color-degraded detection can be performed on the image to be detected. (See reference...) Figure 2 The flowchart shown illustrates an image color processing method, which includes the following steps:
[0049] Step 210: Determine the color distribution information of the original image in the first color space. Based on the color distribution information, reduce the color categories of the original image according to a preset rule to perform local color degradation processing on the original image and obtain an intermediate image.
[0050] Step 220: Convert the intermediate image from the first color space to the second color space, and continue to process the colors of the intermediate image in the second color space to perform overall color degradation processing on the original image, so as to obtain a target image whose colors meet the preset conditions.
[0051] Step 230: Train the color degradation detection model based on the target image to obtain the trained color degradation detection model.
[0052] Step 240: Use the trained color degradation detection model to perform color degradation detection on the image to be detected, so as to determine the degree of color degradation of the image to be detected.
[0053] The technical solution of this embodiment degrades the color of the original image based on the color distribution information of the original image to obtain a target image whose color meets preset conditions. This achieves purposeful color degradation processing of the image and can obtain a more realistic color degradation effect. By simulating color degradation images according to the above method, a large amount of color degradation image data can be generated. Then, the simulated large amount of color degradation image data is used as training samples to train a color degradation detection model. Then, based on the trained color degradation detection model, color degradation detection is performed on the image to be detected, thus achieving the purpose of color degradation detection of the image to be detected.
[0054] Based on the above embodiments, refer to Figure 3 The diagram illustrates a flowchart of an image color processing method. This embodiment provides an optional implementation for step 110, "determining the color distribution information of the original image in a first color space," and step 120, "reducing the color categories of the original image based on the color distribution information and a preset rule to perform local color degradation processing on the original image to obtain an intermediate image."
[0055] like Figure 3 As shown, the image color processing method includes the following steps:
[0056] Step 310: Determine the three-dimensional color histogram of the original image in the Lab color space, wherein the first color space includes the Lab color space.
[0057] Step 320: Based on the three-dimensional color histogram, count the number of pixels at each brightness level. Each pixel includes two components, a and b. A is the component from green to red, and b is the component from blue to yellow. The horizontal axis of the three-dimensional color histogram represents the brightness, and the vertical axis represents the number of pixels.
[0058] Step 330: Determine the two-dimensional color histogram of the original image based on the pixels at each brightness level, wherein the horizontal axis and vertical axis of the two-dimensional color histogram represent a and b, respectively; determine the color distribution information of the original image in the Lab color space based on the two-dimensional color histogram.
[0059] Specifically, in the Lab color space, accumulation is performed along the L direction, that is, the pixels at each brightness level are summed to obtain the pixels of the original image in a two-dimensional color space. In the two-dimensional color space, each pixel is represented by two components: a (the component from green to red) and b (the component from blue to yellow). The pixels in the two-dimensional color space represent the color distribution information. Typically, the total number of pixels in the original image in the two-dimensional color space is 256*256.
[0060] In one implementation, determining the color distribution information of the original image in the Lab color space based on a two-dimensional color histogram includes: inputting pixels at various brightness levels into a preset clustering algorithm to obtain at least two cluster centers and pixel clusters belonging to each of the at least two cluster centers; the at least two cluster centers and the pixel clusters belonging to each of the at least two cluster centers constitute the color distribution information of the original image in the Lab color space. The preset clustering algorithm can be, for example, the DBSCAN algorithm. Inputting 256*256 pixels (each pixel including two components, a and b) into the DBSCAN algorithm yields multiple cluster centers and pixel clusters belonging to each cluster center. A cluster center represents a color category, which is a color representation that exists over a large area in the original image. Pixel clusters belonging to a cluster center represent colors that are the same as or close to the color category represented by that cluster center. Thus, each pixel is labeled with a category tag to identify its color category.
[0061] Step 340: Based on the color distribution information, determine the pixel pairs with a color distance less than a threshold, wherein the color distance characterizes the degree of color similarity between two pixels in the pixel pair.
[0062] Among them, the pixel pair with a color distance less than the threshold includes any pixel in the pixel cluster and the pixel pair formed by the cluster center to which it belongs.
[0063] Step 350: Reduce the distance between the pixel pairs to reduce the color categories of the original image, and compose the intermediate image based on the pixel pairs with reduced distance.
[0064] In some implementations, reducing the distance between the pixel pairs to reduce the color categories of the original image includes: for each pixel at each brightness level, determining a first distance between the current pixel and the cluster center to which the current pixel belongs; keeping the cluster center to which the current pixel belongs unchanged, and linearly reducing the first distance so that the mapped pixels of the current pixel are located on the line connecting the current pixel and the cluster center to which the current pixel belongs; the mapped pixels corresponding to each pixel form the pixels of the intermediate image.
[0065] Specifically, based on preset conditions, the first distance is processed to obtain the mapped pixel corresponding to the current pixel. Here, linearly reducing the first distance means shortening the first distance along the straight line containing the original first distance. See, for example... Figure 4 The diagram illustrates a linear reduction of a first distance, including the current pixel A and the cluster center C to which pixel A belongs. The first distance between the current pixel A and the cluster center C is d1. The linear reduction of this first distance by d1 keeps the position of the cluster center C fixed. A point B is selected on the line connecting the current pixel A and the cluster center C as the mapped pixel corresponding to the current pixel A. The second distance d2 between point B and the cluster center C is used as the distance obtained after linearly reducing the first distance d1. The principle for selecting point B can be determined according to the preset conditions. For example, if the preset conditions indicate a high degree of image color degradation, point B should be located closer to the cluster center C so that the color of the mapped pixel B is closer to the color of the cluster center C. If the preset conditions indicate a low degree of image color degradation, point B should be located farther from the cluster center C to control the direction of color shift. The linear reduction of the first distance d1 can be based on the following formula: d2 = d1 * thr, where thr is a random value between 0.9 and 0.5. thr can be obtained through multiple experiments given a specific degree of color degradation.
[0066] Cluster centers represent a color category, which is a large-area representation of color in the original image. Different images have different color compositions; therefore, clustering algorithms can assign different cluster centers to different images, achieving adaptive image processing. Linearly reducing the first distance controls the direction of color shift, resulting in a more realistic color degradation effect.
[0067] The essence of the above processing is to replace the current pixel with its mapped pixel. The mapped pixel is a point on the line connecting the current pixel and its cluster center, located between the current pixel and its cluster center. By shortening the distance to the cluster center, the color of the current pixel is controlled to tend towards the color of the cluster center. By performing the above processing on each pixel, the goal of reducing the number of colors in the original image is achieved. Essentially, this processing controls the degradation of local colors in the original image.
[0068] Step 360: Convert the intermediate image from the first color space to the second color space, and continue to process the colors of the intermediate image in the second color space to perform overall color degradation processing on the original image, so as to obtain a target image whose colors meet the preset conditions.
[0069] Based on the above embodiments, this embodiment provides a degradation method that adapts to the direction of image color shift and the reduction of the number of colors, achieving a more realistic degradation effect. Specifically, it obtains the color distribution information of the original image through a clustering algorithm, and achieves local control of image color by adjusting the distance between the current pixel and its cluster center. Furthermore, it achieves overall control of image color by converting the intermediate image to the HSV color space and adjusting the saturation component in the HSV color space.
[0070] Based on the above technical solutions, and referring to, as follows Figure 5 The flowchart shown illustrates an image color processing method. For the original image, its color histogram is statistically analyzed. Based on the color histogram, the density centers of the colors (i.e., the cluster centers mentioned above) are analyzed. Local color degradation processing is performed on the original image according to the color density centers. Then, the original image is subjected to overall color degradation by converting the color space to obtain a target image that meets the expectations. This target image can be used as sample data for downstream functions (such as color degradation detection, color scoring, etc.). By generating a large number of target images, the construction and collection of a large amount of sample data can be realized.
[0071] Figure 6 This is a schematic diagram of the structure of an image color processing apparatus according to an embodiment of this disclosure. Figure 6 As shown, the image color processing device specifically includes: a determination module 610, a first degradation module 620, and a second degradation module 630.
[0072] The determination module 610 is used to determine the color distribution information of the original image in a first color space; the first degradation module 620 is used to reduce the color categories of the original image according to the color distribution information and based on preset rules, so as to perform local color degradation processing on the original image and obtain an intermediate image; the second degradation module 630 is used to convert the intermediate image from the first color space to a second color space, and continue to process the colors of the intermediate image in the second color space, so as to perform overall color degradation processing on the original image and obtain a target image whose colors meet preset conditions.
[0073] Optionally, the first degradation module 620 includes: a determining unit, configured to determine pixel pairs with a color distance less than a threshold based on the color distribution information, wherein the color distance characterizes the degree of color similarity between two pixels in the pixel pair; a reducing unit, configured to reduce the distance between the pixel pairs to reduce the color categories of the original image; and a composing unit, configured to compose the intermediate image based on the pixel pairs with reduced distance. Optionally, the determining module 610 includes: a first determining unit, configured to determine a three-dimensional color histogram of the original image in the Lab color space, wherein the first color space includes the Lab color space; a statistical unit, configured to count the number of pixels at each brightness level based on the three-dimensional color histogram, wherein each pixel includes two components, a and b, where a is a component from green to red and b is a component from blue to yellow, and the horizontal axis of the three-dimensional color histogram represents brightness and the vertical axis represents the number of pixels; a second determining unit, configured to determine a two-dimensional color histogram of the original image based on the pixels at each brightness level, wherein the horizontal axis and vertical axis of the two-dimensional color histogram represent a and b, respectively; and a third determining unit, configured to determine the color distribution information of the original image in the Lab color space based on the two-dimensional color histogram. Optionally, the third determining unit is specifically used to: input the pixels at each brightness level into a preset clustering algorithm to obtain at least two cluster centers and pixel clusters belonging to the at least two cluster centers respectively; the at least two cluster centers and pixel clusters belonging to the at least two cluster centers constitute the color distribution information of the original image in the Lab color space.
[0074] Optionally, the pixel pair with a color distance less than a threshold includes any pixel in the pixel cluster and the pixel pair formed by its cluster center. Optionally, the reduction module is specifically used to: for each pixel at each brightness level, determine a first distance between the current pixel and the cluster center to which the current pixel belongs; keep the cluster center to which the current pixel belongs unchanged, and linearly reduce the first distance so that the mapped pixel of the current pixel is located on the line connecting the current pixel and the cluster center to which the current pixel belongs; the mapped pixels corresponding to each pixel respectively form the pixels of the intermediate image.
[0075] Optionally, the second degradation module 630 includes: a conversion unit for converting the intermediate image from the first color space to the HSV color space; and an adjustment unit for linearly adjusting the saturation component in the HSV color space according to the preset conditions to perform overall color degradation processing on the original image.
[0076] Optionally, the image color processing device further includes: a training module, used to train a color degradation detection model based on the target image to obtain a trained color degradation detection model.
[0077] Optionally, the image color processing device further includes: a detection module, used to perform color degradation detection on the image to be detected using the trained color degradation detection model, so as to determine the degree of color degradation of the image to be detected.
[0078] The image color processing apparatus provided in this embodiment degrades the color of the original image according to the color distribution information of the original image to obtain a target image whose color meets preset conditions. This achieves purposeful processing of image color and can obtain a more realistic color effect. By following the above method, low-quality images can be simulated, and a large amount of low-quality image data can be generated. Then, the simulated large amount of low-quality image data is used as training samples to train a color degradation detection model. Then, based on the trained color degradation detection model, color degradation detection is performed on the image to be detected, thus achieving the purpose of color degradation detection of the image to be detected.
[0079] The image color processing apparatus provided in this disclosure embodiment can execute the steps in the image color processing method provided in this disclosure method embodiment, and has the execution steps and beneficial effects, which will not be repeated here.
[0080] Figure 7 This is a schematic diagram of the structure of an electronic device according to an embodiment of this disclosure. See below for details. Figure 7The diagram illustrates a structural schematic suitable for implementing the electronic device 800 in the embodiments of this disclosure. The electronic device 800 in the embodiments of this disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), wearable electronic devices, etc., as well as fixed terminals such as digital TVs, desktop computers, smart home devices, etc. Figure 7 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0081] like Figure 7 As shown, the electronic device 800 may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 801, which can perform various appropriate actions and processes to implement the methods of the embodiments described herein, based on a program stored in a read-only memory (ROM) 802 or a program loaded from a storage device 808 into a random access memory (RAM) 803. The RAM 803 also stores various programs and data required for the operation of the electronic device 800. The processing device 801, ROM 802, and RAM 803 are interconnected via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0082] Typically, the following devices can be connected to I / O interface 805: input devices 806 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 807 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 808 including, for example, magnetic tapes, hard disks, etc.; and communication devices 809. Communication device 809 allows electronic device 800 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 7 An electronic device 800 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.
[0083] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts, thereby implementing the methods as described above. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 809, or installed from a storage device 808, or installed from a ROM 802. When the computer program is executed by the processing device 801, it performs the functions defined in the methods of embodiments of this disclosure.
[0084] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0085] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.
[0086] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0087] The aforementioned computer-readable medium carries one or more programs that, when executed by the electronic device, cause the electronic device to:
[0088] Determine the color distribution information of the original image in a first color space; based on the color distribution information, reduce the color categories of the original image according to a preset rule to perform local color degradation processing on the original image to obtain an intermediate image; convert the intermediate image from the first color space to a second color space, and continue to process the colors of the intermediate image in the second color space to perform overall color degradation processing on the original image to obtain a target image whose colors meet preset conditions.
[0089] Optionally, when one or more of the above-described procedures are executed by the electronic device, the electronic device may also execute other steps described in the above embodiments.
[0090] Computer program code for performing the operations of this disclosure can be written in one or more programming languages or a combination thereof, including but not limited to object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0091] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0092] The units described in the embodiments of this disclosure can be implemented in software or hardware. The names of the units are not, in some cases, intended to limit the specific unit.
[0093] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0094] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0095] According to one or more embodiments of this disclosure, this disclosure provides an image color processing method, comprising: determining color distribution information of an original image in a first color space; reducing the color categories of the original image based on the color distribution information and a preset rule to perform local color degradation processing on the original image to obtain an intermediate image; converting the intermediate image from the first color space to a second color space, and further processing the colors of the intermediate image in the second color space to perform overall color degradation processing on the original image to obtain a target image whose colors meet preset conditions.
[0096] According to one or more embodiments of this disclosure, in the image color processing method provided in this disclosure, optionally, the step of reducing the color categories of the original image based on the color distribution information and a preset rule to perform local color degradation processing on the original image to obtain an intermediate image includes: determining pixel pairs with a color distance less than a threshold based on the color distribution information, wherein the color distance characterizes the degree of color similarity between two pixels in the pixel pair; reducing the distance between the pixel pairs to reduce the color categories of the original image; and composing the intermediate image based on the pixel pairs with reduced distance.
[0097] According to one or more embodiments of this disclosure, in the image color processing method provided in this disclosure, optionally, determining the color distribution information of the original image in a first color space includes: determining a three-dimensional color histogram of the original image in the Lab color space, wherein the first color space includes the Lab color space; based on the three-dimensional color histogram, counting the number of pixels at each brightness level, wherein each pixel includes two components, a and b, where a is a component from green to red and b is a component from blue to yellow, and the horizontal axis of the three-dimensional color histogram represents brightness and the vertical axis represents the number of pixels; determining a two-dimensional color histogram of the original image based on the pixels at each brightness level, wherein the horizontal axis and vertical axis of the two-dimensional color histogram represent a and b, respectively; and determining the color distribution information of the original image in the Lab color space based on the two-dimensional color histogram.
[0098] According to one or more embodiments of this disclosure, in the image color processing method provided in this disclosure, optionally, determining the color distribution information of the original image in the Lab color space based on the two-dimensional color histogram includes: inputting the pixels at each brightness level into a preset clustering algorithm to obtain at least two cluster centers and pixel clusters belonging to the at least two cluster centers respectively; the at least two cluster centers and the pixel clusters belonging to the at least two cluster centers constitute the color distribution information of the original image in the Lab color space.
[0099] According to one or more embodiments of this disclosure, in the image color processing method provided in this disclosure, optionally, the pixel pair with a color distance less than a threshold includes any pixel in the pixel cluster and the pixel pair formed by the cluster center to which it belongs.
[0100] According to one or more embodiments of this disclosure, in the image color processing method provided in this disclosure, optionally, reducing the distance between the pixel pairs to reduce the color categories of the original image includes: for each pixel at each brightness level, determining a first distance between the current pixel and the cluster center to which the current pixel belongs; keeping the cluster center to which the current pixel belongs unchanged, and linearly reducing the first distance so that the mapped pixel of the current pixel is located on the line connecting the current pixel and the cluster center to which the current pixel belongs; the mapped pixels corresponding to each pixel respectively constitute the pixels of the intermediate image.
[0101] According to one or more embodiments of this disclosure, in the image color processing method provided in this disclosure, optionally, the step of converting the intermediate image from the first color space to the second color space, and further processing the color of the intermediate image in the second color space to perform overall color degradation processing on the original image to obtain a target image whose color meets preset conditions includes: converting the intermediate image from the first color space to the HSV color space; and linearly adjusting the saturation component in the HSV color space according to the preset conditions to perform overall color degradation processing on the original image.
[0102] According to one or more embodiments of this disclosure, the image color processing method provided in this disclosure may optionally further include: training a color degradation detection model based on the target image to obtain a trained color degradation detection model.
[0103] According to one or more embodiments of this disclosure, the image color processing method provided in this disclosure may optionally further include: using the trained color degradation detection model to perform color degradation detection on the image to be detected, so as to determine the degree of color degradation of the image to be detected.
[0104] According to one or more embodiments of this disclosure, an image color processing apparatus is provided, comprising: a determining module, configured to determine color distribution information of an original image in a first color space; a first degradation module, configured to reduce the color categories of the original image according to the color distribution information and based on preset rules, so as to perform local color degradation processing on the original image to obtain an intermediate image; and a second degradation module, configured to convert the intermediate image from the first color space to a second color space, and continue to process the colors of the intermediate image in the second color space, so as to perform overall color degradation processing on the original image to obtain a target image whose colors meet preset conditions.
[0105] According to one or more embodiments of this disclosure, in the image color processing apparatus provided in this disclosure, optionally, the first degradation module includes: a determining unit, configured to determine pixel pairs with a color distance less than a threshold based on the color distribution information, wherein the color distance characterizes the degree of color similarity between two pixels in the pixel pair; a reducing unit, configured to reduce the distance between the pixel pairs to reduce the color categories of the original image; and a composing unit, configured to compose the intermediate image based on the pixel pairs with reduced distance.
[0106] According to one or more embodiments of this disclosure, in the image color processing apparatus provided in this disclosure, optionally, the determining module includes: a first determining unit, configured to determine a three-dimensional color histogram of the original image in the Lab color space, wherein the first color space includes the Lab color space; a statistical unit, configured to count the number of pixels at each brightness level based on the three-dimensional color histogram, wherein each pixel includes two components, a and b, where a is a component from green to red and b is a component from blue to yellow, and the horizontal axis of the three-dimensional color histogram represents brightness and the vertical axis represents the number of pixels; a second determining unit, configured to determine a two-dimensional color histogram of the original image based on the pixels at each brightness level, wherein the horizontal axis and vertical axis of the two-dimensional color histogram represent a and b, respectively; and a third determining unit, configured to determine the color distribution information of the original image in the Lab color space based on the two-dimensional color histogram.
[0107] According to one or more embodiments of this disclosure, in the image color processing apparatus provided by this disclosure, optionally, the third determining unit is specifically used to: input the pixels at each brightness level into a preset clustering algorithm to obtain at least two cluster centers and pixel clusters respectively belonging to the at least two cluster centers; the at least two cluster centers and the pixel clusters respectively belonging to the at least two cluster centers constitute the color distribution information of the original image in the Lab color space. According to one or more embodiments of this disclosure, in the image color processing apparatus provided by this disclosure, optionally, the pixel pair with a color distance less than a threshold includes any pixel in the pixel cluster and the pixel pair formed by its respective cluster center.
[0108] According to one or more embodiments of this disclosure, in the image color processing apparatus provided in this disclosure, optionally, the reduction module is specifically configured to: for each pixel at each brightness level, determine a first distance between the current pixel and the cluster center to which the current pixel belongs; keep the cluster center to which the current pixel belongs unchanged, and linearly reduce the first distance so that the mapped pixel of the current pixel is located on the line connecting the current pixel and the cluster center to which the current pixel belongs; the mapped pixels corresponding to each pixel respectively constitute the pixels of the intermediate image.
[0109] According to one or more embodiments of this disclosure, in the image color processing apparatus provided in this disclosure, optionally, the second degradation module includes: a conversion unit, configured to convert the intermediate image from the first color space to the HSV color space; and an adjustment unit, configured to linearly adjust the saturation component in the HSV color space according to the preset conditions, so as to perform overall color degradation processing on the original image.
[0110] According to one or more embodiments of this disclosure, the image color processing apparatus provided herein may optionally further include: a training module, configured to train a color degradation detection model based on the target image to obtain a trained color degradation detection model. According to one or more embodiments of this disclosure, the image color processing apparatus provided herein may optionally further include: a detection module, configured to use the trained color degradation detection model to perform color degradation detection on the image to be detected, to determine the degree of color degradation of the image to be detected. According to one or more embodiments of this disclosure, this disclosure provides an electronic device, including:
[0111] One or more processors;
[0112] Memory, used to store one or more programs;
[0113] When the one or more programs are executed by the one or more processors, the one or more processors implement any of the image color processing methods provided in this disclosure.
[0114] According to one or more embodiments of the present disclosure, the present disclosure provides a computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements an image color processing method as described in any of the present disclosure.
[0115] This disclosure also provides a computer program product, which includes a computer program or instructions that, when executed by a processor, implement the image color processing method described above.
[0116] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.
[0117] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0118] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.
Claims
1. An image color processing method, characterized in that, The method includes: Determine the color distribution information of the original image in the first color space; Based on the color distribution information, the color categories of the original image are reduced according to preset rules to perform local color degradation processing on the original image and obtain an intermediate image; The intermediate image is converted from the first color space to the second color space, and the colors of the intermediate image are further processed in the second color space to perform overall color degradation processing on the original image, so as to obtain a target image whose colors meet the preset conditions. The further processing of the colors of the intermediate image in the second color space includes: linearly adjusting the saturation of the intermediate image according to the preset conditions. The step of reducing the color categories of the original image based on the color distribution information and a preset rule to perform local color degradation processing on the original image to obtain an intermediate image includes: Based on the color distribution information, pixel pairs with a color distance less than a threshold are identified, wherein the color distance characterizes the degree of color similarity between two pixels in the pixel pair; Reduce the distance between the pixel pairs to decrease the number of color categories in the original image; The intermediate image is composed of pixel pairs after the distance has been reduced.
2. The method according to claim 1, characterized in that, Determining the color distribution information of the original image in the first color space includes: In the Lab color space, a three-dimensional color histogram of the original image is determined, wherein the first color space includes the Lab color space; Based on the three-dimensional color histogram, the number of pixels at each brightness level is counted. Each pixel includes two components, a and b. a is the component from green to red, and b is the component from blue to yellow. The horizontal axis of the three-dimensional color histogram represents the brightness, and the vertical axis represents the number of pixels. A two-dimensional color histogram of the original image is determined based on the pixels at each brightness level, wherein the horizontal axis and vertical axis of the two-dimensional color histogram represent a and b, respectively; The color distribution information of the original image in the Lab color space is determined based on the two-dimensional color histogram.
3. The method according to claim 2, characterized in that, Determining the color distribution information of the original image in the Lab color space based on the two-dimensional color histogram includes: The pixels at each brightness level are input into a preset clustering algorithm to obtain at least two cluster centers and pixel clusters belonging to the at least two cluster centers respectively; The at least two cluster centers and the pixel clusters belonging to the at least two cluster centers constitute the color distribution information of the original image in the Lab color space.
4. The method according to claim 3, characterized in that, The pixel pairs with a color distance less than the threshold include any pixel in the pixel cluster and the pixel pair formed by the cluster center to which it belongs.
5. The method according to claim 4, characterized in that, Reducing the distance between the pixel pairs to decrease the color categories of the original image includes: For each pixel at each brightness level, determine the first distance between the current pixel and the cluster center to which the current pixel belongs; The cluster center to which the current pixel belongs is kept unchanged, and the first distance is linearly reduced so that the mapped pixel of the current pixel is located on the line connecting the current pixel and the cluster center to which the current pixel belongs; The pixels of the intermediate image are composed of the mapped pixels corresponding to each pixel.
6. The method according to any one of claims 1-5, characterized in that, The step of converting the intermediate image from the first color space to the second color space, and further processing the colors of the intermediate image in the second color space to perform overall color degradation processing on the original image to obtain a target image whose colors meet preset conditions includes: The intermediate image is converted from the first color space to the HSV color space; In the HSV color space, the saturation component is linearly adjusted according to the preset conditions to perform overall color degradation processing on the original image.
7. The method according to any one of claims 1-5, characterized in that, Also includes: The color degradation detection model is trained based on the target image to obtain a trained color degradation detection model.
8. The method according to claim 7, characterized in that, Also includes: The trained color degradation detection model is used to detect color degradation in the image to be detected, so as to determine the degree of color degradation in the image to be detected.
9. An image color processing apparatus, characterized in that, include: The determination module is used to determine the color distribution information of the original image in the first color space; The first degradation module is used to reduce the color categories of the original image according to the color distribution information and based on preset rules, so as to perform local color degradation processing on the original image and obtain an intermediate image; The second degradation module is used to convert the intermediate image from the first color space to the second color space, and further process the colors of the intermediate image in the second color space to perform overall color degradation processing on the original image to obtain a target image whose colors meet preset conditions. The further processing of the colors of the intermediate image in the second color space includes: linearly adjusting the saturation of the intermediate image according to preset conditions. The step of reducing the color categories of the original image based on the color distribution information and a preset rule to perform local color degradation processing on the original image to obtain an intermediate image includes: Based on the color distribution information, pixel pairs with a color distance less than a threshold are identified, wherein the color distance characterizes the degree of color similarity between two pixels in the pixel pair; Reduce the distance between the pixel pairs to decrease the number of color categories in the original image; The intermediate image is composed of pixel pairs after the distance has been reduced.
10. An electronic device, characterized in that, The electronic device includes: One or more processors; Storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-8.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-8.
Citation Information
Patent Citations
Method and apparatus for suppress glare and enhancing image in low illumination image
CN109064426A
Clothing color extraction method based on human body semantic segmentation
CN111612011A