Disclosure of Invention
The disclosure provides a color gamut conversion method and device, an electronic device and a storage medium.
According to a first aspect of embodiments of the present disclosure, there is provided a color gamut conversion method, including:
acquiring a first pixel value of an image to be processed in a native color gamut;
converting the first pixel value of the native color gamut into a coordinate value of a preset color space; the chroma uniformity of the preset color space is better than that of the color space where the first pixel value is located;
carrying out interpolation processing on the coordinate values of the preset color space;
and obtaining a second pixel value of the target color gamut based on the coordinate value after the preset color space interpolation processing.
Optionally, the converting the first pixel value of the native color gamut into a coordinate value of a preset color space includes:
converting a first pixel value of the native gamut into a first coordinate value of an XYZ color space;
obtaining the coordinate value of the preset color space based on the first coordinate value of the XYZ color space.
Optionally, the obtaining a second pixel value of the target color gamut based on the coordinate value after the preset color space interpolation processing includes:
converting the coordinate value after interpolation processing of the preset color space into a second coordinate value of the XYZ color space;
obtaining the second pixel value of the target color gamut based on a second coordinate value of the XYZ color space.
Optionally, the performing interpolation processing on the coordinate values of the preset color space includes:
and carrying out linear interpolation processing or cubic interpolation processing on the coordinate values of the preset color space.
Optionally, the preset color space is a Lab color space.
According to a second aspect of the embodiments of the present disclosure, there is provided a color gamut conversion device including:
the acquisition module is configured to acquire a first pixel value of the image to be processed in the native color gamut;
a conversion module configured to convert the first pixel value of the native color gamut into a coordinate value of a preset color space; the chroma uniformity of the preset color space is better than that of the color space where the first pixel value is located;
the processing module is configured to perform interpolation processing on the coordinate values of the preset color space;
and the obtaining module is configured to obtain a second pixel value of the target color gamut based on the coordinate value after the preset color space interpolation processing.
Optionally, the conversion module is configured to convert the first pixel value of the native color gamut into a first coordinate value of an XYZ color space; obtaining the coordinate value of the preset color space based on the first coordinate value of the XYZ color space.
Optionally, the processing module is configured to convert the coordinate value after interpolation processing in the preset color space into a second coordinate value in the XYZ color space; obtaining the second pixel value of the target color gamut based on a second coordinate value of the XYZ color space.
Optionally, the processing module is configured to perform linear interpolation processing or cubic interpolation processing on the coordinate values of the preset color space.
Optionally, the preset color space is a Lab color space.
According to a third aspect of the embodiments of the present disclosure, there is provided an electronic apparatus including:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to perform the color gamut conversion method as described in the first aspect above.
According to a fourth aspect of embodiments of the present disclosure, there is provided a storage medium including:
the instructions in the storage medium, when executed by a processor of an electronic device, enable the electronic device to perform the color gamut conversion method as described in the first aspect above.
The technical scheme provided by the embodiment of the disclosure can have the following beneficial effects:
in the embodiment of the disclosure, the chroma of the preset color space is relatively uniform, so that interpolation processing is performed in the color space with more uniform chroma, and the difference between each coordinate value after interpolation processing and each coordinate value before interpolation is not great; and through an interpolation mode, transition can be generated among pixel points with larger pixel value difference in the image to be processed. Therefore, when the second pixel value of the target color gamut is obtained based on the coordinate value after the preset color space interpolation processing, the obtained second pixel values of all the pixel points are smoother, so that the transition of the color and the brightness of the image to be processed is more natural when the image to be processed is converted from the native color gamut to the target color gamut for display, and the discomfort caused to the user when the color and the brightness are changed is relieved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
Fig. 1 is a flowchart illustrating a first color gamut conversion method according to an embodiment of the disclosure, and as shown in fig. 1, the color gamut conversion method includes the following steps:
s11, acquiring a first pixel value of the image to be processed in the native color gamut;
s12, converting the first pixel value of the native color gamut into a coordinate value of a preset color space; the chroma uniformity of the preset color space is better than that of the color space where the first pixel value is located;
s13, carrying out interpolation processing on the coordinate values of the preset color space;
and S14, obtaining a second pixel value of the target color gamut based on the coordinate value after the preset color space interpolation processing.
The color gamut conversion method is applied to the electronic equipment, and the electronic equipment comprises the following steps: a mobile device and a stationary device; the mobile device includes: a mobile phone, a tablet computer, or a wearable device, etc. The stationary device includes, but is not limited to, a Personal Computer (PC).
The screen calibration method is applied to electronic equipment, and the electronic equipment comprises the following steps: mobile devices and stationary devices. The mobile device includes: mobile phones, tablet computers or wearable devices, etc.; the stationary device includes, but is not limited to, a Personal Computer (PC).
The electronic device includes a display screen for displaying an image. However, when the electronic device displays an image, color gamut conversion may be required due to different display requirements, and the color gamut refers to a range of colors that can be presented. Wherein, different display requirements include: for example, the image is an image in the sRGB color gamut, and the color gamut of the OLED screen is larger than the sRGB color gamut, so when the sRGB image is displayed by the OLED screen, color gamut conversion is required. For another example, in the image processing software, it may be necessary to perform the corresponding image processing function in a specific color gamut, and therefore, it is also necessary to convert an image that does not belong to the specific color gamut into a display in the specific color gamut.
In the embodiments of the present disclosure, the color gamut before conversion is referred to as a native color gamut, and the color gamut after conversion is referred to as a target color gamut. For example, the native color gamut may be any one of an sRGB color gamut, a Display-P3 color gamut, an NTSC color gamut, or an AdobeRGB color gamut, and the target color gamut and the native color gamut belong to different color gamuts.
When performing color gamut conversion, usually, a table is looked up based on the pixel values of each node of the native color gamut before conversion stored in the 3D LUT, and a pixel value in the target color gamut after conversion corresponding to the node is obtained, where the node refers to a search object in the 3D LUT, and the object represents the pixel value corresponding to the pixel point. The 3D LUT may include pixel values of, for example, 9 × 9, or 17 × 17 nodes. Specifically, the 3D LUT stores red (R), green (G), and blue (B) pixel values of the input node before conversion (for example, expressed as Rin/Gin/Bin), and also stores red, green, and blue pixel values in the target color gamut corresponding to the node (for example, expressed as Rout/Gout/Bout), thereby facilitating the electronic device to perform conversion based on the pixel values stored in the 3D LUT and corresponding to the input node before conversion and after conversion.
In step S11, the electronic device obtains a first pixel value of the to-be-processed image in the native color gamut. The image to be processed refers to an image to be subjected to color gamut conversion display.
It should be noted that, in the embodiment of the present disclosure, the first pixel value of the to-be-processed image in the native color gamut may be an RGB color space. Further, the second pixel value of the target color gamut may also be an RGB color space.
In step S12, the electronic device converts the first pixel value of the native color gamut into coordinate values of the predetermined color space. The preset color space is different from the color space in which the first pixel value is located, and the chroma uniformity of the preset color space is better than that of the first pixel value. For example, the preset color space may be a Lab color space or a LUV color space, etc. The chromaticity uniformity characterizes the color difference between any two adjacent coordinates with equal spacing in the color space. Preferably, the chromaticity of the preset color space is absolutely uniform, that is, the color difference between any two adjacent coordinates with equal spacing in the preset color space is equal.
In one embodiment, the predetermined color space is a Lab color space.
In the Lab color space, any one of the coordinate values of the L coordinate axis, the a coordinate axis and the b coordinate axis does not cause a large color change when, for example, one unit is changed, and then the perception of human eyes is relatively uniform without such a large change difference.
In step S13, the electronic apparatus performs interpolation processing on the coordinate values of the preset color space, thereby obtaining interpolated coordinate values in the preset color space.
It should be noted that, in an embodiment of the present disclosure, the performing interpolation processing on the coordinate values of the preset color space includes:
and carrying out linear interpolation processing or cubic interpolation processing on the coordinate values of the preset color space.
Of course, when performing interpolation processing, bilinear interpolation, nearest interpolation, and other modes may also be selected, and this disclosure does not specifically limit this.
In step S14, based on the coordinate values after the preset color space interpolation processing, the second pixel value of the target color gamut can be obtained.
It should be noted that, in the embodiment of the present disclosure, because there is a corresponding relationship between the preset color space and the RGB color space, the interpolation processing of the preset color space also affects the pixel values of the RGB color space, and the first pixel value of the native color gamut before interpolation and the second pixel value of the target color gamut after interpolation also have an interpolation mapping relationship.
Illustratively, if the predetermined color space is a Lab color space. Before interpolation, the coordinate value of the preset color space corresponding to the first pixel value is (L, a, b), and the coordinate value obtained by performing interpolation processing based on the interpolation function in each coordinate system is (L, a1, b1), which can be expressed as:
wherein f is1Corresponding to the interpolation function in L coordinate, f2Corresponding to the interpolation function in the a coordinate, f3Corresponding to the interpolation function in b-coordinate. It should be noted that, in the embodiment of the present disclosure, three interpolation functions f1、f2、f3May be the same or different, and the disclosure is not limited thereto.
Based on equation (1), the first pixel value (RGB) of the image to be processed in the native color gamut also has a mapping relationship with the second pixel value (R1G1B1) in the target color gamut as follows:
as described above, the chromaticity of the preset color space is relatively uniform, so that interpolation processing is performed in the color space with relatively uniform chromaticity, and the difference between each coordinate value after interpolation processing and each coordinate value before interpolation is not great; and through an interpolation mode, transition can be generated among pixel points with larger pixel value difference in the image to be processed. Therefore, when the second pixel value of the target color gamut is obtained based on the coordinate value after the preset color space interpolation processing, the obtained second pixel values of all the pixel points are smoother, so that the transition of the color and the brightness of the image to be processed is more natural when the image to be processed is converted from the native color gamut to the target color gamut for display, and the discomfort caused to the user when the color and the brightness are changed is relieved.
Fig. 2 is a flowchart of a color gamut conversion method shown in the embodiment of the present disclosure, and as shown in fig. 2, step S12 in fig. 1 may include:
S12A, converting the first pixel value of the native color gamut into a first coordinate value of an XYZ color space;
S12B, obtaining the coordinate value of the preset color space based on the first coordinate value of the XYZ color space.
In this embodiment, the color space in which the first pixel value of the native color gamut is located is an RGB color space, and in order to convert the first pixel value of the RGB color space into a preset color space with uniform chromaticity, the conversion is required through an XYZ color space.
In this regard, in step S12A, the present disclosure first converts the first pixel values of the native color gamut into first coordinate values of the XYZ color space. Specifically, the first coordinate value may be obtained by a first predetermined transformation matrix. If the first predetermined transformation matrix is D1, the first coordinate value is obtained by multiplying D1 by the first pixel value (including R/G/B color components), wherein D1 is shown in the following formula:
D1=|RGBtoXYZ| (3)
where D1 is a 3 x 3 matrix.
In step S12B, the electronic device obtains coordinate values of a preset color space based on the first coordinate values of the XYZ color space. Specifically, the coordinate values of the preset color space can be obtained through the second preset transformation matrix. If the second predetermined transformation matrix is D2, the coordinate values in the predetermined space can be obtained by multiplying D2 by the first coordinate values.
If the predetermined color space is a Lab color space, D2 is shown as follows:
D2=|XYZtoLAB| (4)
wherein D2 is a 3 x 3 matrix
Fig. 3 is a flowchart illustrating a method for converting color gamut according to an embodiment of the disclosure, and as shown in fig. 3, step S14 in fig. 2 may include:
S14A, converting the coordinate value after interpolation processing of the preset color space into a second coordinate value of the XYZ color space;
S14B, obtaining the second pixel value of the target color gamut based on the second coordinate value of the XYZ color space.
In this embodiment, when conversion to the RGB color space is performed based on the coordinate values after the interpolation processing, conversion by the XYZ color space is also required.
In contrast, in step S14A, the present disclosure converts the coordinate values after the interpolation processing in the preset color space into the second coordinate values in the XYZ color space. Specifically, the second coordinate value may be obtained by a third predetermined transformation matrix. If the third predetermined transformation matrix is D3, the second coordinate value can be obtained by multiplying the coordinate values after interpolation processing of D3 and the predetermined color space. If the predetermined color space is a Lab color space, D3 is shown as follows:
D3=|LABtoXYZ| (5)
where D3 is a 3 x 3 matrix.
In step S14B, the electronic device obtains a second pixel value of the target color gamut based on the second coordinate value of the XYZ color space. Specifically, the second pixel value of the RGB color space may be obtained by a fourth predetermined conversion matrix. If the fourth predetermined transformation matrix is D4, the second pixel value is obtained by multiplying D4 by the second coordinate value. Wherein D4 is shown in the following formula:
D4=|XYZtoRGB| (6)
where D4 is a 3 x 3 matrix.
Based on the above process of fig. 3, taking the first pixel value as RGB, the second pixel value in the target color gamut as R1G1B1, and the preset color space as Lab color space as an example, the whole gamut conversion process can be represented by the following formula:
it can be understood that the present disclosure adopts a manner of interpolation in the preset color space, so that the color and brightness transition is more natural when the image to be processed is converted from the native color gamut to the target color gamut for display, thereby alleviating discomfort caused to the user when the color and brightness change.
Fig. 4 is a diagram illustrating a color gamut conversion device according to an exemplary embodiment. Referring to fig. 4, in an alternative embodiment, the apparatus further comprises:
an obtaining module 101 configured to obtain a first pixel value of an image to be processed in a native color gamut;
a conversion module 102 configured to convert the first pixel value of the native color gamut into a coordinate value of a preset color space; the chroma uniformity of the preset color space is better than that of the color space where the first pixel value is located;
a processing module 103 configured to perform interpolation processing on the coordinate values of the preset color space;
an obtaining module 104 configured to obtain a second pixel value of the target color gamut based on the coordinate value after the preset color space interpolation processing.
Optionally, the conversion module 102 is configured to convert the first pixel value of the native color gamut into a first coordinate value of an XYZ color space; obtaining the coordinate value of the preset color space based on the first coordinate value of the XYZ color space.
Optionally, the processing module 103 is configured to convert the coordinate values after interpolation processing in the preset color space into second coordinate values in the XYZ color space; obtaining the second pixel value of the target color gamut based on a second coordinate value of the XYZ color space.
Optionally, the processing module 103 is configured to perform linear interpolation processing or cubic interpolation processing on the coordinate values of the preset color space.
Optionally, the preset color space is a Lab color space.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Fig. 5 is a block diagram illustrating an electronic device apparatus 800 in accordance with an example embodiment. For example, the device 800 may be a mobile phone, a mobile computer, etc.
Referring to fig. 5, the apparatus 800 may include one or more of the following components: processing component 802, memory 804, power component 806, multimedia component 808, audio component 810, input/output (I/O) interface 812, sensor component 814, and communication component 816.
The processing component 802 generally controls overall operation of the device 800, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing components 802 may include one or more processors 820 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 802 can include one or more modules that facilitate interaction between the processing component 802 and other components. For example, the processing component 802 can include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.
The memory 804 is configured to store various types of data to support operation at the device 800. Examples of such data include instructions for any application or method operating on device 800, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 804 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
Power components 806 provide power to the various components of device 800. The power components 806 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for the device 800.
The multimedia component 808 includes a screen that provides an output interface between the device 800 and a user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front facing camera and/or a rear facing camera. The front-facing camera and/or the rear-facing camera may receive external multimedia data when the device 800 is in an operating mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 810 is configured to output and/or input audio signals. For example, the audio component 810 includes a Microphone (MIC) configured to receive external audio signals when the apparatus 800 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may further be stored in the memory 804 or transmitted via the communication component 816. In some embodiments, audio component 810 also includes a speaker for outputting audio signals.
The I/O interface 812 provides an interface between the processing component 802 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor assembly 814 includes one or more sensors for providing various aspects of state assessment for the device 800. For example, the sensor assembly 814 may detect the open/closed state of the device 800, the relative positioning of the components, such as a display and keypad of the apparatus 800, the sensor assembly 814 may also detect a change in position of the apparatus 800 or a component of the apparatus 800, the presence or absence of user contact with the apparatus 800, orientation or acceleration/deceleration of the apparatus 800, and a change in temperature of the apparatus 800. Sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 816 is configured to facilitate communications between the apparatus 800 and other devices in a wired or wireless manner. The device 800 may access a wireless network based on a communication standard, such as Wi-Fi, 2G, or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the apparatus 800 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer-readable storage medium comprising instructions, such as the memory 804 comprising instructions, executable by the processor 820 of the device 800 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
A non-transitory computer readable storage medium in which instructions, when executed by a processor of an electronic device, enable the electronic device to perform a method of color gamut conversion, the method comprising:
acquiring a first pixel value of an image to be processed in a native color gamut;
converting the first pixel value of the native color gamut into a coordinate value of a preset color space; the chroma uniformity of the preset color space is better than that of the color space where the first pixel value is located;
carrying out interpolation processing on the coordinate values of the preset color space;
and obtaining a second pixel value of the target color gamut based on the coordinate value after the preset color space interpolation processing.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.