CN114841850A - Image processing method and device and electronic equipment - Google Patents

Image processing method and device and electronic equipment Download PDF

Info

Publication number
CN114841850A
CN114841850A CN202110145856.8A CN202110145856A CN114841850A CN 114841850 A CN114841850 A CN 114841850A CN 202110145856 A CN202110145856 A CN 202110145856A CN 114841850 A CN114841850 A CN 114841850A
Authority
CN
China
Prior art keywords
color
material image
image
value
pixel
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110145856.8A
Other languages
Chinese (zh)
Inventor
何志远
陈德银
胡志通
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Oppo Mobile Telecommunications Corp Ltd
Original Assignee
Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangdong Oppo Mobile Telecommunications Corp Ltd filed Critical Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority to CN202110145856.8A priority Critical patent/CN114841850A/en
Publication of CN114841850A publication Critical patent/CN114841850A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/04Context-preserving transformations, e.g. by using an importance map
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/001Texturing; Colouring; Generation of texture or colour

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Image Processing (AREA)

Abstract

The embodiment of the application discloses an image processing method and device and electronic equipment. The method comprises the following steps: acquiring reference information; acquiring a first material image corresponding to the reference information; acquiring color conversion parameters corresponding to the first material image, wherein the color conversion parameters comprise color conversion target values of designated pixels in the first material image; and performing color transformation on the first material image based on the color transformation parameters to obtain a second material image subjected to color transformation. Therefore, after the corresponding first material image is matched based on the reference information, the corresponding color conversion parameter can be obtained again to perform color conversion on the first material image, and the second material image after the color conversion is obtained, so that the first material image which is manufactured in advance can be subjected to adaptive color conversion according to actual needs to obtain the second material image, and the material image can be displayed more flexibly and more diversely.

Description

Image processing method and device and electronic equipment
Technical Field
The present application relates to the field of image processing technologies, and in particular, to an image processing method and apparatus, and an electronic device.
Background
As the images that can be presented in electronic devices become more and more diverse, users of electronic devices also have higher demands on the experience of image display. The image can be used as a background image or a theme image of a certain interface in the electronic device. For example, a smart watch may use a moving image as an image of a dial. However, the related images are all made in advance, so that the electronic device cannot configure the background image or the theme image of the interface more flexibly and variously.
Disclosure of Invention
In view of the above problems, the present application provides an image processing method, an image processing apparatus, and an electronic device to achieve an improvement of the above problems.
In a first aspect, the present application provides an image processing method applied to an electronic device, the method including: acquiring reference information; acquiring a first material image corresponding to the reference information; acquiring color conversion parameters corresponding to the first material image, wherein the color conversion parameters comprise color conversion target values of designated pixels in the first material image; and performing color transformation on the first material image based on the color transformation parameters to obtain a second material image subjected to color transformation.
In a second aspect, the present application provides an image processing method applied to an electronic device, the method including: an image acquisition unit configured to acquire reference information; the material matching unit is used for acquiring a first material image corresponding to the reference information; a parameter acquisition unit configured to acquire a color conversion parameter corresponding to the first material image, the color conversion parameter including a color conversion target value of a specified pixel in the first material image; and the image processing unit is used for carrying out color conversion on the first material image based on the color conversion parameters to obtain a second material image after the color conversion is carried out.
In a third aspect, the present application provides an electronic device comprising one or more processors and a memory; one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs configured to perform the methods described above.
In a fourth aspect, the present application provides a computer-readable storage medium having a program code stored therein, wherein the program code performs the above method when running.
According to the image processing method, the image processing device and the electronic equipment, after the reference information is obtained, the first material image corresponding to the reference information is obtained, the color conversion parameter corresponding to the first material image and including the color conversion target value of the designated pixel in the first material image is obtained, and then the first material image is subjected to color conversion based on the color conversion parameter, so that the second material image subjected to color conversion is obtained. Therefore, after the corresponding first material image is matched based on the reference information, the corresponding color conversion parameter can be obtained to perform color conversion on the first material image, and the second material image after the color conversion is obtained, so that the first material image which is manufactured in advance can be subjected to adaptive color conversion according to actual needs to obtain the second material image, and the material image can be displayed more flexibly and more variously.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic view illustrating an application scenario of an image processing method proposed in the present application;
FIG. 2 shows a flow chart of an image processing method proposed by the present application;
FIG. 3 shows a flow chart of another image processing method proposed by the present application;
FIG. 4 is a schematic diagram illustrating a color transform selection interface proposed by the present application;
FIG. 5 shows a schematic view of a color interface proposed by the present application;
FIG. 6 shows a schematic of three image types proposed by the present application;
FIG. 7 is a flow chart illustrating yet another image processing method proposed by the present application;
fig. 8 is a block diagram showing a configuration of an image processing apparatus proposed in the present application;
fig. 9 shows a block diagram of an electronic device proposed in the present application;
fig. 10 is a storage unit for storing or carrying program codes for implementing an image processing method according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
As the user of the electronic device demands more and more on the visual experience, many interfaces in the electronic device can change the background image or the theme image. For example, in a smart watch, the theme images of the watch face can be changed according to the user's own preferences. For another example, in a smart phone, the background image of the desktop may be replaced according to the user's preference. In the electronic device, the material image may be acquired in advance, and then the acquired material image may be used as a background image or a theme image of a certain interface by operating the electronic device.
The inventor finds in research on related material images that the material images that can be used as background images or theme images are usually pre-made, and further the material images may not be well adapted to the personalized requirements of each user.
Therefore, the inventor proposes an image processing method, an image processing apparatus, and an electronic device in the present application, after acquiring reference information, acquiring a first material image corresponding to the reference information, acquiring a color conversion parameter corresponding to the first material image and including a color conversion target value of a specified pixel in the first material image, and performing color conversion on the first material image based on the color conversion parameter to obtain a second material image after color conversion.
Therefore, after the corresponding first material image is matched based on the reference information, the corresponding color conversion parameters can be obtained again to perform color conversion on the first material image, so as to obtain a second material image after the color conversion, and further, the first material image which is manufactured in advance can be subjected to adaptive color conversion according to actual needs to obtain the second material image, so that the material images can be displayed more flexibly and more variously.
The following first introduces an application scenario related to the embodiment of the present application.
As shown in fig. 1, in the scenario shown in fig. 1, a smart phone 100 and a smart watch 200 are included, and the smart phone 100 and the smart watch 200 may communicate with each other by way of short-range wireless communication (e.g., WiFi or bluetooth) or mobile communication (e.g., a communication base station). The image processing method provided by the embodiment of the application can be independently completed by the smart phone 100, can also be independently completed by the smart watch 200, and can also be completed by the smart phone 100 and the smart watch 200 in a mutual matching manner. For example, the smart phone 100 may be configured to perform obtaining reference information, obtaining a first material image corresponding to the reference information, and obtaining a color transformation parameter corresponding to the first material image, then transmit the color transformation parameter to the smart watch 200, and the smart watch 200 continues to perform color transformation on the first material image based on the color transformation parameter, obtain a second material image after the color transformation, and display the second material image.
It should be noted that the smart phone 100 is merely exemplary, and the smart phone 100 may be replaced by a tablet computer or a computer.
Referring to fig. 2, an image processing method provided by the present application is applied to an electronic device, and the method includes:
s110: reference information is acquired.
In the embodiment of the application, the reference information is a basis for acquiring the material image, and the acquired material image may be a material image related to the reference information. In the embodiment of the present application, the reference information may be a text or an image.
Wherein, the reference information can be obtained by user input. For example, an input interface in which reference information can be input can be provided in the electronic device. Optionally, the image may be acquired by an image acquisition device of the electronic device channel. For example, in the embodiment of the present application, the color may be changed according to the wearing of the user, and then the reference information may be an image of the wearing acquired by the electronic device through the image acquisition device.
S120: and acquiring a first material image corresponding to the reference information.
The first material image is a basic image which is subsequently subjected to color conversion. In the embodiment of the present application, a plurality of material images may be stored in advance, and then, a first material image corresponding to reference information may be acquired from the plurality of material images stored in advance based on the reference information. Alternatively, the plurality of prestored material images may be material images which are previously produced by a developer.
In the case where the reference information may be in a plurality of forms, the manner of acquiring the corresponding first material image may be different for different forms of reference information.
As one way, the reference information is text. In this manner, each material image may correspond with respective description information for describing the image content of the corresponding material image. For example, for a material image whose image content is a natural landscape, the description information corresponding to the material image is "natural scene". For another example, for a material image whose image content is sky, the description information corresponding to the material image is "sky". In this way, the electronic device can match the parameter information in the text form with the description information corresponding to each material image, and then take the material image corresponding to the description information matched with the reference information as the first material image.
Optionally, in the process of determining whether the reference information is matched with the description information, a vector of the reference information and a vector of the description information may be respectively calculated, and then a vector distance between the vector of the reference information and the vector of the description information is calculated to represent whether the matching degree between the reference information and the description information is higher, that is, the smaller the vector distance is, the higher the corresponding matching degree is. Correspondingly, the corresponding description information with the vector distance greater than the first specified distance threshold value can be used as the material image matched with the reference information. In addition, the calculation results of the vector distances may be sorted, and the description information corresponding to the vector distance sorted at the top may be used as the material image matched with the reference information.
Further, optionally, the matching degree may be determined directly based on how much content the reference information and the description information collectively include. Correspondingly, the more the contents are commonly included, the higher the matching degree of the reference information and the description information is, and the reference information and the description information which commonly include the most contents can be used as the matched reference information and description information.
For example, if a plurality of material images are stored in advance, the material images include a material image a, a material image B, a material image C, and a material image D. The material image a corresponds to description information D1, the material image B corresponds to description information D2, the material image C corresponds to description information D3, and the material image D corresponds to description information D4. If the matching degree between the reference information and the description information d1 is m1, if the matching degree between the reference information and the description information d2 is m2, if the matching degree between the reference information and the description information d3 is m3, if the matching degree between the reference information and the description information d4 is m4, and the result of sorting m1 to m4 is that m4 is greater than m3, m3 is greater than m2, and m2 is greater than m 1. Then, in the case where the degree of matching is determined based on the vector and the first material image is determined by the first specified distance threshold, if the first specified distance threshold is m5 and only m4 is greater than m5, the material image D corresponding to the description information D4 corresponding to m4 is taken as the first material image. Then, in the case where the first material image is determined based on the sorting result, the material image D corresponding to the description information D4 corresponding to the top m4 will be regarded as the first material image.
Alternatively, the reference information may be an image. In this way, the first material image may be selected by comparing the reference information with a plurality of material images stored in advance. The purpose of the image comparison is to determine the matching degree between the reference information and the plurality of material images, and then to use the material image with the maximum matching degree as the first material image. In this embodiment, the images may be characterized by the feature vectors corresponding to the images, and then the feature vectors corresponding to each image are compared to determine the matching degree of the images. The reference information in the image form and the material image can be respectively input into a CNN (volumetric Neural networks) model to obtain respective feature vectors, then the distance between the reference information in the image form and the respective feature vectors of the material image is calculated, and if the distance is smaller than a second specified threshold value, the reference information in the image form and the material image are determined to be matched.
As still another mode, the first material image corresponding to the reference information may be acquired by an AI mode. In this way, a neural network model may be trained in advance, and a training sample of the trained neural network model may include a text and an image, so that an input of the neural network model may be either the text or the image. In the process of obtaining the first material image, the reference information (which may be a text or an image) may be directly input into the trained neural network model, and the first material image output by the neural network model may be obtained.
S130: color conversion parameters corresponding to the first material image are acquired, the color conversion parameters including color conversion target values of designated pixels in the first material image.
The designated pixels in the first material image may be all pixels in the first material image, or may be pixels in a partial region. The partial area may be an area corresponding to a partial color, or a partial position area.
It should be noted that, a plurality of colors may be included in the first material image, and in the process of performing color conversion, each color may be converted, or only a part of the colors may be converted, so that in this embodiment, a pixel included in a region where color conversion is required may be used as a designated pixel. Illustratively, the first material image includes a black area, a red area, a green area, and a blue area, where a pixel value of a pixel in the black area is a pixel value representing black, a pixel value of a pixel in the red area is a pixel value representing red, a pixel value of a pixel in the green area is a pixel value representing green, and a pixel value of a pixel in the blue area is a pixel value representing blue. Then, in the case where it is determined that it is necessary to convert red to sky blue, green to purple, and blue to brown, the designated pixel is a pixel included in a region in the first material image whose corresponding pixel value is represented as red, green, or blue. The color transformation parameters include a pixel value corresponding to sky blue, a pixel value corresponding to purple, and a pixel value corresponding to brown.
S140: and performing color transformation on the first material image based on the color transformation parameters to obtain a second material image subjected to color transformation.
Correspondingly, after the color conversion parameters are obtained based on the above steps, the color conversion can be performed on the designated pixels in the first material image, and then the second material image is obtained. For example, if the color conversion parameters include red to sky blue, green to purple, and blue to brown, the second pixel image includes sky blue, purple, and brown.
In the image processing method provided in this embodiment, after reference information is acquired, a first material image corresponding to the reference information is acquired, a color conversion parameter corresponding to the first material image and including a color conversion target value of a specified pixel in the first material image is acquired, and then color conversion is performed on the first material image based on the color conversion parameter, so as to obtain a second material image after color conversion. Therefore, after the corresponding first material image is matched based on the reference information, the corresponding color conversion parameter can be obtained to perform color conversion on the first material image, and the second material image after the color conversion is obtained, so that the first material image which is manufactured in advance can be subjected to adaptive color conversion according to actual needs to obtain the second material image, and the material image can be displayed more flexibly and more variously.
Referring to fig. 3, an image processing method provided by the present application is applied to an electronic device, and the method includes:
s210: reference information is acquired.
S220: and acquiring a first material image corresponding to the reference information.
S230: and acquiring reference transformation colors corresponding to the colors to be transformed in the first material image.
As described above, only a part of the colors can be color-converted in the first material image, and there are various ways to determine the colors to be converted in the first material image in the present embodiment.
As one way, the selection may be made by the user. In this way, a color conversion selection interface may be configured in the electronic device, in which the determined colors included in the first material image may be displayed, and a target color selection control may be displayed corresponding to the included colors, respectively, so that the user may refer to the conversion colors through the target color selection control. Illustratively, as shown in fig. 4, a region 11 and a region 12 are included in the color conversion selection interface 10, wherein the detected colors included in the first material image may be displayed in the region 11, and the target color selection controls corresponding to the colors displayed in the region 11 may be included in the region 12.
S240: and acquiring the respective proportionality coefficients of a plurality of color channels of the appointed pixel in the first material image.
It should be noted that, in an image, areas where different colors contact each other may have color intersections, and thus, pixel values of pixels in the areas where the colors contact each other may have color values on a plurality of color channels. For example, in the image shown in fig. 5, the color of the circular area is red, and the color of the area other than the circular area is black, then in the plurality of color channels of the pixels in the central portion of the circular area, the values of the green channel and the blue channel are both 0, the red channel may have a value of 255, but at the area where the circular area borders the other areas, the same pixel may be crossed by the colors of red and other areas, so that the values of the green channel and the blue channel of the pixels in the boundary area are both greater than 0, and the value of the red channel is less than 255, therefore, in order to accurately determine how the designated pixel in the first material image changes color, the scaling factors of the respective color channels of the designated pixel may be determined, the scaling factor is used for determining the proportion of the color value corresponding to each color channel after color conversion.
As one mode, the acquiring the scale factor of each of the plurality of color channels of the designated pixel in the first material image includes: acquiring an image type corresponding to the first material image; and acquiring respective scale coefficients of a plurality of color channels of the designated pixel in the first material image based on the image type. In this embodiment, the image type is determined based on the color boundary in the first material image. Illustratively, as shown in fig. 6, the filling color corresponding to each region is identified, wherein in the image corresponding to the first type, red, green and blue included in the first material image are respectively bordered with black as a background, and there are no places where the red, green and blue border each other. In the image corresponding to the second type, the first material image includes a border region of red, green and blue colors. In the image corresponding to the third type, the first material image includes the respective corresponding situations of the first type and the second type.
In this embodiment, the type corresponding to each material image may be labeled in advance, so that when the electronic device obtains the first material image, the image type corresponding to the first material image may be obtained correspondingly.
Optionally, the obtaining, based on the image type, the scaling coefficients of each of the multiple color channels of the designated pixel in the first material image includes:
if the image type is a first type, obtaining respective proportionality coefficients of a plurality of color channels based on a first proportionality coefficient determining mode, wherein the first proportionality coefficient determining mode comprises: acquiring a target color channel in a plurality of color channels of a designated pixel, wherein the target color channel is a color channel with the maximum corresponding color value; and setting the scale factor of a target color channel of the designated pixel as 1, and setting the scale factor of a color channel except the target color channel as 0. For example, if the color value corresponding to the red channel of the pixel is 255, and the values of the green channel and the blue channel are both 0, it is determined that the target color channel of the pixel is the red channel. For another example, if the color value corresponding to the red channel of the pixel is 20, the color value of the green channel is 200, and the value of the blue channel is 0, then it is determined that the target color channel of the pixel is the green channel.
Optionally, the obtaining, based on the image type, a scaling factor of each of a plurality of color channels of a specified pixel in the first material image further includes:
if the image type is a second type, obtaining respective proportionality coefficients of a plurality of color channels based on a second proportionality coefficient determining mode, wherein the second proportionality coefficient determining mode comprises the following steps: obtaining a corresponding first target color parameter value of a designated pixel, the first target color parameter value being a smallest one of original color values and first reference color values of a plurality of color channels.
Optionally, the minimum value of the function input parameters may be obtained through a min function. In this way, the original color values of the plurality of color channels of the designated pixel and the first reference color value may be input to the min function, and the min function output value may be used as the first target color parameter value. For example, the original color values of the plurality of color channels include an original color value of a red channel, an original color value of a green channel, and an original color value of a blue channel. Wherein the first reference color value may be 0.2. The first reference color value is used for preventing the problem of low brightness after color conversion.
And acquiring the difference value between each of the original color values of the plurality of color channels and the first target color parameter value and the maximum value in the second color reference value as the current color values of the plurality of color channels.
Optionally, taking the RGB mode as an example, the current color values of the multiple color channels may be determined by the following function: max ((R-min, G-min, B-min),0), where min is the previously determined first target color parameter value, 0 is the second color reference value, R characterizes the original color value of the red channel, G characterizes the original color value of the green channel, and B characterizes the original color value of the blue channel.
Obtaining a maximum value of a sum of current color values of the plurality of color channels and a third color reference value as a second target color parameter value. The second target color parameter value may be calculated by a function of sum max (R + G + B,0.001), where R represents the current color value of the red channel, G represents the current color value of the green channel, and B represents the current color value of the blue channel in the formula. 0.001 is the third color reference value and sun characterizes the second target color parameter value.
And taking the ratio of the current color values of the plurality of color channels to the second target color parameter value as the respective proportionality coefficients of the plurality of color channels of the designated pixel. The scale factor of the red channel is the ratio of the current color value of the red channel to the second target color parameter value, the scale factor of the green channel is the ratio of the current color value of the green channel to the second target color parameter value, and the scale factor of the blue channel is the ratio of the current color value of the blue channel to the second target color parameter value.
Optionally, the obtaining, based on the image type, a scaling factor of each of a plurality of color channels of a specified pixel in the first material image further includes:
if the image type is a third type, obtaining respective scaling coefficients of the plurality of color channels based on a third scaling coefficient determination mode, wherein the third scaling coefficient determination mode comprises:
and determining a mode from the first scale coefficient determining mode and the second scale coefficient determining mode to determine the scale coefficients of the multiple color channels of the current pixel based on the type of the current pixel in the specified pixel and the size of the color values of the multiple color channels corresponding to the current pixel.
Wherein, if the color to be transformed in the first material image includes three colors, determining one of the first scale coefficient determining manner and the second scale coefficient determining manner to determine the scale coefficients of the multiple color channels of the current pixel may include:
if the value of the blue channel and the value of the green channel of the first pixel in the designated pixel are both smaller than the fourth reference color value, determining the proportionality coefficients of the multiple color channels of the first pixel in the first proportionality coefficient determining mode, and otherwise determining the proportionality coefficients of the multiple color channels of the first pixel in the second proportionality coefficient determining mode;
if the value of the red channel and the value of the green channel of the second pixel in the designated pixel are both smaller than the fourth reference color value, determining the proportionality coefficients of the multiple color channels of the second pixel in the first proportionality coefficient determining mode, and otherwise determining the proportionality coefficients of the multiple color channels of the second pixel in the second proportionality coefficient determining mode;
if the value of the red channel and the value of the blue channel of the third pixel in the designated pixel are both smaller than the fourth reference color value, determining the proportionality coefficients of the multiple color channels of the third pixel in the first proportionality coefficient determining mode, and otherwise determining the proportionality coefficients of the multiple color channels of the third pixel in the second proportionality coefficient determining mode.
The color conversion method comprises the steps that three colors included by colors to be converted comprise a first color, a second color and a third color, and a first pixel is a pixel corresponding to a target color channel and the first color in a plurality of corresponding color channels. The second pixel is a pixel corresponding to the second color of a target color channel in the corresponding multiple color channels. The third pixel is a pixel corresponding to the third color of the target color channel in the corresponding multiple color channels. Wherein, the color channel corresponds to a certain color, and it can be understood that the color value represented by the color channel is the same as the certain color. For example, if the first color is red, the second color is green, and the third color is blue, the first pixel is a pixel whose red channel of the corresponding multiple color channels is the target color channel.
Optionally, in this embodiment of the present application, the fourth reference color value is 0.3.
S250: and obtaining a color conversion target value of the designated pixel in the first material image based on the respective scale coefficients of the plurality of color channels of the designated pixel and the respective reference conversion colors corresponding to each color.
As one mode, the obtaining a color conversion target value of a designated pixel in the first material image based on a scaling coefficient of each of the plurality of color channels of the designated pixel and a reference conversion color corresponding to each color includes:
multiplying the proportional coefficients of a plurality of color channels of the designated pixel with reference transformation colors corresponding to the color channels respectively to obtain a plurality of intermediate transformation target values, wherein if the color corresponding to the color channel is the same as the color to be transformed corresponding to the reference transformation color, the color channel corresponds to the reference transformation color;
the plurality of intermediate conversion target values are added to obtain a color conversion target value of the designated pixel.
For example, the color to be transformed includes red, green and anaglyphs, taking the example that the plurality of color channels includes a red channel, a green channel and a blue channel. The reference transform color corresponding to the red color is sky blue, and the red color corresponds to the red channel, so the reference transform color corresponding to the red channel may be sky blue. The reference transform color corresponding to green is purple, and green corresponds to the green channel, then the reference transform color corresponding to the green channel may be purple. The reference transform color corresponding to blue is brown, and blue corresponds to the blue channel, then the reference transform color corresponding to the blue channel may be brown. The following can describe the acquisition of the color conversion target value by a formula;
out=R_ratio*firstColor+G_ratio*secondColor+B_ratio*thirdColor
wherein, R _ ratio is a proportionality coefficient corresponding to a red channel, G _ ratio is a proportionality coefficient corresponding to a green channel, and B _ ratio is a proportionality coefficient corresponding to a blue channel. firstColor is sky blue, secondColor is purple, and thirdccolor is anaglyph, where out is the color transformation target value corresponding to the pixel. Correspondingly, R _ ratio × firstColor, G _ ratio × second color, and B _ ratio × third color respectively characterize the calculated intermediate transformation target values.
It should be noted that, for each intermediate conversion target value, the color values of a plurality of color channels are included, and when the intermediate conversion target values are added, the color conversion target values are obtained by adding the color values of each color channel. For example, if the intermediate conversion target values obtained based on the red channel are (R1, G1, B1), if the intermediate conversion target values obtained based on the green channel are (R2, G2, B2), and if the intermediate conversion target values obtained based on the blue channel are (R3, G3, B3), then the color conversion target values obtained by adding the intermediate conversion target values are (R1+ R2+ R3, G1+ G2+ G3, B1+ B2+ B3). Wherein, R1 is obtained by multiplying R _ ratio by a color value of a red channel corresponding to a first color, R2 is obtained by multiplying G _ ratio by a color value of a red channel corresponding to a second color, R3 is obtained by multiplying B _ ratio by a color value of a red channel corresponding to a third color, and the same is true for color values corresponding to the rest of color channels, for example, G1 is obtained by multiplying R _ ratio by a color value of a green channel corresponding to a first color.
S260: and performing color transformation on the first material image based on the color transformation parameters to obtain a second material image subjected to color transformation.
It should be noted that the color conversion target value corresponding to the pixel actually includes color values of a plurality of color channels, and then performing color conversion on the first material image based on the color conversion parameter may be understood as replacing original color values of the plurality of color channels of the pixel with color values of the plurality of color channels included in the color conversion target value.
It should be noted that a given pixel indicated in the embodiments of the present application may include a plurality of pixels. Then, when the designated pixel includes a plurality of pixels, S240 to S260 in this embodiment are respectively performed on the plurality of pixels included in the designated pixel, so as to sequentially perform color transformation on each pixel included in the designated pixel, so as to obtain a second pixel image.
According to the image processing method provided by the embodiment, after the corresponding first material image is matched based on the reference information, the corresponding color conversion parameter can be obtained again to perform color conversion on the first material image, so that the second material image after the color conversion is obtained, and further, the first material image which is manufactured in advance can be subjected to adaptive color conversion according to actual needs to obtain the second material image, so that the material images can be displayed more flexibly and more variously. In addition, in this embodiment, after the color-changing target corresponding to the color to be changed in the material image is obtained, the corresponding color-changing target values are determined one by one for the designated pixels, so that the accuracy of color change is improved.
Referring to fig. 7, an image processing method provided by the present application is applied to an electronic device, and the method includes:
s310: reference information is acquired.
S320: and acquiring a first material image corresponding to the reference information.
S330: color conversion parameters corresponding to the first material image are acquired, the color conversion parameters including color conversion target values of designated pixels in the first material image.
S340: and sending the color transformation parameters to a target terminal so that the target terminal can carry out color transformation on the first material image based on the color transformation parameters and display a second material image after the color transformation.
Optionally, the electronic device is a smart phone, the target terminal is a smart watch, the reference information is a wearing image collected intelligently, the first material image is a dial plate image of the smart watch, and the smart phone can send the color conversion parameter to the smart watch after acquiring the color conversion parameter, so that the smart watch can perform color conversion on the dial plate image based on the color conversion parameter, obtain the dial plate image (namely, a second material image) after the color conversion, and further perform color conversion according to wearing of a user. Optionally, to avoid the target terminal running a stuck state due to color transformation, the aforementioned color transformation of the first material image based on the color transformation parameter may be performed by a gpu (graphics Processing unit) of the target terminal, and the second material image after the color transformation is displayed.
Optionally, after the electronic device obtains the color transformation parameter, the reference information, the color transformation parameter, and the first material parameter may be stored correspondingly. In this way, after the electronic device obtains the reference information, it may first detect whether the color conversion parameter and the first material image corresponding to the reference information are stored, if the electronic device stores the color conversion parameter and the first material image, the electronic device may directly send the first material image and the color conversion parameter that have been stored correspondingly to the target terminal, and if the electronic device does not store the color conversion parameter and the first material image, the electronic device starts to obtain the first material image corresponding to the reference information. For example, after the electronic device collects an image with content of wearing as reference information through an image collecting device, if the electronic device identifies that a first material image and color conversion information which are stored correspondingly to the image with content of wearing are available, the first material image and the color conversion information which are stored correspondingly to the content of wearing are directly transmitted to a target terminal, and the target terminal can directly trigger to replace an image of a designated interface (for example, a dial interface) with a second material image after performing color conversion according to the received first material image and the received color conversion information to obtain the second material image.
According to the image processing method provided by the embodiment, after the corresponding first material image is matched based on the reference information, the corresponding color conversion parameters can be obtained again to perform color conversion on the first material image, so as to obtain the second material image after the color conversion, and further, the first material image which is manufactured in advance can be subjected to adaptive color conversion according to actual needs to obtain the second material image, so that the material image can be displayed more flexibly and more variously. In addition, in this embodiment, the first material image actually acquired is an image for displaying in the target terminal, and then the corresponding color conversion parameter is acquired in advance by the electronic device, so that the target terminal can have more diversified material images to display, and the data operation pressure of the target terminal can be reduced.
Referring to fig. 8, an image processing apparatus 400 provided in the present application is applied to an electronic device, the apparatus 400 includes:
an image obtaining unit 410 for obtaining the reference information.
A material matching unit 420, configured to obtain a first material image corresponding to the reference information.
A parameter acquisition unit 430 for acquiring color conversion parameters corresponding to the first material image, the color conversion parameters including color conversion target values of specified pixels in the first material image.
An image processing unit 440, configured to perform color transformation on the first material image based on the color transformation parameter, so as to obtain a second material image after color transformation.
As one mode, the parameter obtaining unit 430 is specifically configured to obtain reference transform colors corresponding to colors to be transformed in the first material image; obtaining respective proportionality coefficients of a plurality of color channels of a designated pixel in the first material image; and obtaining a color conversion target value of the designated pixel in the first material image based on the respective scale coefficients of the plurality of color channels of the designated pixel and the respective reference conversion colors corresponding to each color.
Optionally, the parameter obtaining unit 430 is specifically configured to obtain an image type corresponding to the first material image; and acquiring respective scale coefficients of a plurality of color channels of the designated pixel in the first material image based on the image type. The parameter obtaining unit 430 is specifically configured to, if the image type is a first type, obtain respective scaling coefficients of the multiple color channels based on a first scaling coefficient determining manner, where the first scaling coefficient determining manner includes: acquiring a target color channel in a plurality of color channels of a designated pixel, wherein the target color channel is a color channel with the maximum corresponding color value; and setting the scale factor of a target color channel of the designated pixel as 1, and setting the scale factor of a color channel except the target color channel as 0.
Furthermore, the parameter obtaining unit 430 is further specifically configured to, if the image type is a second type, obtain the scaling factors of the multiple color channels based on a second scaling factor determining manner, where the second scaling factor determining manner includes: acquiring a corresponding first target color parameter value of a designated pixel, wherein the first target color parameter value is the minimum value of original color values and a first reference color value of a plurality of color channels; acquiring the difference value between each of the original color values of the multiple color channels and the first target color parameter value and the maximum value in a second color reference value to serve as the current color values of the multiple color channels; obtaining the maximum value of the sum of the current color values of the multiple color channels and a third color reference value as a second target color parameter value; and taking the ratio of the current color values of the plurality of color channels to the second target color parameter value as the respective proportionality coefficients of the plurality of color channels of the designated pixel.
Further, the parameter obtaining unit 430 is further specifically configured to, if the image type is a third type, obtain the scaling factors of the multiple color channels based on a third scaling factor determining manner, where the third scaling factor determining manner includes: and determining a mode from the first scale coefficient determining mode and the second scale coefficient determining mode to determine the scale coefficients of the multiple color channels of the current pixel based on the type of the current pixel in the specified pixel and the size of the color values of the multiple color channels corresponding to the current pixel.
As a manner, the parameter obtaining unit 430 is specifically configured to determine, if both a value of a blue channel and a value of a green channel of a first pixel in the designated pixel are smaller than a fourth reference color value, scaling coefficients of the multiple color channels of the first pixel by the first scaling coefficient determining manner, and determine, if not, scaling coefficients of the multiple color channels of the first pixel by the second scaling coefficient determining manner;
if the value of the red channel and the value of the green channel of the second pixel in the designated pixel are both smaller than the fourth reference color value, determining the proportionality coefficients of the multiple color channels of the second pixel in the first proportionality coefficient determining mode, and otherwise determining the proportionality coefficients of the multiple color channels of the second pixel in the second proportionality coefficient determining mode;
if the value of the red channel and the value of the blue channel of the third pixel in the designated pixel are both smaller than the fourth reference color value, determining the proportionality coefficients of the multiple color channels of the third pixel in the first proportionality coefficient determining mode, and otherwise determining the proportionality coefficients of the multiple color channels of the third pixel in the second proportionality coefficient determining mode.
The application provides an image processing device, after reference information is obtained, a first material image corresponding to the reference information is obtained, color transformation parameters corresponding to the first material image and including a color transformation target value of a designated pixel in the first material image are obtained, and then color transformation is carried out on the first material image based on the color transformation parameters, so that a second material image after color transformation is obtained. Therefore, after the corresponding first material image is matched based on the reference information, the corresponding color conversion parameter can be obtained to perform color conversion on the first material image, and the second material image after the color conversion is obtained, so that the first material image which is manufactured in advance can be subjected to adaptive color conversion according to actual needs to obtain the second material image, and the material image can be displayed more flexibly and more variously.
An electronic device provided by the present application will be described with reference to fig. 9.
Referring to fig. 9, based on the image processing method and apparatus, another electronic device 100 capable of executing the terminal control method is further provided in the embodiment of the present application. The electronic device 100 includes one or more processors 102 (only one shown), a memory 104, a network module 106, and an image acquisition apparatus 108 coupled to each other. The memory 104 stores programs that can execute the content of the foregoing embodiments, and the processor 102 can execute the programs stored in the memory 104.
Processor 102 may include one or more processing cores, among other things. The processor 102 interfaces with various components throughout the electronic device 100 using various interfaces and circuitry to perform various functions of the electronic device 100 and process data by executing or executing instructions, programs, code sets, or instruction sets stored in the memory 104 and invoking data stored in the memory 104. Alternatively, the processor 102 may be implemented in hardware using at least one of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), and Programmable Logic Array (PLA). The processor 102 may integrate one or more of a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), a modem, and the like. Wherein, the CPU mainly processes an operating system, a user interface, an application program and the like; the GPU is used for rendering and drawing display content; the modem is used to handle wireless communications. It is understood that the modem may not be integrated into the processor 102, but may be implemented by a communication chip.
The Memory 104 may include a Random Access Memory (RAM) or a Read-Only Memory (Read-Only Memory). The memory 104 may be used to store instructions, programs, code sets, or instruction sets. The memory 104 may include a stored program area and a stored data area, wherein the stored program area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing various method embodiments described below, and the like. The storage data area may also store data created by the terminal 100 in use, such as a phonebook, audio-video data, chat log data, and the like.
The network module 106 is configured to receive and transmit electromagnetic waves, and implement interconversion between the electromagnetic waves and electrical signals, so as to communicate with a communication network or other devices, for example, an audio playing device. The wireless module 106 may include various existing circuit elements for performing these functions, such as an antenna, a radio frequency transceiver, a digital signal processor, an encryption/decryption chip, a Subscriber Identity Module (SIM) card, memory, and so forth. The wireless module 106 may communicate with various networks, such as the internet, an intranet, a wireless network, or with other devices via a wireless network. The wireless network may comprise a cellular telephone network, a wireless local area network, or a metropolitan area network.
Furthermore, the image capture device 108 may be used for image capture. Optionally, the image capturing device 108 may include a color image capturing device and a depth image capturing device.
Referring to fig. 10, a block diagram of a computer-readable storage medium according to an embodiment of the present application is shown. The computer-readable medium 800 has stored therein a program code that can be called by a processor to execute the method described in the above-described method embodiments.
The computer-readable storage medium 800 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read only memory), an EPROM, a hard disk, or a ROM. Alternatively, the computer-readable storage medium 800 includes a non-volatile computer-readable storage medium. The computer readable storage medium 800 has storage space for program code 810 to perform any of the method steps of the method described above. The program code can be read from or written to one or more computer program products. The program code 810 may be compressed, for example, in a suitable form.
In summary, according to the image processing method, the image processing apparatus, and the electronic device, after reference information is obtained, a first material image corresponding to the reference information is obtained, color transformation parameters corresponding to the first material image and including a color transformation target value of a designated pixel in the first material image are obtained, and then color transformation is performed on the first material image based on the color transformation parameters, so that a second material image after color transformation is obtained. Therefore, after the corresponding first material image is matched based on the reference information, the corresponding color conversion parameter can be obtained to perform color conversion on the first material image, and the second material image after the color conversion is obtained, so that the first material image which is manufactured in advance can be subjected to adaptive color conversion according to actual needs to obtain the second material image, and the material image can be displayed more flexibly and more variously.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit the same; although the present application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not necessarily depart from the spirit and scope of the corresponding technical solutions in the embodiments of the present application.

Claims (11)

1. An image processing method applied to an electronic device, the method comprising:
acquiring reference information;
acquiring a first material image corresponding to the reference information;
acquiring color conversion parameters corresponding to the first material image, wherein the color conversion parameters comprise color conversion target values of designated pixels in the first material image;
and performing color transformation on the first material image based on the color transformation parameters to obtain a second material image subjected to color transformation.
2. The method according to claim 1, wherein the obtaining of color transformation parameters corresponding to the first material image comprises:
acquiring reference transformation colors corresponding to colors to be transformed in a first material image;
obtaining respective proportionality coefficients of a plurality of color channels of a designated pixel in the first material image;
and obtaining a color conversion target value of the designated pixel in the first material image based on the respective scale coefficients of the plurality of color channels of the designated pixel and the respective reference conversion colors corresponding to each color.
3. The method according to claim 2, wherein the obtaining of the scaling factor of each of the plurality of color channels of the designated pixel in the first material image comprises:
acquiring an image type corresponding to the first material image;
and acquiring respective scale coefficients of a plurality of color channels of the designated pixel in the first material image based on the image type.
4. The method according to claim 3, wherein the obtaining of the scale factor of each of the plurality of color channels of the designated pixel in the first material image based on the image type comprises:
if the image type is a first type, obtaining respective proportionality coefficients of a plurality of color channels based on a first proportionality coefficient determining mode, wherein the first proportionality coefficient determining mode comprises:
acquiring a target color channel in a plurality of color channels of a designated pixel, wherein the target color channel is a color channel with the maximum corresponding color value;
and setting the scale factor of a target color channel of the designated pixel as 1, and setting the scale factor of a color channel except the target color channel as 0.
5. The method according to claim 4, wherein the obtaining of the scale factor of each of the plurality of color channels of the designated pixel in the first material image based on the image type further comprises:
if the image type is a second type, obtaining respective proportionality coefficients of a plurality of color channels based on a second proportionality coefficient determining mode, wherein the second proportionality coefficient determining mode comprises the following steps:
acquiring a corresponding first target color parameter value of a designated pixel, wherein the first target color parameter value is the minimum value of original color values and a first reference color value of a plurality of color channels;
acquiring the difference value between each of the original color values of the multiple color channels and the first target color parameter value and the maximum value in a second color reference value to serve as the current color values of the multiple color channels;
obtaining the maximum value of the sum of the current color values of the multiple color channels and a third color reference value as a second target color parameter value;
and taking the ratio of the current color values of the plurality of color channels to the second target color parameter value as the respective proportionality coefficients of the plurality of color channels of the designated pixel.
6. The method according to claim 5, wherein the obtaining of the scale factor of each of the plurality of color channels of the designated pixel in the first material image based on the image type further comprises:
if the image type is a third type, obtaining respective scaling coefficients of the plurality of color channels based on a third scaling coefficient determination mode, wherein the third scaling coefficient determination mode comprises:
and determining a mode from the first scale coefficient determining mode and the second scale coefficient determining mode to determine the scale coefficients of the multiple color channels of the current pixel based on the type of the current pixel in the specified pixel and the size of the color values of the multiple color channels corresponding to the current pixel.
7. The method according to any one of claims 2 to 6, wherein obtaining the color conversion target value of the designated pixel in the first material image based on the scaling factor of each of the plurality of color channels of the designated pixel and the reference conversion color corresponding to each color comprises:
multiplying the proportional coefficients of a plurality of color channels of the designated pixel with reference transformation colors corresponding to the color channels respectively to obtain a plurality of intermediate transformation target values, wherein if the color corresponding to the color channel is the same as the color to be transformed corresponding to the reference transformation color, the color channel corresponds to the reference transformation color;
the plurality of intermediate conversion target values are added to obtain a color conversion target value of the designated pixel.
8. The method according to claim 1, wherein the color transforming the first material image based on the color transformation parameters to obtain a color transformed second material image comprises:
and sending the color conversion parameters to a target terminal so that the target terminal can perform color conversion on the first material image based on the color conversion parameters and display a second material image after the color conversion.
9. An image processing method applied to an electronic device, the method comprising:
an image acquisition unit configured to acquire reference information;
the material matching unit is used for acquiring a first material image corresponding to the reference information;
a parameter acquisition unit configured to acquire a color conversion parameter corresponding to the first material image, the color conversion parameter including a color conversion target value of a specified pixel in the first material image;
and the image processing unit is used for carrying out color conversion on the first material image based on the color conversion parameters to obtain a second material image after the color conversion is carried out.
10. An electronic device comprising one or more processors and memory;
one or more programs stored in the memory and configured to be executed by the one or more processors, the one or more programs configured to perform the method of any of claims 1-7.
11. A computer-readable storage medium, characterized in that a program code is stored in the computer-readable storage medium, wherein the program code when executed performs the method of any of claims 1-7.
CN202110145856.8A 2021-02-02 2021-02-02 Image processing method and device and electronic equipment Pending CN114841850A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110145856.8A CN114841850A (en) 2021-02-02 2021-02-02 Image processing method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110145856.8A CN114841850A (en) 2021-02-02 2021-02-02 Image processing method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN114841850A true CN114841850A (en) 2022-08-02

Family

ID=82562490

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110145856.8A Pending CN114841850A (en) 2021-02-02 2021-02-02 Image processing method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN114841850A (en)

Similar Documents

Publication Publication Date Title
CN111476780B (en) Image detection method and device, electronic equipment and storage medium
CN107256555B (en) Image processing method, device and storage medium
CN109741279A (en) Image saturation method of adjustment, device, storage medium and terminal
RU2669511C2 (en) Method and device for recognising picture type
US8160358B2 (en) Method and apparatus for generating mosaic image
JP6718978B2 (en) System language switching method and system language switching terminal device
CN107633499B (en) Image processing method and related product
CN109062715B (en) Method and device for determining memory clock frequency and terminal
CN107292817B (en) Image processing method, device, storage medium and terminal
CN109255774B (en) Image fusion method, device and equipment
CN110599554A (en) Method and device for identifying face skin color, storage medium and electronic device
CN113421312A (en) Method and device for coloring black and white video, storage medium and terminal
CN110933312A (en) Photographing control method and related product
CN113129222A (en) Color shading correction method, terminal device and computer-readable storage medium
CN111179370B (en) Picture generation method and device, electronic equipment and storage medium
CN115908165A (en) Cloud desktop image processing method, equipment and storage medium
CN109615620B (en) Image compression degree identification method, device, equipment and computer readable storage medium
CN111935418B (en) Video processing method and device, electronic equipment and storage medium
CN116229188B (en) Image processing display method, classification model generation method and equipment thereof
CN112487223A (en) Image processing method and device and electronic equipment
CN111462158A (en) Image processing method and device, intelligent device and storage medium
KR101214674B1 (en) Apparatus and method for generating mosaic image including text
CN114841850A (en) Image processing method and device and electronic equipment
CN115953597B (en) Image processing method, device, equipment and medium
CN112991497B (en) Method, device, storage medium and terminal for coloring black-and-white cartoon video

Legal Events

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