Image processing method and device, computer readable storage medium and electronic equipment
By converting the image into RGBA mode, separating and converting color values, and using HSV color values to perform automatic color replacement, the inefficiency problem caused by manual color adjustment in the prior art is solved, and efficient image batch color processing is achieved.
Patent Information
- Application Number
- CN202411127613.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-15
- Publication Date
- 2024-12-10
AI Technical Summary
Existing image processing methods require manual image color adjustment, resulting in low processing efficiency and inability to achieve batch color replacement operations.
By converting the image to be processed into RGBA color value mode, color value separation and conversion are performed, the HSV color value is obtained, and color replacement is performed according to the preset HSV color value, automatic image color replacement is achieved.
It improves image processing efficiency, realizes automatic color replacement for multiple images, reduces manual operation intensity, and saves time and energy.
Smart Images

Figure CN119110044A_ABST
Abstract
Description
Background Art
[0002] In the existing image color changing method, the color of the image needs to be manually adjusted based on the corresponding image processing tools. However, this method will make the image processing efficiency low.
[0003] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0004] The purpose of the present disclosure is to provide an image processing method, an image processing device, a computer-readable storage medium, and an electronic device, thereby overcoming the problem of low image processing efficiency caused by the limitations and defects of related technologies at least to a certain extent.
[0005] According to one aspect of the present disclosure, there is provided an image processing method, comprising:
[0006] Acquire a first image to be processed, and convert the first image to be processed having an original color value mode into a second image to be processed having an RGBA color value mode;
[0007] Performing color value separation on the second image to be processed to obtain a first R color light value list, a first G color light value list, a first B color light value list, and a first A color light value list;
[0008] Performing color value conversion on the first R color light value list, the first G color light value list, the first B color light value list, and the first A color light value list to obtain a first HSV color light value;
[0009] According to the first HSV color light value and the preset HSV color light value to be replaced, a target image after color replacement is obtained.
[0010] According to one aspect of the present disclosure, there is provided an image processing apparatus, comprising:
[0011] A first image conversion module is used to obtain a first image to be processed, and convert the first image to be processed having an original color value mode into a second image to be processed having an RGBA color value mode;
[0012] a color value separation module, configured to perform color value separation on the second image to be processed to obtain a first R color light value list, a first G color light value list, a first B color light value list, and a first A color light value list;
[0013] A second image conversion module is used to perform color value conversion on the first R color light value list, the first G color light value list, the first B color light value list and the first A color light value list to obtain a first HSV color light value;
[0014] The target image generation module is used to determine the target image after color replacement according to the first HSV color value and the preset HSV color value to be replaced.
[0015] According to one aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the image processing method described in any one of the above is implemented.
[0016] According to one aspect of the present disclosure, there is provided an electronic device, including:
[0017] Processor; and
[0018] A memory, configured to store executable instructions of the processor;
[0019] The processor is configured to perform any one of the above-mentioned image processing methods by executing the executable instructions.
[0020] An image processing method provided by the embodiment of the present disclosure, on the one hand, acquires a first image to be processed, and converts the first image to be processed with an original color value mode into a second image to be processed with an RGBA color value mode; then performs color value separation on the second image to be processed to obtain a first R color light value list, a first G color light value list, a first B color light value list and a first A color light value list; then performs color value conversion on the first R color light value list, the first G color light value list, the first B color light value list and the first A color light value list to obtain a first HSV color light value; finally, according to the first HSV color light value and the preset HSV color light value to be replaced, a target image after color replacement is obtained, thereby realizing automatic replacement of the color of the original image to be processed, and solving the problem of low image processing efficiency caused by the need for manual color replacement in the prior art; on the other hand, batch color replacement operations can also be performed on the images to be processed based on the image processing method, thereby further improving the image processing efficiency.
[0021] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0023] Figure 1A flowchart of an image processing method according to an exemplary embodiment of the present disclosure is schematically shown.
[0024] Figure 2 An example diagram of an interface display of a preset interactive control according to an example embodiment of the present disclosure is schematically shown.
[0025] Figure 3 An example interface diagram of a specific setting of a preset HSV color value to be replaced according to an example embodiment of the present disclosure is schematically shown.
[0026] Figure 4 An example diagram schematically illustrates a first image to be processed and a target image corresponding to the first image to be processed according to an example embodiment of the present disclosure.
[0027] Figure 5 A flowchart of a method for obtaining a target image after color replacement according to a first HSV color value and an HSV color value to be replaced according to an exemplary embodiment of the present disclosure is schematically shown.
[0028] Figure 6 A block diagram schematically shows an image processing apparatus according to an exemplary embodiment of the present disclosure.
[0029] Figure 7 An electronic device for implementing an image processing method according to an exemplary embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0030] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as being limited to the examples set forth herein; on the contrary, these embodiments are provided so that the present disclosure will be more comprehensive and complete, and the concepts of the example embodiments are fully conveyed to those skilled in the art. The described features, structures, or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present disclosure.
[0031] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0032] In the process of making some game resources, it is necessary to produce 4-5 different colors of resource outputs through one resource at the same time; at the same time, in the process of making multiple resources of different colors, you can manually drag the resources into Adobe Photoshop to change the color and adjust the files; specifically, in the process of color adjustment based on Adobe Photoshop, it can be achieved in the following ways: first, Photoshop opens the resources one by one and repeats the coloring operation one by one, and then outputs them one by one; secondly, Photoshop enters the coloring action: through the actions in Photoshop, a new action is created to record all the required color adjustments, and the process is subsequently simplified through actions; among them, the new output action can include: Window-Action-New Action-Window Floating (for easy stopping recording)-Edit-Convert to Profile-Target Space-sRGB Output Size-File-Save As-Create a special output folder-Output Close-Do Not Save-Stop Recording Actions. From this, we can see that although this method has the characteristics of high repeatability, low difficulty, and a single manual production process, it requires manually opening multiple Photoshop files to adjust colors and output images, so there is a problem of low efficiency; further, Photoshop actions can only output previously preset colors. If new sizes and colors require adjusting actions, manual adjustments and modifications are required, which has certain limitations.
[0033] Based on this, this exemplary embodiment first provides an image processing method, which can be run on a terminal device, a server, a server cluster or a cloud server, etc. Of course, those skilled in the art can also run the method disclosed in this disclosure on other platforms as required, and this exemplary embodiment does not specifically limit this. Figure 1 As shown, the image processing method may include the following steps:
[0034] Step S110. Acquire a first image to be processed, and convert the first image to be processed having an original color value mode into a second image to be processed having an RGBA color value mode;
[0035] Step S120. Perform color value separation on the second image to be processed to obtain a first R color light value list, a first G color light value list, a first B color light value list, and a first A color light value list;
[0036] Step S130: performing color value conversion on the first R color light value list, the first G color light value list, the first B color light value list and the first A color light value list to obtain a first HSV color light value;
[0037] Step S140: Obtain a target image after color replacement according to the first HSV color value and the preset HSV color value to be replaced.
[0038] In the above-mentioned image processing method, on the one hand, by acquiring a first image to be processed, and converting the first image to be processed with an original color value mode into a second image to be processed with an RGBA color value mode; then performing color value separation on the second image to be processed to obtain a first R color value list, a first G color value list, a first B color value list and a first A color value list; then performing color value conversion on the first R color value list, the first G color value list, the first B color value list and the first A color value list to obtain a first HSV color value; finally, according to the first HSV color value and the preset HSV color value to be replaced, a target image after color replacement is obtained, thereby realizing automatic replacement of the color of the original image to be processed, and solving the problem of low image processing efficiency caused by the need for manual color replacement in the prior art; on the other hand, batch color replacement operations can also be performed on the images to be processed based on the image processing method, thereby further improving the image processing efficiency.
[0039] Hereinafter, the image processing method described in the exemplary embodiment of the present disclosure will be explained and illustrated in detail with reference to the accompanying drawings.
[0040] First, the technical implementation principle of the exemplary embodiment of the present disclosure is explained and illustrated. Specifically, in the process of actual application, when processing the color change operation of a large number of resources, it is impossible to batch process at one time, which makes this process inefficient; at the same time, the color change of resources can only be manually processed one by one, resulting in a waste of time and energy; for this reason, the present disclosure provides an image processing method, which can replace the colors of all pictures with one click, solve the problems of numerous resources in the project, inconsistent image specifications and styles, and high cost of each resource entry action, and requires script control to automatically identify the content that needs to be replaced in the newly added source file, and output it with one click without repeated modification. Further, in the specific process of executing image color change, the hue, saturation, brightness and transparency of the graphics can be adjusted by filling in the corresponding values to perform pixel-level image color change; at the same time, the method uses RGB color value separation to convert the image to RGB and HSV modes, and converts the HSV color value to RBG mode after adjustment to color and output the image, completing the color change demand.
[0041] Secondly, the specific setting process of the preset HSV color value to be replaced recorded in the example embodiment of the present disclosure is explained and illustrated. Specifically, the specific setting process of the preset HSV color value to be replaced can be achieved in the following way: in response to the touch operation on the preset interactive control, the color value parameter input interface is displayed; in response to the input operation of the hue parameter, saturation parameter, brightness parameter and transparency parameter in the color value parameter input interface, the HSV color value to be replaced is determined. Among them, the preset interactive control recorded here can be a one-key replacement control in the display interface corresponding to the image color conversion tool. For specific example diagrams, please refer to Figure 2 As shown, the color light value parameter input interface recorded here can refer to Figure 3 As shown; at the same time, Figure 3 In the example diagram shown, the value range of the hue parameter (Hue) is 0 to 360, the value range of the saturation parameter (Saturation) is (-1,1), and the specific value range of the brightness parameter (Value) is (-1,1); the value range of the transparency parameter (Alpha) is 0.0 to 1.0; in actual application, the hue parameter, saturation parameter, brightness parameter and transparency parameter can be filled in according to the color that needs to be converted; among them, the hue parameter, saturation parameter, brightness parameter and transparency parameter of various colors can be obtained based on experience, or can be obtained based on the correlation relationship between the color and the hue parameter, saturation parameter, brightness parameter and transparency parameter, or can be predicted based on a network model, and this example does not impose any special restrictions on this.
[0042] The following will be combined Figure 2 as well as Figure 3 right Figure 1 The image processing method shown in is further explained and illustrated. Specifically:
[0043] In step S110, a first image to be processed is acquired, and the first image to be processed having an original color value mode is converted into a second image to be processed having an RGBA color value mode.
[0044] In this example embodiment, first, a first image to be processed is obtained; wherein the first image to be processed recorded here may refer to a picture resource that needs to be replaced, which may be placed in the Input folder in advance; at the same time, the picture resource that needs to be replaced may refer to Figure 4 As shown in 401 in; at the same time, the acquisition process of the first image to be processed can be implemented by calling the Image.open('input / '+filename) function; that is, the image file stored in the 'input / ' directory can be opened by calling Image.open('input / '+filename); the filename recorded here is the name of the image file. It should be additionally explained here that Image.open is a function in Python's PIL (Pillow) library, which is used to open an image file.
[0045] Secondly, perform image mode conversion; specifically, in actual application, once the first image to be processed is successfully loaded, the .convert('RGBA') method can be directly called to convert the image into RGBA mode; that is, the .convert('RGBA') method can be directly called to convert the first image to be processed with the original color value mode into the second image to be processed with the RGBA color value mode; wherein the obtained second image to be processed contains not only color information (RGB), but also transparency information (Alpha channel), which facilitates subsequent image processing and rendering operations.
[0046] In step S120, the second image to be processed is subjected to color value separation to obtain a first R color light value list, a first G color light value list, a first B color light value list, and a first A color light value list.
[0047] Specifically, the color value separation process can be implemented in the following manner: first, extract the original pixel points in the second image to be processed, and extract the first RGBA color light value of the original pixel points; second, perform color value separation on the first RGBA color light value to obtain a first R channel image object, a first G channel image object, a first B channel image object and a first A channel image object; then, extract the first R color light value, the first G color light value, the first B color light value and the first A color light value in the first R channel image object, the first G channel image object, the first B channel image object and the first A channel image object; finally, according to the original pixel point position of the original pixel point in the second image to be processed, the first R color light value, the first G color light value, the first B color light value and the first A color light value of the original pixel point are stored in the corresponding color light value list in sequence to obtain the first R color light value list, the first G color light value list, the first B color light value list and the first A color light value list.
[0048] In an example embodiment, in the actual application process, the image.split() function can be called to implement a specific color value separation process; that is, the image.split() function can be used to separate the first RGBA color value of the original pixel point in the second image to be processed into four separate image objects, and then the pixel value of each channel is extracted through the getdata() method, and these values are stored in corresponding lists; these lists contain the red, green, blue and transparency values of each pixel position respectively. It should be supplemented here that in the process of storing the color value in the corresponding list, the original pixel position of the original pixel point and the color value of the original pixel point can be stored accordingly to facilitate subsequent processing.
[0049] It needs to be further explained here that, in the obtained first R channel image object, first G channel image object, first B channel image object and first A channel image object, the corresponding first R color light value, first G color light value, first B color light value and first A color light value can be arranged in sequence in the corresponding channel image objects according to the original pixel position of each original pixel; further, after the corresponding pixel value in each channel image object is extracted through the getdata() method, the extracted color light values can be stored in the corresponding color light value list in sequence based on the original pixel position.
[0050] In step S130 , color value conversion is performed on the first R color light value list, the first G color light value list, the first B color light value list, and the first A color light value list to obtain a first HSV color light value.
[0051] Specifically, the color value conversion process can be implemented in the following manner: first, traverse the first R color light value list, the first G color light value list, the first B color light value list and the first A color light value list, and extract the first R color light value, the first G color light value, the first B color light value and the first A color light value of the original pixel based on the original pixel position in the second image to be processed; secondly, construct a pixel value sequence according to the first R color light value, the first G color light value, the first B color light value and the first A color light value, and extract the first R color light value, the first G color light value and the first B color light value from the pixel value sequence in turn; then, normalize the first R color light value, the first G color light value and the first B color light value to obtain the first HSV color light value.
[0052] Specifically, in the actual application process, the specific color value conversion process can be implemented based on the Zip function; at the same time, in the process of implementing the color value conversion based on the Zip function, it is necessary to first obtain the pixel data, then iterate the pixel data, and finally process the data to implement the specific color value conversion process. Furthermore, since RGBA is four different channel image objects, they represent the red channel, green channel, blue channel and transparency channel respectively; therefore, it is necessary to first call the .getdata() function to extract the pixel data from each image object (that is, traverse the first R color light value list, the first G color light value list, the first B color light value list and the first A color light value list, and call the .getdata() function according to the original pixel position of the original pixel point to extract the first R color light value, the first G color light value, the first B color light value and the first A color light value of the original pixel point); further, since these data are usually a sequence containing pixel values (for example, a list or a tuple), the zip(r.getdata(), g.getdata(), b.getdata(), a.getdata()) method can be used. , the data of the four channels are bound together to form an iterator (that is, a sequence of pixel values), and the Zip function iterates these four sequences in parallel; and, in each loop iteration, pixel_r, pixel_g, pixel_b, pixel_a correspond to the red, green, blue and transparency values of the current pixel respectively; and, for each tuple (pixel_r, pixel_g, pixel_b, pixel_a) obtained from Zip, any required operation can be performed; for example, these values can be combined to form a new RGBA pixel, or some adjustment or filtering can be applied; under this premise, the first R color light value, the first G color light value, and the first B color light value can be extracted from the pixel value sequence in turn, and then the first R color light value, the first G color light value, and the first B color light value can be normalized to obtain the first HSV color light value.
[0053] In an exemplary embodiment, in the process of converting the first RGB color light value into the first HSV color light value, the first R color light value, the first G color light value, and the first B color light value may be normalized first, that is, the first R color light value, the first G color light value, and the first B color light value are divided by 255, and the result obtained is the normalized result; then, the corresponding conversion function (RGB to HSV) in the Colorsystem is called to convert the normalized result to obtain the first HSV color light value. It should be noted here that the reason why it needs to be converted to the HSV color light value again is that the HSV color system is more in line with color perception and can ensure that the image is displayed in three primary colors, saturation, and brightness. At the same time, HSV color can also make color retrieval simpler. If you want to adjust the hue of an image, you only need to change the H value; to adjust the saturation of an image, you only need to change the S value; to adjust the brightness of an image, you only need to change the V value; that is, in the HSV color system, it is simpler to change the hue, saturation, and brightness of an image; conversion to the HSV color model makes many image processing tasks simpler and more efficient. Therefore, in applications that require color adjustment, analysis, or segmentation, RGB color values are often converted to HSV color values.
[0054] In step S140, a target image after color replacement is obtained according to the first HSV color value and the preset HSV color value to be replaced.
[0055] Specifically, refer to Figure 5 As shown, obtaining a target image after color replacement according to the first HSV color value and the preset HSV color value to be replaced may include the following steps:
[0056] Step S510, determining a second R color light value list, a second G color light value list, a second B color light value list, and a second A color light value list according to the first HSV color light value and the preset HSV color light value to be replaced.
[0057] Specifically, the specific determination process of the second R color light value list, the second G color light value list, the second B color light value list, and the second A color light value list can be implemented in the following manner: first, according to the first HSV color light value and the preset HSV color light value to be replaced, the second HSV color light value and the second A color light value are determined; secondly, the second HSV color value is converted to obtain the second RGB color light value, and according to the second RGB color light value and the second A color light value, the second R color light value list, the second G color light value list, the second B color light value list, and the second A color light value list are determined. That is, in the actual application process, in order to obtain the second R color light value list, the second G color light value list, the second B color light value list, and the second A color light value list, it is first necessary to determine the second HSV color light value and the second A color light value, and then the second HSV color light value is converted to obtain the corresponding RGBA color light value list. At the same time, it should be noted here that the reason why the HSV color value needs to be converted back to RGB color value again is because most image processing and display devices (such as computer monitors, printers, etc.) use the RGB color model, so the processed color value needs to be converted back to RGB for display or storage.
[0058] In an exemplary embodiment, determining the second HSV color light value and the second A color light value based on the first HSV color light value and the preset HSV color light value to be replaced can be achieved in the following manner: first, extracting the H color light value to be replaced, the S color light value to be replaced, the V color light value to be replaced and the A color light value to be replaced from the HSV color light value to be replaced; secondly, taking the A color light value to be replaced as the second A color light value, and taking the H color light value to be replaced as the second H color light value; then, determining the second S color light value based on the S color light value to be replaced and the first S color light value in the first HSV color light value, and determining the second V color light value based on the V color light value to be replaced and the first V color light value in the first HSV color light value; finally, determining the second HSV color light value based on the second H color light value, the second S color light value and the second V color light value. The second S color light value is determined according to the S color light value to be replaced and the first S color light value in the first HSV color light value, and the second V color light value is determined according to the V color light value to be replaced and the first V color light value in the first HSV color light value, which can be achieved in the following manner: first, the S color light value to be replaced and the first S color light value in the first HSV color light value are summed to obtain the second S color light value; secondly, the V color light value to be replaced and the first V color light value in the first HSV color light value are fit to obtain the second V color light value. That is, the value of the second H color light value is target_hue; the value of the second S color light value is S+target_saturation; and the value of the second V color light value is: V+target_Value.
[0059] In an exemplary embodiment, in the process of converting the second HSV color value to obtain the second RGB color value, the corresponding conversion function (HSV to RGB) in Colorsystem may be called to implement the calculation process: rgb = colorsys.hsv_to_rgb (target_hue, s+target_saturation, v+target_value).
[0060] In an example embodiment, determining a second R color light value list, a second G color light value list, a second B color light value list, and a second A color light value list based on the second RGB color light value and the second A color light value can be achieved in the following manner: first, based on the original pixel position of the original pixel point, determining the placement positions of the second RGB color light value and the second A color light value in the corresponding color light value lists; secondly, based on the placement positions, storing the second RGB color light value and the second A color light value in the corresponding color light value lists in sequence to obtain a second R color light value list, a second G color light value list, a second B color light value list, and a second A color light value list. That is, based on the corresponding placement positions, the second RGB color light value and the second A color light value can be used to replace the corresponding first R color light value, first G color light value, first B color light value and first A color light value in the first R color light value list, the first G color light value list, the first B color light value list and the first A color light value list to obtain the second R color light value list, the second G color light value list, the second B color light value list and the second A color light value list.
[0061] Step S520 , performing channel merging on the second R color light value list, the second G color light value list, the second B color light value list, and the second A color light value list to obtain a target image after color replacement.
[0062] Specifically, the specific generation process of the target image after color replacement can be achieved in the following way: based on the original pixel position of the original pixel point, the second R color light value, the second G color light value, the second B color light value and the second A color light value in the second R color light value list, the second G color light value list, the second B color light value list and the second A color light value list are sequentially placed into the corresponding channels to obtain a second R channel image object, a second G channel image object, a second B channel image object and a second A channel image object; the second R channel image object, the second G channel image object, the second B channel image object and the second A channel image object are fused to obtain a target pixel point corresponding to the original pixel point, and based on the target pixel point, the target image after color replacement is generated. That is, in the actual application process, firstly, the corresponding second R color light value, second G color light value, second B color light value and second A color light value need to be saved, and then the second R color light value, second G color light value, second B color light value and second A color light value are sequentially applied to the corresponding channels to obtain the corresponding channel image objects, and then the channel image objects are merged to obtain a new RGBA pixel point; finally, the pixel points are sequentially spliced according to the position of each pixel point to obtain the target image after color replacement; wherein, the target image after color replacement obtained can refer to Figure 4 As shown in 402.
[0063] The image processing method described in the example embodiments of the present disclosure has at least the following advantages: on the one hand, it can greatly improve work efficiency; specifically, the method can use a one-click color changing tool to automatically process the color changing operations of resources in batches, saving a lot of time and energy for manual operations, thereby improving work efficiency; on the other hand, it can enhance work flexibility; specifically, the one-click color changing tool can handle the color changing operations of resources more flexibly, and different color changing rules can be set to meet various version requirements; on the other hand, it can reduce work intensity; specifically, the prior art uses manual processing of the color changing operations of a large number of resources, which may cause visual fatigue, hand fatigue and other problems; however, the use of a one-click color changing tool in this example embodiment can greatly reduce the intensity of the operation and reduce the burden of manual operations.
[0064] The following are embodiments of the device disclosed herein, which can be used to execute the method embodiments disclosed herein. For details not disclosed in the device embodiments disclosed herein, please refer to the method embodiments disclosed herein.
[0065] The exemplary embodiment of the present disclosure also provides an image processing device. Specifically, refer to Figure 6 As shown, the image processing device may include a first image conversion module 610, a color value separation module 620, a second image conversion module 630 and a target image generation module 640. Among them:
[0066] The first image conversion module 610 may be used to obtain a first image to be processed, and convert the first image to be processed having an original color value mode into a second image to be processed having an RGBA color value mode;
[0067] The color value separation module 620 may be used to perform color value separation on the second image to be processed to obtain a first R color light value list, a first G color light value list, a first B color light value list, and a first A color light value list;
[0068] The second image conversion module 630 may be used to perform color value conversion on the first R color light value list, the first G color light value list, the first B color light value list, and the first A color light value list to obtain a first HSV color light value;
[0069] The target image generation module 640 may be configured to determine a target image after color replacement according to the first HSV color value and a preset HSV color value to be replaced.
[0070] In the above-mentioned image processing device, on the one hand, by acquiring a first image to be processed, and converting the first image to be processed with an original color value mode into a second image to be processed with an RGBA color value mode; then performing color value separation on the second image to be processed to obtain a first R color light value list, a first G color light value list, a first B color light value list and a first A color light value list; then performing color value conversion on the first R color light value list, the first G color light value list, the first B color light value list and the first A color light value list to obtain a first HSV color light value; finally, according to the first HSV color light value and the preset HSV color light value to be replaced, a target image after color replacement is obtained, thereby realizing automatic replacement of the color of the original image to be processed, and solving the problem of low image processing efficiency caused by the need for manual color replacement in the prior art; on the other hand, batch color replacement operations can also be performed on the images to be processed based on the image processing method, thereby further improving the image processing efficiency.
[0071] In an exemplary embodiment of the present disclosure, color value separation is performed on the second image to be processed to obtain a first R color light value list, a first G color light value list, a first B color light value list, and a first A color light value list, including: extracting original pixels in the second image to be processed, and extracting first RGBA color light values of the original pixels; color value separation is performed on the first RGBA color light values to obtain a first R channel image object, a first G channel image object, a first B channel image object, and a first A channel image object; extracting the first R color light value, the first G color light value, the first B color light value, and the first A color light value in the first R channel image object, the first G channel image object, the first B channel image object, and the first A channel image object; according to the original pixel position of the original pixel in the second image to be processed, the first R color light value, the first G color light value, the first B color light value, and the first A color light value of the original pixel are stored in the corresponding color light value lists in sequence to obtain the first R color light value list, the first G color light value list, the first B color light value list, and the first A color light value list.
[0072] In an exemplary embodiment of the present disclosure, the first R color light value list, the first G color light value list, the first B color light value list and the first A color light value list are processed to obtain a first HSV color light value, including: traversing the first R color light value list, the first G color light value list, the first B color light value list and the first A color light value list, and extracting the first R color light value, the first G color light value, the first B color light value and the first A color light value of the original pixel point based on the original pixel point position in the second image to be processed; constructing a pixel value sequence according to the first R color light value, the first G color light value, the first B color light value and the first A color light value, and extracting the first R color light value, the first G color light value and the first B color light value from the pixel value sequence in turn; normalizing the first R color light value, the first G color light value and the first B color light value to obtain the first HSV color light value.
[0073] In an exemplary embodiment of the present disclosure, a target image after color replacement is obtained according to the first HSV color light value and the preset HSV color light value to be replaced, including: determining a second R color light value list, a second G color light value list, a second B color light value list and a second A color light value list according to the first HSV color light value and the preset HSV color light value to be replaced; and performing channel merging on the second R color light value list, the second G color light value list, the second B color light value list and the second A color light value list to obtain the target image after color replacement.
[0074] In an exemplary embodiment of the present disclosure, a second R color light value list, a second G color light value list, a second B color light value list and a second A color light value list are determined according to the first HSV color light value and the preset HSV color light value to be replaced, including: determining the second HSV color light value and the second A color light value according to the first HSV color light value and the preset HSV color light value to be replaced; converting the second HSV color value to obtain a second RGB color light value, and determining the second R color light value list, the second G color light value list, the second B color light value list and the second A color light value list according to the second RGB color light value and the second A color light value.
[0075] In an exemplary embodiment of the present disclosure, the preset HSV color value to be replaced is obtained in the following manner: in response to a touch operation on a preset interactive control, a color light value parameter input interface is displayed; in response to an input operation on a hue parameter, a saturation parameter, a brightness parameter and a transparency parameter in the color light value parameter input interface, the HSV color value to be replaced is determined.
[0076] In an exemplary embodiment of the present disclosure, a second HSV color light value and a second A color light value are determined according to the first HSV color light value and a preset HSV color light value to be replaced, including: extracting the H color light value to be replaced, the S color light value to be replaced, the V color light value to be replaced and the A color light value to be replaced from the HSV color light value to be replaced; using the A color light value to be replaced as the second A color light value, and using the H color light value to be replaced as the second H color light value; determining the second S color light value according to the S color light value to be replaced and the first S color light value in the first HSV color light value, and determining the second V color light value according to the V color light value to be replaced and the first V color light value in the first HSV color light value; determining the second HSV color light value according to the second H color light value, the second S color light value and the second V color light value.
[0077] In an exemplary embodiment of the present disclosure, a second S color light value is determined based on the S color light value to be replaced and the first S color light value in the first HSV color light value, and a second V color light value is determined based on the V color light value to be replaced and the first V color light value in the first HSV color light value, including: performing a sum operation on the S color light value to be replaced and the first S color light value in the first HSV color light value to obtain the second S color light value; performing a fit operation on the V color light value to be replaced and the first V color light value in the first HSV color light value to obtain the second V color light value.
[0078] In an exemplary embodiment of the present disclosure, a second R color light value list, a second G color light value list, a second B color light value list and a second A color light value list are determined according to the second RGB color light value and the second A color light value, including: determining the placement positions of the second RGB color light value and the second A color light value in the corresponding color light value lists based on the original pixel positions of the original pixels; storing the second RGB color light value and the second A color light value in the corresponding color light value lists in sequence based on the placement positions to obtain the second R color light value list, the second G color light value list, the second B color light value list and the second A color light value list.
[0079] In an exemplary embodiment of the present disclosure, the second R color light value list, the second G color light value list, the second B color light value list and the second A color light value list are channel-merged to obtain a target image after color replacement, including: based on the original pixel position of the original pixel point, the second R color light value, the second G color light value, the second B color light value and the second A color light value in the second R color light value list, the second G color light value list, the second B color light value and the second A color light value list are sequentially placed into corresponding channels to obtain a second R channel image object, a second G channel image object, a second B channel image object and a second A channel image object; the second R channel image object, the second G channel image object, the second B channel image object and the second A channel image object are fused to obtain a target pixel point corresponding to the original pixel point, and the target image after color replacement is generated according to the target pixel point.
[0080] The specific details of each module in the above-mentioned image processing device have been described in detail in the corresponding image processing method, so they will not be repeated here.
[0081] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0082] In addition, although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0083] In an exemplary embodiment of the present disclosure, an electronic device capable of implementing the above method is also provided.
[0084] Those skilled in the art will appreciate that various aspects of the present disclosure may be implemented as systems, methods or program products. Therefore, various aspects of the present disclosure may be specifically implemented in the following forms, namely: complete hardware implementation, complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as "circuits", "modules" or "systems".
[0085] Refer to the following Figure 7 An electronic device 700 according to this embodiment of the present disclosure is described. Figure 7 The electronic device 700 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0086] like Figure 7 As shown, the electronic device 700 is in the form of a general computing device. The components of the electronic device 700 may include, but are not limited to: the at least one processing unit 710, the at least one storage unit 720, a bus 730 connecting different system components (including the storage unit 720 and the processing unit 710), and a display unit 740.
[0087] The storage unit stores program codes, which can be executed by the processing unit 710, so that the processing unit 710 performs the steps according to various exemplary embodiments of the present disclosure described in the above “Exemplary Method” section of this specification. For example, the processing unit 710 can perform the following steps: Figure 1 Step S110 shown in: obtaining a first image to be processed, and converting the first image to be processed with an original color value mode into a second image to be processed with an RGBA color value mode; step S120: performing color value separation on the second image to be processed to obtain a first R color light value list, a first G color light value list, a first B color light value list and a first A color light value list; step S130: performing color value conversion on the first R color light value list, the first G color light value list, the first B color light value list and the first A color light value list to obtain a first HSV color light value; step S140: obtaining a target image after color replacement according to the first HSV color light value and the preset HSV color light value to be replaced.
[0088] The storage unit 720 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 7201 and / or a cache storage unit 7202 , and may further include a read-only storage unit (ROM) 7203 .
[0089] The storage unit 720 may also include a program / utility 7204 having a set (at least one) of program modules 7205, such program modules 7205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0090] Bus 730 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0091] The electronic device 700 may also communicate with one or more external devices 800 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 700, and / or communicate with any device that enables the electronic device 700 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 750. Furthermore, the electronic device 700 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 760. As shown, the network adapter 760 communicates with other modules of the electronic device 700 via a bus 730. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 700, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.
[0092] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0093] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the above method of the present specification is stored. In some possible implementations, various aspects of the present disclosure may also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps according to various exemplary implementations of the present disclosure described in the above "Exemplary Method" section of the present specification.
[0094] According to the program product for implementing the above method in the embodiment of the present disclosure, it can adopt a portable compact disk read-only memory (CD-ROM) and include program code, and can be run on a terminal device, such as a personal computer. However, the program product of the present disclosure is not limited thereto. In this document, a readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, an apparatus or a device.
[0095] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0096] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, in which readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Readable signal media may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0097] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0098] Program code for performing the operations of the present disclosure may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).
[0099] In addition, the above-mentioned figures are only schematic illustrations of the processes included in the method according to the exemplary embodiments of the present disclosure, and are not intended to be limiting. It is easy to understand that the processes shown in the above-mentioned figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.
[0100] Other embodiments of the present disclosure will be readily apparent to those skilled in the art after considering the specification and practicing the inventions invented herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not invented by the present disclosure. The specification and examples are to be considered merely exemplary, and the true scope and spirit of the present disclosure are indicated by the claims.
Claims
1. An image processing method, characterized in that: include: Acquire a first image to be processed, and convert the first image to be processed having an original color value mode map into a second image to be processed having an RGBA color value mode; Performing color value separation on the second image to be processed to obtain a first R color light value list, a first G color light value list, a first B color light value list, and a first A color light value list; Performing color value conversion on the first R color light value list, the first G color light value list, the first B color light value list, and the first A color light value list to obtain a first HSV color light value; According to the first HSV color light value and the preset HSV color light value to be replaced, a target image after color replacement is obtained.
2. The image processing method according to claim 1, characterized in that: Performing color value separation on the second image to be processed to obtain a first R color light value list, a first G color light value list, a first B color light value list, and a first A color light value list, including: Extracting original pixel points in the second to-be-processed image, and extracting first RGBA color light values of the original pixel points; Performing color value separation on the first RGBA color light values to obtain a first R channel image object, a first G channel image object, a first B channel image object, and a first A channel image object; Extracting a first R color light value, a first G color light value, a first B color light value, and a first A color light value from the first R channel image object, the first G channel image object, the first B channel image object, and the first A channel image object; According to the original pixel position of the original pixel in the second image to be processed, the first R color light value, the first G color light value, the first B color light value and the first A color light value of the original pixel are stored in the corresponding color light value lists in sequence to obtain the first R color light value list, the first G color light value list, the first B color light value list and the first A color light value list.
3. The image processing method according to claim 1, characterized in that: The first R color light value list, the first G color light value list, the first B color light value list, and the first A color light value list are processed to obtain a first HSV color light value, including: Traversing the first R color light value list, the first G color light value list, the first B color light value list, and the first A color light value list, and extracting the first R color light value, the first G color light value, the first B color light value, and the first A color light value of the original pixel point based on the original pixel point position in the second to-be-processed image; Constructing a pixel value sequence according to the first R color light value, the first G color light value, the first B color light value, and the first A color light value, and extracting the first R color light value, the first G color light value, and the first B color light value from the pixel value sequence in sequence; The first R color light value, the first G color light value, and the first B color light value are normalized to obtain the first HSV color light value.
4. The image processing method according to claim 1, characterized in that: Obtaining a target image after color replacement according to the first HSV color value and the preset HSV color value to be replaced, including: Determine a second R color light value list, a second G color light value list, a second B color light value list, and a second A color light value list according to the first HSV color light value and the preset HSV color light value to be replaced; Channel merging is performed on the second R color light value list, the second G color light value list, the second B color light value list, and the second A color light value list to obtain a target image after color replacement.
5. The image processing method according to claim 4, characterized in that: Determining a second R color light value list, a second G color light value list, a second B color light value list, and a second A color light value list according to the first HSV color light value and the preset HSV color light value to be replaced, including: Determine a second HSV color light value and a second A color light value according to the first HSV color light value and the preset HSV color light value to be replaced; The second HSV color value is converted to obtain a second RGB color light value, and a second R color light value list, a second G color light value list, a second B color light value list, and a second A color light value list are determined according to the second RGB color light value and the second A color light value.
6. The image processing method according to claim 4, characterized in that: The preset HSV color value to be replaced is obtained in the following manner: In response to a touch operation on a preset interactive control, a color light value parameter input interface is displayed; In response to input operations on the hue parameter, saturation parameter, brightness parameter and transparency parameter in the color light value parameter input interface, the HSV color value to be replaced is determined.
7. The image processing method according to claim 5, characterized in that: Determining a second HSV color light value and a second A color light value according to the first HSV color light value and the preset HSV color light value to be replaced includes: Extracting the H color value to be replaced, the S color value to be replaced, the V color value to be replaced, and the A color value to be replaced from the HSV color value to be replaced; Using the A color light value to be replaced as the second A color light value, and using the H color light value to be replaced as the second H color light value; Determine a second S color light value according to the S color light value to be replaced and a first S color light value in the first HSV color light value, and determine a second V color light value according to the V color light value to be replaced and a first V color light value in the first HSV color light value; The second HSV color light value is determined according to the second H color light value, the second S color light value, and the second V color light value.
8. The image processing method according to claim 7, characterized in that: Determining a second S color light value according to the S color light value to be replaced and a first S color light value in the first HSV color light value, and determining a second V color light value according to the V color light value to be replaced and a first V color light value in the first HSV color light value, including: Performing a sum operation on the S color light value to be replaced and the first S color light value in the first HSV color light value to obtain a second S color light value; A fitting operation is performed on the V color light value to be replaced and the first V color light value in the first HSV color light value to obtain a second V color light value.
9. The image processing method according to claim 5, characterized in that: According to the second RGB color light value and the second A color light value, determining a second R color light value list, a second G color light value list, a second B color light value list, and a second A color light value list includes: Based on the original pixel position of the original pixel, determine the placement position of the second RGB color light value and the second A color light value in the corresponding color light value list; Based on the placement position pairs, the second RGB color light values and the second A color light values are sequentially stored in corresponding color light value lists to obtain a second R color light value list, a second G color light value list, a second B color light value list and a second A color light value list.
10. The image processing method according to claim 4, characterized in that: Merging the second R color light value list, the second G color light value list, the second B color light value list, and the second A color light value list to obtain a target image after color replacement, including: Based on the original pixel position of the original pixel point, the second R color light value, the second G color light value, the second B color light value and the second A color light value in the second R color light value list, the second G color light value list, the second B color light value and the second A color light value list are sequentially placed into corresponding channels to obtain a second R channel image object, a second G channel image object, a second B channel image object and a second A channel image object; The second R channel image object, the second G channel image object, the second B channel image object and the second A channel image object are fused to obtain target pixel points corresponding to the original pixel points, and a target image after color replacement is generated based on the target pixel points.
11. An image processing device, characterized in that: include: A first image conversion module is used to obtain a first image to be processed, and convert the first image to be processed having an original color value mode into a second image to be processed having an RGBA color value mode; a color value separation module, configured to perform color value separation on the second image to be processed to obtain a first R color light value list, a first G color light value list, a first B color light value list, and a first A color light value list; A second image conversion module is used to perform color value conversion on the first R color light value list, the first G color light value list, the first B color light value list and the first A color light value list to obtain a first HSV color light value; The target image generation module is used to determine the target image after color replacement according to the first HSV color value and the preset HSV color value to be replaced.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the image processing method according to any one of claims 1 to 10 is implemented.
13. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; Wherein, the processor is configured to perform the image processing method according to any one of claims 1 to 10 by executing the executable instructions.
Citation Information
Cited By
Color modification method, image forming device, electronic equipment and storage medium
CN120263918A
