Method, device, storage medium and electronic device for updating material instance color

CN117379781BActive Publication Date: 2026-10-09NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311335931.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-13
Publication Date
2026-10-09
Estimated Expiration
2043-10-13

AI Technical Summary

Technical Problem

[0004]本申请至少部分实施例提供了一种更新材质实例颜色的方法、装置、存储介质及电子装置,以至少解决相关技术中在更新材质实例颜色时由于生成颜色与原始颜色存在色差而导致材质实例的制作效率低的技术问题

Benefits of technology

[0009] In at least some embodiments of this application, by acquiring an image to be identified, performing image color recognition on the image to be identified, obtaining color recognition results, selecting a target color to be used from the color recognition results, and finally updating the color of a material instance in a preset game engine based on the target color, the purpose of efficiently updating the color of the material instance is achieved, thereby realizing the technical effect of improving the production efficiency of the material instance, and thus solving the technical problem in the related art that the production efficiency of the material instance is low due to the color difference between the generated color and the original color when updating the color of the material instance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117379781B_ABST
    Figure CN117379781B_ABST
Patent Text Reader

Abstract

The application discloses a method and device for updating material instance color, a storage medium and an electronic device. The method comprises: obtaining a to-be-identified image; performing image color identification on the to-be-identified image to obtain a color identification result, wherein the color identification result is used to determine the pixel color classification contained in the to-be-identified image; selecting a target color to be used from the color identification result; and updating the color of a material instance in a preset game engine based on the target color. The application solves the technical problem of low production efficiency of the material instance caused by the color difference between the generated color and the original color when updating the color of the material instance in the related art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer vision, and more specifically, to a method, apparatus, storage medium, and electronic device for updating the color of a material instance. Background Technology

[0002] With the iterative updates of game products, creating diverse costumes for virtual game characters has become an important way for game developers to attract players. In such game development projects, it's often necessary to create generic color-changing effects for a large number of virtual game characters. This involves adjusting the colors of the identity (ID) areas on the material instances to be colored using Unreal Engine (UE4). However, relying solely on artists to manually adjust the colors of these areas requires a significant amount of manpower when creating costume material instances. Among related technologies, using k-means clustering to achieve color-changing effects only yields the dominant colors in the image, not all colors. Furthermore, while this method can statistically determine color distribution and proportions, it may produce non-existent color blocks. Using color histograms to achieve color-changing effects can also result in the synthesis of new colors. Therefore, because the clustering color-changing methods in these technologies all involve synthesizing new colors with a certain color difference from the original colors, they are difficult to meet the needs of game development, thus affecting the efficiency of material instance production.

[0003] There is currently no effective solution to the above problems. Summary of the Invention

[0004] At least some embodiments of this application provide a method, apparatus, storage medium, and electronic device for updating the color of a material instance, so as to at least solve the technical problem in the related art that the production efficiency of material instances is low due to the color difference between the generated color and the original color when updating the color of a material instance.

[0005] According to one embodiment of this application, a method for updating the color of a material instance is provided, comprising: acquiring an image to be identified; performing image color recognition on the image to be identified to obtain a color recognition result, wherein the color recognition result is used to determine the pixel color classification contained in the image to be identified; selecting a target color to be used from the color recognition result; and updating the color of a material instance in a preset game engine based on the target color.

[0006] According to one embodiment of this application, an apparatus for updating the color of a material instance is also provided, comprising: an acquisition module for acquiring an image to be identified; an identification module for performing image color identification on the image to be identified to obtain a color identification result, wherein the color identification result is used to determine the pixel color classification contained in the image to be identified; a selection module for selecting a target color to be used from the color identification result; and an update module for updating the color of a material instance in a preset game engine based on the target color.

[0007] According to one embodiment of this application, a computer-readable storage medium is also provided, which stores a computer program, wherein the computer program is configured to execute the method of updating the color of a material instance as described above when running.

[0008] According to one embodiment of this application, an electronic device is also provided, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the method of updating the color of a material instance as described above.

[0009] In at least some embodiments of this application, by acquiring an image to be identified, performing image color recognition on the image to be identified, obtaining color recognition results, selecting a target color to be used from the color recognition results, and finally updating the color of a material instance in a preset game engine based on the target color, the purpose of efficiently updating the color of the material instance is achieved, thereby realizing the technical effect of improving the production efficiency of the material instance, and thus solving the technical problem in the related art that the production efficiency of the material instance is low due to the color difference between the generated color and the original color when updating the color of the material instance. Attached Figure Description

[0010] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0011] Figure 1 This is a hardware structure block diagram of a mobile terminal for a method of updating the color of a material instance according to one embodiment of this application;

[0012] Figure 2 This is a flowchart of a method for updating the color of a material instance according to one embodiment of this application;

[0013] Figure 3 This is a schematic diagram of a plugin interface for updating the color of a material instance according to one embodiment of this application;

[0014] Figure 4This is a structural block diagram of an apparatus for updating the color of a material instance according to one embodiment of this application;

[0015] Figure 5 This is a schematic diagram of an electronic device according to one embodiment of the present application. Detailed Implementation

[0016] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0017] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0018] First, some nouns or terms that appear in the description of the embodiments of this application shall be interpreted as follows:

[0019] Open Source Computer Vision Library (OpenCV) is a programming function library primarily designed for real-time computer vision.

[0020] Image recognition (Identification) refers to the technology of using computers to process, analyze, and understand images in order to identify targets and objects of various patterns. The traditional image recognition process consists of four steps: image acquisition, image preprocessing, feature extraction, and image recognition.

[0021] Slate is the name of a custom user interface (UI) programming framework in Unreal Engine, written in C++.

[0022] Map: A data structure that is an associative container that stores key-value pairs in a specific order, consisting of key-value pairs and mapped values. Key-value pairs are unique, but mapped values ​​are not.

[0023] Standard color (sRGB): This is a color language protocol. The sRGB color space uses a non-linear gamma correction function to correct color values. The gamma correction function is a piecewise function, consisting of a linear part and an exponential part. The linear part is used to process color values ​​in dark areas, and the exponential part is used to process color values ​​in bright areas. The parameters of both parts have been determined experimentally and through standardization.

[0024] The calculation process of the k-means clustering algorithm in related technologies is as follows: First, the image is read, and the RGB values ​​of each pixel are obtained. Then, the RGB values ​​are standardized to the range of 0-1. Subsequently, the standardized RGB values ​​are used as data points, and the k-means clustering algorithm is used to cluster them. For each cluster, the cluster center is calculated, which is the RGB value of the color represented by that cluster. In this way, k main colors can be extracted from the image. By adjusting the value of k, different numbers of main colors can be obtained.

[0025] The calculation process of the color histogram method used in related technologies is as follows: the image is converted to a color space (Hue, Saturation, Value). Image retrieval in the HSV space uses H (hue) and S (saturation) components to calculate and compare histograms, thereby outputting the k most dominant pixel colors.

[0026] However, when using the k-means clustering algorithm to achieve color replacement effects, only the main colors in the image can be obtained, not all colors. Furthermore, while this method can statistically determine color distribution and proportions, it may produce non-existent color patches. Similarly, using color histograms can result in the synthesis of new colors. Therefore, because all clustering-based color replacement methods in these technologies involve the synthesis of new colors with some color difference from the original colors, they are difficult to meet the needs of game development, thus affecting the efficiency of material instance creation.

[0027] The methods and embodiments described above in this disclosure can be executed on mobile terminals, computer terminals, or similar computing devices. Taking a mobile terminal as an example, the mobile terminal can be a smartphone, tablet computer, PDA, mobile internet device, PAD, game console, or other terminal device. Figure 1 This is a hardware structure block diagram of a mobile terminal for a method of updating the color of a material instance according to an embodiment of this application. Figure 1As shown, a mobile terminal may include one or more ( Figure 1 Only one is shown in the image. Processor 102 (processor 102 may include, but is not limited to, a central processing unit (CPU), graphics processing unit (GPU), digital signal processing (DSP) chip, microprocessor (MCU), programmable logic device (FPGA), neural network processor (NPU), tensor processor (TPU), artificial intelligence (AI) type processor, etc.) and memory 104 for storing data. In one embodiment of this application, it may also include: input / output device 108 and display device 110.

[0028] In some optional embodiments primarily focused on gaming scenarios, the aforementioned device may also provide a human-computer interaction interface with a touch-sensitive surface. This interface can sense finger contact and / or gestures to interact with a graphical user interface (GUI). The human-computer interaction functions may include the following: creating web pages, drawing, word processing, creating electronic documents, playing games, video conferencing, instant messaging, sending and receiving emails, call interfaces, playing digital videos, playing digital music, and / or web browsing, etc. Executable instructions for performing the aforementioned human-computer interaction functions are configured / stored in one or more processor-executable computer program products or readable storage media.

[0029] Those skilled in the art will understand that Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the mobile terminal described above. For example, the mobile terminal may also include components that are more... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.

[0030] According to one embodiment of this application, an embodiment of a method for updating the color of a material instance is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than that shown here.

[0031] Figure 2 This is a flowchart of a method for updating the color of a material instance according to one embodiment of this application, such as... Figure 2 As shown, the method includes the following steps:

[0032] Step S21: Obtain the image to be recognized;

[0033] Step S22: Perform image color recognition on the image to be recognized to obtain color recognition results, wherein the color recognition results are used to determine the color classification of the pixels contained in the image to be recognized.

[0034] Step S23: Select the target color to be used from the color recognition results;

[0035] Step S24: Update the color of the material instance in the preset game engine based on the target color.

[0036] The aforementioned image to be identified is used to provide the target color to be used. The image to be identified can be quickly obtained by using the UE4 Slate format editing and art user interaction parts. In the plugin's UI interface, the image to be identified can be obtained through the storage path of the image to be identified.

[0037] The color recognition result described above can be a set of pixel color categories contained in the image to be recognized. The color recognition result can be obtained by iterating through the various colors contained in the image and the frequency of each color. The target color mentioned above is used to update material instances in Unreal Engine.

[0038] Based on the above steps S21 to S24, by acquiring the image to be identified, performing image color recognition on the image to be identified, obtaining the color recognition result, selecting the target color to be used from the color recognition result, and finally updating the color of the material instance in the preset game engine based on the target color, the purpose of efficiently updating the color of the material instance is achieved, thereby realizing the technical effect of improving the production efficiency of the material instance, and solving the technical problem in the related technology that the production efficiency of the material instance is low due to the color difference between the generated color and the original color when updating the color of the material instance.

[0039] The method for updating the color of material instances in the embodiments of this application will be further described below.

[0040] Optionally, in step S22, image color recognition is performed on the image to be recognized, and the color recognition result includes:

[0041] Step S221: Traverse the pixels contained in the image to be identified and obtain the color of the pixel and the number of times the color appears;

[0042] Step S222: Using a key-value pair storage method, the color of the pixel and the number of times the color appears are stored in a mapping type data structure to obtain the color recognition result.

[0043] Specifically, the image to be recognized is read using OpenCV. Then, each pixel in the image is iterated through and stored in a map. Because the underlying structure of the map is non-repeating and insertion is ordered, preliminary data is obtained after the iteration, with the key values ​​being the pixel's color and the frequency of that color. Further, using a key-value pair storage method, the pixel's color and the frequency of its occurrence are stored in the map to obtain the color recognition result.

[0044] Based on the above optional embodiments, by traversing the pixels contained in the image to be recognized, the color of the pixel and the number of times the color appears are obtained. Then, a key-value pair storage method is used to store the color of the pixel and the number of times the color appears in the mapping type data structure, thereby quickly obtaining the color recognition result for selecting the target color, further improving the color changing efficiency and the production efficiency of material instances.

[0045] Optionally, in step S221, traversing the pixels contained in the image to be identified and obtaining the color of the pixel and the number of times the color appears includes: traversing the pixels contained in the image to be identified row by row and obtaining the color of the pixel and the number of times the color appears.

[0046] Specifically, a function named `getColorCounts` is declared and defined. This function returns a map object representing the number of occurrences of each color. `getColorCounts` accepts an OpenCV matrix parameter `image`, representing the input image to be recognized. Within the function, a map variable named `colorCounts` is defined to store the color counts. Two nested `for` loops iterate through each pixel of the image to be recognized. The outer loop iterates through each row of the image, and the inner loop iterates through each pixel in each row, thus obtaining the color of each pixel and the number of times each color occurs.

[0047] Based on the above optional embodiments, by traversing the pixels in the image to be identified row by row, the color of the pixel and the number of times the color appears can be quickly obtained.

[0048] Optionally, the mapping type data structure includes: a first vector type object and a mapping type object, and obtaining the pixel color and the number of times the color appears includes:

[0049] Step S2211: Use a first vector type object from the computer vision library to obtain the color of the pixel. The first vector type object includes multiple element vectors, which are used to obtain the intensity values ​​of multiple color channels in the pixel.

[0050] Step S2212: The number of times a color appears is obtained by incrementing the color count of the pixel through the mapping type object.

[0051] Specifically, the first vector type object is a variable of type cv::Vec3b, and at each pixel, the first vector type object image.at from the computer vision library is used. <cv::vec3b>(y,x) retrieves the color of the pixel, where cv::Vec3b is a class in the OpenCV library used to represent a vector of three uchar elements, typically used to represent pixel values ​​in a color image. Each element vector can represent the intensity value of the red, green, and blue color channels.

[0052] After obtaining the color of a pixel, it is stored in a cv::Vec3b variable named `color`. This variable can be used as a key in the aforementioned map. The count of `color` in `colorCounts` is incremented by 1 using `colorCounts[color]++`. After the loop ends, `colorCounts` stores the occurrence count of each color in the image to be recognized. Finally, the `getColorCounts` function returns the `colorCounts` variable, which is an OpenCV map object representing the occurrence count of each color.

[0053] Based on the above optional embodiments, by using a first vector type object from a computer vision library to obtain the color of a pixel, and then by incrementally counting the color of the pixel using a mapping type object, the occurrence frequency of the color can be quickly obtained.

[0054] Optionally, in step S23, selecting the target color to be used from the color recognition results includes:

[0055] Step S231: Sort the color recognition results according to the frequency of color occurrence to obtain the color sorting results;

[0056] Step S232: Based on a preset quantity threshold, the color sorting results are deduplicated to obtain the target color. The preset quantity threshold is used to determine the upper limit of the number of colors in the target color.

[0057] Specifically, declare and define a function named sortColorsByCount, which will return a std::vector<st ... <std::pair<cv::Vec3b,size_t> An object of type > represents each color and its occurrence count, and is sorted in descending order of occurrence count to obtain the color sorting result. Further, a maximum number of colors (maxColors) for the target color is determined based on a preset threshold. The color sorting result is then deduplicated according to maxColors to obtain the target color.

[0058] Based on the above optional embodiments, the color recognition results are sorted according to the frequency of color occurrence to obtain a color sorting result. Then, based on a preset quantity threshold, the color sorting result is deduplicated to obtain the target color. Thus, by sorting and deduplicating the color recognition results, the target color can be determined more accurately, and the same color can be avoided from being calculated repeatedly, thereby improving the accuracy and efficiency of color recognition.

[0059] Optionally, in step S231, the color recognition results are sorted according to the frequency of color occurrence, resulting in a color sorting result including:

[0060] Step S2311: According to the frequency of occurrence of each color, compare each pair of adjacent colors in the color recognition result to obtain the comparison result;

[0061] Step S2312: Based on the comparison results, the color recognition results are sorted in descending order to obtain the color sorting results.

[0062] Specifically, the `sortColorsByCount` function accepts a `colorCounts` parameter of type `map`, which represents the number of times each color appears in the image to be recognized. Within the function, a `vector` variable named `sortedColors` is defined to store the sorted colors and their occurrence counts. `sortedColors` is constructed using `colorCounts.begin()` and `colorCounts.end()`, copying all key-value pairs from `colorCounts` to `sortedColors`, where each key-value pair represents each color and its occurrence count. Then, the `std::sort` function is called to sort `sortedColors`. During sorting, a lambda expression is used as a comparison function to sort colors from largest to smallest occurrence count. Specifically, the comparison function compares two `std::pair` pairs.<cv::Vec3b,size_t> The comparison returns true if objects a and b are of type a and b, where a and b are two adjacent colors.

[0063] After the loop finishes, `sortedColors` stores the colors and their occurrence counts, sorted from largest to smallest. Finally, the `sortColorsByCount` function returns the `sortedColors` variable, which is a `std::vector`. <std::pair<cv::Vec3b,size_t> An object of type > represents each color and its occurrence count. Sort the colors in descending order of their occurrence count to obtain the color sorting result.

[0064] Based on the above optional embodiments, by comparing each pair of adjacent colors in the color recognition results according to the frequency of their occurrence, a comparison result is obtained. Then, based on the comparison result, the color recognition results are sorted in descending order to obtain the color sorting result. This allows colors that occur more frequently to be listed first, and colors that occur less frequently to be listed later, thus making it easier to analyze and process colors.

[0065] Optionally, in step S232, based on a preset quantity threshold, the color sorting results are deduplicated to obtain the target colors, including:

[0066] Step S2321: Obtain the first color from the color sorting result and the second color from the second vector type object, wherein the second vector type object is used to store the colors retained after deduplication in the color sorting result;

[0067] Step S2322: Calculate the Euclidean distance between the first color and the second color, and obtain the calculation result;

[0068] Step S2323: In response to the calculation result being greater than or equal to a preset distance threshold, the first color is stored in a second vector type object;

[0069] Step S2324: Detect whether the number of colors currently stored in the second vector type object exceeds a preset number threshold;

[0070] Step S2325: In response to the fact that the number of colors currently stored in the second vector type object does not exceed a preset number threshold, the target color is determined based on the colors currently stored in the second vector type object.

[0071] Specifically, declare and define a function named colorDistance, which accepts two parameters of type cv::Vec3b, color1 and color2, representing the first color and the second color respectively, and returns the Euclidean distance between the two colors.

[0072] Declare and define a function named removeSimilarColors, which accepts three parameters: a std::vector<st ... <std::pair<cv::Vec3b,size_t> The parameter `sortedColors` of type `>` represents the list of colors sorted by the frequency of their occurrence; the parameter `threshold` of type `double` represents the Euclidean distance threshold at which colors are considered similar, i.e., the preset distance threshold; and the parameter `maxColors` of type `int` represents the upper limit of the number of colors to be output, i.e., the preset number threshold.

[0073] In the function, define a std::vector named mainColors. <cv::vec3b>The variable of type `mainColors`, i.e., a second vector type object, is used to store the list of colors after deduplication. `mainColors` is initially empty and can be any color selected from `sortedColors`.

[0074] Use a for loop to iterate through each color in sortedColors and its occurrence count. For each color, use colorCountPair.first to get the color value and store it in a variable of type cv::Vec3b named color.

[0075] Within the loop, for each color, another for loop iterates through each color in `mainColors`. For each color already stored in `mainColors`, the `colorDistance` function is called to calculate the Euclidean distance between the current color and other colors, and this distance is compared to a threshold. If the distance between the current color and any color already stored in `mainColors` is less than the threshold, the two colors are considered similar, and the boolean variable `isSimilar` is set to true. If the distance between the current color and any color already stored in `mainColors` is greater than or equal to the threshold (meaning the current color is not similar to any color already stored in `mainColors`), then the current color is stored in `mainColors`.

[0076] After storing the current color, check if the number of colors stored in mainColors has reached the specified maximum value maxColors. If the number of colors stored exceeds maxColors, exit the loop and stop processing subsequent colors.

[0077] After the loop finishes, `mainColors` stores a list of deduplicated colors, and its number does not exceed the specified maximum value `maxColors`. Finally, the `removeSimilarColors` function returns the `mainColors` variable, which is a `std::vector`. <cv::vec3b>An object of type `colors.define` represents a list of colors after deduplication, with the number of colors not exceeding a preset threshold. For example, excluding similar colors and limiting the material instance to 16 color regions, the output color count ranges from 1 to 16, and cannot exceed 16.

[0078] Based on the above optional embodiments, by calculating the Euclidean distance between the first color and the second color, a calculation result is obtained. In response to the calculation result being greater than or equal to a preset distance threshold, the first color is stored in a second vector type object. Then, it is detected whether the number of colors currently stored in the second vector type object exceeds a preset number threshold. In response to the number of colors currently stored in the second vector type object not exceeding the preset number threshold, the target color is determined based on the colors currently stored in the second vector type object, which can further improve the deduplication efficiency.

[0079] Optionally, in step S2325, determining the target color based on the color currently stored in the second vector type object includes: converting the first color space corresponding to the color currently stored in the second vector type object into the second color space to obtain the target color, wherein the first color space is the linear space corresponding to the color currently stored in the second vector type object, and the second color space is the gamma space corresponding to the color currently stored in the second vector type object.

[0080] Specifically, the linear color space of type cv::Vec3b is converted to sRGB color space and stored in TArray. sRGB color space is a gamma color space, which is a color space adapted to the display to facilitate parameter passing for material instances.

[0081] Furthermore, define an integer variable `i` to record the index of the currently processed color, initialized to 0. Use a `for` loop to iterate through each color in `mainColors`. For each color, use `const cv::Vec3b&color` to assign it to a constant reference `color` of type `cv::Vec3b`.

[0082] Within the loop, the Unreal Engine Log (UE_LOG) macro is used to output information about the current color, including its index in the list, the values ​​of the R, G, and B channels, and a fixed opacity value of 1.0. Here, color[2] represents the value of the red channel, color[1] represents the value of the green channel, and color[0] represents the value of the blue channel.

[0083] After outputting the color information, the FMath::Pow function is used to calculate the 2.2 power of the value of each channel, which is stored as a color object in sRGB space, and colors_.Emplace is called to add it to colors_.

[0084] After the loop ends, colors_ stores the converted color information. Each element is a color value in sRGB space, corresponding to each color stored in mainColors.

[0085] Based on the above optional embodiments, the target color is obtained by converting the first color space corresponding to the color currently stored in the second vector type object into the second color space, thereby achieving accurate color display, cross-platform compatibility, and color processing.

[0086] Optionally, in step S24, updating the color of the material instance in the preset game engine based on the target color includes:

[0087] Step S241: Based on the target color, set the color area to be enabled for the material instance in the preset game engine and the color value corresponding to the color area to obtain the setting result;

[0088] Step S242: Update the color of the material instance using the setting results.

[0089] Specifically, based on the target color setting, the preset color area to be enabled for the material instance in the game engine and the corresponding color value of the color area are obtained to obtain the setting result. Then, the setting result is passed to the material instance in UE4, so that the color of the material instance can be updated using the setting result.

[0090] Based on the above optional embodiments, by setting the color area to be enabled for the material instance in the preset game engine and the color value corresponding to the color area based on the target color, the setting result is obtained, and then the color of the material instance can be quickly updated using the setting result, further improving the production efficiency of the material instance.

[0091] Optionally, in step S241, the setting of the color area to be enabled for the material instance in the preset game engine and the color value corresponding to the color area are set based on the target color. The setting result includes: setting the first color parameter and the second color parameter of the material instance in the preset game engine based on the target color. The first color parameter is used to determine the on or off state of the color area, and the second color parameter is used to determine the actual color value corresponding to the color area.

[0092] Specifically, the first step is to check the number of colors. If the number of colors exceeds the preset threshold, an error message is returned and the function execution is terminated. Then, the validity of the material instance is checked. If the material instance is invalid, an error message is also returned and the function execution is terminated.

[0093] Furthermore, two color parameters of type FName are defined: a first color parameter ColorationID and a second color parameter TintColorID. The first color parameter is used to determine whether the color region is enabled (1 for enabled, 0 for disabled). The second color parameter is used to determine the color value corresponding to the enabled color region. An integer variable index is defined and initialized to 1 to name each color parameter.

[0094] Iterate through the input color array colors. For each color, use the FString::Printf function to generate a string as the parameter name of that color in the material instance, and set it to one of ColorationID and TintColorID.

[0095] For each color, use the SelectedMaterialInstance->SetScalarParameterValueEditorOnly function to set its ColorationID parameter in the material instance to 1, indicating that the color is enabled.

[0096] For each color, use the SelectedMaterialInstance->SetVectorParameterValueEditorOnly function to set its TintColorID parameter in the material instance to the FLINearColor type value for that color.

[0097] After the loop is completed, it returns true, indicating that the material instance color parameter has been successfully updated, and finally the UE4 material instance obtains the main color required on the image to be recognized.

[0098] Based on the above optional embodiments, by setting the first color parameter and the second color parameter of the material instance in the preset game engine based on the target color, the setting result is obtained, which is used to quickly update the color of the material instance, thereby further improving the production efficiency of the material instance.

[0099] It is noteworthy that the method for updating the color of a material instance in this application embodiment can be implemented through a UE4 plugin. This plugin includes three production modules: a panel interaction module, an image color extraction module, and a parameter passing module. UE4 Slate can be used to write interactive UI interfaces with users, the image color extraction module can be used to extract the main colors in an image, and the parameter passing module is used to pass the color results obtained from the image color extraction module to the material instance in UE4 for updating. Figure 3 This is a schematic diagram of a plugin interface for updating the color of a material instance according to one embodiment of this application, such as... Figure 3 As shown, the part that uses UE4 Slate format editing for the interaction between the artist and the user is shown. This part includes the UI interface and interaction logic. Figure 3 The plugin's UI includes: the path to the image to be recognized; setting the required number of colors, which will be input into the maxColors parameter in the second module; buttons to move the color order forward or backward and to delete the selected color; a button to start parsing the image; a function to rotate the material instance; and a "overwrite material instance" button to pass the final color result obtained in the parameter passing module to the material instance.

[0100] In this embodiment, an image to be identified is acquired, and then image color recognition is performed on the image to be identified to obtain color recognition results. Subsequently, a target color to be used is selected from the color recognition results. Finally, the colors of material instances in the preset game engine are updated based on the target color. This method can accurately calculate the color proportion of the image to be identified and avoids generating colors that do not exist in the image to be identified. This improves the efficiency of material instance creation by 90%, reducing the time for material instance creation from 0.5 person-days to 0.05 person-days. Furthermore, the method for updating material instance colors in this embodiment can be implemented through a UE4 plugin, allowing for easy sharing across projects and further increasing the number of users.

[0101] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0102] This embodiment also provides a device for updating the color of a material instance. This device is used to implement the above embodiments and preferred embodiments, and will not be repeated as already described. As used below, "technique" or "module" can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.

[0103] Figure 4 This is a structural block diagram of an apparatus for updating the color of a material instance according to one embodiment of this application, such as... Figure 4 As shown, the device includes:

[0104] Acquisition module 401 is used to acquire the image to be recognized;

[0105] The recognition module 402 is used to perform image color recognition on the image to be recognized and obtain color recognition results, wherein the color recognition results are used to determine the color classification of the pixels contained in the image to be recognized;

[0106] The selection module 403 is used to select the target color to be used from the color recognition results;

[0107] Update module 404 is used to update the color of material instances in the preset game engine based on the target color.

[0108] Optionally, the recognition module 402 is further configured to: traverse the pixels contained in the image to be recognized, obtain the color of the pixel and the number of times the color appears; and store the color of the pixel and the number of times the color appears in a mapping type data structure using a key-value pair storage method to obtain the color recognition result.

[0109] Optionally, the recognition module 402 is also used to: perform row-by-row traversal of the pixels contained in the image to be recognized, and obtain the color of the pixel and the number of times the color appears.

[0110] Optionally, the recognition module 402 is further configured to: obtain the color of a pixel using a first vector type object from a computer vision library, wherein the first vector type object includes: multiple element vectors, which are used to obtain the intensity values ​​of multiple color channels in the pixel respectively; and increment the count of the color of the pixel by using a mapping type object to obtain the number of times the color appears.

[0111] Optionally, the selection module 403 is further configured to: sort the color recognition results according to the number of times the color appears, and obtain a color sorting result; and perform deduplication processing on the color sorting result based on a preset quantity threshold to obtain a target color, wherein the preset quantity threshold is used to determine the upper limit of the number of colors of the target color.

[0112] Optionally, the selection module 403 is further configured to: compare each pair of adjacent colors in the color recognition result according to the frequency of their occurrence, and obtain a comparison result; based on the comparison result, sort the color recognition result in descending order to obtain a color sorting result.

[0113] Optionally, the selection module 403 is further configured to: obtain a first color from the color sorting result and a second color from a second vector type object, wherein the second vector type object is used to store the colors retained after deduplication in the color sorting result; calculate the Euclidean distance between the first color and the second color to obtain the calculation result; in response to the calculation result being greater than or equal to a preset distance threshold, store the first color in the second vector type object; detect whether the number of colors currently stored in the second vector type object exceeds a preset number threshold; in response to the number of colors currently stored in the second vector type object not exceeding the preset number threshold, determine the target color based on the colors currently stored in the second vector type object.

[0114] Optionally, the selection module 403 is further configured to: convert the first color space corresponding to the currently stored color in the second vector type object into the second color space to obtain the target color, wherein the first color space is the linear space corresponding to the currently stored color in the second vector type object, and the second color space is the gamma space corresponding to the currently stored color in the second vector type object.

[0115] Optionally, the update module 404 is also used to: set the color area to be enabled for the material instance in the preset game engine and the color value corresponding to the color area based on the target color, and obtain the setting result; and update the color of the material instance using the setting result.

[0116] Optionally, the update module 404 is further configured to: set a first color parameter and a second color parameter of a material instance in the preset game engine based on the target color, and obtain a setting result, wherein the first color parameter is used to determine the on or off state of the color area, and the second color parameter is used to determine the actual color value corresponding to the color area.

[0117] It should be noted that the above modules can be implemented by software or hardware. For the latter, they can be implemented in the following ways, but are not limited to: all the above modules are located in the same processor; or, the above modules are located in different processors in any combination.

[0118] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above method embodiments when run.

[0119] Optionally, in this embodiment, the computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.

[0120] Optionally, in this embodiment, the computer-readable storage medium may be located in any computer terminal in a group of computer terminals in a computer network, or in any mobile terminal in a group of mobile terminals.

[0121] Optionally, in this embodiment, the computer-readable storage medium may be configured to store a computer program for performing the following steps:

[0122] S1, acquire the image to be recognized;

[0123] S2, perform image color recognition on the image to be recognized to obtain color recognition results, wherein the color recognition results are used to determine the color classification of the pixels contained in the image to be recognized;

[0124] S3, Select the target color to be used from the color recognition results;

[0125] S4 updates the color of material instances in the preset game engine based on the target color.

[0126] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: traversing the pixels contained in the image to be recognized, obtaining the color of the pixel and the number of times the color appears; using a key-value pair storage method, storing the color of the pixel and the number of times the color appears into a mapping type data structure to obtain the color recognition result.

[0127] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: traversing the pixels contained in the image to be identified row by row to obtain the color of the pixel and the number of times the color appears.

[0128] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: obtaining the color of a pixel using a first vector type object from a computer vision library, wherein the first vector type object includes: multiple element vectors, which are used to obtain the intensity values ​​of multiple color channels in the pixel respectively; and incrementing the color of the pixel by using a mapping type object to obtain the number of times the color appears.

[0129] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: sorting the color recognition results according to the number of times the color appears to obtain a color sorting result; and deduplicating the color sorting result based on a preset quantity threshold to obtain a target color, wherein the preset quantity threshold is used to determine the upper limit of the number of colors of the target color.

[0130] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: comparing each pair of adjacent colors in the color recognition result according to the frequency of their occurrence, and obtaining a comparison result; based on the comparison result, sorting the color recognition result in descending order to obtain a color sorting result.

[0131] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: obtaining a first color from a color sorting result and obtaining a second color from a second vector type object, wherein the second vector type object is used to store colors retained after deduplication in the color sorting result; calculating the Euclidean distance between the first color and the second color to obtain a calculation result; storing the first color in the second vector type object in response to the calculation result being greater than or equal to a preset distance threshold; detecting whether the number of colors currently stored in the second vector type object exceeds a preset number threshold; and determining a target color based on the colors currently stored in the second vector type object in response to the number of colors currently stored in the second vector type object not exceeding the preset number threshold.

[0132] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: converting the first color space corresponding to the currently stored color in the second vector type object to the second color space to obtain the target color, wherein the first color space is the linear space corresponding to the currently stored color in the second vector type object, and the second color space is the gamma space corresponding to the currently stored color in the second vector type object.

[0133] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: setting the color region to be enabled for a material instance in a preset game engine and the color value corresponding to the color region based on the target color, and obtaining the setting result; updating the color of the material instance using the setting result.

[0134] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: setting a first color parameter and a second color parameter of a material instance in a preset game engine based on a target color, and obtaining a setting result, wherein the first color parameter is used to determine the on or off state of a color region, and the second color parameter is used to determine the actual color value corresponding to the color region.

[0135] In the computer-readable storage medium of this embodiment, by acquiring an image to be identified, performing image color recognition on the image to be identified, obtaining a color recognition result, selecting a target color to be used from the color recognition result, and finally updating the color of a material instance in a preset game engine based on the target color, the purpose of efficiently updating the color of the material instance is achieved, thereby realizing the technical effect of improving the production efficiency of the material instance, and solving the technical problem in the related art that the production efficiency of the material instance is low due to the color difference between the generated color and the original color when updating the color of the material instance.

[0136] Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this application can be embodied in the form of a software product, which can be stored in a computer-readable storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, terminal device, or network device, etc.) to execute the methods according to the embodiments of this application.

[0137] In exemplary embodiments of this application, a computer-readable storage medium stores a program product capable of implementing the methods described above in this embodiment. In some possible implementations, various aspects of the embodiments of this application may also be implemented as a program product including program code, which, when the program product is run on a terminal device, causes the terminal device to perform the steps according to the various exemplary embodiments of this application described in the "Exemplary Methods" section above.

[0138] The program product for implementing the above-described method according to embodiments of this application may employ a portable compact disc read-only memory (CD-ROM) and include program code, and may run on a terminal device, such as a personal computer. However, the program product of the embodiments of this application is not limited thereto. In the embodiments of this application, the computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.

[0139] The aforementioned program product may take the form of any combination of one or more computer-readable media. Such computer-readable storage media may be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples (not exhaustive) of computer-readable storage media include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0140] It should be noted that the program code contained on the computer-readable storage medium can be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

[0141] Embodiments of this application also provide an electronic device including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.

[0142] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.

[0143] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:

[0144] S1, acquire the image to be recognized;

[0145] S2, perform image color recognition on the image to be recognized to obtain color recognition results, wherein the color recognition results are used to determine the color classification of the pixels contained in the image to be recognized;

[0146] S3, Select the target color to be used from the color recognition results;

[0147] S4 updates the color of material instances in the preset game engine based on the target color.

[0148] Optionally, the processor may also be configured to perform the following steps via a computer program: traversing the pixels contained in the image to be recognized, obtaining the color of the pixel and the number of times the color appears; storing the color of the pixel and the number of times the color appears in a mapping type data structure using a key-value pair storage method to obtain the color recognition result.

[0149] Optionally, the processor may also be configured to perform the following steps via a computer program: traversing the pixels contained in the image to be recognized row by row to obtain the color of the pixel and the number of times the color appears.

[0150] Optionally, the processor described above can also be configured to perform the following steps via a computer program: using a first vector type object from a computer vision library to obtain the color of a pixel, wherein the first vector type object includes: multiple element vectors, which are used to obtain the intensity values ​​of multiple color channels in the pixel respectively; and incrementing the color of the pixel by using a mapping type object to obtain the number of times the color appears.

[0151] Optionally, the processor may also be configured to perform the following steps via a computer program: sorting the color recognition results according to the number of times the color appears to obtain a color sorting result; and deduplicating the color sorting result based on a preset quantity threshold to obtain a target color, wherein the preset quantity threshold is used to determine the upper limit of the number of colors of the target color.

[0152] Optionally, the processor may also be configured to perform the following steps via a computer program: comparing each pair of adjacent colors in the color recognition result according to the frequency of their occurrence, and obtaining a comparison result; based on the comparison result, sorting the color recognition result in descending order to obtain a color sorting result.

[0153] Optionally, the processor may also be configured to perform the following steps via a computer program: obtaining a first color from the color sorting result and obtaining a second color from a second vector type object, wherein the second vector type object is used to store the colors retained after deduplication in the color sorting result; calculating the Euclidean distance between the first color and the second color to obtain the calculation result; in response to the calculation result being greater than or equal to a preset distance threshold, storing the first color in the second vector type object; detecting whether the number of colors currently stored in the second vector type object exceeds a preset number threshold; in response to the number of colors currently stored in the second vector type object not exceeding the preset number threshold, determining the target color based on the colors currently stored in the second vector type object.

[0154] Optionally, the processor may also be configured to perform the following steps via a computer program: converting the first color space corresponding to the currently stored color in the second vector type object into the second color space to obtain the target color, wherein the first color space is the linear space corresponding to the currently stored color in the second vector type object, and the second color space is the gamma space corresponding to the currently stored color in the second vector type object.

[0155] Optionally, the processor may also be configured to perform the following steps via a computer program: setting the color region to be enabled for a material instance in the preset game engine and the color value corresponding to the color region based on the target color, and obtaining the setting result; and updating the color of the material instance using the setting result.

[0156] Optionally, the processor may also be configured to perform the following steps via a computer program: setting a first color parameter and a second color parameter of a material instance in a preset game engine based on the target color, and obtaining a setting result, wherein the first color parameter is used to determine the on or off state of the color area, and the second color parameter is used to determine the actual color value corresponding to the color area.

[0157] In the electronic device of this embodiment, an image to be identified is acquired, and then image color recognition is performed on the image to be identified to obtain a color recognition result. Subsequently, a target color to be used is selected from the color recognition result. Finally, the color of the material instance in the preset game engine is updated based on the target color, thereby achieving the purpose of efficiently updating the color of the material instance. This achieves the technical effect of improving the production efficiency of the material instance, and solves the technical problem in the related art that the production efficiency of the material instance is low due to the color difference between the generated color and the original color when updating the color of the material instance.

[0158] Figure 5 This is a schematic diagram of an electronic device according to an embodiment of this application. Figure 5 As shown, the electronic device 500 is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.

[0159] like Figure 5 As shown, the electronic device 500 is presented in the form of a general-purpose computing device. The components of the electronic device 500 may include, but are not limited to: at least one processor 510, at least one memory 520, a bus 530 connecting different system components (including memory 520 and processor 510), and a display 540.

[0160] The memory 520 stores program code that can be executed by the processor 510, causing the processor 510 to perform the steps described in the method section of the embodiments of this application according to various exemplary implementations of this disclosure.

[0161] The memory 520 may include a readable medium in the form of volatile memory cells, such as random access memory (RAM) 5201 and / or cache memory 5202, and may further include read-only memory (ROM) 5203, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory.

[0162] In some instances, memory 520 may also include programs / utilities 5204 having a set (at least one) of program modules 5205, including but not limited to: an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Memory 520 may further include memory remotely located relative to processor 510, which can be connected to electronic device 500 via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0163] Bus 530 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, peripheral bus, graphics acceleration port, processor 510, or a local bus using any of the various bus structures.

[0164] The display 540 may be, for example, a touchscreen liquid crystal display (LCD) that allows a user to interact with the user interface of the electronic device 500.

[0165] Optionally, the electronic device 500 can also communicate with one or more external devices 600 (e.g., keyboard, pointing device, Bluetooth device, etc.), one or more devices that enable a user to interact with the electronic device 500, and / or any device that enables the electronic device 500 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via the input / output (I / O) interface 550. Furthermore, the electronic device 500 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via a network adapter 560. Figure 5 As shown, network adapter 560 communicates with other modules of electronic device 500 via bus 530. It should be understood that, although... Figure 5 As not shown, other hardware and / or software modules may be used in conjunction with electronic device 500, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0166] The aforementioned electronic device 500 may also include: a keyboard, a cursor control device (such as a mouse), an input / output interface (I / O interface), a network interface, a power supply, and / or a camera.

[0167] Those skilled in the art will understand that Figure 5 The structure shown is for illustrative purposes only and does not limit the structure of the electronic device described above. For example, the electronic device 500 may also include components that are more... Figure 5 The more or fewer components shown, or having the same Figure 1 Different configurations are shown. The memory 520 can be used to store computer programs and corresponding data, such as the computer program and corresponding data corresponding to the method for updating the color of a material instance in this embodiment of the present disclosure. The processor 510 executes various functional applications and data processing by running the computer program stored in the memory 520, thereby implementing the aforementioned method for updating the color of a material instance.

[0168] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0169] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0170] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For instance, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.

[0171] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0172] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0173] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.

[0174] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A method for updating the color of a material instance, characterized in that, include: Acquire the image to be recognized; The image to be identified is subjected to image color recognition to obtain a color recognition result, wherein the color recognition result is used to determine the color classification of the pixels contained in the image to be identified; Select the target color to be used from the color recognition results; Update the color of the material instance in the preset game engine based on the target color; The process of performing image color recognition on the image to be recognized to obtain the color recognition result includes: traversing the pixels contained in the image to be recognized to obtain the color of the pixel and the number of times the color appears; and storing the color of the pixel and the number of times the color appears in a mapping type data structure using a key-value pair storage method to obtain the color recognition result. Selecting a target color from the color recognition results includes: obtaining a first color from a color sorting result and a second color from a second vector type object, wherein the second vector type object is used to store the colors retained after deduplication in the color sorting result; calculating the Euclidean distance between the first color and the second color to obtain a calculation result; in response to the calculation result being greater than or equal to a preset distance threshold, storing the first color in the second vector type object; detecting whether the number of colors currently stored in the second vector type object exceeds a preset number threshold, wherein the preset number threshold is used to determine the upper limit of the number of colors for the target color; in response to the number of colors currently stored in the second vector type object not exceeding the preset number threshold, determining the target color based on the colors currently stored in the second vector type object.

2. The method according to claim 1, characterized in that, The process of traversing the pixels contained in the image to be identified and obtaining the color of each pixel and the frequency of occurrence of that color includes: The pixels in the image to be identified are traversed row by row to obtain the color of each pixel and the number of times each color appears.

3. The method according to claim 2, characterized in that, The mapping type data structure includes: a first vector type object and a mapping type object. Obtaining the color of the pixel and the frequency of occurrence of the color includes: The color of the pixel is obtained by using a first vector type object from a computer vision library, wherein the first vector type object includes: multiple element vectors, which are used to obtain the intensity values ​​of multiple color channels in the pixel respectively; The number of times a color appears is obtained by incrementing the color count of the pixel using a mapping type object.

4. The method according to claim 1, characterized in that, The method further includes: The color recognition results are sorted according to the frequency of occurrence of the color to obtain the color sorting results.

5. The method according to claim 4, characterized in that, The color recognition results are sorted according to the frequency of occurrence of the color, resulting in the following color sorting results: Based on the frequency of occurrence of the color, each pair of adjacent colors in the color recognition result is compared to obtain a comparison result; Based on the comparison results, the color recognition results are sorted in descending order to obtain the color sorting results.

6. The method according to claim 1, characterized in that, Determining the target color based on the color currently stored in the second vector type object includes: The target color is obtained by converting the first color space corresponding to the currently stored color in the second vector type object into the second color space, wherein the first color space is the linear space corresponding to the currently stored color in the second vector type object, and the second color space is the gamma space corresponding to the currently stored color in the second vector type object.

7. The method according to claim 1, characterized in that, Updating the color of material instances in the preset game engine based on the target color includes: Based on the target color, the color region to be enabled for the material instance in the preset game engine and the color value corresponding to the color region are set to obtain the setting result; The color of the material instance is updated using the settings result.

8. The method according to claim 7, characterized in that, Based on the target color, the preset game engine sets the color region to be enabled for the material instance and the corresponding color value for the color region, resulting in the following settings: Based on the target color, the first color parameter and the second color parameter of the material instance in the preset game engine are set to obtain the setting result, wherein the first color parameter is used to determine the on or off state of the color area, and the second color parameter is used to determine the actual color value corresponding to the color area.

9. An apparatus for updating the color of a material instance, characterized in that, include: The acquisition module is used to acquire the image to be recognized; The recognition module is used to perform image color recognition on the image to be recognized and obtain a color recognition result, wherein the color recognition result is used to determine the color classification of the pixels contained in the image to be recognized; A selection module is used to select a target color to be used from the color recognition results; The update module is used to update the color of material instances in the preset game engine based on the target color; The recognition module is used to perform the following steps: traversing the pixels contained in the image to be recognized, obtaining the color of the pixel and the number of times the color appears; using a key-value pair storage method, storing the color of the pixel and the number of times the color appears into a mapping type data structure to obtain the color recognition result; The selection module performs the following steps: obtaining a first color from the color sorting result and a second color from a second vector type object, wherein the second vector type object is used to store the colors retained after deduplication in the color sorting result; calculating the Euclidean distance between the first color and the second color to obtain a calculation result; in response to the calculation result being greater than or equal to a preset distance threshold, storing the first color in the second vector type object; detecting whether the number of colors currently stored in the second vector type object exceeds a preset number threshold, wherein the preset number threshold is used to determine the upper limit of the number of colors of the target color; in response to the number of colors currently stored in the second vector type object not exceeding the preset number threshold, determining the target color based on the colors currently stored in the second vector type object.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program is configured to execute, when run by a processor, the method for updating the color of a material instance as described in any one of claims 1 to 8.

11. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to run the computer program to perform the method for updating the color of a material instance as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Virtual-environment-based object construction method and method and readable storage medium

    CN110064200A

  • Virtual object rendering method of game and device thereof, equipment and storage medium

    CN113648653A