CN114904271A - Color gradient map generation method and device, electronic equipment and storage medium - Google Patents

Color gradient map generation method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN114904271A
CN114904271A CN202210524596.XA CN202210524596A CN114904271A CN 114904271 A CN114904271 A CN 114904271A CN 202210524596 A CN202210524596 A CN 202210524596A CN 114904271 A CN114904271 A CN 114904271A
Authority
CN
China
Prior art keywords
component
saturation
gradient map
virtual scene
scene image
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210524596.XA
Other languages
Chinese (zh)
Inventor
刘怡安
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN202210524596.XA priority Critical patent/CN114904271A/en
Publication of CN114904271A publication Critical patent/CN114904271A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/001Texturing; Colouring; Generation of texture or colour
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/50Controlling the output signals based on the game progress
    • A63F13/52Controlling the output signals based on the game progress involving aspects of the displayed game scene
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/80Special adaptations for executing a specific game genre or game mode
    • A63F13/822Strategy games; Role-playing games
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/40Image enhancement or restoration by the use of histogram techniques
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F2300/00Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game
    • A63F2300/60Methods for processing data by generating or executing the game program
    • A63F2300/66Methods for processing data by generating or executing the game program for rendering three dimensional images
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F2300/00Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game
    • A63F2300/60Methods for processing data by generating or executing the game program
    • A63F2300/66Methods for processing data by generating or executing the game program for rendering three dimensional images
    • A63F2300/6646Methods for processing data by generating or executing the game program for rendering three dimensional images for the computation and display of the shadow of an object or character
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F2300/00Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game
    • A63F2300/80Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game specially adapted for executing a specific type of game
    • A63F2300/807Role playing or strategy games

Abstract

The embodiment of the application discloses a color gradient map generation method, a color gradient map generation device, electronic equipment and a storage medium; the method comprises the following steps: acquiring a virtual scene image; converting the initial color space to which the virtual scene image belongs into an HSV color space; acquiring a brightness component gradient map of the color gradient map to be generated according to the brightness component of the converted virtual scene image; acquiring a saturation component gradient map of the color gradient map to be generated according to the saturation component of the converted virtual scene image; calculating a hue component value of the color gradient map to be generated according to the hue component of the converted virtual scene image; a color gradient map in an initial color space is generated based on the luma component gradient map, the saturation component gradient map, and the hue component values. In the application, the color gradient map corresponding to the virtual scene image is obtained by performing the above processing on the virtual scene image, so that the automatic generation of the color gradient map can be realized; the workload is small, and the consumption of labor cost can be reduced.

Description

Color gradient map generation method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of computers, and in particular, to a color gradient map generation method, apparatus, electronic device, and storage medium.
Background
In the prior art, in order to make a virtual cartoon character in a game have different expression effects in different scenes and different environments, a color gradient diagram is introduced on the basis of a general cartoon character coloring process, and the coloring effect of the cartoon character is influenced by using the color gradient diagram, so that the purpose that the coloring effect of the cartoon character slightly changes in different scenes and different environments is achieved.
However, in the prior art, the color gradient map usually only depends on the color setting of each gradient of the color gradient map manually by the designer, and the method for making the color gradient map has large workload and high labor cost.
Disclosure of Invention
The embodiment of the application provides a color gradient map generation method and device, electronic equipment and a storage medium, and can solve the problems that in the prior art, a method for manufacturing a color gradient map is large in workload and high in labor cost.
The embodiment of the application provides a color gradient map generation method, which comprises the following steps:
acquiring a virtual scene image, wherein the virtual scene image is an image of a virtual scene in which a virtual role is positioned;
converting an initial color space to which the virtual scene image belongs to an HSV color space, wherein the HSV color space comprises a brightness component, a saturation component and a hue component;
acquiring a brightness component gradient map of the color gradient map to be generated according to the brightness component of the converted virtual scene image;
acquiring a saturation component gradient map of the color gradient map to be generated according to the converted saturation component of the virtual scene image;
calculating a hue component value of the color gradient map to be generated according to the hue component of the converted virtual scene image;
generating a color gradient map in the initial color space based on the luma component gradient map, saturation component gradient map, and hue component values.
An embodiment of the present application further provides a color gradient map generating apparatus, including:
the scene image acquiring unit is used for acquiring a virtual scene image, wherein the virtual scene image is an image of a virtual scene where a virtual role is positioned;
a color space conversion unit, configured to convert an initial color space to which the virtual scene image belongs to an HSV color space, where the HSV color space includes a lightness component, a saturation component, and a hue component;
the brightness gradient map unit is used for acquiring a brightness component gradient map of the color gradient map to be generated according to the brightness component of the converted virtual scene image;
the saturation gradient map unit is used for acquiring a saturation component gradient map of the color gradient map to be generated according to the converted saturation component of the virtual scene image;
the hue component value unit is used for calculating the hue component value of the color gradient image to be generated according to the hue component of the converted virtual scene image;
a gradient map generating unit configured to generate a color gradient map in the initial color space based on the lightness component gradient map, the saturation component gradient map, and the hue component values.
In some embodiments, a brightness gradient map unit, comprises:
a lightness histogram subunit, configured to obtain a lightness component histogram of the converted virtual scene image, where the lightness component histogram includes m first rectangular bars, each of the first rectangular bars corresponds to a different lightness component value on an abscissa of the lightness component histogram, and each of the first rectangular bars corresponds to a different percentage value on an ordinate of the lightness component histogram;
a lightness gradient map subunit, configured to generate a lightness component gradient map according to the lightness component values corresponding to each of the m first rectangular bars and the percentage ratio corresponding to each of the first rectangular bars, where the lightness component gradient map includes m gradients, the gradient values of the m gradients are m lightness component values arranged in an ascending order, and a ratio of each gradient in the lightness component gradient map is the same as a percentage ratio of the gradient value of the gradient in the lightness component histogram.
In some embodiments, a luma histogram subunit, comprises:
a brightness component subunit, configured to obtain multiple brightness components included in the converted virtual scene image;
the brightness ratio subunit is used for acquiring the number of pixel points belonging to the same brightness component for each brightness component in the multiple brightness components, and calculating the ratio of the number of the pixel points belonging to the same brightness component to the total number of the pixel points of the virtual scene image to obtain the ratio corresponding to each brightness component;
and the lightness histogram secondary subunit is used for generating an initial lightness component histogram according to the ascending order of the values of the lightness components by using a plurality of lightness components as abscissa values and using the ratio corresponding to each lightness component as ordinate values, wherein the initial lightness component histogram is the lightness component histogram.
In some embodiments, a luma histogram subunit, comprises:
a brightness component sub-unit, configured to obtain a plurality of brightness components included in the converted virtual scene image;
the brightness ratio subunit is used for acquiring the number of pixel points belonging to the same brightness component for each brightness component in the multiple brightness components, and calculating the ratio of the number of the pixel points belonging to the same brightness component to the total number of the pixel points of the virtual scene image to obtain the ratio corresponding to each brightness component;
a lightness histogram sub-unit, configured to generate an initial lightness component histogram according to an ascending order of values of the lightness components by using a plurality of lightness components as abscissa values and using a ratio corresponding to each lightness component as ordinate values, where the initial lightness component histogram includes a plurality of initial lightness rectangular bars, and the number of the initial lightness rectangular bars is the same as the number of the lightness components;
and the proportion removal secondary subunit is used for removing the initial brightness rectangular bars which are positioned at the edge positions in the initial brightness component histogram and account for a% of the total amount, and lengthening the height values of the remaining initial brightness rectangular bars by 1/(1-a%) times to obtain the brightness component histogram.
In some embodiments, a saturation gradient map unit, comprises:
a saturation histogram subunit, configured to obtain a saturation component histogram of the converted virtual scene image, where the saturation component histogram includes n second rectangular bars, an abscissa of each second rectangular bar in the saturation component histogram corresponds to a different saturation component value, and an ordinate of each second rectangular bar in the saturation component histogram corresponds to a different percentage value;
and the saturation component gradient map subunit is configured to generate a saturation component gradient map according to the saturation component value corresponding to each of the n second rectangular bars and the percentage ratio corresponding to each of the second rectangular bars, where the saturation component gradient map includes n gradients, the gradient values of the n gradients are n saturation component values arranged in an ascending order, and the percentage ratio of each gradient to the saturation component gradient map is the same as the percentage ratio of the gradient value of the gradient in the saturation component histogram.
In some embodiments, a saturation histogram subunit includes:
the saturation component subunit is configured to obtain multiple saturation components included in the converted virtual scene image;
the saturation ratio subunit is configured to obtain, for each saturation component of the multiple saturation components, the number of pixels belonging to the same saturation component, and calculate a ratio between the number of pixels belonging to the same saturation component and the total number of pixels of the virtual scene image, so as to obtain a ratio corresponding to each saturation component;
and the saturation histogram secondary subunit is used for generating an initial saturation component histogram by using the plurality of saturation components as abscissa values and the ratio corresponding to each saturation component as ordinate values according to the ascending order of the numerical values of the saturation components, wherein the initial saturation component histogram is the saturation component histogram.
In some embodiments, a saturation histogram subunit includes:
the saturation component subunit is configured to obtain a plurality of saturation components included in the converted virtual scene image;
the saturation ratio subunit is configured to obtain, for each saturation component of the multiple saturation components, the number of pixels belonging to the same saturation component, and calculate a ratio between the number of pixels belonging to the same saturation component and the total number of pixels of the virtual scene image, so as to obtain a ratio corresponding to each saturation component;
a saturation histogram sub-unit, configured to generate an initial saturation component histogram according to an ascending order of values of saturation components by using a plurality of saturation components as abscissa values and using a ratio corresponding to each of the saturation components as ordinate values, where the initial saturation component histogram includes a plurality of initial saturation rectangular bars, and the number of the initial saturation rectangular bars is the same as the number of the saturation components;
and the height elongation subunit is used for removing the initial saturation rectangular bars which are positioned at the edge positions in the initial saturation component histogram and account for b% of the total amount, and elongating the height values of the remaining initial saturation rectangular bars by 1/(1-b%) times to obtain the saturation component histogram.
In some embodiments, the hue component value unit is specifically configured to calculate an average value of hue components of the transformed virtual scene image, where the average value is a hue component value of the color gradient map to be generated.
In some embodiments, the gradient map generating unit comprises:
an HSV gradient map subunit for generating a color gradient map in an HSV color space based on the lightness component gradient map, the saturation component gradient map and the hue component values;
and the color space subunit is used for converting the color gradient map in the HSV color space from the HSV color space to the initial color space to obtain the color gradient map in the initial color space.
The embodiment of the present application further provides a computer-readable storage medium, where a plurality of instructions are stored, and the instructions are suitable for being loaded by a processor to perform any one of the steps in the color gradient map generating method provided in the embodiment of the present application.
In the color gradient map generation method provided by the embodiment of the application, the virtual scene image can be obtained first, and the virtual scene image is converted into the HSV color space from the original color space to which the virtual scene image belongs. Then, respectively obtaining a brightness component gradient diagram and a saturation component gradient diagram of the color gradient diagram to be generated according to the brightness component and the saturation component of the converted virtual scene image; calculating a hue component value of the color gradient map to be generated according to the hue component of the converted virtual scene image; and then generating a color gradient map in the initial color space according to the lightness component gradient map, the saturation component gradient map and the hue component values.
In the application, the color gradient map corresponding to the virtual scene image can be obtained by performing the above processing on the virtual scene image, so that the automatic generation of the color gradient map can be realized.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1a is a schematic scene diagram of a color gradient map generation method provided in an embodiment of the present application;
FIG. 1b is a schematic flow chart of a color gradient map generation method provided in an embodiment of the present application;
FIG. 1c illustrates a luminance component histogram in a particular embodiment;
FIG. 1d illustrates a luminance component histogram in another particular embodiment;
FIG. 1e is a luma component gradient map corresponding to the luma component histogram shown in FIG. 1 c;
fig. 1f is a luma component gradient map corresponding to the luma component histogram shown in fig. 1 d;
FIG. 1g shows a corresponding schematic diagram of an embodiment of a color gradient map;
FIG. 2 is a schematic flow chart diagram illustrating a color gradient map generation method according to another embodiment of the present application;
FIG. 3 is a schematic structural diagram of a color gradient map generating apparatus according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of an electronic device provided in an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The embodiment of the application provides a color gradient map generation method, a color gradient map generation device, a mobile terminal and a storage medium.
The color gradient map generation method may be specifically integrated in an electronic device, and the electronic device may be a terminal, a server, or other devices. The terminal can be a mobile phone, a tablet Computer, an intelligent bluetooth device, a notebook Computer, or a Personal Computer (PC), and the like; the server may be a single server or a server cluster composed of a plurality of servers.
In some embodiments, the color gradient map generation method may also be integrated in a plurality of electronic devices, for example, the color gradient map generation method may be integrated in a plurality of servers, and the color gradient map generation method of the present application is implemented by the plurality of servers.
In some embodiments, the server may also be implemented in the form of a terminal.
For example, referring to fig. 1a, in some embodiments, the electronic device may be a mobile terminal, and the embodiment may acquire a virtual scene image, where the virtual scene image is an image of a virtual scene in which a virtual character is located; converting an initial color space to which the virtual scene image belongs to an HSV color space, wherein the HSV color space comprises a brightness component, a saturation component and a hue component; acquiring a brightness component gradient map of the color gradient map to be generated according to the brightness component of the converted virtual scene image; acquiring a saturation component gradient map of the color gradient map to be generated according to the converted saturation component of the virtual scene image; calculating a hue component value of the color gradient map to be generated according to the hue component of the converted virtual scene image; generating a color gradient map at the initial color space based on the luma component gradient map, saturation component gradient map, and hue component values.
In one embodiment of the present disclosure, a color gradient map generation method may be executed on a terminal device or a server. The terminal device may be a local terminal device. When the color gradient map generation method is executed on a server, the method can be implemented and executed based on a cloud interaction system, wherein the cloud interaction system comprises the server and a client device.
In an optional embodiment, various cloud applications may be run under the cloud interaction system, for example: and (5) cloud games. Taking a cloud game as an example, a cloud game refers to a game mode based on cloud computing. In the cloud game operation mode, the game program operation main body and the game picture presentation main body are separated, the storage and the operation of the color gradient map generation method are completed on the cloud game server, and the client device is used for receiving and sending data and presenting the game picture, for example, the client device can be a display device with a data transmission function close to a user side, such as a terminal, a television, a computer, a palm computer and the like; however, the terminal device performing the color gradient map generation is a cloud game server in the cloud. When a game is played, a user operates the client device to send an operation instruction, such as an operation instruction of touch operation, to the cloud game server, the cloud game server runs the game according to the operation instruction, data such as a game picture and the like are encoded and compressed and returned to the client device through a network, and finally, the client device decodes the data and outputs the game picture.
In an alternative embodiment, the terminal device may be a local terminal device. Taking a game as an example, the local terminal device stores a game program and is used for presenting a game screen. The local terminal device is used for interacting with a user through a graphical user interface, namely, a game program is downloaded and installed and operated through the electronic device conventionally. The manner in which the local terminal device provides the graphical user interface to the user may include a variety of ways, for example, it may be rendered for display on a display screen of the terminal or provided to the user by holographic projection. For example, the local terminal device may include a display screen for presenting a graphical user interface including a game screen and a processor for running the game, generating the graphical user interface, and controlling display of the graphical user interface on the display screen.
A game scene (or referred to as a virtual scene) is a virtual scene that an application program displays (or provides) when running on a terminal or a server. Optionally, the virtual scene is a simulated environment of the real world, or a semi-simulated semi-fictional virtual environment, or a purely fictional virtual environment. The virtual scene is any one of a two-dimensional virtual scene and a three-dimensional virtual scene, and the virtual environment can be sky, land, sea and the like, wherein the land comprises environmental elements such as deserts, cities and the like. For example, in a sandbox type 3D shooting game, the virtual scene is a 3D game world for the user to control the virtual object to play against, and an exemplary virtual scene may include: at least one element selected from the group consisting of mountains, flat ground, rivers, lakes, oceans, deserts, sky, plants, buildings, and vehicles.
The game interface is an interface corresponding to an application program provided or displayed through a graphical user interface, the interface comprises a graphical user interface and a game picture for interaction of a user, and the game picture is a picture of a game scene.
In alternative embodiments, game controls (e.g., skill controls, behavior controls, functionality controls, etc.), indicators (e.g., direction indicators, character indicators, etc.), information presentation areas (e.g., number of clicks, game play time, etc.), or game setting controls (e.g., system settings, stores, coins, etc.) may be included in the UI interface.
In an optional embodiment, the game screen is a display screen corresponding to a virtual scene displayed by the terminal device, and the game screen may include a game object performing game logic in the virtual scene, a Non-Player Character (NPC), an Artificial Intelligence (AI) Character, and other virtual objects.
For example, in some embodiments, the content displayed in the graphical user interface at least partially comprises a game scene, wherein the game scene comprises at least one game object.
In some embodiments, the game objects in the game scene comprise virtual objects, i.e., user objects, manipulated by the player user.
The game object refers to a virtual object in a virtual scene, including a game character, which is a dynamic object that can be controlled, i.e., a dynamic virtual object. Alternatively, the dynamic object may be a virtual character, a virtual animal, an animation character, or the like. The virtual object is a character controlled by a user through an input device, or an AI set in a virtual environment match-up through training, or an NPC set in a virtual scene match-up.
Optionally, the virtual object is a virtual character playing a game in a virtual scene. Optionally, the number of virtual objects in the virtual scene match is preset, or dynamically determined according to the number of clients participating in the match, which is not limited in the embodiment of the present application.
In one possible implementation, the user can control the virtual object to play the game behavior in the virtual scene, and the game behavior can include moving, releasing skills, using props, dialog, and the like, for example, controlling the virtual object to run, jump, crawl, and the like, and can also control the virtual object to fight with other virtual objects using the skills, virtual props, and the like provided by the application program.
The virtual camera is a necessary component for game scene pictures, is used for presenting the game scene pictures, one game scene at least corresponds to one virtual camera, two or more than two virtual cameras can be used as game rendering windows according to actual needs, the game rendering windows are used for capturing and presenting picture contents of a game world for a user, and the viewing angles of the game world, such as a first person viewing angle and a third person viewing angle, of the user can be adjusted by setting parameters of the virtual camera.
In an optional implementation manner, an embodiment of the present invention provides a color gradient map generating method, where a graphical user interface is provided by a terminal device, where the terminal device may be the aforementioned local terminal device, and may also be the aforementioned client device in a cloud interaction system.
The following are detailed below. The numbers in the following examples are not intended to limit the order of preference of the examples.
In this embodiment, a color gradient map generation method is provided, as shown in fig. 1b, a specific flow of the method may include the following steps 110 to 160:
110. and acquiring a virtual scene image.
The virtual scene image is an image of a virtual scene where the virtual character is located, and the image of the virtual scene can be a scene original picture made by an art designer. The virtual scene at the virtual character body can be multiple; accordingly, steps 110 to 160 may be performed for each of the plurality of virtual scenes, and a color gradient map corresponding to each virtual scene image is obtained.
120. And converting the initial color space to which the virtual scene image belongs into an HSV color space.
The HSV color space includes a value component V, a saturation component S, and a hue component H.
The initial color space is a color space to which the virtual scene image originally belongs, the initial color space may be any one of an RGB color space, a CMY/CMYK color space, a Lab color space, and a YUV/YcbCr color space, and a specific color space type of the initial color space should not be construed as a limitation to the present application.
130. And acquiring a brightness component gradient map of the color gradient map to be generated according to the brightness component of the converted virtual scene image.
The color gradient map Ramp is an elongated gradient map, and the color gradually changes from one end of the elongated gradient map to the other end of the elongated gradient map. The color gradient map to be generated is a color gradient map to be generated corresponding to the virtual scene image.
The lightness component gradient map is another strip-shaped gradient map, and the lightness component gradually changes from one end of the strip-shaped gradient map to the other end of the strip-shaped gradient map.
After obtaining the virtual scene image converted into the HSV color space, obtaining a lightness component gradient map of the color gradient map to be generated according to a lightness component (i.e., a V component) of the virtual scene image, which may specifically include the following steps 131 to 132:
131. obtaining a brightness component histogram of the converted virtual scene image, wherein the brightness component histogram includes m first rectangular bars, each first rectangular bar corresponds to a different brightness component value on the abscissa of the brightness component histogram, and each first rectangular bar corresponds to a different percentage ratio on the ordinate of the brightness component histogram.
m is a positive integer and the particular value of m should not be construed as limiting the application. Each of the m first rectangular bars has its own corresponding lightness component value, and each first rectangular bar has its own corresponding percentage ratio, that is, each lightness component value has its own percentage ratio, which is used to reflect the percentage of its own corresponding lightness component value in the m lightness component values, so that the percentages of the m lightness component values are added to 100%.
Optionally, in a specific embodiment, the step 131 may include the following steps a1 to A3:
a1, acquiring a plurality of brightness components included in the virtual scene image after conversion.
Specifically, the brightness component of each pixel point in all pixel points included in the converted virtual scene image can be obtained, and then the pixel points with the same brightness component are aggregated together, so that a multi-cluster pixel point set can be obtained, the brightness components corresponding to the pixel point sets of different clusters are different, and the number of the pixel point sets is the same as the number of the brightness components. The plurality of brightness components included in the converted virtual scene image may be acquired in the above manner.
And A2, for each lightness component in the lightness components, acquiring the number of pixel points belonging to the same lightness component, and calculating the ratio of the number of the pixel points belonging to the same lightness component to the total number of the pixel points of the virtual scene image to obtain the ratio corresponding to each lightness component.
Specifically, when calculating the ratio corresponding to each brightness component, the number of pixels included in the pixel set corresponding to the current brightness component may be obtained first, then the total number of pixels included in the converted virtual scene image is obtained, and then the ratio of the former to the latter is calculated, where the ratio is the ratio corresponding to the current brightness component.
And A3, taking a plurality of lightness components as abscissa values, taking the ratio corresponding to each lightness component as ordinate values, and generating an initial lightness component histogram according to the ascending order of the values of the lightness components, wherein the initial lightness component histogram is the lightness component histogram.
After obtaining the multiple lightness components and the ratios corresponding to each lightness component, the values of the lightness components may be used as abscissa values, and the ratios corresponding to the lightness components may be used as ordinate values, to generate multiple rectangular bars, and the multiple rectangular bars are formed according to the following formula: the order of the lightness components from small to large, arranged in a coordinate system, can generate an initial lightness component histogram.
In this embodiment, the initial luma component histogram may be directly treated as the luma component histogram.
For details, please refer to fig. 1c, if m is 10, the converted virtual scene image includes 10 brightness components, which are: v0, v1, v2, v3, v4, v5, v6, v7, v8 and v 9.
Then, by the same method as step a2, a ratio corresponding to each luma component is calculated, taking v0 as an example, according to the following formula:
Figure BDA0003643626110000111
and calculating a ratio r0 corresponding to v0, wherein f (vi) is the number of pixels with the brightness component vi, and i is a positive integer.
Through the same procedure, the ratios corresponding to v1, v2, v3, v4, v5, v6, v7, v8 and v9 can be obtained in sequence: r1, r2, r3, r4, r5, r6, r7, r8 and r 9.
Then, taking v0 as an abscissa value and r0 as an ordinate value, generating a first rectangular bar;
a second rectangular bar is generated by taking v1 as an abscissa value and r1 as an ordinate value;
a third rectangular bar is generated by taking v2 as an abscissa value and r2 as an ordinate value;
……
the tenth rectangle is generated by using v9 as an abscissa and r9 as an ordinate.
Then, the ten rectangular bars are arranged in the coordinate system according to the order of lightness components from small to large, so as to obtain the initial lightness component histogram as shown in fig. 1c, in this specific embodiment, the initial lightness component histogram is the lightness component histogram obtained in step 131.
In the above embodiment, a plurality of rectangular bars may be drawn according to a plurality of brightness components included in the converted virtual scene image and a ratio corresponding to each brightness component, and the plurality of rectangular bars are arranged in a coordinate system according to a sequence from small to large of the brightness components to obtain a final brightness component histogram, where the brightness component histogram may more accurately reflect the ratio corresponding to each brightness component, so as to obtain a brightness component histogram more closely attached to the virtual scene image.
Alternatively, in another specific embodiment, the step 131 may include the following steps B1 to B4:
and B1, acquiring a plurality of brightness components included in the converted virtual scene image.
And B2, for each brightness component in the multiple brightness components, acquiring the number of pixel points belonging to the same brightness component, and calculating the ratio of the number of the pixel points belonging to the same brightness component to the total number of the pixel points of the virtual scene image to obtain the ratio corresponding to each brightness component.
B3, generating an initial lightness component histogram including a plurality of initial lightness rectangular bars in ascending order of the numerical values of the lightness components with the plurality of lightness components as abscissa values and the ratio corresponding to each of the lightness components as ordinate values, the number of the initial lightness rectangular bars being the same as the number of the lightness components.
Steps B1 through B3 correspond to steps a1 through A3 described above, and are not described herein again.
And B4, removing initial brightness rectangular bars which are positioned at the edge positions in the initial brightness component histogram and account for a% of the total amount, and lengthening the height values of the remaining initial brightness rectangular bars by 1/(1-a%) times to obtain the brightness component histogram.
After the initial brightness component histogram is obtained, the initial brightness rectangular bars in the initial brightness component histogram, which are located at edge positions and account for a% of the total number of rectangular bars, may be removed.
Optionally, the two side edge positions of the initial lightness component histogram may be removed with the same number of initial lightness rectangular bars, or with different numbers of initial lightness rectangular bars; namely, the left edge position of the initial brightness component histogram can be removed by the initial brightness rectangular bar of a/2%, and the right edge position of the initial brightness component histogram can be removed by the initial brightness rectangular bar of a/2%; it is also possible to remove a 0% of the initial luma rectangular bars at the left edge position of the initial luma component histogram and (a-a 0)% of the initial luma rectangular bars at the right edge position of the initial luma component histogram, where a0 is a positive number.
After the removal operation is performed, the sum of the percentages corresponding to the remaining initial brightness rectangular bars becomes 1-a%, and 1-a% is less than 100%, so that in order to make the sum of the percentages corresponding to the remaining initial brightness rectangular bars become 100% again, the height values of the remaining initial brightness rectangular bars (i.e., the ratios corresponding to the remaining brightness components, respectively) can be lengthened by 1/(1-a%) times, so that the brightness component histogram can be obtained.
For details, please refer to fig. 1c and fig. 1d, it is not assumed that the percentage ratio of the initial brightness rectangular bars collectively corresponding to v0 and v9 in fig. 1c is a% of the total amount of the rectangular bars; therefore, after removing the initial brightness rectangular bars corresponding to v0, r0, and the initial brightness rectangular bars corresponding to v9, r9, the ratios corresponding to v1, v2, v3, v4, v5, v6, v7, v8 respectively may be: r1, r2, r3, r4, r5, r6, r7 and r8 are all elongated by 1/(1-a%) times, so that the ratios after elongation can be obtained: z1, z2, z3, z4, z5, z6, z7, and z8, and further obtain the luma component histogram shown in fig. 1d, in this specific embodiment, the luma component histogram shown in fig. 1d is the luma component histogram acquired in step 131.
In the above embodiment, the rectangular bar having a small influence on the lightness component histogram can be removed, and the obtained lightness component histogram can be made more practical.
132. And generating a brightness component gradient map according to the brightness component value corresponding to each of the m first rectangular bars and the percentage ratio corresponding to each of the first rectangular bars, wherein the brightness component gradient map comprises m gradients, the gradient values of the m gradients are m brightness component values which are arranged in an ascending order, and the proportion of each gradient in the brightness component gradient map is the same as the percentage ratio of the gradient value of the gradient in the brightness component histogram corresponding to the brightness component histogram.
The lightness component gradient map is an elongated gradient map, the gradient map comprises m gradients, and gradient values from one end to the other end of the elongated gradient map are m lightness component values which are arranged in an ascending order. In the m gradients, each gradient occupies the proportion of the whole lightness component gradient map, and the percentage ratio corresponding to the gradient value of the gradient in the lightness component histogram is the same.
See fig. 1e and 1f for details, where fig. 1e is a luma component gradient map corresponding to the luma component histogram shown in fig. 1 c; fig. 1f is a luma component gradient map corresponding to the luma component histogram shown in fig. 1 d.
In one embodiment, let m be 10, see fig. 1e, the 10 gradients of the lightness component gradient map are, in order from left to right, the gradient values: v0, v1, v2, v3, v4, v5, v6, v7, v8, v 9; accordingly, the ratio of the length of the 10 gradients to the total length of the whole lightness component gradient map is, in order: r0, r1, r2, r3, r4, r5, r6, r7, r8 and r 9.
In another embodiment, let m be 8, see fig. 1f, the 8 gradients of the lightness component gradient map are, in order from left to right, the gradient values in the following order: v1, v2, v3, v4, v5, v6, v7, v 8; accordingly, the ratio of the length of the 8 gradients to the total length of the entire brightness component gradient map is, in order: z1, z2, z3, z4, z5, z6, z7, z 8.
In the above embodiment, a brightness component histogram corresponding to the virtual scene image may be determined according to a correspondence relationship between all pixel points in the virtual scene image and the brightness component, where the brightness component histogram includes m first rectangular bars. Then, a lightness component gradient map is determined according to the lightness component values of the m first rectangular bars corresponding to the abscissa of the lightness component histogram and the percentage ratios of the m first rectangular bars corresponding to the ordinate of the lightness component histogram. The above embodiments may obtain a gradient map of its corresponding brightness component based on the virtual scene image, so as to more intuitively present the brightness component of the virtual scene image.
140. And acquiring a saturation component gradient map of the color gradient map to be generated according to the converted saturation component of the virtual scene image.
The saturation component gradient map is another strip-shaped gradient map, and the saturation components gradually change from one end of the strip-shaped gradient map to the other end of the strip-shaped gradient map.
After obtaining the virtual scene image converted into the HSV color space, obtaining a saturation component gradient map of a color gradient map to be generated according to a saturation component (i.e., a V component) of the virtual scene image, which may specifically include the following steps 141 to 142:
141. and acquiring a saturation component histogram of the converted virtual scene image, wherein the saturation component histogram comprises n second rectangular bars, the abscissa of each second rectangular bar in the saturation component histogram corresponds to different saturation component values, and the ordinate of each second rectangular bar in the saturation component histogram corresponds to different percentage ratios.
n is a positive integer, and the particular value of n should not be construed as limiting the application. Each of the n second rectangular bars has its own corresponding saturation component, and each of the n second rectangular bars has its own corresponding percentage ratio, that is, each of the saturation components has its own percentage ratio, which is used to reflect the percentage of its own corresponding saturation component in the m saturation components, so that the percentage of the m saturation components is added to 100%.
Alternatively, in a specific embodiment, step 141 may include steps C1 through C3 as follows:
and C1, acquiring a plurality of saturation components included in the converted virtual scene image.
Specifically, the saturation component of each pixel point in all pixel points included in the converted virtual scene image can be obtained, and then the pixel points with the same saturation component are aggregated together, so that a multi-cluster pixel point set can be obtained, the saturation components corresponding to the pixel point sets of different clusters are different, and the number of the pixel point sets is the same as the number of the saturation components. The multiple saturation components included in the converted virtual scene image may be obtained in the manner described above.
And C2, acquiring the number of pixel points belonging to the same saturation component for each saturation component in the saturation components, and calculating the ratio of the number of the pixel points belonging to the same saturation component to the total number of the pixel points of the virtual scene image to obtain the ratio corresponding to each saturation component.
Specifically, when calculating the ratio corresponding to each saturation component, the number of pixels included in the pixel set corresponding to the current saturation component may be obtained first; and then, acquiring the total number of pixel points included in the converted virtual scene image, and then calculating the ratio of the pixel points to the pixel points, wherein the ratio is the ratio corresponding to the current saturation component.
And C3, taking a plurality of saturation components as abscissa values and the ratio corresponding to each saturation component as ordinate values, and generating an initial saturation component histogram according to the ascending order of the numerical values of the saturation components, wherein the initial saturation component histogram is the saturation component histogram.
After obtaining the multiple saturation components and the ratios corresponding to the saturation components, the values of the saturation components may be used as abscissa values, the ratios corresponding to the saturation components may be used as ordinate values, and multiple rectangular bars may be generated, and the multiple rectangular bars may be arranged in the coordinate system according to the order from small to large of the saturation components, so as to generate an initial saturation component histogram.
In this embodiment, the initial saturation component histogram may be directly used as the saturation component histogram.
In the above embodiment, a plurality of rectangular bars may be drawn according to a plurality of saturation components included in the converted virtual scene image and a ratio corresponding to each saturation component, and the plurality of rectangular bars are arranged in a coordinate system according to a sequence from small to large of the saturation components to obtain a final saturation component histogram, where the saturation component histogram may more accurately reflect the ratio corresponding to each saturation component, so as to obtain a saturation component histogram more fitting the virtual scene image.
Alternatively, in another specific embodiment, step 141 may include the following steps D1 to D4:
d1, acquiring a plurality of saturation components included in the converted virtual scene image.
D2, for each saturation component in the multiple saturation components, obtaining the number of pixel points belonging to the same saturation component, and calculating the ratio of the number of the pixel points belonging to the same saturation component to the total number of the pixel points of the virtual scene image to obtain the ratio corresponding to each saturation component.
D3, taking a plurality of saturation components as abscissa values, taking the ratio corresponding to each saturation component as ordinate values, and generating an initial saturation component histogram according to the ascending order of the values of the saturation components, wherein the initial saturation component histogram comprises a plurality of initial saturation rectangular bars, and the number of the initial saturation rectangular bars is the same as that of the saturation components.
Steps D1 to D3 correspond to steps C1 to C3, and are not described herein.
D4, removing the initial saturation rectangular bars which are positioned at the edge positions in the initial saturation component histogram and account for b% of the total amount, and lengthening the height values of the remaining initial saturation rectangular bars by 1/(1-b%) times to obtain the saturation component histogram.
After the initial saturation component histogram is obtained, the initial saturation rectangular bars in the initial saturation component histogram, which are located at edge positions and occupy b% of the total number of rectangular bars, may be removed. After the removal operation is performed, the sum of the percentages of the remaining initial saturation rectangular bars becomes 1-b%, and 1-b% is less than 100%, so that in order to make the sum of the percentages of the remaining initial saturation rectangular bars become 100% again, the height values of the remaining initial saturation rectangular bars (i.e., the ratios of the remaining saturation components, respectively) may be each extended by 1/(1-b%), thereby obtaining a saturation component histogram.
In the above embodiment, the rectangular bar having a small influence on the saturation component histogram may be removed, so that the obtained saturation component histogram may have higher practicability.
142. And generating a saturation component gradient map according to the saturation component value corresponding to each second rectangular strip in the n second rectangular strips and the percentage ratio corresponding to each second rectangular strip, wherein the saturation component gradient map comprises n gradients, the gradient values of the n gradients are n saturation component values which are arranged in an ascending order, and the proportion of each gradient in the saturation component gradient map is the same as the percentage ratio of the gradient value of the gradient in the saturation component histogram.
The saturation component gradient map is a strip-shaped gradient map, the gradient map comprises n gradients, and gradient values from one end to the other end of the strip-shaped gradient map are n saturation component values which are arranged in an ascending order. In the n gradients, the proportion of each gradient in the whole saturation component gradient map is the same as the percentage ratio of the gradient value of the gradient in the saturation component histogram.
In the foregoing embodiment, a saturation component histogram corresponding to the virtual scene image may be determined according to a correspondence between all pixel points in the virtual scene image and the saturation components, where the saturation component histogram includes n second rectangular bars. And then, determining a saturation component gradient map according to the saturation component values of the n second rectangular bars corresponding to the abscissa of the saturation component histogram and the percentage ratios of the n second rectangular bars corresponding to the ordinate of the saturation component histogram. The above embodiment may obtain a gradient map of the corresponding saturation component based on the virtual scene image, so as to present the saturation component of the virtual scene image more intuitively.
150. And calculating the tone component value of the color gradient map to be generated according to the converted tone component of the virtual scene image.
Alternatively, the "calculating the hue component value of the color gradient map to be generated" may specifically be implemented by the following steps: and calculating the average value of the tone components of the converted virtual scene image, wherein the average value is the value of the tone component of the color gradient map to be generated.
In the above-described embodiment, the average value of the hue components of the converted virtual scene image may be used as the hue component value of the color gradient map to be generated. It should be understood that other ways of calculating the hue component values of the color gradient map to be generated can be used, and the specific calculation process of the hue component values of the color gradient map to be generated should not be construed as limiting the application.
160. Generating a color gradient map at the initial color space based on the luma component gradient map, saturation component gradient map, and hue component values.
After obtaining the color gradient map, the developer may also clip the color gradient map according to the requirement of the developer, so that the clipped color gradient map is used as a resource to participate in rendering of the virtual character, and please refer to fig. 1 g.
Optionally, in a specific embodiment, step 160 may include the following steps 161 to 162:
161. generating a color gradient map in HSV color space based on the lightness component gradient map, the saturation component gradient map, and the hue component values.
162. And converting the color gradient map in the HSV color space from the HSV color space to the initial color space to obtain the color gradient map in the initial color space.
In the above embodiment, the color gradient map in the HSV color space may be generated according to the acquired lightness component gradient map, saturation component gradient map, and hue component value of the color gradient map to be generated; and then, converting the color gradient map from the HSV color space to the initial color space so as to facilitate the subsequent use of the color gradient map. In the application, after the image of the virtual scene at the virtual character body is acquired, the color gradient map corresponding to the image of the virtual scene can be acquired by executing the processing procedure, so that the automatic generation of the color gradient map corresponding to the image of each virtual scene is realized.
In the color gradient map generation method provided by the embodiment of the application, the virtual scene image can be obtained first, and the virtual scene image is converted into the HSV color space from the original color space to which the virtual scene image belongs. Then, respectively obtaining a brightness component gradient diagram and a saturation component gradient diagram of the color gradient diagram to be generated according to the brightness component and the saturation component of the converted virtual scene image; calculating a hue component value of the color gradient map to be generated according to the hue component of the converted virtual scene image; and then generating a color gradient map in the initial color space according to the lightness component gradient map, the saturation component gradient map and the hue component values. In the application, the color gradient map corresponding to the virtual scene image can be obtained by performing the above processing on the virtual scene image, so that automatic generation of the color gradient map can be realized.
The method provided by the embodiment of the application can reduce the consumption of labor cost.
The method described in the above embodiments is further described in detail below.
In this embodiment, the method of the embodiment of the present application will be described in detail by taking an example in which the initial color space is an RGB color space.
As shown in fig. 2, a specific flow of the color gradient map generation method is as follows:
201. and acquiring a virtual scene image.
The virtual scene image is an image of a virtual scene where a virtual character is located.
202. Converting the virtual scene image from an RGB color space to an HSV color space, wherein the HSV color space comprises a brightness component, a saturation component and a hue component.
203. Acquiring a plurality of brightness components included in the converted virtual scene image.
204. For each brightness component in the multiple brightness components, the number of pixel points belonging to the same brightness component is obtained, and the ratio of the number of the pixel points belonging to the same brightness component to the total number of the pixel points of the virtual scene image is calculated to obtain the ratio corresponding to each brightness component.
205. And generating an initial lightness component histogram according to the ascending order of the numerical values of the lightness components by taking the lightness components as abscissa values and the ratio corresponding to each lightness component as ordinate values.
Wherein the initial luma component histogram includes a plurality of initial luma rectangular bars, the number of initial luma rectangular bars being the same as the number of luma components.
206. And removing initial brightness rectangular bars which are positioned at edge positions in the initial brightness component histogram and account for a% of the total amount, and lengthening the height values of the remaining initial brightness rectangular bars by 1/(1-a%) times to obtain the brightness component histogram.
Wherein the luma component histogram includes m first rectangular bars, each of the first rectangular bars corresponding to a respective different luma component value on an abscissa of the luma component histogram, and each of the first rectangular bars corresponding to a respective different percentage value on an ordinate of the luma component histogram.
207. And generating a brightness component gradient map according to the brightness component value corresponding to each first rectangular bar in the m first rectangular bars and the percentage ratio corresponding to each first rectangular bar.
The lightness component gradient map comprises m gradients, gradient values of the m gradients are m lightness component values which are arranged in an ascending order, and the percentage ratio of each gradient in the lightness component gradient map to the percentage ratio of the gradient value of the gradient in the lightness component histogram is the same.
208. And acquiring a plurality of saturation components included in the converted virtual scene image.
209. And for each saturation component in the multiple saturation components, acquiring the number of pixel points belonging to the same saturation component, and calculating the ratio of the number of the pixel points belonging to the same saturation component to the total number of the pixel points of the virtual scene image to obtain the ratio corresponding to each saturation component.
210. And generating an initial saturation component histogram by taking the plurality of saturation components as abscissa values and the ratio corresponding to each saturation component as ordinate values according to the ascending order of the numerical values of the saturation components.
Wherein the initial saturation component histogram includes a plurality of initial saturation rectangles, and the number of initial saturation rectangles is the same as the number of saturation components.
211. And removing the initial saturation rectangular bars which are positioned at the edge positions in the initial saturation component histogram and account for b% of the total amount, and lengthening the height values of the remaining initial saturation rectangular bars by 1/(1-b%) times to obtain the saturation component histogram.
The saturation component histogram comprises n second rectangular bars, the abscissa of each second rectangular bar in the saturation component histogram corresponds to different saturation component values, and the ordinate of each second rectangular bar in the saturation component histogram corresponds to different percentage ratios.
212. And generating a saturation component gradient map according to the saturation component value corresponding to each second rectangular strip in the n second rectangular strips and the percentage ratio corresponding to each second rectangular strip.
The saturation component gradient map comprises n gradients, gradient values of the n gradients are n saturation component values which are arranged in an ascending order, and the percentage ratio of each gradient in the saturation component gradient map is the same as the percentage ratio of the gradient value of the gradient in the saturation component histogram.
213. And calculating the average value of the tone components of the converted virtual scene image, wherein the average value is the value of the tone component of the color gradient map to be generated.
214. Generating a color gradient map in HSV color space based on the lightness component gradient map, the saturation component gradient map, and the hue component values.
215. And converting the color gradient map in the HSV color space from the HSV color space to the initial color space to obtain the color gradient map in the initial color space.
As can be seen from the above, in the color gradient map generation method provided in the embodiment of the present application, the virtual scene image may be obtained first, and the virtual scene image is converted from the original color space to which the virtual scene image belongs to the HSV color space. Then, respectively obtaining a brightness component gradient diagram and a saturation component gradient diagram of the color gradient diagram to be generated according to the brightness component and the saturation component of the converted virtual scene image; calculating a hue component value of the color gradient map to be generated according to the hue component of the converted virtual scene image; and then generating a color gradient map in the initial color space according to the lightness component gradient map, the saturation component gradient map and the hue component values.
In the application, the color gradient map corresponding to the virtual scene image can be obtained by performing the above processing on the virtual scene image, so that the automatic generation of the color gradient map can be realized.
In order to better implement the above method, an embodiment of the present application further provides a color gradient map generating apparatus, where the color gradient map generating apparatus may be specifically integrated in an electronic device, and the electronic device may be a terminal. The terminal can be a mobile phone, a tablet computer, an intelligent Bluetooth device, a notebook computer, a personal computer and other devices.
For example, in the present embodiment, the color gradient map generating apparatus is specifically integrated in the terminal as an example, and the apparatus of the embodiment of the present application is described in detail.
For example, as shown in fig. 3, the color gradient map generating means may include:
a scene image obtaining unit 301, configured to obtain a virtual scene image, where the virtual scene image is an image of a virtual scene where a virtual character is located;
a color space converting unit 302, configured to convert an initial color space to which the virtual scene image belongs into an HSV color space, where the HSV color space includes a brightness component, a saturation component, and a hue component;
a lightness gradient map unit 303, configured to obtain, according to the lightness component of the converted virtual scene image, a lightness component gradient map of the color gradient map to be generated;
a saturation gradient map unit 304, configured to obtain a saturation component gradient map of the color gradient map to be generated according to the converted saturation component of the virtual scene image;
a hue component value unit 305, configured to calculate a hue component value of the color gradient map to be generated according to the converted hue component of the virtual scene image;
a gradient map generating unit 306, configured to generate a color gradient map in the initial color space based on the lightness component gradient map, the saturation component gradient map, and the hue component values.
In some embodiments, the brightness gradient map unit 303 includes:
a lightness histogram subunit, configured to obtain a lightness component histogram of the converted virtual scene image, where the lightness component histogram includes m first rectangular bars, each of the first rectangular bars corresponds to a different lightness component value on an abscissa of the lightness component histogram, and each of the first rectangular bars corresponds to a different percentage value on an ordinate of the lightness component histogram;
a lightness gradient map subunit, configured to generate a lightness component gradient map according to the lightness component values corresponding to each of the m first rectangular bars and the percentage ratio corresponding to each of the first rectangular bars, where the lightness component gradient map includes m gradients, the gradient values of the m gradients are m lightness component values arranged in an ascending order, and a ratio of each gradient in the lightness component gradient map is the same as a percentage ratio of the gradient value of the gradient in the lightness component histogram.
In some embodiments, a luma histogram subunit, comprises:
a brightness component sub-unit, configured to obtain a plurality of brightness components included in the converted virtual scene image;
the brightness ratio subunit is used for acquiring the number of pixel points belonging to the same brightness component for each brightness component in the multiple brightness components, and calculating the ratio of the number of the pixel points belonging to the same brightness component to the total number of the pixel points of the virtual scene image to obtain the ratio corresponding to each brightness component;
and the lightness histogram secondary subunit is used for generating an initial lightness component histogram according to the ascending order of the values of the lightness components by using a plurality of lightness components as abscissa values and using the ratio corresponding to each lightness component as ordinate values, wherein the initial lightness component histogram is the lightness component histogram.
In some embodiments, a luma histogram subunit, comprises:
a brightness component sub-unit, configured to obtain a plurality of brightness components included in the converted virtual scene image;
the brightness ratio subunit is used for acquiring the number of pixel points belonging to the same brightness component for each brightness component in the multiple brightness components, and calculating the ratio of the number of the pixel points belonging to the same brightness component to the total number of the pixel points of the virtual scene image to obtain the ratio corresponding to each brightness component;
a lightness histogram sub-unit, configured to generate an initial lightness component histogram according to an ascending order of values of the lightness components by using a plurality of lightness components as abscissa values and using a ratio corresponding to each lightness component as ordinate values, where the initial lightness component histogram includes a plurality of initial lightness rectangular bars, and the number of the initial lightness rectangular bars is the same as the number of the lightness components;
and the proportion removal secondary subunit is used for removing the initial brightness rectangular bars which are positioned at the edge positions in the initial brightness component histogram and account for a% of the total amount, and lengthening the height values of the remaining initial brightness rectangular bars by 1/(1-a%) times to obtain the brightness component histogram.
In some embodiments, the saturation gradient map unit 304 includes:
a saturation histogram subunit, configured to obtain a saturation component histogram of the converted virtual scene image, where the saturation component histogram includes n second rectangular bars, an abscissa of each second rectangular bar in the saturation component histogram corresponds to a different saturation component value, and an ordinate of each second rectangular bar in the saturation component histogram corresponds to a different percentage value;
and the saturation component gradient map subunit is configured to generate a saturation component gradient map according to the saturation component value corresponding to each of the n second rectangular bars and the percentage ratio corresponding to each of the second rectangular bars, where the saturation component gradient map includes n gradients, the gradient values of the n gradients are n saturation component values that are sequentially arranged in an ascending order, and the proportion of each gradient in the saturation component gradient map is the same as the percentage ratio of the gradient value of the gradient in the saturation component histogram.
In some embodiments, a saturation histogram subunit includes:
the saturation component subunit is configured to obtain a plurality of saturation components included in the converted virtual scene image;
the saturation ratio subunit is configured to obtain, for each of the plurality of saturation components, the number of pixels belonging to the same saturation component, and calculate a ratio between the number of pixels belonging to the same saturation component and the total number of pixels of the virtual scene image, to obtain a ratio corresponding to each saturation component;
and the saturation histogram secondary subunit is used for generating an initial saturation component histogram by using the plurality of saturation components as abscissa values and the ratio corresponding to each saturation component as ordinate values according to the ascending order of the numerical values of the saturation components, wherein the initial saturation component histogram is the saturation component histogram.
In some embodiments, a saturation histogram subunit includes:
the saturation component subunit is configured to obtain a plurality of saturation components included in the converted virtual scene image;
the saturation ratio subunit is configured to obtain, for each saturation component of the multiple saturation components, the number of pixels belonging to the same saturation component, and calculate a ratio between the number of pixels belonging to the same saturation component and the total number of pixels of the virtual scene image, so as to obtain a ratio corresponding to each saturation component;
a saturation histogram sub-unit, configured to generate an initial saturation component histogram according to an ascending order of values of saturation components by using a plurality of saturation components as abscissa values and using a ratio corresponding to each of the saturation components as ordinate values, where the initial saturation component histogram includes a plurality of initial saturation rectangular bars, and the number of the initial saturation rectangular bars is the same as the number of the saturation components;
and the height elongation subunit is used for removing the initial saturation rectangular bars which are positioned at the edge positions in the initial saturation component histogram and account for b% of the total amount, and elongating the height values of the remaining initial saturation rectangular bars by 1/(1-b%) times to obtain the saturation component histogram.
In some embodiments, the hue component value unit 305 is specifically configured to calculate an average value of the hue components of the transformed virtual scene image, where the average value is the hue component value of the color gradient map to be generated.
In some embodiments, the gradient map generating unit 306 includes:
an HSV gradient map subunit for generating a color gradient map in an HSV color space based on the lightness component gradient map, the saturation component gradient map and the hue component values;
and the color space subunit is used for converting the color gradient map in the HSV color space from the HSV color space to the initial color space to obtain the color gradient map in the initial color space.
In a specific implementation, the above units may be implemented as independent entities, or may be combined arbitrarily to be implemented as the same or several entities, and the specific implementation of the above units may refer to the foregoing method embodiments, which are not described herein again.
Therefore, the color gradient map corresponding to the virtual scene image can be obtained by performing the above processing on the virtual scene image, so that the color gradient map can be automatically generated.
The embodiment of the application can reduce the workload of developers and save the time of game development.
The embodiment of the application also provides the electronic equipment which can be equipment such as a terminal and a server. The terminal can be a mobile phone, a tablet computer, an intelligent Bluetooth device, a notebook computer, a personal computer and the like; the server may be a single server, a server cluster composed of a plurality of servers, or the like.
In some embodiments, the color gradient map generating apparatus may also be integrated in a plurality of electronic devices, for example, the color gradient map generating apparatus may be integrated in a plurality of servers, and the color gradient map generating method of the present application is implemented by the plurality of servers.
In this embodiment, the electronic device of this embodiment is described in detail as an example, for example, as shown in fig. 4, it shows a schematic structural diagram of the electronic device according to the embodiment of the present application, specifically:
the electronic device may include components such as a processor 401 of one or more processing cores, memory 402 of one or more computer-readable storage media, a power supply 403, an input module 404, and a communication module 405. Those skilled in the art will appreciate that the electronic device configuration shown in fig. 4 does not constitute a limitation of the electronic device and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components. Wherein:
the processor 401 is a control center of the electronic device, connects various parts of the whole electronic device by various interfaces and lines, performs various functions of the electronic device and processes data by running or executing software programs and/or modules stored in the memory 402 and calling data stored in the memory 402, thereby performing overall monitoring of the electronic device. In some embodiments, processor 401 may include one or more processing cores; in some embodiments, processor 401 may integrate an application processor, which primarily handles operating systems, user interfaces, applications, etc., and a modem processor, which primarily handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 401.
The memory 402 may be used to store software programs and modules, and the processor 401 executes various functional applications and data processing by operating the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data created according to use of the electronic device, and the like. Further, the memory 402 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 access to the memory 402.
The electronic device also includes a power supply 403 for supplying power to the various components, and in some embodiments, the power supply 403 may be logically coupled to the processor 401 via a power management system, such that the power management system may manage charging, discharging, and power consumption. The power supply 403 may also include any component of one or more dc or ac power sources, recharging systems, power failure detection circuitry, power converters or inverters, power status indicators, and the like.
The electronic device may also include an input module 404, the input module 404 operable to receive input numeric or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
The electronic device may also include a communication module 405, and in some embodiments the communication module 405 may include a wireless module, through which the electronic device may wirelessly transmit over short distances, thereby providing wireless broadband internet access to the user. For example, the communication module 405 may be used to assist a user in sending and receiving e-mails, browsing web pages, accessing streaming media, and the like.
Although not shown, the electronic device may further include a display unit and the like, which are not described in detail herein. Specifically, in this embodiment, the processor 401 in the electronic device loads the executable file corresponding to the process of one or more application programs into the memory 402 according to the following instructions, and the processor 401 runs the application programs stored in the memory 402, thereby implementing various functions as follows:
acquiring a virtual scene image, wherein the virtual scene image is an image of a virtual scene in which a virtual role is positioned; converting an initial color space to which the virtual scene image belongs to an HSV color space, wherein the HSV color space comprises a brightness component, a saturation component and a hue component; acquiring a brightness component gradient diagram of a color gradient diagram to be generated according to the brightness component of the converted virtual scene image; acquiring a saturation component gradient map of the color gradient map to be generated according to the converted saturation component of the virtual scene image; calculating the hue component value of the color gradient map to be generated according to the hue component of the converted virtual scene image; generating a color gradient map at the initial color space based on the luma component gradient map, saturation component gradient map, and hue component values.
The above operations can be implemented in the foregoing embodiments, and are not described in detail herein.
It will be understood by those skilled in the art that all or part of the steps of the methods of the above embodiments may be performed by instructions or by associated hardware controlled by the instructions, which may be stored in a computer readable storage medium and loaded and executed by a processor.
To this end, the present application provides a computer-readable storage medium, in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any color gradient map generation method provided in the present application. For example, the instructions may perform the steps of:
acquiring a virtual scene image, wherein the virtual scene image is an image of a virtual scene in which a virtual role is positioned; converting an initial color space to which the virtual scene image belongs to an HSV color space, wherein the HSV color space comprises a brightness component, a saturation component and a hue component; acquiring a brightness component gradient map of the color gradient map to be generated according to the brightness component of the converted virtual scene image; acquiring a saturation component gradient map of the color gradient map to be generated according to the converted saturation component of the virtual scene image; calculating the hue component value of the color gradient map to be generated according to the hue component of the converted virtual scene image; generating a color gradient map at the initial color space based on the luma component gradient map, saturation component gradient map, and hue component values.
Wherein the storage medium may include: read Only Memory (ROM), Random Access Memory (RAM), magnetic or optical disks, and the like.
According to an aspect of the application, a computer program product or computer program is provided, comprising computer instructions, the computer instructions being stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to cause the computer device to perform the method provided in the various alternative implementations provided in the embodiments described above.
Since the instructions stored in the storage medium may execute the steps in any color gradient map generation method provided in the embodiments of the present application, beneficial effects that can be achieved by any color gradient map generation method provided in the embodiments of the present application may be achieved, which are detailed in the foregoing embodiments and will not be described again here.
The foregoing detailed description is directed to a color gradient map generating method, apparatus, electronic device, and computer-readable storage medium provided by embodiments of the present application, and specific examples are used herein to explain the principles and implementations of the present application, and the descriptions of the foregoing embodiments are only used to help understand the method and its core ideas of the present application; meanwhile, for those skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (12)

1. A method of generating a color gradient map, the method comprising:
acquiring a virtual scene image, wherein the virtual scene image is an image of a virtual scene in which a virtual role is positioned;
converting an initial color space to which the virtual scene image belongs to an HSV color space, wherein the HSV color space comprises a brightness component, a saturation component and a hue component;
acquiring a brightness component gradient map of the color gradient map to be generated according to the brightness component of the converted virtual scene image;
acquiring a saturation component gradient map of the color gradient map to be generated according to the converted saturation component of the virtual scene image;
calculating the hue component value of the color gradient map to be generated according to the hue component of the converted virtual scene image;
generating a color gradient map at the initial color space based on the luma component gradient map, saturation component gradient map, and hue component values.
2. The method as claimed in claim 1, wherein the obtaining a lightness component gradient map of the color gradient map to be generated according to the lightness components of the converted virtual scene image comprises:
obtaining a brightness component histogram of the converted virtual scene image, wherein the brightness component histogram includes m first rectangular bars, each first rectangular bar corresponds to a different brightness component value on the abscissa of the brightness component histogram, and each first rectangular bar corresponds to a different percentage ratio on the ordinate of the brightness component histogram;
generating a brightness component gradient map according to the brightness component value corresponding to each of the m first rectangular bars and the percentage ratio corresponding to each of the first rectangular bars, where the brightness component gradient map includes m gradients, the gradient values of the m gradients are m brightness component values in ascending order, and the proportion of each gradient in the brightness component gradient map is the same as the percentage ratio of the gradient value of the gradient in the brightness component histogram.
3. The method of claim 2, wherein obtaining the transformed luminance component histogram of the virtual scene image comprises:
obtaining a plurality of brightness components included in the converted virtual scene image;
for each brightness component in the multiple brightness components, acquiring the number of pixel points belonging to the same brightness component, and calculating the ratio of the number of the pixel points belonging to the same brightness component to the total number of the pixel points of the virtual scene image to obtain the ratio corresponding to each brightness component;
and generating an initial lightness component histogram by taking a plurality of lightness components as abscissa values and the ratio corresponding to each lightness component as ordinate values, wherein the initial lightness component histogram is the lightness component histogram according to the ascending order of the numerical values of the lightness components.
4. The method of claim 2, wherein the obtaining the transformed luminance component histogram of the virtual scene image comprises:
obtaining a plurality of brightness components included in the converted virtual scene image;
for each brightness component in the multiple brightness components, acquiring the number of pixel points belonging to the same brightness component, and calculating the ratio of the number of the pixel points belonging to the same brightness component to the total number of the pixel points of the virtual scene image to obtain the ratio corresponding to each brightness component;
generating an initial lightness component histogram in ascending order of values of lightness components with a plurality of lightness components as abscissa values and a ratio corresponding to each lightness component as ordinate values, the initial lightness component histogram including a plurality of initial lightness rectangular bars, the number of the initial lightness rectangular bars being the same as the number of the lightness components;
and removing initial brightness rectangular bars which are positioned at edge positions in the initial brightness component histogram and account for a% of the total amount, and lengthening the height values of the remaining initial brightness rectangular bars by 1/(1-a%) times to obtain the brightness component histogram.
5. The method as claimed in claim 1, wherein the obtaining a saturation component gradient map of the color gradient map to be generated according to the converted saturation components of the virtual scene image comprises:
acquiring a saturation component histogram of the converted virtual scene image, wherein the saturation component histogram comprises n second rectangular bars, the abscissa of each second rectangular bar in the saturation component histogram corresponds to different saturation component values, and the ordinate of each second rectangular bar in the saturation component histogram corresponds to different percentage ratios;
and generating a saturation component gradient map according to the saturation component value corresponding to each second rectangular strip in the n second rectangular strips and the percentage ratio corresponding to each second rectangular strip, wherein the saturation component gradient map comprises n gradients, the gradient values of the n gradients are n saturation component values which are arranged in an ascending order, and the proportion of each gradient in the saturation component gradient map is the same as the percentage ratio of the gradient value of the gradient in the saturation component histogram.
6. The method as claimed in claim 5, wherein said obtaining a histogram of saturation component of the transformed image of the virtual scene comprises:
acquiring a plurality of saturation components included in the converted virtual scene image;
for each saturation component in the multiple saturation components, acquiring the number of pixel points belonging to the same saturation component, and calculating the ratio of the number of the pixel points belonging to the same saturation component to the total number of the pixel points of the virtual scene image to obtain the ratio corresponding to each saturation component;
and generating an initial saturation component histogram by taking the plurality of saturation components as abscissa values and the ratio corresponding to each saturation component as ordinate values according to the ascending order of the numerical values of the saturation components, wherein the initial saturation component histogram is the saturation component histogram.
7. The method of claim 5, wherein obtaining the histogram of saturation component of the transformed image of the virtual scene comprises:
acquiring a plurality of saturation components included in the converted virtual scene image;
for each saturation component in the multiple saturation components, acquiring the number of pixel points belonging to the same saturation component, and calculating the ratio of the number of the pixel points belonging to the same saturation component to the total number of the pixel points of the virtual scene image to obtain the ratio corresponding to each saturation component;
generating an initial saturation component histogram by using a plurality of saturation components as abscissa values and using a ratio corresponding to each saturation component as ordinate values according to an ascending order of numerical values of the saturation components, wherein the initial saturation component histogram comprises a plurality of initial saturation rectangular bars, and the number of the initial saturation rectangular bars is the same as that of the saturation components;
and removing the initial saturation rectangular bars which are positioned at the edge positions in the initial saturation component histogram and account for b% of the total amount, and lengthening the height values of the remaining initial saturation rectangular bars by 1/(1-b%) times to obtain the saturation component histogram.
8. The method as claimed in claim 1, wherein said calculating hue component values of said color gradient map to be generated based on the hue components of said transformed virtual scene image comprises:
and calculating the average value of the tone components of the converted virtual scene image, wherein the average value is the value of the tone component of the color gradient map to be generated.
9. The method of claim 1, wherein generating the color gradient map in the initial color space based on the luma component gradient map, the saturation component gradient map, and the hue component values comprises:
generating a color gradient map in an HSV color space based on the lightness component gradient map, the saturation component gradient map, and the hue component values;
and converting the color gradient map in the HSV color space from the HSV color space to the initial color space to obtain the color gradient map in the initial color space.
10. A color gradient map generating apparatus, characterized in that the apparatus comprises:
the scene image acquiring unit is used for acquiring a virtual scene image, wherein the virtual scene image is an image of a virtual scene where a virtual role is positioned;
a color space conversion unit, configured to convert an initial color space to which the virtual scene image belongs to an HSV color space, where the HSV color space includes a lightness component, a saturation component, and a hue component;
the lightness gradient map unit is used for acquiring a lightness component gradient map of the color gradient map to be generated according to the lightness component of the converted virtual scene image;
the saturation gradient map unit is used for acquiring a saturation component gradient map of the color gradient map to be generated according to the converted saturation component of the virtual scene image;
the hue component value unit is used for calculating the hue component value of the color gradient image to be generated according to the hue component of the converted virtual scene image;
a gradient map generating unit configured to generate a color gradient map in the initial color space based on the lightness component gradient map, the saturation component gradient map, and the hue component values.
11. An electronic device comprising a processor and a memory, the memory storing a plurality of instructions; the processor loads instructions from the memory to perform the steps of the color gradient map generating method according to any one of claims 1 to 9.
12. A computer readable storage medium storing instructions adapted to be loaded by a processor to perform the steps of the color gradient map generating method according to any of claims 1 to 9.
CN202210524596.XA 2022-05-13 2022-05-13 Color gradient map generation method and device, electronic equipment and storage medium Pending CN114904271A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210524596.XA CN114904271A (en) 2022-05-13 2022-05-13 Color gradient map generation method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210524596.XA CN114904271A (en) 2022-05-13 2022-05-13 Color gradient map generation method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114904271A true CN114904271A (en) 2022-08-16

Family

ID=82765791

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210524596.XA Pending CN114904271A (en) 2022-05-13 2022-05-13 Color gradient map generation method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114904271A (en)

Similar Documents

Publication Publication Date Title
CN109771951B (en) Game map generation method, device, storage medium and electronic equipment
CN110047123B (en) Map rendering method, map rendering device, storage medium and computer program product
CN108579082A (en) The method, apparatus and terminal of shadow are shown in game
CN111476851B (en) Image processing method, device, electronic equipment and storage medium
WO2023160054A1 (en) Image rendering method and apparatus, electronic device, computer-readable storage medium, and computer program product
CN112138386A (en) Volume rendering method and device, storage medium and computer equipment
CN113952720A (en) Game scene rendering method and device, electronic equipment and storage medium
CN111583378B (en) Virtual asset processing method and device, electronic equipment and storage medium
CN115082608A (en) Virtual character clothing rendering method and device, electronic equipment and storage medium
US20230074060A1 (en) Artificial-intelligence-based image processing method and apparatus, electronic device, computer-readable storage medium, and computer program product
CN114359458A (en) Image rendering method, device, equipment, storage medium and program product
CN112231020B (en) Model switching method and device, electronic equipment and storage medium
CN112070854A (en) Image generation method, device, equipment and storage medium
CN111784814A (en) Virtual character skin adjusting method and device
CN114904271A (en) Color gradient map generation method and device, electronic equipment and storage medium
CN115082607A (en) Virtual character hair rendering method and device, electronic equipment and storage medium
CN115501590A (en) Display method, display device, electronic equipment and storage medium
JP7301453B2 (en) IMAGE PROCESSING METHOD, IMAGE PROCESSING APPARATUS, COMPUTER PROGRAM, AND ELECTRONIC DEVICE
CN112118494B (en) Video data processing method and device and storage medium
JP6892557B2 (en) Learning device, image generator, learning method, image generation method and program
WO2023165198A1 (en) Image rendering method and apparatus, electronic device, computer-readable storage medium, and computer program product
CN112752131B (en) Barrage information display method and device, storage medium and electronic device
CN113694518B (en) Freezing effect processing method and device, storage medium and electronic equipment
WO2023169121A1 (en) Image processing method, game rendering method and apparatus, device, program product, and storage medium
CN116977533A (en) Mapping budget method, mapping budget device, electronic equipment and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination