Conversion method and electronic equipment

By using normalization and difference calculation methods, efficient conversion between the RBCY and HSV color spaces is achieved, solving the problem of color information conversion and making it suitable for color presentation in electronic devices and adaptation to other color spaces.

CN121922058APending Publication Date: 2026-04-24SHENZHEN INTELLIROCKS TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN INTELLIROCKS TECH CO LTD
Filing Date
2025-10-23
Publication Date
2026-04-24

AI Technical Summary

Technical Problem

There is a lack of effective methods in the existing technology to convert color information between the RBCY color space and the HSV color space, especially the color space conversion problem when adapting to display devices.

Method used

By normalizing the red, blue, indigo, and yellow components of the RBCY color space, calculating the differences and extreme values, and combining the absolute values ​​and ratios of the differences and extreme values, the hue, saturation, and lightness values ​​in the HSV color space are determined. In the conversion from the HSV color space to the RBCY color space, the hue values ​​are scaled and rounded, and combined with the saturation and lightness values, the color information is converted.

Benefits of technology

It achieves efficient conversion between RBCY and HSV color spaces, simplifies the calculation process, reduces the computational load of complex trigonometric functions, and is suitable for color rendering in electronic devices and conversion between other color spaces.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121922058A_ABST
    Figure CN121922058A_ABST
Patent Text Reader

Abstract

The invention discloses a conversion method and electronic equipment. The conversion method comprises the following steps: acquiring third color information in an HSV color space; the third color information comprises a second hue value, a second saturation value and a second lightness value; if the second saturation value is greater than 0, zooming the second hue value to [0, M] to obtain a first intermediate value; rounding the first intermediate value to obtain a second intermediate value; calculating a difference value between the first intermediate value and the second intermediate value to obtain a third intermediate value; determining a red proportion, a blue proportion, an indigo proportion and a yellow proportion corresponding to the third color information according to the second intermediate value, the third intermediate value and the second saturation value; and according to the second lightness value, mapping a red proportion, a blue proportion, an indigo proportion and a yellow proportion corresponding to the third color information to [0, 255] to obtain fourth color information corresponding to the third color information in the RBCY color space. According to the scheme, the color information in the HSV color space can be converted into the RBCY color space.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application is a divisional application filed on October 23, 2025, with application number 2025115229721 and entitled "Conversion Method and Electronic Device", the entire contents of which are incorporated herein by reference. Technical Field

[0002] This application relates to the field of computer technology, and more specifically, to a conversion method and an electronic device. Background Technology

[0003] With technological advancements, the RBCY color space was proposed to better meet users' color presentation needs. In the RBCY color space, a color is expressed using red, blue, indigo, and yellow components; that is, the RBCY color space is a four-primary-color representation method. To adapt to display devices or convert to other three-primary-color spaces (such as the RGB color space), color information needs to be converted between the RBCY and HSV color spaces. Therefore, how to achieve color information conversion between the RBCY and HSV color spaces is a pressing technical problem that needs to be solved in related technologies. Summary of the Invention

[0004] In view of the above problems, this application proposes a conversion method and electronic device to realize the conversion of color information between RBCY color space and HSV color space.

[0005] In a first aspect, a method for converting from the RBCY color space to the HSV color space is provided, comprising: obtaining first color information in the RBCY color space, the first color information including a first red component, a first blue component, a first indigo component, and a first yellow component; normalizing the first red component, the first blue component, the first indigo component, and the first yellow component respectively to obtain corresponding red proportions, blue proportions, indigo proportions, and yellow proportions; calculating a first difference between the red proportion and the indigo proportion; calculating a second difference between the yellow proportion and the blue proportion; taking the maximum value of the red proportion and the indigo proportion as a first extreme value; and, taking the blue proportion and the yellow proportion as... The maximum value among the proportions is taken as the second extreme value; the difference between the third and fourth extreme values ​​is determined as the first reference value, and the sum of the absolute values ​​of the first and second differences is calculated as the second reference value; wherein, the third extreme value refers to the maximum value among the red proportion, the blue proportion, the indigo proportion, and the yellow proportion; the fourth extreme value refers to the minimum value among the red proportion, the blue proportion, the indigo proportion, and the yellow proportion; based on the first difference, the second difference, the first reference value, the second reference value, the first extreme value, the second extreme value, and the third extreme value, the second color information corresponding to the first color information in the HSV color space is determined.

[0006] Secondly, a method for converting from the HSV color space to the RBCY color space is provided, comprising: obtaining third color information in the HSV color space; the third color information includes a second hue value, a second saturation value, and a second brightness value; if the second saturation value is greater than 0, scaling the second hue value to [0, M) to obtain a first intermediate value; M = 4k, k is a positive integer; rounding the first intermediate value to obtain a second intermediate value; calculating the difference between the first intermediate value and the second intermediate value to obtain a third intermediate value; determining the red, blue, indigo, and yellow proportions corresponding to the third color information based on the second intermediate value, the third intermediate value, and the second saturation value; mapping the red, blue, indigo, and yellow proportions corresponding to the third color information to [0, 255] based on the second brightness value to obtain the fourth color information corresponding to the third color information in the RBCY color space.

[0007] Thirdly, a method for converting between RGB color space and RBCY color space is provided, comprising: acquiring multiple fifth color information in HSV color space, each fifth color information including a third hue value, a third saturation value, and a third lightness value, wherein the third hue values ​​of different fifth color information are different, the third saturation values ​​of multiple fifth color information are the same, and the third lightness values ​​of different fifth color information are the same; converting each fifth color information to RGB color space to obtain corresponding sixth color information; aligning each sixth color information to RBCY color space to obtain seventh color information corresponding to RBCY color space; converting each seventh color information to HSV color space according to the conversion method from RBCY color space to HSV color space to obtain eighth color information; establishing a hue value mapping relationship between RGB color space and RBCY color space based on the mapping relationship between the fourth hue values ​​of multiple eighth color information and the third hue values ​​of multiple fifth color information; and performing color information conversion between RGB color space and RBCY color space according to the hue value mapping relationship.

[0008] Fourthly, an electronic device is provided, comprising: a processor; and a memory storing computer-readable instructions, which, when executed by the processor, implement the method described above.

[0009] Fifthly, a computer-readable storage medium is provided that stores computer-readable instructions thereon, which, when executed by a processor, implement the method described above.

[0010] In a sixth aspect, a computer program product is provided, including computer instructions that, when executed by a processor, implement the method described above.

[0011] In this application, after normalizing the first red component, first blue component, first indigo component, and first yellow component in the first color information to obtain the corresponding red ratio, blue ratio, indigo ratio, and yellow ratio, the first difference between the red ratio and the indigo ratio, the second difference between the yellow ratio and the blue ratio, the maximum value of the red ratio and the indigo ratio as the first extreme value, the maximum value of the blue ratio and the yellow ratio as the second extreme value, the maximum value of the red ratio, blue ratio, indigo ratio, and yellow ratio as the third extreme value, and the minimum value of the red ratio, blue ratio, indigo ratio, and yellow ratio as the fourth extreme value, then the difference between the third extreme value and the fourth extreme value is determined as the first reference value, and the sum of the absolute values ​​of the first difference and the second difference is calculated as the second reference value; then, based on the first difference, the second difference, the first reference value, the second reference value, the first extreme value, the second extreme value, and the third extreme value, the second color information corresponding to the first color information in the HSV color space is determined. This achieves the conversion of the first color information in the RBCY color space to the HSV color space. Attached Figure Description

[0012] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. It is obvious that the drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.

[0013] Figure 1 This is a flowchart illustrating a conversion method according to an embodiment of this application.

[0014] Figure 2 This is a flowchart illustrating a conversion method according to an embodiment of this application.

[0015] Figure 3 This is a flowchart illustrating step 240 according to an embodiment of this application.

[0016] Figure 4 An exemplary diagram of the hue range in the HSV color space is shown.

[0017] Figure 5 This is a flowchart illustrating a conversion method according to an embodiment of this application.

[0018] Figure 6 This is a flowchart illustrating step 560 according to an embodiment of this application.

[0019] Figure 7This is a flowchart illustrating a conversion method according to an embodiment of this application.

[0020] Figure 8 This is a flowchart illustrating step 730 according to an embodiment of this application.

[0021] Figure 9 An example is shown of the color gamut of the RBCY color space in the CIE chromaticity coordinate system.

[0022] Figure 10 It is a hue value mapping curve between the RGB color space and the RBCY color space shown in an embodiment of this application.

[0023] Figure 11 This is a flowchart illustrating step 760 according to an embodiment of this application.

[0024] Figure 12 This is a flowchart illustrating step 760 according to an embodiment of this application.

[0025] Figure 13 This is a block diagram of an electronic device according to an embodiment of this application. Detailed Implementation

[0026] The embodiments of this application are described in detail below. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain this application, and should not be construed as limiting this application.

[0027] In the following description, the terms "first" and "second" are used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first" and "second" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.

[0028] In this document, "multiple" refers to two or more. "And / or" describes the relationship between associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following associated objects are in an "or" relationship. In the following description, references to "some embodiments or some embodiment methods" describe a subset of all possible embodiments. However, it is understood that "some embodiments" can be the same subset or different subsets of all possible embodiments and can be combined with each other without conflict.

[0029] This application provides a method for converting from the RBCY color space to the HSV color space. This method can be executed by an electronic device, which can be a terminal, server, or other device with computing capabilities. The terminal can be a smartphone, tablet, laptop, or smart home device (such as a smart TV or smart display). Figure 1 As shown, the method includes at least steps 110 to 150, which are detailed below: Step 110: Obtain first color information in the RBCY color space. The first color information includes a first red component, a first blue component, a first indigo component, and a first yellow component.

[0030] In the RBCY color space, each color is represented by R (red), B (blue), C (cyan), and Y (yellow). That is, in the RBCY color space, a color can be represented as a mixture of red, blue, indigo, and yellow. Correspondingly, the color information of a color in the RBCY color space includes the red component, blue component, indigo component, and yellow component. The primary color components (red component, blue component, indigo component, and yellow component) of a color in the RBCY color space are ∈ [0, 255].

[0031] The first color information refers to the color information in the RBCY color space that needs to be converted to the HSV color space. For ease of distinction, the red component, blue component, indigo component, and yellow component in the first color information are respectively called the first red component, the first blue component, the first indigo component, and the first yellow component.

[0032] Step 120: Normalize the first red component, first blue component, first indigo component, and first yellow component to obtain the corresponding red ratio, blue ratio, indigo ratio, and yellow ratio. Divide each of the first red component, first blue component, first indigo component, and first yellow component by the maximum component value (i.e., 255) to obtain the corresponding red ratio, blue ratio, indigo ratio, and yellow ratio.

[0033] For example, if the first red component is R1, the first blue component is B1, the first indigo component is C1, and the first yellow component is Y1, then the red ratio r1 = R1 / 255; the blue ratio b1 = B1 / 255; the indigo ratio c1 = C1 / 255; and the yellow ratio = Y1 / 255.

[0034] Step 130: Calculate the first difference between the red and indigo proportions, calculate the second difference between the yellow and blue proportions, and take the maximum value of the red and indigo proportions as the first extreme value, and the maximum value of the blue and yellow proportions as the second extreme value. Assume the first difference is represented as... The second difference is expressed as Let the first extreme value be denoted as max1 and the second extreme value as max2, then: ;(Formula 1) ;(Formula 2) max1=max(r1,c1); (Formula 3) max2=max(y1,b1); (Formula 4) Here, max() represents the function to find the maximum value.

[0035] Step 140: Determine the difference between the third and fourth extreme values ​​as the first reference value, and calculate the sum of the absolute values ​​of the first and second differences as the second reference value; wherein, the third extreme value refers to the maximum value among the red, blue, indigo, and yellow proportions; the fourth extreme value refers to the minimum value among the red, blue, indigo, and yellow proportions.

[0036] If the first reference value is expressed as The second reference value is expressed as The third extreme value is denoted as max3, and the fourth extreme value is denoted as min1. Then: max3 = max(r1, b1, c1, y1) = max(max1, max2); (Formula 5) min1=min(r1, b1, c1, y1); (Formula 6) ;(Formula 7) ;(Formula 8) Here, min() represents the function that finds the minimum value.

[0037] Step 150: Determine the second color information corresponding to the first color information in the HSV color space based on the first difference, the second difference, the first reference value, the second reference value, the first extreme value, the second extreme value, and the third extreme value.

[0038] In the HSV color space, a color is represented by three components: hue (H), saturation (S), and value (V). Hue ranges from [0° to 360°], saturation represents the purity or vividness of a color and ranges from [0 to 1], and value represents the lightness or darkness of a color and ranges from [0 to 1].

[0039] In step 150, the first color information in the RBCY color space is converted to the HSV color space. The resulting second color information in the HSV color space corresponds to the first color information. This second color information refers to the representation of the color indicated by the first color information in the HSV color space. In other words, the color indicated by the first color information and the color indicated by the second color information are the same color, only represented differently. It can be understood that the second color information includes hue, saturation, and lightness values. For ease of distinction, the hue, saturation, and lightness values ​​in the second color information are respectively referred to as the first hue value, first saturation value, and first lightness value.

[0040] In some embodiments, such as Figure 2 As shown, step 150 includes the following steps 210-240: Step 210, the third extreme value is determined as the -first brightness value corresponding to the first color information in the HSV color space. Continuing the assumption above, the first brightness value V1 is: V1 = ;(Formula 9) Step 220: Calculate the sum of the first extreme value and the second extreme value, using it as the third reference value. Then, use the ratio of the second reference value to the third reference value as the first saturation value corresponding to the first color information in the HSV color space. Continuing the assumption above, the first saturation value S1 is: S1 = / (max1+max2)=( ) / (max1+max2); (Formula 10) Among them, max1+max2 is the third reference value.

[0041] Step 230: Determine the hue value determination method applicable to the first color information based on the first reference value and the second reference value; the hue value determination method is either an assignment method or a method of calculating the hue value by combining the first difference and the second difference.

[0042] Step 240: Determine the first hue value of the first color information in the HSV color space according to the hue value determination method applicable to the first color information.

[0043] If the hue value determination method applicable to the first color information is the assignment method, it means that the first hue value corresponding to the first color information in the HSV color space is assigned a preset value. In some embodiments, the assignment method includes a first assignment method and a second assignment method; the first assignment method is used to assign the first hue value to a first preset value, and the second assignment method is used to assign the first hue value to a second preset value; the first preset value and the second preset value are different.

[0044] In some embodiments, step 230 includes the following ①-③: ① If the first reference value is equal to 0, determine that the hue value determination method applicable to the first color information is the first assignment method.

[0045] When the first reference value When =0, the color represented by the first color information is grayscale, and its corresponding hue value is usually set to 0. However, considering that the hue value of red in the HSV color space is also 0, in order to avoid confusion with the hue value of red in the HSV color space, the first preset value indicated by the first assignment method can be set to a value close to 360° or 0°, or other values ​​different from the hue value corresponding to red, so as to distinguish it from the hue value corresponding to red. In some embodiments, if the hue value is represented by 16 bits in the code, the first preset value can be set to 65535 (which is the largest decimal number that 16 bits can represent), and the first preset value can be scaled to [0°, 360°] later.

[0046] ②If the first reference value is greater than 0 and the second reference value is equal to 0, the hue value determination method applicable to the first color information is the second assignment method.

[0047] When the first reference value =0 and the second reference value When =0, it indicates that the color represented by the first color information is a zero-saturation color, which is a color with extremely low saturation. However, it is not exactly the same as grayscale. Therefore, the second preset value indicated by the second assignment method can be set to a different value than the hue value corresponding to grayscale to avoid confusion with grayscale hue. In some embodiments, if the hue value is represented by 16 bits in the code, and the first preset value is set to 65535, the second preset value can be set to a value slightly smaller than 65535, such as 65534, 65533, etc. The second preset value can then be scaled to [0°, 360°].

[0048] ③ If the second reference value is greater than 0, the method for determining the applicable hue value for the first color information is to calculate the hue value by combining the first difference and the second difference. In this case, such as Figure 3 As shown, step 240 includes steps 310-340: Step 310, calculate a third difference between the absolute value of the first difference and the absolute value of the second difference. Step 320, calculate the ratio of the third difference to the second reference value, as an intermediate coefficient. Step 330, calculate the product of the intermediate coefficient and the reference angle to obtain the intermediate angle; the reference angle is less than 90°. Step 340, determine the first hue value corresponding to the first color information in the HSV color space based on the first difference, the second difference, and the intermediate angle.

[0049] Figure 4An exemplary diagram illustrating the hue range in the HSV color space is shown, such as... Figure 4 As shown, considering that red corresponds to a hue value of 0°, yellow corresponds to a hue value of 90°, indigo corresponds to a hue value of 180°, and blue corresponds to a hue value of 270°, we can... Figure 4 The positive horizontal axis in the hue range diagram shown represents: the hue value corresponding to red - the hue value corresponding to indigo, and the negative horizontal axis represents: -(the hue value corresponding to red - the hue value corresponding to indigo). Because... = ,thus, Figure 4 The positive direction of the horizontal axis in the middle is equivalent to The negative direction of the horizontal axis is equivalent to - Similarly, Figure 4 The positive vertical axis represents: the hue value of yellow minus the hue value of indigo; the negative vertical axis represents: -(the hue value of yellow minus the hue value of indigo). ,therefore, Figure 4 The positive direction of the vertical axis in the middle is equivalent to The negative direction of the vertical axis is equivalent to - ,therefore, Figure 4 The hue range shown is a horizontal axis. The axis and the vertical axis are A two-dimensional plane coordinate system for the axes.

[0050] Therefore, on this basis Figure 4 The hue values ​​in the hue range coordinate system shown can be represented as vectors. Geometric angles (i.e., vectors) (The angle between the x-axis and the positive x-axis). However, considering that this method involves trigonometric functions, the calculation process is complex and not convenient for rapid calculation. Therefore, in this embodiment, the calculation method for the hue value in each quadrant of the hue range coordinate system is set separately.

[0051] In this embodiment, the intermediate coefficient is used as the calculation location Figure 4 The variable representing the hue value in each quadrant of the hue range coordinate system shown.

[0052] If the intermediate coefficient is expressed as Then the intermediate coefficient for: ;(Formula 11) Assuming the reference angle is 'a', then the intermediate angle 'x' is: ;(Formula 12) in, This is the third difference. In some embodiments, the reference angle a = 360° / M, where M = 4k, and k is a positive integer. Therefore, when k = 2, the reference angle is equal to 45°. In other embodiments, k can also be set to 1, 3, etc.

[0053] First difference Second difference The hue value range (hue value quadrant) corresponding to the first hue value of the color represented by the first color information is determined. Therefore, a calculation formula for the hue value in each quadrant can be pre-defined (this formula is related to the intermediate coefficient, or in other words, the intermediate angle). Then, it is combined with the first difference. Second difference To determine the quadrant where the first hue value corresponding to the first color information is located, and to calculate the first hue value according to the hue value calculation formula corresponding to the quadrant where the first hue value is located.

[0054] In some embodiments, step 340 includes the following (1)-(4): (1) If the first difference is not less than 0 and the second difference is not less than 0, the difference between the first angle and the middle angle is used as the candidate first hue value corresponding to the first color information; the first angle is not less than the reference angle and the first angle is less than 90°.

[0055] When the first difference ≥0 and the second difference When the first hue value corresponding to the first color information is located in the first quadrant, the value of the first hue value H1 is ∈ [0, 90). In some embodiments, since the first hue value corresponding to the first color information is located in the first quadrant, the median angle in the first quadrant can be used as the first angle, that is, the first angle = 45°. Then, the candidate first hue value corresponding to the first color information can be determined. For example, with reference angle a = 45°, the candidate first hue value corresponding to the first color information can be determined according to the following formula. : ;(Formula 13) (2) If the first difference is less than 0 and the second difference is not less than 0, the sum of the second angle and the middle angle shall be used as the candidate first hue value corresponding to the first color information; the second angle is greater than the first angle and less than 180°.

[0056] When the first difference <0 and the second difference When the first hue value corresponding to the first color information is located in the second quadrant, the value of the first hue value H1 is ∈ [90, 180]. In some embodiments, since the first hue value corresponding to the first color information is located in the second quadrant, the median angle in the second quadrant can be used as the second angle, that is, the second angle = 135. Then, the candidate first hue value corresponding to the first color information can be determined. For example, with a reference angle a = 45, the candidate first hue value corresponding to the first color information can be determined according to the following formula. : ;(Formula 14) (3) If the first difference is less than 0 and the second difference is less than 0, the difference between the third angle and the middle angle shall be used as the candidate first hue value corresponding to the first color information; the third angle is greater than the second angle and less than 270°.

[0057] When the first difference <0 and the second difference When the first hue value corresponding to the first color information is located in the third quadrant, the value of the first hue value H1 is ∈ [180, 270]. In some embodiments, since the first hue value corresponding to the first color information is located in the third quadrant, the median angle in the third quadrant can be used as the third angle, that is, the third angle = 225. Then, the candidate first hue value corresponding to the first color information can be determined. For example, with a reference angle a = 45, the candidate first hue value corresponding to the first color information can be determined according to the following formula. : ;(Formula 15) (4) If the first difference is not less than 0 and the second difference is less than 0, the sum of the fourth angle and the middle angle shall be used as the candidate first hue value corresponding to the first color information; the fourth angle is greater than the third angle and less than 360°.

[0058] When the first difference ≥0 and the second difference When the first hue value corresponding to the first color information is located in the fourth quadrant, the value of the first hue value H1 is ∈ [270, 360). In some embodiments, since the first hue value corresponding to the first color information is located in the fourth quadrant, the median angle in the fourth quadrant can be used as the fourth angle, that is, the fourth angle = 315. Then, the candidate first hue value corresponding to the first color information can be determined. For example, with a reference angle a = 45, the candidate first hue value corresponding to the first color information can be determined according to the following formula. : ;(Formula 16) (5) Map the candidate first hue value corresponding to the first color information to [0, 360°) to obtain the first hue value corresponding to the first color information in the HSV color space.

[0059] Considering that the candidate first hue values ​​calculated according to formulas 13-16 above may not be within the range [0, 360°), the candidate first hue values ​​corresponding to the first color information are mapped to [0, 360°) to ensure that the first hue values ​​corresponding to the obtained first color information in the HSV color space are ∈ [0, 360°). In some embodiments, the candidate first hue values ​​corresponding to the first color information can be mapped using the mod() function. Mapped to [0, 360°), the first hue value H1 corresponding to the first color information in the HSV color space is determined according to the following formula: ;(Formula 17) In this application, after normalizing the first red component, first blue component, first indigo component, and first yellow component in the first color information to obtain the corresponding red ratio, blue ratio, indigo ratio, and yellow ratio, the first difference between the red ratio and the indigo ratio, the second difference between the yellow ratio and the blue ratio, the maximum value of the red ratio and the indigo ratio as the first extreme value, the maximum value of the blue ratio and the yellow ratio as the second extreme value, the maximum value of the red ratio, blue ratio, indigo ratio, and yellow ratio as the third extreme value, and the minimum value of the red ratio, blue ratio, indigo ratio, and yellow ratio as the fourth extreme value, then the difference between the third extreme value and the fourth extreme value is determined as the first reference value, and the sum of the absolute values ​​of the first difference and the second difference is calculated as the second reference value; then, based on the first difference, the second difference, the first reference value, the second reference value, the first extreme value, the second extreme value, and the third extreme value, the second color information corresponding to the first color information in the HSV color space is determined. This converts the first color information in the RBCY color space to the HSV color space. This facilitates subsequent color rendering based on the corresponding second color information in the HSV color space, or further conversion to other color spaces such as the RGB color space.

[0060] Furthermore, in the above embodiments, the first color information in the RBCY color space is calculated to correspond to the first hue value in the HSV color space using basic addition, subtraction, multiplication, and division operations. The calculation is simple, does not involve complex trigonometric functions, and greatly reduces the amount of calculation required to convert from the RBCY color space to the HSV color space.

[0061] This application also provides a method for converting from the HSV color space to the RBCY color space, which can be performed by an electronic device, such as... Figure 5 As shown, the method includes the following steps 510-560: Step 510, obtaining the third color information in the HSV color space; the third color information includes the second hue value, the second saturation value, and the second brightness value. The third color information refers to any color information in the HSV color space to be converted to the RBCY color space. The third color information is represented by the hue value, saturation value, and brightness value. For ease of distinction, the hue value, saturation value, and brightness value in the third color information are respectively referred to as the second hue value, the second saturation value, and the second brightness value.

[0062] Step 520: If the second saturation value is greater than 0, then scale the second hue value to [0, M) to obtain the first intermediate value; M = 4k, where k is a positive integer. If the second saturation value is greater than 0, it indicates that the color represented by the third color information is chromatic. If the second hue value is represented as H2, and k = 2, the corresponding N = 8, then the second hue value can be scaled to [0, 8) according to the following formula to obtain the first intermediate value. : ;(Formula 18) Step 530: Round the first intermediate value to obtain the second intermediate value. The second intermediate value i can be determined using the following formula: ;(Formula 19) in, () is the floor function.

[0063] Step 540: Calculate the difference between the first and second intermediate values ​​to obtain the third intermediate value. The third intermediate value f can be calculated using the following formula: ;(Formula 20) Step 550: Based on the second intermediate value, the third intermediate value, and the second saturation value, determine the proportions of red, blue, indigo, and yellow corresponding to the third color information.

[0064] In some embodiments, step 550 includes the following 1)-2): 1) Determine the target ratio calculation method applicable to the second intermediate value according to the correspondence between the numerical value and the ratio calculation method; the target ratio calculation method includes the target red ratio calculation method, the target blue ratio calculation method, the target indigo ratio calculation method and the target yellow ratio calculation method.

[0065] In some embodiments, when k=2, the step of determining the target ratio calculation method applicable to the second intermediate value based on the correspondence between the numerical value and the ratio calculation method includes: If the second intermediate value = 0, the target red ratio is calculated as follows: r = 2 - f, the target blue ratio is calculated as follows: b = f(1 - S), the target indigo ratio is calculated as follows: c = (2 - f)(1 - S), and the target yellow ratio is calculated as follows: y = f.

[0066] If the second intermediate value = 1, the target red ratio is calculated as follows: r = 1 - f, the target blue ratio is calculated as follows: b = (1 + f)(1 - S), the target indigo ratio is calculated as follows: c = (1 - f)(1 - S), and the target yellow ratio is calculated as follows: y = 1 + f.

[0067] If the second intermediate value = 2, the target red ratio is calculated as follows: r = f(1-S), the target blue ratio is calculated as follows: b = (2-f)(1-S), the target indigo ratio is calculated as follows: c = f, and the target yellow ratio is calculated as follows: y = 2-f.

[0068] If the second intermediate value is 3, the target red ratio is calculated as follows: r = (1 + f)(1 - S), the target blue ratio is calculated as follows: b = (1 - f)(1 - S), the target indigo ratio is calculated as follows: c = 1 + f, and the target yellow ratio is calculated as follows: y = 1 - f.

[0069] If the second intermediate value is 4, the target red ratio is calculated as follows: r = (2-f)(1-S), the target blue ratio is calculated as follows: b = f, the target indigo ratio is calculated as follows: c = 2-f, and the target yellow ratio is calculated as follows: y = f(1-S).

[0070] If the second intermediate value is 5, the target red ratio is calculated as follows: r = (1-f)(1-S), the target blue ratio is calculated as follows: b = 1+f, the target indigo ratio is calculated as follows: c = 1-f, and the target yellow ratio is calculated as follows: y = (1+f)(1-S).

[0071] If the second intermediate value is 6, the target red ratio is calculated as follows: r=f, the target blue ratio is calculated as follows: b=2-f, the target indigo ratio is calculated as follows: c=f(1-S), and the target yellow ratio is calculated as follows: y=(2-f)(1-S).

[0072] If the second intermediate value is 7, the target red ratio is calculated as follows: r = 1 + f, the target blue ratio is calculated as follows: b = 1 - f, the target indigo ratio is calculated as follows: c = (1 + f)(1 - S), and the target yellow ratio is calculated as follows: y = (1 - f)(1 - S).

[0073] Where r represents the proportion of red corresponding to the third color information; b represents the proportion of blue corresponding to the third color information; c represents the proportion of indigo corresponding to the third color information; y represents the proportion of yellow corresponding to the third color information; f represents the third intermediate value; and S represents the second saturation value. In other words, the target proportion calculation method corresponding to the second intermediate value i can be determined according to Table 1 below: Table 1 2) Based on the third intermediate value and the second saturation value, determine the red ratio corresponding to the third color information according to the target red ratio calculation method, the blue ratio corresponding to the third color information according to the target blue ratio calculation method, the indigo ratio corresponding to the third color information according to the target indigo ratio calculation method, and the yellow ratio corresponding to the third color information according to the target yellow ratio calculation method.

[0074] After determining the target ratio calculation method applicable to the second intermediate value, the calculation can be performed according to the calculation method (calculation formula) shown in Table 1 to obtain the red ratio, blue ratio, indigo ratio and yellow ratio corresponding to the third color information.

[0075] Step 560: Based on the second brightness value, map the red, blue, indigo, and yellow proportions corresponding to the third color information to [0, 255] respectively, to obtain the fourth color information corresponding to the third color information in the RBCY color space.

[0076] The fourth color information includes a red component, a blue component, an indigo component, and a yellow component. For ease of distinction, the red, blue, indigo, and yellow components in the fourth color information are respectively referred to as the second red component, the second blue component, the second indigo component, and the second yellow component. In some embodiments, such as Figure 6 As shown, step 560 includes: step 610, determining the maximum ratio value among the red, blue, indigo, and yellow ratios corresponding to the third color information. This maximum ratio value is the highest value among the red, blue, indigo, and yellow ratios corresponding to the third color information.

[0077] Step 620: Use the ratio of the second brightness value to the maximum proportion value as the conversion coefficient. As described above, when converting color information from the RBCY color space to the HSV color space, the brightness value of the color information in the HSV color space is the maximum value among the four primary color proportions. Therefore, theoretically, the second brightness value should be the same as the determined maximum proportion value. However, in practice, there may be deviations, causing the second brightness value to differ from the determined maximum proportion value. Therefore, in this case, it is necessary to combine the second brightness value and the determined maximum proportion value to determine the conversion coefficient in order to convert the red, blue, indigo, and yellow proportions corresponding to the third color information, thereby ensuring the accuracy of the subsequently determined primary color components.

[0078] The conversion factor can be determined using the following formula. : ;(Formula 21) in, This indicates the second brightness value. This indicates the proportion of red corresponding to the third color information. Blue ratio Indigo ratio Yellow ratio The maximum value in.

[0079] Step 630: Multiply the red proportion, conversion coefficient, and maximum component value corresponding to the third color information to obtain the second red component; maximum component value = 255. That is, determine the second red component R2 according to the following formula: ;(Formula 22) Step 640: Multiply the blue proportion, conversion coefficient, and maximum component value corresponding to the third color information to obtain the second blue component. Similarly, determine the second blue component B2 according to the following formula: ;(Formula 23) Step 650: Multiply the indigo ratio, conversion coefficient, and maximum component value corresponding to the third color information to obtain the second indigo component. Determine the second indigo component C2 according to the following formula: ;(Formula 23) Step 660: Multiply the yellow proportion, conversion coefficient, and maximum component value corresponding to the third color information to obtain the second yellow component. Determine the second yellow component Y2 according to the following formula: ;(Formula 24) In some embodiments, after step 510, the method further includes: if the second saturation value is equal to 0, determining that the second red component, the second blue component, the second indigo component, and the second yellow component corresponding to the third color information in the RBCY color space are all equal to the product of the second lightness value and 255.

[0080] If the second saturation value S2=0, it means that the color indicated by the third color information is a grayscale value. If the second brightness value is represented as V2, the second red component R2, the second blue component B2, the second indigo component C2, and the second yellow component Y2 can be determined according to the following formula: R2=B2=C2=Y2=V2×255; (Formula 25) In the above embodiment, for the third color information in the HSV color space, if the second saturation value in the third color information is greater than 0, the second hue value in the third color information is scaled to [0, M) to obtain a first intermediate value. Since the RBCY color space is a four-primary-color color space, and M is an integer divisible by 4, scaling the second hue value to [0, M) facilitates subsequent conversion to the RBCY color space based on the first intermediate value. Then, the first intermediate value is rounded to obtain a second intermediate value; and the difference between the first and second intermediate values ​​is calculated to obtain a third intermediate value; and based on the second intermediate value, the third intermediate value, and the second saturation value, the red, blue, indigo, and yellow proportions corresponding to the third color information are determined; finally, based on the second brightness value, the red, blue, indigo, and yellow proportions corresponding to the third color information are mapped to [0, 255] respectively to obtain the fourth color information corresponding to the third color information in the RBCY color space. In this way, color information in the HSV color space can be converted to the RBCY color space, which makes it easier for display devices that use the color representation method corresponding to the RBCY color space to display colors. It also makes it easier for color information in other color spaces to be converted to the RBCY color space using the HSV color space as an intermediary.

[0081] This application also provides a method for converting between RGB color space and RBCY color space, which can be performed by an electronic device, such as... Figure 7 As shown, the method includes: step 710, obtaining multiple fifth color information in the HSV space, each fifth color information including a third hue value, a third saturation value and a third brightness value, the third hue value in different fifth color information is different, the third saturation value in multiple fifth color information is the same, and the third brightness value in different fifth color information is the same.

[0082] The fifth color information is defined by three components: hue, saturation, and lightness. The hue value in the fifth color information is called the third hue value; similarly, the saturation value is called the third saturation value, and the lightness value is called the third lightness value. Different fifth color information represents different colors. It can be understood that for different fifth color information, the third saturation value and the third lightness value are the same; only the third hue value in the hue dimension differs. This ensures the accuracy of the hue value mapping relationship constructed subsequently.

[0083] In some embodiments, a third saturation value and a third brightness value can be set as needed, where the third saturation value ∈ [0, 1] and the third brightness value ∈ [0, 1]. For example, the third saturation value can be set to 1 and the third brightness value to 1; or the third saturation value can be set to 0.9 and the third brightness value to 0.8, etc. No specific limitation is made here.

[0084] In some embodiments, considering that the hue value ranges from 0 to 360, the angles from 0 to 360 can be divided into a preset number of points. This preset number is the number of fifth color information points. For example, the angles from 0 to 360 can be divided into 1001 points or 3601 points (one point represents one third hue value). Of course, it is not limited to this.

[0085] Step 720 involves converting each fifth color information to the RGB color space to obtain the corresponding sixth color information. In the RGB color space, color is represented by three components: red (R), green (G), and blue (B). That is, any color can be considered a mixture of red, green, and blue. Correspondingly, the sixth color information includes red, green, and blue components. In step 720, the fifth color information is converted from the HSV color space to the RGB color space so that the color indicated by the fifth color information is represented by the red, green, and blue components.

[0086] Step 730: Align each sixth color information to the RBCY color space to obtain the corresponding seventh color information in the RBCY color space. That is, convert the sixth color information to the RBCY color space so that the color indicated by the sixth color information is represented as a mixture of four color components: red, blue, indigo, and yellow. Correspondingly, the seventh color information corresponding to one sixth color information in the RBCY color space includes the red component, blue component, indigo component, and yellow component.

[0087] In some embodiments, the sixth color information can be aligned to the RBCY color space using the CIE chromaticity coordinate system. In the CIE chromaticity coordinate system, the chromaticity coordinates of a color are dimensionless parameters calculated by ratioing the tristimulus values ​​(X, Y, Z) of the color to the sum of those three stimulus values. Furthermore, in the CIE chromaticity coordinate system, colors are described using two-dimensional (x, y) coordinates (also called chromaticity coordinates), visually displaying the color's position within the CIE chromaticity coordinate system. ; .

[0088] Based on this, for ease of calculation, the third saturation value in the selected multiple fifth color information can all be 1, such as... Figure 8 As shown, step 730 includes the following steps 810-830: Step 810, calculate the first chromaticity coordinates of each sixth color information in the CIE chromaticity coordinate system.

[0089] The sixth color information can be converted to the CIE chromaticity coordinate system in the same way as the color information in the RGB color space. The corresponding first chromaticity coordinate is then determined. This first chromaticity coordinate is a two-dimensional chromaticity coordinate.

[0090] Step 820: Determine the intersection point between each target ray and the gamut boundary line of the RBCY color space in the CIE chromaticity coordinate system, and obtain the second chromaticity coordinates of the intersection point in the CIE chromaticity coordinate system; the target ray refers to the ray pointing from the central white point in the CIE chromaticity coordinate system to the first chromaticity coordinate.

[0091] Figure 9 The example illustrates the color gamut of the RBCY color space in the CIE chromaticity coordinate system. In the CIE chromaticity coordinate system, yellow is located at point P1, red at point P2, blue at point P3, and indigo at point P4. The quadrilateral region enclosed by P1, P2, P3, and P4 in the CIE chromaticity coordinate system is the color gamut of the RBCY color space in the CIE chromaticity coordinate system. P1P2, P2P3, P3P4, and P1P4 are the four color gamut boundary lines of the RBCY color space in the CIE chromaticity coordinate system.

[0092] In this embodiment, considering that the color with the highest saturation value in the RBCY color space within the CIE chromaticity coordinate system (referred to as the RBCY chromaticity gamut for ease of description), and that the third saturation value of all selected fifth color information in this embodiment is 1, i.e., the maximum saturation value, theoretically, the first chromaticity coordinate should be located on the RBCY chromaticity gamut boundary. However, considering that in practice, during the conversion between different color spaces, the color information determined in the new color space may have deviations, the point represented by the determined first chromaticity coordinate may not actually be located on the RBCY chromaticity gamut boundary in the CIE chromaticity coordinate system.

[0093] Therefore, in this embodiment, the intersection point between the target ray and the color gamut boundary line of the RBCY color space in the CIE chromaticity coordinate system is used as the second chromaticity coordinate of the intersection point in the CIE chromaticity coordinate system, or as the chromaticity coordinate of the fifth color information in the CIE chromaticity coordinate system after the color indicated by the fifth color information is converted to the RBCY color space.

[0094] Please continue reading Figure 9 In the CIE chromaticity coordinate system, the central white point refers to the chromaticity coordinate point representing white. Figure 9 Midpoint P5 is the chromaticity coordinate point representing white. Assume a point represented by a first chromaticity coordinate is located at... Figure 9 If point Q1 is in the RGBY color gamut, then the target ray is the line from point P5 to point Q1. Ray P5Q1 intersects the boundary line of the RGBY color gamut, P2P3, at point Q2. Therefore, the chromaticity coordinates of point Q2 are the second chromaticity coordinates.

[0095] Step 830: Convert each second chromaticity coordinate to the RBCY color space to obtain the seventh color information corresponding to each second chromaticity coordinate in the RBCY color space.

[0096] First, the transformation matrix between the weighting coefficients for mixing the four primary colors in the RBCY color space and the three-dimensional chromaticity coordinates in the CIE chromaticity coordinate system. Explanation: The four primary colors in the RBCY color space, namely red, blue, indigo, and yellow, have the following three-dimensional chromaticity coordinates (x, y, z) in the CIE chromaticity coordinate system (where x+y+z=1 in the three-dimensional chromaticity coordinates of one of the colors): R = (0.6900, 0.3050, 0.0050); B = (0.1400, 0.0700, 0.7900); C = (0.0250, 0.5000, 0.4750); Y = (0.4000, 0.5800, 0.0200). Therefore, the transformation matrix... for: ; Where the transformation matrix The first three items in the first column are obtained by multiplying the three-dimensional chromaticity coordinates of red with the white balance coefficient KR = 0.6933 corresponding to red; this is the transformation matrix. The first three items in the second column are obtained by multiplying the three-dimensional chromaticity coordinates of blue by the corresponding white balance coefficient KB = 1.0399; the first three items in the third column are obtained by multiplying the three-dimensional chromaticity coordinates of indigo by the corresponding white balance coefficient KC = 0.5226; the first three items in the fourth column are obtained by multiplying the three-dimensional chromaticity coordinates of yellow by the corresponding white balance coefficient KY = 0.7835; transformation matrix The values ​​in the fourth row are all 1, to ensure that the 4×4 matrix has an inverse matrix.

[0097] Correspondingly, the transformation matrix inverse matrix for: ; Next, a transformation matrix is ​​used to express the relationship between the weighting coefficients (mixing ratios) of the four primary colors in the RBCY color space and the chromaticity coordinates. The relationship is as follows: ;(Formula 26) ;(Formula 27) in, The range of values ​​for (j = 1, 2, 3, 4) is ∈ [0, 1], representing the weighting coefficients (mixing ratios) of the four primary colors. The value of N can be determined using the D65 white point. The coordinates of the D65 white point in the CIE chromaticity coordinate system are (0.9504, 1.0000, 1.0889); for ease of calculation, a 4th-order matrix is ​​needed. Therefore, the D65 white point is written as 4-dimensional chromatic coordinates: ; When ηi (i = 1, 2, 3, 4) = 1, the color coordinate expression of D65 is obtained as follows: ; As can be seen from the above, in each group The scale value can determine a unique color coordinate. The value of N ranges from [0, 4]. However, the value of N differs from... It's not a one-to-one correspondence. A group This could correspond to multiple values ​​of N. This means that a fixed set of... Multiple groups can be matched. This means that the same color can have multiple mixing methods. Although this set contains 3D color coordinates... They are the same, but the values ​​of N are different. Figure 9 In the quadrilateral RBCY color gamut, the closer to the gamut boundary, the fewer the N values ​​corresponding to the chromaticity coordinates. When the chromaticity coordinates are taken on the four boundary lines of the quadrilateral RBCY color gamut, there will only be one N value. The N value corresponding to a single chromaticity coordinate changes continuously, that is, within a certain range, Nmax ≥ N ≥ Nmin.

[0098] Based on this, a center value N can be defined, denoted as . Select the center when picking a color. Corresponding color mixing ratio value Perform color mixing. Plot the coordinates of the 3D tristimulus values. Divide by (X+Y+Z) and normalize to Take the center. This forms a normalized color coordinate N-value 3D space. When the selected color coordinates are outside the quadrilateral containing the RBCY color gamut, the color mixing ratio ηi (i = 1, 2, 3, 4) will produce a negative value. N values ​​resulting in negative color mixing ratios are discarded. When there is no value for N, the 3D space... The Nm point in the array is assigned a value of 0.

[0099] As described above, the 4D color coordinates of the four primary colors in the RBCY color space are respectively the transformation matrix. One of the columns, namely: ; ; ; ; The four primary colors (red, blue, indigo, and yellow) and white (W, i.e., the D65 white point mentioned above) are correspondingly determined. These five points correspond to the normalized color coordinates N values ​​in 3D coordinates. The values ​​are (where r represents red, b represents blue, c represents indigo, y represents yellow, and w represents white): ; ; ; ; ; The planar equations for the three colors RBW are: The plane equations for the three colors BCW are: The plane equations for the three colors CYW are: The plane equations for the three colors YRW are: Combining these four plane equations, we can obtain the expression for the value of N as follows: Where i = 1, 2, 3, 4; (Formula 28) The normalized color coordinates N values ​​of r, b, c, y, w determined above are converted into 3D coordinates. Substituting these values ​​into the corresponding plane equations, we can obtain the coefficients. , , : ; ; ; .

[0100] Thus, for any chromaticity coordinates (X, Y, Z) in the CIE chromaticity coordinate system represented by tristimulus values, we can normalize them using X+Y+Z to obtain the x and y values, and then combine them with the coefficients determined above. , , Substituting these values ​​into Formula 28 yields four sets of Ni values. Substituting the 4-dimensional color coordinates (x, y, z, N) into Formula 27 gives the normalized color mixing ratio. Multiplying this by the normalization coefficient (X+Y+Z) gives the final ratio value. At this point, there will be four sets of ratio values ​​corresponding to four sets of Ni values. Only the ratio values ​​that are non-negative are retained. Sometimes, although the ratio value is negative, due to numerical error, its absolute value is less than 0.0010, and this value can be considered equal to 0, which is also a non-negative value. Similarly, the absolute value of the difference from 1 that is less than 0.0010 can be considered equal to 1.

[0101] This means that in the RBCY color space, the same color can have multiple mixing methods. This characteristic makes the 4-primary-color mixing system using the RBCY color space more stable. (Proportion value) Within a certain range, the corresponding 3D color coordinates change very little.

[0102] Then, based on the determined ratio values, the color component values ​​of a color in the RBCY color space can be represented: that is, the red component values. Blue component Indigo color quantity and yellow portion The relationship between the two can be summarized as follows: ;(Formula 29) Correspondingly, ;(Formula 30) Based on this, in step 830, if the second chromaticity coordinates are (x, y), the coefficients determined above will be... , , Substituting the second chromaticity coordinates (x, y) into Formula 28 above, we can obtain four sets of Ni values. Then, substituting the four-dimensional chromaticity coordinates (x, y, z, Ni) corresponding to the second chromaticity coordinates (x, y) into Formula 27 above, we can obtain the proportion values ​​under normalized coordinates. Then, the scale value under normalized coordinates Multiply by the sum of the tristimulus values ​​(X+Y+Z) corresponding to the second chromaticity coordinate of the coefficient to obtain the final result. Then, discard the set of values ​​with negative scaling factors, and substitute the remaining scaling factors into formula 30 to obtain the red component values ​​in the RBCY color space. Blue component Indigo color quantity and yellow portion This means obtaining the seventh color information corresponding to the second chromaticity coordinates in the RBCY color space.

[0103] Step 740: Following the conversion method from RBCY color space to HSV color space, convert each seventh color information to the HSV color space to obtain the eighth color information.

[0104] In other words, according to the conversion method from RBCY color space to HSV color space provided in this application, the seventh color information in the RBCY color space is converted to the HSV color space to obtain the eighth color information represented by hue, saturation, and lightness. The specific process is described above. For ease of distinction, the hue value in the eighth color information is referred to as the fourth hue value.

[0105] Step 750: Based on the mapping relationship between the fourth hue value in multiple eighth color information and the third hue value in multiple fifth color information, establish the hue value mapping relationship between the RGB color space and the RBCY color space.

[0106] There is a mapping relationship between the third hue value in a fifth color information and the fourth hue value in the eighth color information determined by that fifth color information. The third hue value in a fifth color information is equivalent to the hue value obtained by converting the color information in the RGB color space to the HSV color space. Therefore, the third hue value in the fifth color information can be called the hue value corresponding to the color information in the RGB color space, or simply the RGB hue value. Similarly, the fourth hue value in an eighth color information is equivalent to the hue value obtained by converting the color information in the RBCY color space to the HSV color space. Therefore, the fourth hue value in the eighth color information is called the hue value corresponding to the color information in the RBCY color space, or simply the RGB hue value.

[0107] Therefore, based on the mapping relationship between the third hue value in a fifth color information and the fourth hue value in the eighth color information determined by the fifth color information, a hue value mapping relationship between the RGB color space and the RBCY color space can be established. That is, the hue value mapping relationship between the RGB color space and the RBCY color space includes multiple sets of mapping relationships between RGB hue values.

[0108] In some embodiments, the hue value mapping relationship between the RGB color space and the RBCY color space can be presented in tabular form, ordered pairs, or curve form. If presented as a curve, the RGB and RBCY hue values ​​with the mapping relationship are used as points in a coordinate system, and then multiple points are fitted together to form the curve. Figure 10 This is a hue value mapping curve between the RGB color space and the RBCY color space shown in an embodiment of this application. The hue value mapping curve reflects the hue value mapping relationship between the RGB color space and the RBCY color space. Figure 10 In the diagram, the horizontal axis represents RGB hue values, and the vertical axis represents RBCY hue values. The horizontal and vertical coordinates of points on the curve are the RGB hue values ​​and RBCY hue values ​​that have a mapping relationship, respectively.

[0109] In some embodiments, the number of ordered pairs of RGB hue values ​​and RBCY hue values ​​with mapping relationships established in the manner described above is limited. To characterize the mapping relationship between hue values ​​with finer granularity, interpolation can also be performed. This can form a smoother hue value mapping curve and avoid amplifying numerical errors due to excessive curve fluctuations.

[0110] Step 760: Based on the hue value mapping relationship, perform color information conversion between the RGB color space and the RBCY color space. Based on the established hue value mapping relationship, the RGB color space and the RBCY color space are essentially associated through hue values. Therefore, the hue value mapping relationship can be used as an intermediary to convert color information in the RGB color space to the RBCY color space, and vice versa.

[0111] Therefore, if the given color information is represented in the RGB color space, but the display device displays according to the color information in the RBCY color space, the given color information can be converted from the RGB color space to the RBCY color space according to the method of this application to adapt to the display needs of the display device. Similarly, if the given color information is represented in the RBCY color space, but the display device displays according to the color information in the RGB color space, the given color information can be converted from the RBCY color space to the RGB color space according to the method of this application before the converted color information is sent to the display device for display.

[0112] The RGB color space is a three-primary-color gamut space, and it is currently the mainstream color gamut space. Many software color palettes use this three-primary-color representation method. In the above embodiment, by using the HSV hue space, the three-primary-color RGB color space and the four-primary-color RBCY color space are associated through the separated one-dimensional hue values. That is, a hue value mapping relationship is established between the RGB color space and the RBCY color space, avoiding complex geometric calculations. Subsequently, color information can be converted between the RGB color space and the RBCY color space, and it can be ensured that high-saturation colors in the RGB color space correspond to high-saturation colors in the RBCY color space. In this way, the three-primary-color space and the four-primary-color space are connected through hue values.

[0113] Furthermore, establishing the hue value mapping relationship between the RGB color space and the RBCY color space requires pre-defining multiple fifth color information in the HSV space. Different fifth color information have different third hue values, multiple fifth color information have the same third saturation value, and different fifth color information have the same third lightness value. Because changing the third saturation value and / or the third lightness value results in slight differences in the established hue value mapping relationship between the RGB color space and the RBCY color space, hue can be fine-tuned by changing the third saturation value and / or the third lightness value.

[0114] In some embodiments, it can be in accordance with Figure 11 The process shown converts color information from the RGB color space to the RBCY color space, as follows: Figure 11 As shown, step 760 includes: step 1110, obtaining the ninth color information in the RGB color space. The ninth color information generally refers to the color information in the RGB color space that needs to be converted to the RBCY color space, and the ninth color information includes the red component, green component and blue component.

[0115] Step 1120: Convert the ninth color information to the HSV color space to obtain the tenth color information; the tenth color information includes the fifth hue value, the fifth saturation value, and the fifth lightness value. The ninth color information can be converted to the HSV color space using methods that convert between the RGB and HSV color spaces.

[0116] Step 1130: Based on the hue value mapping relationship, determine the target hue value corresponding to the RBCY color space mapped to the fifth hue value. The fifth hue value in the tenth color information is used as an RGB hue value. Through the hue value mapping relationship, the RBCY hue value mapped to the fifth hue value in the tenth color information can be determined; that is, the target hue value corresponding to the RBCY color space mapped to the fifth hue value. For example, in... Figure 10 The hue value mapping curve shown can be used to determine the point on the curve with the horizontal coordinate of the fifth hue value in the tenth color information as the first target point. The vertical coordinate of the determined first target point is the target hue value mapped by the fifth hue value to the RBCY color space.

[0117] Step 1140: Following the conversion method from HSV color space to RBCY color space, the color information formed by the target hue value, fifth saturation value, and fifth lightness value is converted to the RBCY color space to obtain the tenth color information in the RBCY color space. The determined tenth color information includes the red component, blue component, indigo component, and yellow component.

[0118] Through the above embodiments, the color information in the RGB color space is converted to the RBCY color space by means of the determined hue value mapping relationship.

[0119] In some embodiments, it can be in accordance with Figure 12 The process shown converts color information from the RBCY color space to the RGB color space, as follows: Figure 12As shown, step 760 includes: step 1210, obtaining the eleventh color information in the RBCY color space. The eleventh color information generally refers to the color information to be converted to the RGB color space, and is represented using the representation method corresponding to the RBCY color space. The eleventh color information includes the red component, blue component, indigo component, and yellow component.

[0120] Step 1220: Following the conversion method from RBCY color space to HSV color space, the eleventh color information is converted to the HSV color space to obtain the twelfth color information; the twelfth color information includes the sixth hue value, the sixth saturation value, and the sixth brightness value.

[0121] Step 1230: Based on the hue value mapping relationship, determine the reference hue value corresponding to the RGB color space mapped to the sixth hue value. Similarly, the sixth hue value in the twelfth color information, as the RBCY hue value, can have its corresponding RGB hue value determined through the hue value mapping relationship; this is the reference hue value corresponding to the RGB color space mapped to the sixth hue value. For example, in... Figure 10 The hue value mapping curve shown can be used to determine the point on the curve whose vertical coordinate is the sixth hue value in the twelfth color information, which is then used as the second target point. The horizontal coordinate of the determined second target point is the reference hue value mapped by the sixth hue value.

[0122] Step 1240: Convert the color information formed by the reference hue value, sixth saturation value, and sixth brightness value to the RGB color space to obtain the thirteenth color information in the RGB color space. This conversion can be based on the conversion relationship between the HSV and RGB color spaces. The thirteenth color information includes red, green, and blue components.

[0123] Through the above embodiments, the color information in the RBCY color space is converted to the RGB color space by means of the determined hue value mapping relationship.

[0124] Figure 13 This is a block diagram of an electronic device according to an embodiment of this application. The electronic device may include a processor 1310 and a memory 1320, the memory 1320 storing computer-readable instructions. When the computer-readable instructions are executed by the processor 1310, the electronic device can be used to implement the method in any of the above method embodiments.

[0125] Processor 1310 may include one or more processing cores. Processor 1310 connects to various parts of the electronic device using various interfaces and lines, and performs various functions and processes data by running or executing instructions, programs, code sets, or instruction sets stored in memory 1320, and by calling data stored in memory 1320. Optionally, processor 1310 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). Processor 1310 may integrate one or more of a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), and a modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the displayed content; and the modem handles wireless communication. It is understood that the modem may also not be integrated into processor 1310 and may be implemented separately using a communication chip.

[0126] The memory 1320 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 1320 may include a program storage area and a data storage area. The program storage area may store instructions for implementing an operating system, instructions for implementing at least one function, instructions for implementing the various method embodiments described below, etc. The data storage area may also store data created during the use of the electronic device.

[0127] This application also provides a computer-readable storage medium storing computer-readable instructions that, when executed by a processor, implement the methods in any of the above-described method embodiments. The computer-readable storage medium may be an electronic memory such as flash memory, EEPROM (Electrically Erasable Programmable Read-Only Memory), EPROM, hard disk, or ROM. Optionally, the computer-readable storage medium includes a non-transitory computer-readable storage medium. The computer-readable storage medium has storage space for computer-readable instructions that perform any of the method steps described above. These computer-readable instructions can be read from or written to one or more computer program products. The computer-readable instructions may, for example, be compressed in a suitable form.

[0128] According to one aspect of the embodiments of this application, a computer program product is provided, the computer program product including computer-readable instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer-readable instructions from the computer-readable storage medium, and the processor executes the computer-readable instructions, causing the computer device to perform the methods of any of the above embodiments.

[0129] 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 the embodiments of this application, 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.

[0130] Through 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 application 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, touch terminal, or network device, etc.) to execute the methods according to the embodiments of this application.

[0131] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the embodiments disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein.

[0132] It should be understood that this application is not limited to the precise structure 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 application is limited only by the appended claims.

Claims

1. A method for converting from HSV color space to RBCY color space, characterized in that, include: Obtain the third color information in the HSV color space; The third color information includes a second hue value, a second saturation value, and a second brightness value; If the second saturation value is greater than 0, then the second hue value is scaled to [0, M) to obtain the first intermediate value; M = 4k, where k is a positive integer; The first intermediate value is rounded down to obtain the second intermediate value; Calculate the difference between the first intermediate value and the second intermediate value to obtain the third intermediate value; Based on the second intermediate value, the third intermediate value, and the second saturation value, determine the proportions of red, blue, indigo, and yellow corresponding to the third color information; Based on the second brightness value, the red, blue, indigo, and yellow proportions corresponding to the third color information are mapped to [0, 255] respectively, to obtain the fourth color information corresponding to the third color information in the RBCY color space.

2. The method according to claim 1, characterized in that, The step of determining the red, blue, indigo, and yellow proportions corresponding to the third color information based on the second intermediate value, the third intermediate value, and the second saturation value includes: Based on the correspondence between numerical values ​​and proportion calculation methods, the target proportion calculation method applicable to the second intermediate value is determined; the target proportion calculation method includes the target red proportion calculation method, the target blue proportion calculation method, the target indigo proportion calculation method, and the target yellow proportion calculation method. Based on the third intermediate value and the second saturation value, the red ratio corresponding to the third color information is determined according to the target red ratio calculation method, the blue ratio corresponding to the third color information is determined according to the target blue ratio calculation method, the indigo ratio corresponding to the third color information is determined according to the target indigo ratio calculation method, and the yellow ratio corresponding to the third color information is determined according to the target yellow ratio calculation method.

3. The method according to claim 1, characterized in that, When k=2, determining the target ratio calculation method applicable to the second intermediate value based on the correspondence between the numerical value and the ratio calculation method includes: If the second intermediate value = 0, the target red ratio is calculated as follows: r = 2 - f, the target blue ratio is calculated as follows: b = f(1 - S), the target indigo ratio is calculated as follows: c = (2 - f)(1 - S), and the target yellow ratio is calculated as follows: y = f. If the second intermediate value = 1, the target red ratio is calculated as follows: r = 1 - f; the target blue ratio is calculated as follows: b = (1 + f)(1 - S); the target indigo ratio is calculated as follows: c = (1 - f)(1 - S); and the target yellow ratio is calculated as follows: y = 1 + f. If the second intermediate value = 2, the target red ratio is calculated as follows: r = f(1-S), the target blue ratio is calculated as follows: b = (2-f)(1-S), the target indigo ratio is calculated as follows: c = f, and the target yellow ratio is calculated as follows: y = 2-f. If the second intermediate value = 3, the target red ratio is calculated as follows: r = (1 + f)(1 - S), the target blue ratio is calculated as follows: b = (1 - f)(1 - S), the target indigo ratio is calculated as follows: c = 1 + f, and the target yellow ratio is calculated as follows: y = 1 - f. If the second intermediate value = 4, the target red ratio is calculated as follows: r = (2-f)(1-S), the target blue ratio is calculated as follows: b = f, the target indigo ratio is calculated as follows: c = 2-f, and the target yellow ratio is calculated as follows: y = f(1-S). If the second intermediate value = 5, the target red ratio is calculated as follows: r = (1-f)(1-S), the target blue ratio is calculated as follows: b = 1+f, the target indigo ratio is calculated as follows: c = 1-f, and the target yellow ratio is calculated as follows: y = (1+f)(1-S). If the second intermediate value = 6, the target red ratio is calculated as follows: r = f, the target blue ratio is calculated as follows: b = 2 - f, the target indigo ratio is calculated as follows: c = f(1 - S), and the target yellow ratio is calculated as follows: y = (2 - f)(1 - S). If the second intermediate value = 7, the target red ratio is calculated as follows: r = 1 + f, the target blue ratio is calculated as follows: b = 1 - f, the target indigo ratio is calculated as follows: c = (1 + f)(1 - S), and the target yellow ratio is calculated as follows: y = (1 - f)(1 - S). Where r represents the proportion of red corresponding to the third color information; b represents the proportion of blue corresponding to the third color information; c represents the proportion of indigo corresponding to the third color information; y represents the proportion of yellow corresponding to the third color information; f represents the third intermediate value; and S represents the second saturation value.

4. The method according to claim 1, characterized in that, The fourth color information includes a second red component, a second blue component, a second indigo component, and a second yellow component; the step of mapping the red, blue, indigo, and yellow proportions corresponding to the third color information to [0, 255] based on the second brightness value, to obtain the fourth color information corresponding to the third color information in the RBCY color space, includes: Determine the maximum proportion value among the red, blue, indigo, and yellow proportions corresponding to the third color information; The ratio of the second brightness value to the maximum ratio value is used as the conversion factor; The second red component is obtained by multiplying the red proportion corresponding to the third color information, the conversion coefficient, and the maximum component value; the maximum component value = 255. The second blue component is obtained by multiplying the blue ratio corresponding to the third color information, the conversion coefficient, and the maximum component value. The second indigo component is obtained by multiplying the indigo ratio corresponding to the third color information, the conversion coefficient, and the maximum component value. The second yellow component is obtained by multiplying the yellow proportion corresponding to the third color information, the conversion coefficient, and the maximum component value.

5. The method according to claim 1, characterized in that, After obtaining the third color information in the HSV color space, the method further includes: If the second saturation value is equal to 0, then the second red component, second blue component, second indigo component, and second yellow component corresponding to the third color information in the RBCY color space are all equal to the product of the second brightness value and 255.

6. A method for converting between RGB color space and RBCY color space, characterized in that, include: Obtain the hue value mapping relationship between the RGB color space and the RBCY color space; Obtain the ninth color information in the RGB color space; The ninth color information is converted to the HSV color space to obtain the tenth color information; The tenth color information includes the fifth hue value, the fifth saturation value, and the fifth brightness value; Based on the hue value mapping relationship, determine the target hue value corresponding to the RBCY color space that the fifth hue value maps to; According to any one of claims 1 to 5, the color information formed by the target hue value, the fifth saturation value and the fifth brightness value is converted to the RBCY color space to obtain the tenth color information in the RBCY color space.

7. The method according to claim 6, characterized in that, Before obtaining the hue value mapping relationship between the RGB color space and the RBCY color space, the method further includes: Multiple fifth color information in the HSV space are obtained. Each fifth color information includes a third hue value, a third saturation value, and a third lightness value. The third hue values ​​of different fifth color information are different, the third saturation values ​​of multiple fifth color information are the same, and the third lightness values ​​of different fifth color information are the same. The fifth color information is converted to the RGB color space to obtain the corresponding sixth color information; Align each of the sixth color information to the RBCY color space to obtain the seventh color information corresponding to the RBCY color space; The seventh color information is converted to the HSV color space to obtain the eighth color information; Based on the mapping relationship between the fourth hue value in the plurality of eighth color information and the third hue value in the plurality of fifth color information, a hue value mapping relationship between the RGB color space and the RBCY color space is established.

8. The method according to claim 7, characterized in that, The third saturation value in each of the plurality of fifth color information is 1; aligning each of the sixth color information to the RBCY color space to obtain the seventh color information corresponding to the RBCY color space includes: Calculate the first chromaticity coordinates of each of the sixth color information in the CIE chromaticity coordinate system; Determine the intersection point between each target ray and the gamut boundary line of the RBCY color space in the CIE chromaticity coordinate system, and obtain the second chromaticity coordinate of the intersection point in the CIE chromaticity coordinate system; the target ray refers to the ray pointing from the central white point in the CIE chromaticity coordinate system to the first chromaticity coordinate. Each of the second chromaticity coordinates is converted to the RBCY color space to obtain the seventh color information corresponding to each of the second chromaticity coordinates in the RBCY color space.

9. The method according to claim 6, characterized in that, After obtaining the hue value mapping relationship between the RGB color space and the RBCY color space, the method further includes: Obtain the eleventh color information in the RBCY color space; The eleventh color information is converted to the HSV color space to obtain the twelfth color information; the twelfth color information includes the sixth hue value, the sixth saturation value, and the sixth brightness value; Based on the hue value mapping relationship, determine the reference hue value corresponding to the RGB color space that the sixth hue value maps to; The color information formed by the reference hue value, the sixth saturation value, and the sixth brightness value is converted to the RGB color space to obtain the thirteenth color information in the RGB color space.

10. An electronic device, characterized in that, include: processor; A memory storing computer-readable instructions that, when executed by the processor, implement the method as described in any one of claims 1-9.