Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The application provides an image color migration method which can be applied to an application environment as shown in FIG. 1. Wherein the server 10 and the storage device 20 communicate via a network. The storage device 20 stores a plurality of images. Each image is provided with colors and images, and can also be provided with corresponding characters, numbers and the like. The server 10 is configured to read an image from the storage device 20 and perform color migration processing on the image to obtain an image that meets the requirement. Specifically, the server 10 stores therein color values of a plurality of colors. The server 10 reads the image to be converted from the storage device 20 and determines the color value of the corresponding target color from the internal storage according to the received color migration instruction. Further, by adopting the image color migration method provided by the application, the target color is migrated to the image to be converted according to the color value of the target color, so that the target image meeting the color migration instruction is realized. Further, the server 10 communicates with the terminal device group 40 through a network. Generally, the server 10 communicates with the terminal device group 40 through the cloud network 30, and issues the target image obtained after color migration to each terminal of the terminal device group 40. The terminals of the terminal device group 40 may be, but are not limited to, various personal computers, notebook computers, smart phones, tablet computers, desktop computers, and the like, and the server 10 may be implemented by an independent server or a server cluster composed of a plurality of servers.
In one embodiment, as shown in fig. 2, an image color migration method is provided, which is described by taking the method as an example applied to the server in fig. 1, and includes the following steps:
s100, extracting color values of the main colors of the image to be converted.
In this embodiment, a plurality of images for color migration are stored in the background storage device. And the server acquires the image to be converted from the background storage equipment according to the received color migration instruction. The image format of the image to be converted is JPG, JPEG, TIFF, PNG, RAW or BMP, etc. In addition, the server also determines a target color for transferring to the image to be converted according to the received color transferring instruction. The target color may be stored in the form of a color value in the server or in a background storage device, or may be stored in the form of a color image in the server or in a background storage device.
Further, the server acquires the main color of the image to be converted, and then extracts the color value of the main color. The color value of the main color may be a hexadecimal color code, or may be any form such as an RGB value, an HSV value, or the like.
In one embodiment, the image color migration method further includes: sampling an image to be converted by using a color quantization algorithm to obtain a plurality of quantized colors; and taking the color with the highest occurrence probability in the plurality of colors as the main color of the image to be converted.
Specifically, the server reads an image to be converted by using an OpenCV (Open Source Computer Vision Library) Library, and samples the image to be converted by using a color quantization algorithm, wherein each sampling operation obtains one color, thereby obtaining a plurality of quantized colors; and taking the color with the maximum occurrence probability in the plurality of colors obtained after sampling as the main color of the image to be converted. Specifically, the color quantization algorithm includes a median segmentation method, a K-means clustering method, an octree method, a frequency series method, and the like. In one embodiment, a Median Cut Quantization (MMCQ) is used as a color Quantization algorithm to process an image to be converted, so as to obtain a plurality of output colors, and a color with the highest frequency of appearance among the plurality of output colors is selected as a main color of the image to be converted.
S200, determining a migration vector adopted when the target color is migrated to the image to be converted according to the color value of the main color of the image to be converted and the color value of the target color.
In this embodiment, after the server determines the target color, the color value of the target color is read. Further, a migration vector when the image color migration is executed is determined according to the color value of the main color and the color value of the target color of the image to be converted. The migration vector is a movement vector which is referred to when the target color is migrated to the image to be converted. The color value of the main color of the image to be converted and the color value of the target color are corresponding color values in the same color space, so that the feasibility of obtaining the migration vector is ensured
In one embodiment, as shown in fig. 3, step S200 includes:
s210, acquiring a first three-dimensional color vector corresponding to the color value of the main color of the image to be converted in a target color space.
And S230, acquiring a second three-dimensional color vector corresponding to the color value of the target color in the target color space.
And S250, determining a migration vector according to the first three-dimensional color vector and the second three-dimensional color vector.
In this embodiment, the server places the color value of the main color and the color value of the target color of the image to be converted in the same color space, and then calculates to obtain the migration vector. Specifically, the server determines a target color space. The target color space is a three-dimensional color space, and the three dimensions are used for representing a brightness channel, a saturation channel and a hue channel in the color respectively. The target color space used in this embodiment is the CIE-LCH color model space, but other color spaces may be used to perform the numerical conversion calculation.
The server obtains a first three-dimensional color vector corresponding to the color value of the main color of the image to be converted in a target color space and a second three-dimensional color vector corresponding to the color value of the target color in the target color space, and determines a migration vector according to the first three-dimensional color vector and the second three-dimensional color vector in the target color space. The migration vector here is also the corresponding three-dimensional vector in the target color space.
Specifically, the main color of the image to be converted and the target color subjected to color migration are converted into a CIE-LCH color model space. The conversion mode can use a third-party library of python to perform image processing by using a corresponding function in the scimit-image processing packet. In addition, if the image to be converted has a transparent channel, the transparent channel is extracted and then converted, and the transparent channel is stored separately. Therefore, under the CIE-LCH color model space, the color value of the main color and the color value of the target color of the image to be converted are processed to determine the migration vector, wherein the property that the response of the CIE-LCH color model space to the same transformation has a uniform interval is utilized, so that the controllability of color migration can be ensured.
For traditional digital image color processing, color model spaces such as HSV, HSL, RGB and the like are commonly used, and the response degrees of the color spaces to the same transformation are greatly different in visual effect for pixel processing of different colors. Taking HSV space as an example, for two pixels with hues in yellow and blue regions, respectively, the saturation is also increased by 5, the visual impression of the yellow pixel changes very drastically, and the visual impression of the blue pixel does not change much. Thus, when a consistent color transformation is applied, the visual perception of the different color pixels changes uncontrollably, resulting in a resulting image with no readability. The CIE-LCH color model space adopted by the embodiment of the application well solves the problem of uncontrollable property in the traditional color migration.
In one embodiment, step S250 includes: and acquiring a translation transformation vector adopted when the first three-dimensional color vector is translated to the second three-dimensional color, and taking the translation transformation vector as a migration vector.
In this embodiment, after a first three-dimensional color vector corresponding to a color value of a main color of an image to be converted and a second three-dimensional color vector corresponding to a color value of a target color are determined in a target color space, the first three-dimensional color vector is translated to the second three-dimensional color vector to obtain a translation transformation vector adopted in a translation process, and the translation transformation vector is used as a translation vector. Specifically, in the CIE-LCH color model space, the translation transformation vector is dist lch Then, the translation transformation vector is calculated as follows:
dist lch =lch target -lch theme ;
wherein, lch target Representing a second three-dimensional color vector; lch theme Representing a first three-dimensional color vector. dist lch Is a translation transformation vector. Each dimension represents a distance that the corresponding dimension moves about the corresponding coordinate axis in the CIE-LCH color model space. dist lch Is in the CIE-LCH color space,a euclidean distance between the second three dimensional color vector and the first three dimensional color vector.
Therefore, when the translation transformation vector adopted when the first three-dimensional color vector is translated to the second three-dimensional color is taken as the migration vector, and the target color is subsequently migrated to the image to be converted by adopting the migration vector, the color contrast relation among different color areas is basically maintained, the color matching rule of the image to be converted cannot be damaged, and the image generated after migration is more attractive.
And S300, migrating the target color to the image to be converted according to the migration vector.
In this embodiment, the server migrates the target color into the image to be converted according to the migration vector, thereby implementing image color migration. In a specific implementation manner, the color values of all the color values of the image to be converted are moved according to the migration vector, and in the image obtained after the movement, the color that appears is the color effect after the target color is migrated to the image to be converted. And moving the color value of the image part to be converted according to the migration vector, wherein the color shown in the image obtained after the movement is the color effect of the target color after the target color is migrated to the image to be converted. Therefore, the limitation that the reference picture is needed by the traditional color migration technology is overcome.
In an embodiment, the migration vector is a three-dimensional vector determined according to a first three-dimensional color vector corresponding to a color value of a main color of an image to be converted in a target color space and a second three-dimensional color vector corresponding to a color value of the target color. At this time, step S300 includes: and extracting the color value of the pixel of the image to be converted, transferring the color value of the pixel of the image to be converted according to the transfer vector, taking the transferred image to be converted as a target image, and transferring the target color to the image to be converted.
Specifically, when color migration is executed, a color value of a pixel of the image to be converted is extracted, the color value of the pixel is migrated according to the migration vector, and in the target image obtained after migration, the displayed color is a color display result of the target color in the image to be converted, so that the target color is migrated to the image to be converted. The color values of all pixels of the image to be converted may be migrated according to the migration vector, and the migrated image to be converted is used as the target image. Or, the color values of the partial pixels of the image to be converted are migrated according to the migration vector, and the migrated image to be converted is taken as the target image.
In an embodiment, migrating color values of pixels of an image to be converted according to a migration vector, including: according to the migration vector, migrating the color values of the pixels of the image to be converted according to a brightness dimension, a saturation dimension and a hue dimension respectively; wherein the target color space includes a luminance dimension, a saturation dimension, and a hue dimension.
Specifically, the target color space is a three-dimensional space, and three corresponding dimensions in the three-dimensional space are a brightness dimension, a saturation dimension, and a hue dimension. That is, the color value of the pixel of the image to be converted is represented as a numerical value represented by three dimensional values in the target color space, and the three dimensional values represent the brightness, saturation and hue of the pixel respectively. In addition, the migration vector is a three-dimensional vector, and the three dimensions represent the brightness, saturation and hue corresponding to the color respectively. And in the target color space, the color value of the pixel of the image to be converted is transferred according to the transfer vector, and the transferred image is the image for transferring the target color to the image to be converted. In the color migration process, color values of all pixels of the image to be converted may be migrated according to the migration vector, or color values of some pixels of the image to be converted may be migrated according to the migration vector.
In an implementation manner of this embodiment, migrating color values of pixels of an image to be converted according to a luminance dimension, a saturation dimension, and a hue dimension respectively according to a migration vector includes: according to a first normalization function, performing normalization processing on brightness data corresponding to a brightness dimension in the color values of pixels of an image to be converted to obtain a first numerical value; according to the migration vector and the first numerical value, migrating the color value of the pixel of the image to be converted according to the brightness dimension; according to a second normalization function, normalization processing is carried out on saturation data corresponding to a saturation dimension in the color values of the pixels of the image to be converted, and a second numerical value is obtained; according to the migration vector and the second numerical value, migrating the color value of the pixel of the image to be converted according to the saturation dimension; acquiring a sum of the color values of the pixels of the migration vector and the image to be converted, taking the sum of 2 pi, and migrating the color values of the pixels of the image to be converted according to hue dimensions according to a residue taking result; and pi is the circumferential ratio.
Specifically, the color values of all pixels of the image to be converted are migrated according to the migration vector. When the pixels of the image to be converted are migrated in the target color space according to the migration vector, the following steps are carried out:
p i,j [L]'=p i,j [L]+f l (p i,j [L])*dist lch [L];
p i,j [C]'=p i,j [C]+f c (p i,j [C])*dist lch [C];
p i,j [H]'=(p i,j [H]+dist lch [H])MOD2π;
wherein i and j are two-dimensional coordinates in the image, L represents a brightness dimension, C represents a saturation dimension, and H represents a hue dimension. p is a radical of i,j [L]Representing the value, p, of the image to be converted in the luminance dimension i,j [C]Representing the value, p, of the image to be converted in the saturation dimension i,j [H]Representing the value of the image to be converted in the hue dimension. f. of l (p i,j [L]) Representing a first normalization function, f c (p i,j [C]) Representing the second normalization function and MOD the remainder operation. dist lch [L]Representing the value of the migration vector in the luminance dimension, dist lch [C]Representing the value of the migration vector in the saturation dimension, dist lch [H]Representing the value of the migration vector in the hue dimension. p is a radical of i,j [L]' represents the value, p, obtained after the luminance dimension shift of the image to be converted i,j [C]' represents the value, p, obtained after the migration of the image to be converted in the saturation dimension i,j [H]' represents a value obtained after the hue dimension of the image to be converted is shifted.
First normalization function f
l (p
i,j [L]) Comprises the following steps:
second normalization function f
c (p
i,j [C]) Comprises the following steps:
wherein p is i,j [L]And p i,j [C]Has a domain of [0, 100 ]],p i,j [H]Has a definition field of [0,2 pi ]]。 f l (p i,j [L]) And f c (p i,j [C]) Value range of [0,1]],p i,j [H]The value range of' is [0,2 π]。
In addition, a first normalization function f
l (p
i,j [L]) The method can also comprise the following steps:
second normalization function f
c (p
i,j [C]) The method can also comprise the following steps:
the embodiment defines the image to be converted by using the normalization function to ensure that the color values of the transformed pixels still fall within the definition domain as much as possible. In addition, the defined normalization function is continuous in the whole definition domain, so that the images after color migration are ensured, tearing feeling cannot be generated in each edge area, and readability is enhanced.
The choice of the first normalization function and the second normalization function may be various, subject to the constraints in the physical sense of:
for the luminance channel, the normalization function value field is [0,1], is symmetric about x ═ 50 axis in the defined field, the function monotonically increases when x <50, the function monotonically decreases when x >50, and takes the maximum value of 1 when x ═ 50. This is because black and white areas are generally areas where it is not desirable to participate in color conversion, such as black and white text. And weighting the translation vector through a normalization function to ensure that the colors of the black and white patterns in the original image are basically unchanged.
With respect to the saturation channel, the normalization function monotonically increases within the domain of the definition, with a value range of [0,1 ]. Therefore, when the original color value saturation is low, the change amplitude of the saturation is also low, and inaccurate color values after color conversion are avoided.
The following two different sets of normalization functions are used as examples, and different effects are achieved for the same input:
a first group:
first normalization function f
l (p
i,j [L]) Comprises the following steps:
second normalization function f
c (p
i,j [C]) Comprises the following steps:
second group:
first normalization function f
l (p
i,j [L]) Comprises the following steps:
second normalization function f
c (p
i,j [C]) Comprises the following steps:
after color migration is performed by using the two sets of functions, the result graph is shown in fig. 4. Referring to fig. 4, a color image 11 of a target color is subjected to color migration by using a first set of functions to obtain a new image, which is an image 22, and is subjected to color migration by using a second set of functions to obtain a new image, which is an image 33. Comparing the image 22 and the image 33 shows that after the target color is shifted, the display effect of the image and the document in the image 22 is obviously different from the display effect of the image and the document in the image 33.
The contrast of the file is reduced when the first set of functions is used for generating the pictures, and the contrast of the file is clear, but the color saturation and the brightness are reduced when the second set of functions is used for generating the pictures.
The selection of the normalization functions is subjective, the two groups of normalization functions provided by the application are considered to be two groups with better presentation effect through experiments, and on the premise of ensuring the basic effect of generating the picture, the two groups of normalization functions respectively focus on bright and relatively steady scenes. In practice, the functions subject to the above constraints may be used as normalization functions, but may also have different effects on the generated picture.
In an embodiment, after step S300, the image color migration method further includes: and converting the image obtained after the target color is transferred to the image to be converted into the image with the corresponding target format.
Specifically, in the process of transferring the target color to the image to be converted, the target color and the image to be converted need to be converted into the target color space for processing, and the obtained image after the transfer is also an image in the target color space. Therefore, it is necessary to convert the image obtained after the migration into an image in a target format corresponding to the requirement, and finally output the image in the target format. Or, the format of the image obtained after the target color is transferred to the image to be converted may be converted according to various requirements. For example, the image to be converted and the target color are both the image and the color represented in the RGB color space, the image and the target color are converted into the CIE-LCH color model space for color migration, the image obtained after the migration is converted back into the RGB color space, and finally the image in the RGB color space is output.
According to the image color migration method, when the color value of the target color which is migrated to the image to be converted is determined, the color value of the main color of the image to be converted is extracted, the migration vector for color migration is determined through the color value of the main color of the image to be converted and the color value of the target color, and finally the target color can be migrated to the image to be converted according to the migration vector. Therefore, the color migration of the image to be converted can be realized without a target reference picture, and the limitation that the traditional color migration technology needs the reference picture is broken, so that the color migration technology meets more application scenes.
To better illustrate an image color migration method of the above embodiment, a specific embodiment is given below:
1. and reading the picture to be processed, namely the image to be converted by using an OpenCV library.
2. The picture to be processed is taken by using a Median Cut Quantization (MMCQ) process to obtain 10 output colors, and the color with the highest frequency of appearance is selected as the main color of the picture to be processed.
3. And converting the obtained main color and the target color needing color migration into a CIE-LCH color model space, and performing image processing by using a corresponding function in a python third-party library and scimit-image to obtain the color value of the main color and the color value of the target color. And if the picture to be processed has a transparent channel, the transparent channel is extracted and then converted, and the transparent channel is independently stored.
4. Using the obtained color value of the dominant color and the color value of the target color, a translation transformation vector from the color value of the dominant color to the color value of the target color in the CIE-LCH color model space is calculated using the vector subtraction of the Numpy multidimensional array.
5. And performing corresponding transformation on each pixel in the picture to be processed according to the translation transformation vector by using the vector addition of the Numpy multi-dimensional array to obtain the transformed picture.
6. And converting the transformed picture into an RGB color space from a CIE-LCH color model space, and specifically, performing image processing by using a corresponding function in scimit-image by using a python third-party library. Similarly, if there is a transparent channel in the transformed picture, the transformed picture is added to the transparent channel saved in step 3 using the Numpy.
7. And finishing, and outputting the transformed target picture.
In this embodiment, the results achieved are shown in fig. 5. And transferring the target color 44 to the picture 55 to be processed, and finally obtaining a target picture 66 after the transfer.
Therefore, when a new color matching requirement exists for an existing design drawing, according to the technical implementation scheme of the application, only the existing template bitmap and the target color value specified according to the requirement need to be input, the image after color migration can be obtained according to the original template within a few seconds, and then only manual review or fine adjustment is needed. The method not only greatly reduces the repeated labor of designers, but also only needs to maintain a PSD (Photoshop specific image file format) file in the system, can generate the required pictures in real time after receiving the color matching requirement, and greatly saves the storage resources.
It should be understood that, although the steps in the flowchart are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least a portion of the steps in the flowchart may include multiple sub-steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of performing the sub-steps or stages is not necessarily sequential, but may be performed alternately or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
In one embodiment, as shown in fig. 6, there is provided an image color migration apparatus including: an extraction module 100, a determination module 200, and a migration module 300, wherein:
the extracting module 100 is configured to extract a color value of a main color of an image to be converted.
The determining module 200 is configured to determine a migration vector used when the target color is migrated to the image to be converted according to the color value of the main color of the image to be converted and the color value of the target color.
And the migration module 300 is configured to migrate the target color to the image to be converted according to the migration vector.
In one embodiment, the determining module 200 may include (not shown in fig. 6):
the first obtaining unit is used for obtaining a first three-dimensional color vector corresponding to the color value of the main color of the image to be converted in the target color space.
And the second acquisition unit is used for acquiring a second three-dimensional color vector corresponding to the color value of the target color in the target color space.
And the determining unit is used for determining the migration vector according to the first three-dimensional color vector and the second three-dimensional color vector.
In one embodiment, the determining unit may include:
and the determining subunit is used for acquiring a translation transformation vector adopted when the first three-dimensional color vector is translated to the second three-dimensional color, and taking the translation transformation vector as a migration vector.
In one embodiment, the migration module 300 may include (not shown in FIG. 6):
and the extraction unit is used for extracting the color value of the pixel of the image to be converted.
The migration unit is used for migrating the color values of the pixels of the image to be converted according to the migration vector, and taking the image to be converted after migration as a target image;
the target image is an image obtained by transferring a target color to an image to be converted.
In one embodiment, the migration unit further includes:
and the migration subunit is used for migrating the color value of the pixel of the image to be converted according to the brightness dimension, the saturation dimension and the hue dimension in the target color space respectively according to the migration vector.
In one embodiment, the migration subunit further comprises (not shown in fig. 6):
the first processing unit is used for carrying out normalization processing on brightness data corresponding to a brightness dimension in the color values of the pixels of the image to be converted according to a first normalization function to obtain a first numerical value; according to the migration vector and the first numerical value, migrating the color value of the pixel of the image to be converted according to the brightness dimension;
the second processing unit is used for carrying out normalization processing on saturation data corresponding to a saturation dimension in the color values of the pixels of the image to be converted according to a second normalization function to obtain a second numerical value; according to the migration vector and the second numerical value, migrating the color value of the pixel of the image to be converted according to the saturation dimension;
the third processing unit is used for acquiring a migration vector and a sum of color values of pixels of the image to be converted, taking the sum of 2 pi as a remainder, and migrating the color values of the pixels of the image to be converted according to hue dimensions according to the remainder result; and pi is the circumferential ratio.
In one embodiment, the image color migration apparatus further includes (not shown in fig. 6):
the segmentation module is used for sampling the image to be converted by using a color quantization algorithm to obtain a plurality of quantized colors; and taking the color with the highest occurrence probability in the plurality of colors as the main color of the image to be converted.
For specific limitations of the image color migration apparatus, reference may be made to the above limitations of the image color migration method, which are not described herein again. The modules in the image color migration apparatus can be wholly or partially implemented by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a server for image processing, and its internal structure diagram may be as shown in fig. 7. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer device is used for storing data such as color values of target colors. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement an image color migration method.
It will be appreciated by those skilled in the art that the configuration shown in fig. 7 is a block diagram of only a portion of the configuration associated with the present application, and is not intended to limit the computing device to which the present application may be applied, and that a particular computing device may include more or fewer components than shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the computer program:
extracting color values of main colors of the image to be converted; determining a migration vector adopted when the target color is migrated to the image to be converted according to the color value of the main color of the image to be converted and the color value of the target color; and migrating the target color to the image to be converted according to the migration vector.
In one embodiment, when the processor executes the computer program to determine a migration vector adopted when the target color is migrated to the image to be converted according to the color value of the main color and the color value of the target color of the image to be converted, the following steps are further implemented:
acquiring a first three-dimensional color vector corresponding to the color value of the main color of the image to be converted in a target color space; acquiring a second three-dimensional color vector corresponding to the color value of the target color in the target color space; and determining a migration vector according to the first three-dimensional color vector and the second three-dimensional color vector.
In one embodiment, the processor executes a computer program to determine a migration vector based on the first three-dimensional color vector and the second three-dimensional color vector, and further performs the steps of:
and acquiring a translation transformation vector adopted when the first three-dimensional color vector is translated to the second three-dimensional color, and taking the translation transformation vector as a migration vector.
In one embodiment, the processor executes the computer program to realize the following steps when migrating the target color to the image to be converted according to the migration vector:
extracting color values of pixels of an image to be converted; according to the migration vector, migrating the color value of the pixel of the image to be converted, and taking the image to be converted after migration as a target image; the target image is an image obtained by transferring a target color to an image to be converted.
In one embodiment, the processor executes a computer program to realize the following steps when migrating the color values of the pixels of the image to be converted according to the migration vector:
and according to the migration vector, migrating the color value of the pixel of the image to be converted according to the brightness dimension, the saturation dimension and the hue dimension in the target color space.
In one embodiment, when the processor executes a computer program to realize that the color values of the pixels of the image to be converted are migrated according to the luminance dimension, the saturation dimension, and the hue dimension, respectively, according to the migration vector, the following steps are further realized:
according to a first normalization function, performing normalization processing on brightness data corresponding to a brightness dimension in the color values of pixels of an image to be converted to obtain a first numerical value; according to the migration vector and the first numerical value, migrating the color value of the pixel of the image to be converted according to the brightness dimension; according to a second normalization function, normalization processing is carried out on saturation data corresponding to a saturation dimension in the color values of the pixels of the image to be converted, and a second numerical value is obtained; according to the migration vector and the second numerical value, migrating the color value of the pixel of the image to be converted according to the saturation dimension; acquiring a sum of the color values of the pixels of the migration vector and the image to be converted, taking the sum of 2 pi, and migrating the color values of the pixels of the image to be converted according to hue dimensions according to a residue taking result; and pi is the circumferential ratio.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
sampling an image to be converted by using a color quantization algorithm to obtain a plurality of quantized colors; and taking the color with the highest occurrence probability in the plurality of colors as the main color of the image to be converted.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of:
extracting color values of main colors of the image to be converted; determining a migration vector adopted when the target color is migrated to the image to be converted according to the color value of the main color of the image to be converted and the color value of the target color; and migrating the target color to the image to be converted according to the migration vector.
In one embodiment, when the computer program is executed by the processor and determines a migration vector used for migrating the target color to the image to be converted according to the color value of the main color and the color value of the target color of the image to be converted, the following steps are further implemented:
acquiring a first three-dimensional color vector corresponding to the color value of the main color of the image to be converted in a target color space; acquiring a second three-dimensional color vector corresponding to the color value of the target color in the target color space; and determining a migration vector according to the first three-dimensional color vector and the second three-dimensional color vector.
In one embodiment, the computer program when executed by the processor for determining a migration vector from the first three-dimensional color vector and the second three-dimensional color vector further performs the steps of:
and acquiring a translation transformation vector adopted when the first three-dimensional color vector is translated to the second three-dimensional color, and taking the translation transformation vector as a migration vector.
In one embodiment, the computer program is executed by a processor, and when migrating a target color to an image to be converted according to a migration vector, further implements the following steps:
extracting color values of pixels of an image to be converted; according to the migration vector, migrating the color value of the pixel of the image to be converted, and taking the image to be converted after migration as a target image; the target image is an image obtained by transferring a target color to an image to be converted.
In one embodiment, the computer program is executed by a processor, and when migrating color values of pixels of an image to be converted according to a migration vector, further implements the following steps:
according to the migration vector, migrating the color value of the pixel of the image to be converted according to the brightness dimension, the saturation dimension and the hue dimension in the target color space respectively; wherein the target color space includes a luminance dimension, a saturation dimension, and a hue dimension.
In one embodiment, the computer program is executed by a processor, and when the color values of the pixels of the image to be converted are migrated according to the luminance dimension, the saturation dimension, and the hue dimension, respectively, according to the migration vector, the following steps are further implemented:
according to a first normalization function, performing normalization processing on brightness data corresponding to a brightness dimension in the color values of pixels of an image to be converted to obtain a first numerical value; according to the migration vector and the first numerical value, migrating the color value of the pixel of the image to be converted according to the brightness dimension; according to a second normalization function, normalization processing is carried out on saturation data corresponding to a saturation dimension in the color values of the pixels of the image to be converted, and a second numerical value is obtained; according to the migration vector and the second numerical value, migrating the color value of the pixel of the image to be converted according to the saturation dimension; acquiring a sum of the color values of the pixels of the migration vector and the image to be converted, taking the sum of 2 pi, and migrating the color values of the pixels of the image to be converted according to hue dimensions according to a residue taking result; and pi is the circumferential ratio.
In one embodiment, the computer program, when executed by the processor, further performs the steps of: sampling an image to be converted by using a color quantization algorithm to obtain a plurality of quantized colors; and taking the color with the highest occurrence probability in the plurality of colors as the main color of the image to be converted.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.