Image processing methods and apparatuses, computer-readable storage media and electronic devices
By determining the dominant color of the image and using a histogram to generate a color enhancement curve to adjust pixel values, the problem of inconsistent image colors was solved, and image quality was improved.
Patent Information
- Application Number
- CN202211147887.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-19
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2042-09-19
AI Technical Summary
Existing image color enhancement schemes result in inconsistent colors and poor image quality in the enhanced images.
By determining the dominant color of the image to be processed, a color enhancement curve is generated using the histogram corresponding to the dominant color. The pixel values of the pixels corresponding to the dominant color are then adjusted based on this curve to avoid applying the same enhancement method to all pixels.
It improves the harmony and quality of image colors, avoids the problem of imprecise enhancement effects, and generates images with more balanced colors.
Smart Images

Figure CN115423727B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of imaging technology, and more specifically, to an image processing method, an image processing apparatus, a computer-readable storage medium, and an electronic device. Background Technology
[0002] With the development of imaging technology and the popularization of imaging equipment, users have increasingly higher requirements for image quality, resulting in the emergence of various image processing algorithms.
[0003] Currently, some image color enhancement solutions may result in inconsistent colors and poor image quality after enhancement. Summary of the Invention
[0004] This disclosure provides an image processing method, an image processing apparatus, a computer-readable storage medium, and an electronic device, thereby overcoming, at least to some extent, the problem of poor image quality after color enhancement.
[0005] According to a first aspect of this disclosure, an image processing method is provided, comprising: determining at least one dominant color of the image to be processed using color information of each pixel in the image to be processed; determining a histogram of the pixels corresponding to the dominant color, and determining a color enhancement curve corresponding to the dominant color using the histogram; and adjusting the pixel values of the pixels corresponding to the dominant color in combination with the color enhancement curve to generate a processed image.
[0006] According to a second aspect of this disclosure, an image processing apparatus is provided, comprising: a primary color determination module, configured to determine at least one primary color of the image to be processed using color information of each pixel in the image to be processed; an enhancement curve determination module, configured to determine a histogram of the pixels corresponding to the primary color, and to determine a color enhancement curve corresponding to the primary color using the histogram; and a pixel value adjustment module, configured to adjust the pixel values of the pixels corresponding to the primary color in combination with the color enhancement curve corresponding to the primary color, so as to generate a processed image.
[0007] According to a third aspect of this disclosure, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the image processing method described above.
[0008] According to a fourth aspect of this disclosure, an electronic device is provided, including a processor; and a memory for storing one or more programs, which, when executed by the processor, cause the processor to implement the image processing method described above.
[0009] In some embodiments of this disclosure, at least one dominant color of the image to be processed is determined, a histogram of the pixels corresponding to the dominant color is determined, a color enhancement curve corresponding to the dominant color is determined using the histogram, and the pixel values of the pixels corresponding to the dominant color are adjusted based on the color enhancement curve to generate the processed image. This disclosure distinguishes pixels in the image to be processed based on whether they are dominant colors. For pixels corresponding to dominant colors, the pixel values are adjusted based on the color enhancement curve corresponding to the dominant color. This avoids the problem of imprecise enhancement effects that may occur when using the same enhancement method for all pixels, resulting in more harmonious colors in the enhanced image and improved image quality.
[0010] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0011] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure. It is obvious that the drawings described below are merely some embodiments of this disclosure, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort. In the drawings:
[0012] Figure 1 A schematic diagram of the image processing stage according to an embodiment of the present disclosure is shown;
[0013] Figure 2 A flowchart illustrating an embodiment of the image processing method of this disclosure is shown schematically.
[0014] Figure 3 A schematic diagram of a clustering algorithm according to an embodiment of the present disclosure is shown;
[0015] Figure 4 A flowchart illustrating the entire process of the image processing scheme according to an embodiment of the present disclosure is shown schematically.
[0016] Figure 5 A block diagram of an image processing apparatus according to an embodiment of the present disclosure is shown schematically;
[0017] Figure 6 A block diagram of an electronic device according to an exemplary embodiment of the present disclosure is shown schematically. Detailed Implementation
[0018] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided to make this disclosure more comprehensive and complete, and to fully convey the concept of the example embodiments to those skilled in the art. The described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a full understanding of embodiments of this disclosure. However, those skilled in the art will recognize that the technical solutions of this disclosure can be practiced with one or more of the specific details omitted, or other methods, components, apparatus, steps, etc., can be employed. In other instances, well-known technical solutions are not shown or described in detail to avoid obscuring various aspects of this disclosure.
[0019] Furthermore, the accompanying drawings are merely illustrative of this disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0020] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all steps. For example, some steps may be broken down, while others may be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances. Furthermore, all the terms "first" and "second" used below are for distinction purposes only and should not be construed as limiting the scope of this disclosure.
[0021] In the process of image color enhancement, the same enhancement method can be applied to every pixel in the image. However, this approach may result in unrefined and inconsistent color reproduction in the processed image. Therefore, this disclosure provides a novel image processing scheme to improve the quality of the enhanced image to a certain extent.
[0022] The image processing scheme of this disclosure can be implemented by an electronic device. That is, the electronic device can execute each step of the image processing method described below, and the image processing apparatus described below can be configured within the electronic device. For example, the image processing scheme of this disclosure can be implemented by an image signal processor equipped in the electronic device. In addition, this disclosure does not limit the type of electronic device, and may include, but is not limited to, smartphones, tablets, smart wearable devices, personal computers, servers, etc.
[0023] Figure 1A schematic diagram illustrating the stage at which the image processing scheme of this disclosure embodiment is applied is shown. (Reference) Figure 1 The image to be processed in this embodiment can be an image captured by a camera module equipped with an electronic device, or an image acquired by the electronic device from an external source (i.e., another device). This disclosure does not limit the image source, image content, image size, etc. of the input image.
[0024] The image processing procedure of this disclosure can be used to process the image to be processed to obtain a color-enhanced image. Subsequently, the electronic device can send the color-enhanced image back to the ISP pipeline (Image Signal Processing Pipeline) to continue processing such as brightness enhancement, noise reduction, and recognition. The electronic device can also perform operations such as displaying, storing, and sending the color-enhanced image to other devices. This disclosure does not limit the subsequent processing of the color-enhanced image.
[0025] The image processing scheme of this disclosure can be applied to scenarios such as image capture and video stream processing to make image colors harmonious and improve image quality.
[0026] Figure 2 A flowchart illustrating an exemplary embodiment of the image processing method of this disclosure is shown schematically. Reference Figure 2 The image processing method may include the following steps:
[0027] S22. Using the color information of each pixel in the image to be processed, determine at least one dominant color of the image to be processed.
[0028] In the exemplary embodiments of this disclosure, the dominant color of the image to be processed is the color that occupies the main position among the colors of the image to be processed, and may also be referred to as the main color, subject color, primary color, etc.
[0029] Electronic devices can combine clustering methods to determine the dominant color of the image to be processed.
[0030] First, electronic devices can cluster the color information of each pixel in the image to be processed to obtain multiple first candidate colors.
[0031] Color information can be clustered using the k-means clustering algorithm. (Reference) Figure 3 Under initial conditions, multiple cluster centers are randomly selected, and color information is allocated to each cluster according to the nearest neighbor principle based on distance difference. The centroid of each cluster is recalculated using the averaging method, and used as the new cluster center for the next iteration. This iterative process is repeated until the distance the cluster center point moves is less than a set threshold or the number of iterations exceeds a set threshold, at which point the iteration terminates. Thus, the final cluster average value is used as the cluster center, thereby determining multiple first candidate colors.
[0032] Next, at least one primary color of the image to be processed can be determined based on multiple first candidate colors.
[0033] According to some embodiments of this disclosure, an electronic device can directly determine the first candidate color as the dominant color of the image to be processed. In other words, the dominant color of the image to be processed can be directly determined through clustering.
[0034] According to other embodiments of this disclosure, the electronic device can determine the color difference values between each pair of first candidate colors. These color difference values, also known as color difference distances, can be calculated using, for example, the CIE2000 color difference calculation method.
[0035] After determining the color difference value, it can be compared with a color difference threshold. If the color difference value is less than the color difference threshold, it indicates that the two or more first candidate colors are similar. In this case, the electronic device can merge the corresponding two or more first candidate colors into a second candidate color. If the color difference value is greater than the color threshold, it indicates that the two or more first candidate colors have a large color difference. In this case, the two or more first candidate colors are directly retained for subsequent processing. This disclosure does not limit the specific value of the color difference threshold.
[0036] Using the color merging scheme based on color difference values described above, a candidate color set can be formed by combining the second candidate color and the first candidate color that did not participate in the color merging. The electronic device can then determine at least one dominant color of the image to be processed from this candidate color set.
[0037] In one embodiment, the electronic device may determine each candidate color in the candidate color set as the dominant color of the image to be processed.
[0038] In another embodiment, the electronic device can determine the number of pixels corresponding to each candidate color in the candidate color set and compare the number of pixels with a quantity threshold. The quantity threshold can be determined based on the total number of pixels in the image to be processed, for example, 10% of the total number of pixels in the image to be processed. This disclosure does not limit the specific value of the quantity threshold. Specifically, the electronic device can determine candidate colors with a number of pixels greater than the quantity threshold as primary colors. It is understood that candidate colors with a number of pixels less than or equal to the quantity threshold are not primary colors.
[0039] According to further embodiments of this disclosure, after determining a plurality of first candidate colors, the electronic device can determine the number of pixels corresponding to each first candidate color and compare the number of pixels with a number threshold, which may be the same as the number threshold in the above embodiments. Specifically, the electronic device can determine the first candidate color with a number of pixels greater than the number threshold as the primary color. It is understood that the first candidate color with a number of pixels less than or equal to the number threshold is not the primary color.
[0040] In addition to the above-mentioned method of combining clustering to determine the main color, electronic devices can also convert the number of RGB three-channel images to the HSV domain and then determine the main color by statistical saturation histogram. This disclosure does not limit the specific process.
[0041] Furthermore, electronic devices can also count the number of pixels belonging to each color in the image to be processed and determine the dominant color based on the statistical results. Specifically, the color with the largest number of pixels can be determined as the dominant color of the image to be processed. Alternatively, the colors can be sorted in descending order of pixel count, and the top n colors can be determined as the dominant colors of the image to be processed, where n can be a positive integer greater than 1. Alternatively, the colors with a pixel count greater than the aforementioned threshold can be directly determined as the dominant colors of the image to be processed.
[0042] S24. Determine the histogram of the pixels corresponding to the main color, and use the histogram to determine the color enhancement curve corresponding to the main color.
[0043] After determining the primary color, for each primary color, the electronic device can identify the pixels belonging to that primary color and generate a histogram of those pixels. For the pixel histogram, the vertical axis can be the number of pixels, and the horizontal axis can be the pixel value. For example, for 8-bit data, the pixel value range on the horizontal axis can be 0-255.
[0044] Electronic devices can use histograms to determine the color enhancement curve corresponding to the primary color.
[0045] According to some embodiments of this disclosure, histograms can be processed using algorithms such as CLAHE (Limited Contrast Adaptive Histogram Equalization) to obtain color enhancement curves corresponding to the primary color.
[0046] According to other embodiments of this disclosure, when there are multiple primary colors in the image to be processed, firstly, the electronic device can perform histogram equalization on the histogram to generate an intermediate enhancement curve. Secondly, the electronic device can determine the statistical values of the color difference values between each primary color. The statistical values of the color difference values mentioned in this disclosure may include the mean and / or the variance of the color difference values between each primary color.
[0047] Next, the electronic device can use the statistical values of the color difference to filter the intermediate enhancement curve to determine the color enhancement curve corresponding to the main color. Specifically, the statistical values of the color difference can be used as parameters for Gaussian filtering to filter the intermediate enhancement curve.
[0048] The mean of the color difference values is used to determine the approximate adjustment range of the color enhancement curve, while the variance of the color difference values can be used to achieve fine curve adjustments.
[0049] By adjusting the enhancement curve using statistical values of color difference, the algorithm adds constraints to the relationship between the main colors, which makes the main colors of the subsequently adjusted image more balanced and avoids situations where the color contrast is too large or too small.
[0050] Furthermore, the intermediate enhancement curve can be adjusted based on one or more elements of the brightness, saturation, and specific primary color of the image to be processed, so as to obtain a color enhancement curve corresponding to the primary color to be applied to subsequent processing. This disclosure does not limit this.
[0051] S26. Based on the color enhancement curve corresponding to the main color, adjust the pixel values of the pixels corresponding to the main color to generate the processed image.
[0052] According to some embodiments of this disclosure, an electronic device can use a color enhancement curve corresponding to a primary color to adjust the pixel value of a pixel corresponding to that primary color. For example, if the pixel value of a pixel corresponding to the primary color is V0, the pixel value V1 can be mapped to it via the color enhancement curve corresponding to that primary color. Replacing V0 with V1 achieves the adjustment of the pixel value.
[0053] By iterating through all the pixels of the primary color and performing the color enhancement curve mapping operation, the color enhancement processing of the pixels of the primary color in the image to be processed can be completed.
[0054] For image regions in the image to be processed that are not of the dominant color, no processing is required. Alternatively, interpolation can be performed using neighboring image regions that belong to the dominant color. Alternatively, color adjustment can be performed using the default mapping curve. This disclosure does not impose any limitations on these methods.
[0055] To avoid or reduce the problem of excessive color distortion caused by large color differences between adjacent primary color image areas after color enhancement, the pixel values of pixels can be adjusted by combining the adjacent primary colors.
[0056] The primary color includes a first primary color and at least one second primary color that is adjacent to the first primary color in position. For a target pixel belonging to the first primary color (any pixel corresponding to the first primary color), on one hand, the electronic device can adjust the pixel value of the target pixel using the color enhancement curve corresponding to the first primary color to obtain a first intermediate pixel value. On the other hand, the electronic device can adjust the pixel value of the target pixel using the color enhancement curve corresponding to the second primary color to obtain a second intermediate pixel value. It is understood that the number of second intermediate pixel values is the same as the number of second primary colors.
[0057] Next, the electronic device can fuse the first intermediate pixel value with the second intermediate pixel value to determine the adjusted pixel value of the target pixel.
[0058] Specifically, the electronic device can use a weight determined by the distance of the target pixel to the image region corresponding to the second primary color to perform a weighted average of the first intermediate pixel value and at least one second intermediate pixel value to determine the pixel value adjustment result of the target pixel. The weight of the first intermediate pixel value can be configured to 1 or other adjustable weights. It is understood that the weight of the first intermediate pixel value is usually configured to be greater than the weight of the second intermediate pixel value.
[0059] For example, the distance from the target pixel to the image region corresponding to the second primary color can be used as the weight. First, a weighted average of at least one second intermediate pixel value is calculated to obtain a third intermediate pixel value. Then, a weighted average of the first and third intermediate pixel values is calculated to obtain the adjusted pixel value of the target pixel. In this example of weighted averaging in two steps, the weight of the second intermediate pixel value can differ from the weight of the second intermediate pixel value in the single-weighted averaging scheme in the previous example. Similarly, the weight of the first intermediate pixel value is usually configured to be greater than the weight of the third intermediate pixel value.
[0060] The following is for reference. Figure 4 The image processing process of the embodiments of this disclosure will be described.
[0061] In step S402, the electronic device can acquire the image to be processed.
[0062] In step S404, the electronic device can cluster the color information of each pixel in the image to be processed to obtain multiple first candidate colors.
[0063] In step S406, the electronic device can determine the color difference value between the first candidate colors.
[0064] In step S408, the electronic device can determine whether the color difference value determined in step S406 is less than the color difference threshold. If it is less, then step S410 is executed using the first candidate color; if it is not less, then step S412 is executed using the first candidate color.
[0065] In step S410, the electronic device can merge the first candidate color into the second candidate color.
[0066] In step S412, the electronic device may determine a candidate color set, which includes secondary candidate colors and unmerged first candidate colors.
[0067] In step S414, the electronic device can determine the number of pixels corresponding to the candidate colors in the candidate color set.
[0068] In step S416, the electronic device can compare the number of pixels determined in step S414 with a quantity threshold. If the number of pixels is greater than the quantity threshold, step S418 is executed to determine the candidate color as the primary color; if the number of pixels is less than the quantity threshold, step S414 is returned to execute the next step of counting the number of pixels corresponding to the candidate color.
[0069] In step S420, the electronic device can determine the histogram of the pixels corresponding to the main color.
[0070] In step S422, the electronic device can use the histogram to generate an intermediate enhancement curve.
[0071] In step S424, the electronic device can adjust the intermediate enhancement curve into a color enhancement curve by using the statistical value of the color difference between the main colors.
[0072] In step S426, the electronic device can adjust the pixel value of the pixel corresponding to the main color using the color enhancement curve of the main color and the color enhancement curve of the adjacent main colors.
[0073] In step S428, the electronic device can output a color-enhanced image corresponding to the image to be processed.
[0074] The image processing described above, as disclosed in this invention, makes the color representation of the enhanced image more harmonious and balanced, thereby effectively improving image quality.
[0075] It should be noted that although the steps of the method in this disclosure are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in that specific order, or that all the steps shown must be performed to achieve the desired result. Additional or alternative steps may be omitted, multiple steps may be combined into one step, and / or a step may be broken down into multiple steps.
[0076] Furthermore, this example embodiment also provides an image processing apparatus.
[0077] Figure 5 A block diagram of an image processing apparatus according to an exemplary embodiment of the present disclosure is shown schematically. Reference Figure 5 The image processing apparatus 5 according to an exemplary embodiment of the present disclosure may include a main color determination module 51, an enhancement curve determination module 53, and a pixel value adjustment module 55.
[0078] Specifically, the main color determination module 51 can be used to determine at least one main color of the image to be processed using the color information of each pixel in the image to be processed; the enhancement curve determination module 53 can be used to determine the histogram of the pixel corresponding to the main color, and use the histogram to determine the color enhancement curve corresponding to the main color; the pixel value adjustment module 55 can be used to adjust the pixel value of the pixel corresponding to the main color in combination with the color enhancement curve corresponding to the main color, so as to generate the processed image.
[0079] According to an exemplary embodiment of the present disclosure, the main color determination module 51 can be configured to perform: clustering the color information of each pixel in the image to be processed to obtain a plurality of first candidate colors; and determining at least one main color of the image to be processed based on the plurality of first candidate colors.
[0080] According to an exemplary embodiment of the present disclosure, the process by which the primary color determination module 51 determines at least one primary color of the image to be processed based on a plurality of first candidate colors can be configured to perform: determining the color difference value between each of the first candidate colors; if the color difference value is less than a color difference threshold, merging the corresponding two or more first candidate colors into a second candidate color; wherein the second candidate color and the first candidate colors that did not participate in the color merging constitute a candidate color set; and determining at least one primary color of the image to be processed from the candidate color set.
[0081] According to an exemplary embodiment of the present disclosure, the process by which the main color determination module 51 determines at least one main color of the image to be processed from the candidate color set can be configured to perform: determining the number of pixels corresponding to each candidate color in the candidate color set; and determining the candidate color whose number of pixels is greater than a number threshold as the main color.
[0082] According to an exemplary embodiment of the present disclosure, the process by which the main color determination module 51 determines at least one main color of the image to be processed based on a plurality of first candidate colors can also be configured to perform: determining the number of pixels corresponding to each first candidate color; and determining the first candidate color whose number of pixels is greater than a number threshold as the main color.
[0083] According to an exemplary embodiment of this disclosure, there are multiple primary colors. In this case, the process by which the enhancement curve determination module 53 determines the color enhancement curve corresponding to the primary color using a histogram can be configured to perform: histogram equalization processing on the histogram to generate intermediate enhancement curves; determining statistical values of color difference values between each primary color; the statistical values of color difference values include the mean and / or variance of color difference values; and filtering the intermediate enhancement curves using the statistical values of color difference values to determine the color enhancement curve corresponding to the primary color.
[0084] According to an exemplary embodiment of this disclosure, the primary color includes a first primary color and at least one second primary color that is geographically adjacent to the first primary color. In this case, the pixel value adjustment module 55 can be configured to perform the following: for a target pixel belonging to the first primary color, adjust the pixel value of the target pixel using a color enhancement curve corresponding to the first primary color to obtain a first intermediate pixel value; adjust the pixel value of the target pixel using a color enhancement curve corresponding to the second primary color to obtain at least one second intermediate pixel value whose number is the same as that of the second primary color; and perform a weighted average of the first intermediate pixel value and the at least one second intermediate pixel value based on a weight determined according to the distance of the target pixel from the second primary color to determine the pixel value adjustment result of the target pixel.
[0085] Since the functional modules of the image processing apparatus of this disclosure are the same as those in the above-described method embodiments, they will not be described again here.
[0086] Figure 6 A schematic diagram of an electronic device suitable for implementing exemplary embodiments of the present disclosure is shown. It should be noted that... Figure 6 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0087] The electronic device disclosed herein includes at least a processor and a memory, the memory being used to store one or more programs, which, when executed by the processor, enable the processor to implement the image processing method of the exemplary embodiments of this disclosure.
[0088] Specifically, such as Figure 6As shown, the electronic device 60 may include: a processor 610, an internal memory 621, an external memory interface 622, a Universal Serial Bus (USB) interface 630, a charging management module 640, a power management module 641, a battery 642, antenna 1, antenna 2, a mobile communication module 650, a wireless communication module 660, an audio module 670, a sensor module 680, a display screen 690, a camera module 691, an indicator 692, a motor 693, buttons 694, and a Subscriber Identification Module (SIM) card interface 695, etc. The sensor module 680 may include a depth sensor, a pressure sensor, a gyroscope sensor, a barometric pressure sensor, a magnetic sensor, an accelerometer, a distance sensor, a proximity sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, and a bone conduction sensor, etc.
[0089] It is understood that the structures illustrated in the embodiments of this disclosure do not constitute a specific limitation on the electronic device 60. In other embodiments of this disclosure, the electronic device 60 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0090] Processor 610 may include one or more processing units, such as an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural network processing unit (NPU). Different processing units may be independent devices or integrated into one or more processors. Additionally, processor 610 may include memory for storing instructions and data.
[0091] The electronic device 60 can implement shooting functions through an ISP, camera module 691, video codec, GPU, display screen 690, and application processor. In some embodiments, the electronic device 60 may include one or N camera modules 691, where N is a positive integer greater than 1. If the electronic device 60 includes N cameras, one of the N cameras is the main camera.
[0092] Internal memory 621 can be used to store executable program code, including instructions. Internal memory 621 may include a program storage area and a data storage area. External memory interface 622 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of electronic device 60.
[0093] This disclosure also provides a computer-readable storage medium, which may be included in the electronic device described in the above embodiments; or it may exist independently and not assembled into the electronic device.
[0094] Computer-readable storage media can be, for example—but not limited to—electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having 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 thereof. In this disclosure, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0095] A computer-readable storage medium can be sent, propagated, or transmitted for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable storage medium can be transmitted using any suitable medium, including but not limited to: wireless, wireline, optical fiber, RF, etc., or any suitable combination thereof.
[0096] A computer-readable storage medium carries one or more programs that, when executed by an electronic device, cause the electronic device to perform the methods described in the embodiments of this disclosure.
[0097] 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 a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may 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.
[0098] The units described in the embodiments of this disclosure can be implemented in software or hardware, and the described units can also be located in a processor. The names of these units do not necessarily limit the unit itself.
[0099] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, terminal device, or network device, etc.) to execute the methods according to the embodiments of this disclosure.
[0100] Furthermore, the above figures are merely illustrative of the processes included in the method according to exemplary embodiments of this disclosure and are not intended to be limiting. It is readily understood that the processes shown in the above figures do not indicate or limit the temporal order of these processes. Additionally, it is readily understood that these processes may be executed synchronously or asynchronously, for example, in multiple modules.
[0101] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.
[0102] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the disclosure herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the claims.
[0103] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. An image processing method, characterized in that, include: Using the color information of each pixel in the image to be processed, at least one primary color of the image to be processed is determined; wherein, the primary color includes a first primary color and at least one second primary color that is adjacent to the first primary color in position; Determine the histogram of the pixels corresponding to the main color, and use the histogram to determine the color enhancement curve corresponding to the main color; For a target pixel belonging to the first primary color, the pixel value of the target pixel is adjusted using the color enhancement curve corresponding to the first primary color to obtain a first intermediate pixel value; the pixel value of the target pixel is adjusted using the color enhancement curve corresponding to the second primary color to obtain at least one second intermediate pixel value with the same number as the second primary color; and a weighted average is performed on the first intermediate pixel value and the at least one second intermediate pixel value based on the weight determined according to the distance of the target pixel from the second primary color to determine the pixel value adjustment result of the target pixel, so as to generate the processed image.
2. The image processing method according to claim 1, characterized in that, Using the color information of each pixel in the image to be processed, determining at least one dominant color of the image to be processed includes: Cluster the color information of each pixel in the image to be processed to obtain multiple first candidate colors; At least one primary color of the image to be processed is determined based on the plurality of first candidate colors.
3. The image processing method according to claim 2, characterized in that, Determining at least one primary color of the image to be processed based on the plurality of first candidate colors includes: Determine the color difference value between each of the first candidate colors; If the color difference value is less than the color difference threshold, then two or more corresponding first candidate colors are merged into a second candidate color; wherein, the second candidate color and the first candidate colors that did not participate in the color merging constitute a candidate color set; Determine at least one primary color of the image to be processed from the candidate color set.
4. The image processing method according to claim 3, characterized in that, Determining at least one dominant color of the image to be processed from the candidate color set includes: Determine the number of pixels corresponding to each candidate color in the candidate color set; Candidate colors whose number of pixels exceeds a certain threshold are identified as the primary color.
5. The image processing method according to claim 2, characterized in that, Determining at least one primary color of the image to be processed based on the plurality of first candidate colors includes: Determine the number of pixels corresponding to each of the first candidate colors; The first candidate color whose number of pixels is greater than the number threshold is determined as the main color.
6. The image processing method according to claim 1, characterized in that, The number of primary colors is multiple; wherein, the color enhancement curve corresponding to the primary color is determined using the histogram, including: The histogram is subjected to histogram equalization to generate an intermediate enhancement curve; Determine the statistical values of the color difference values between each of the primary colors; the statistical values of the color difference values include the mean and / or the variance of the color difference values. The intermediate enhancement curve is filtered using the statistical values of the color difference to determine the color enhancement curve corresponding to the main color.
7. An image processing apparatus, characterized in that, include: The primary color determination module is used to determine at least one primary color of the image to be processed using the color information of each pixel in the image to be processed; wherein, the primary color includes a first primary color and at least one second primary color that is adjacent to the first primary color in position; The enhancement curve determination module is used to determine the histogram of the pixels corresponding to the main color, and to determine the color enhancement curve corresponding to the main color using the histogram; The pixel value adjustment module is used to adjust the pixel value of a target pixel belonging to the first primary color using the color enhancement curve corresponding to the first primary color to obtain a first intermediate pixel value; and to adjust the pixel value of the target pixel using the color enhancement curve corresponding to the second primary color to obtain at least one second intermediate pixel value with the same number as the second primary color; and to perform a weighted average of the first intermediate pixel value and the at least one second intermediate pixel value based on a weight determined according to the distance of the target pixel from the second primary color to determine the pixel value adjustment result of the target pixel, so as to generate the processed image.
8. 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 image processing method as described in any one of claims 1 to 6.
9. An electronic device, characterized in that, include: processor; A memory for storing one or more programs, which, when executed by the processor, cause the processor to implement the image processing method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Color enhancement method and device
CN111899182A
Image main color recognition method and device, electronic equipment and storage medium
CN112509068A