Image processing method and device and storage medium
By determining the color distance and brightness value of pixels in the image and adjusting the transparency channel value to remove the target color, the problem that existing technologies can only remove black backgrounds is solved. This achieves the removal of any color and a natural transition, improving the flexibility and practicality of image processing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-09
- Publication Date
- 2026-04-10
AI Technical Summary
Existing technical tools can only remove black backgrounds from images, but cannot remove other colors, which limits their flexibility and practicality.
By determining the color distance and brightness value between the initial color of a pixel in the image to be processed and the target color to be removed, the transparency channel value of the pixel is adjusted to achieve the degree of color preservation, and then the transparency of the pixel is adjusted to achieve the removal of any target color and the smooth transition of colors.
It enables the removal of any target color, improving the flexibility and practicality of color removal from images, and producing natural color transitions.
Smart Images

Figure CN121842367A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer and network communication technology, and in particular to an image processing method, device and storage medium. Background Technology
[0002] In one image processing scenario, it is necessary to perform image or video cutout so that the cutout image can be used as a texture or special effect to be composited into any multimedia content such as images or videos.
[0003] In existing technologies, tools such as the Unmult plugin can be used to remove the black background from images or videos taken on a black background. For example, if the image or video is of fire, smoke, or water taken on a black background, by removing the black background, a simple image or video of fire, smoke, or water can be obtained, which is suitable for compositing into other images or videos to achieve the compositing of special effects such as fire, smoke, and water.
[0004] However, tools like the Unmult plugin can only remove the black parts of an image, not other colors, which limits their flexibility and practicality. Summary of the Invention
[0005] This disclosure provides an image processing method, apparatus, and storage medium to remove arbitrary target colors from an image.
[0006] In a first aspect, embodiments of this disclosure provide an image processing method, including:
[0007] Determine the color distance between the initial color of a pixel in the image to be processed and the target color to be removed;
[0008] Determine the brightness value of the pixel;
[0009] The degree to which the initial color of the pixel is retained is determined based on the brightness value and the color distance;
[0010] For the image to be processed, the pixels are adjusted according to the degree to which the initial color of the pixels is preserved.
[0011] In a second aspect, embodiments of this disclosure provide an image processing apparatus, comprising:
[0012] The color distance determination unit is used to determine the color distance between the initial color of a pixel in the image to be processed and the target color to be removed.
[0013] A brightness determination unit is used to determine the brightness value of the pixel;
[0014] The parameter determination unit is used to determine the degree of initial color retention of the pixel based on the brightness value and the color distance;
[0015] An adjustment unit is used to adjust the pixels in the image to be processed according to the degree of preservation of the initial color of the pixels.
[0016] Thirdly, embodiments of this disclosure provide an electronic device, including: at least one processor and a memory;
[0017] The memory stores computer-executed instructions;
[0018] The at least one processor executes computer execution instructions stored in the memory, causing the at least one processor to perform the image processing method as described in the first aspect and various possible designs of the first aspect.
[0019] Fourthly, embodiments of this disclosure provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the image processing method described in the first aspect and various possible designs of the first aspect.
[0020] Fifthly, embodiments of this disclosure provide a computer program product including computer execution instructions, which, when executed by a processor, implement the image processing method described in the first aspect and various possible designs of the first aspect.
[0021] The image processing method, apparatus, and storage medium provided in this disclosure determine the color distance between the initial color of a pixel in an image to be processed and the target color to be removed; determine the brightness value of the pixel; determine the degree of preservation of the initial color of the pixel based on the brightness value and the color distance; and adjust the pixel according to the degree of preservation of the initial color of the pixel in the image to be processed. By determining the degree of preservation of the initial color of the pixel's alpha channel based on the color distance between the initial color and the target color and the pixel's brightness value, and adjusting the pixel based on the degree of preservation of the initial color, arbitrary target color removal can be achieved, and a smooth color transition can be realized, improving the flexibility and practicality of color removal from images. Attached Figure Description
[0022] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0023] Figure 1 A schematic diagram of a scene for an image processing method provided in an embodiment of this disclosure;
[0024] Figure 2 This is a schematic flowchart of an image processing method provided in an embodiment of the present disclosure;
[0025] Figure 3 This is a schematic flowchart of an image processing method provided in another embodiment of the present disclosure;
[0026] Figure 4 This is a structural block diagram of an image processing apparatus provided in an embodiment of the present disclosure;
[0027] Figure 5 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present disclosure. Detailed Implementation
[0028] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this disclosure, and not all embodiments. Based on the embodiments of this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.
[0029] In existing technologies, tools such as the Unmult plugin can be used to remove the black background from images or videos taken on a black background. For example, if the image or video is of fire, smoke, or water taken on a black background, by removing the black background, a simple image or video of fire, smoke, or water can be obtained, which is suitable for compositing into other images or videos to achieve the compositing of special effects such as fire, smoke, and water.
[0030] However, tools like the Unmult plugin can only remove the black parts of an image, not other colors, which limits their flexibility and practicality.
[0031] To address the aforementioned technical problems, this disclosure provides an image processing method. This method involves determining the color distance between the initial color of a pixel in the image to be processed and the target color to be removed; determining the pixel's brightness value; determining the pixel's alpha channel value based on the brightness value and color distance; and adjusting the pixel's transparency based on the alpha channel value to obtain the target image. By determining the degree of initial color retention based on the color distance between the pixel's initial color and the target color, as well as the pixel's brightness value, and adjusting the pixel based on this retention degree, arbitrary target color removal can be achieved, along with a smooth color transition, thus improving the flexibility and practicality of color removal from images.
[0032] The image processing method disclosed herein can be applied to any electronic device, such as a terminal device or a server, for example, in applications such as... Figure 1In the terminal device shown, an image to be processed can be input into the terminal device, and a target color to be removed can be set. The terminal device determines the color distance between the initial color of any pixel in the image to be processed and the target color to be removed; determines the brightness value of the pixel; determines the degree of preservation of the initial color of the pixel based on the brightness value and the color distance; and adjusts the pixel based on the degree of preservation of the initial color of the pixel to obtain the target image.
[0033] The image processing method of this disclosure will be described in detail below with reference to specific embodiments.
[0034] refer to Figure 2 , Figure 2 This is a schematic flowchart of an image processing method according to an embodiment of the present disclosure. The method of this embodiment can be applied to any electronic device such as a terminal device or server. The image processing method includes:
[0035] S201. Determine the color distance between the initial color of the pixels in the image to be processed and the target color to be removed.
[0036] In this embodiment, if the user needs to remove any target color from the image to be processed, the user can first set the target color, for example, set the values of each RGB color channel of the target color.
[0037] Furthermore, for any pixel in the image to be processed, the color distance between the initial color and the target color of the pixel can be calculated. The color distance can be used to measure the difference between the initial color and the target color. Any known method for calculating the color distance can be used, and no restriction is imposed in this embodiment.
[0038] Optionally, when calculating the color distance between the initial color and the target color of a pixel, the following method can be used:
[0039] Obtain the sum of squares of the differences between the initial color of the pixel and the RGB color channel values of the target color, obtain the product of the square root of the sum of squares and a second preset coefficient, and determine the color distance as the product.
[0040] The specific calculation formula is as follows:
[0041]
[0042] Where Distance represents the color distance, [R1,G1,B1] are the values of each RGB color channel of the initial color of the pixel; [R0,G0,B0] are the values of each RGB color channel of the target color to be removed. The second preset coefficient is...
[0043] Optionally, the target color in this embodiment can be any color, including black.
[0044] Optionally, the image to be processed in this embodiment can be any image.
[0045] Optionally, if the target color is not black, the image to be processed can also be an image with the black background removed. For example, an image with the black background removed can be an image processed by the Unmult plugin, which is a plugin for removing black backgrounds from images. Of course, other methods can also be used to obtain an image with the black background removed. In this embodiment, the target color (non-black) is removed on the basis of the image with the black background removed, which makes the target color removal cleaner and the transition more natural. This avoids the unnatural transition caused by simply removing the target color without removing the black background. Furthermore, the method of this embodiment can also be used as an extension function of the Unmult plugin, enabling the Unmult plugin to remove both the black background and the target color simultaneously.
[0046] In other words, before determining the color distance between the initial color of the pixels in the image to be processed and the target color to be removed, the original image (the image without removing the black background) can be obtained first. Then, the black background is removed from the original image to obtain the image with the black background removed, which is then used as the image to be processed for subsequent processing.
[0047] S202, Determine the brightness value of the pixel.
[0048] In this embodiment, the brightness value of a pixel can be determined based on its RGB color, or by other means; no limitation is imposed in this embodiment. The brightness value is also the Y channel value in the YUV color space.
[0049] Optionally, when determining the brightness value of a pixel based on its RGB color, the brightness value can be determined using the values of each RGB color channel of the pixel and specific coefficients. For example, if the brightness value uses the BT.709 color gamut, the brightness value of the pixel can be determined using the following formula:
[0050] Y=0.2126R1+0.7152G1+0.0722B1
[0051] Where Y is the brightness value of the pixel.
[0052] It should be noted that S201 and S202 can be executed in any order, or simultaneously.
[0053] S203. Determine the degree of preservation of the initial color of the pixel based on the brightness value and the color distance.
[0054] In this embodiment, after determining the brightness value and color distance of a pixel, the degree of initial color retention for that pixel can be determined based on these factors. The closer the initial color of a pixel is to the target color, the less of the initial color is retained. Specifically, if the initial color of a pixel is the target color or very close to it, the initial color will be directly removed. Conversely, if the initial color of a pixel is far from the target color, it needs to be retained. To achieve better color transition, the brightness value of the pixel can be further considered to adjust the degree of initial color retention. By determining the degree of initial color retention, the target color can be removed from the image to be processed.
[0055] Optionally, the alpha value of the pixel can be determined based on the brightness value and color distance to determine the pixel's transparency, which represents the degree to which the pixel's initial color is preserved. Pixels with the target color or a color close to the target color have zero transparency, meaning their initial color is not preserved, thus achieving the removal of the target color. Pixels that are not close to the target color are preserved. The color distance can be used to measure whether the pixel's initial color is the same as or close to the target color, while the brightness value can be used to achieve the transition in transparency. The determination of the alpha value of the pixel based on the brightness value and the color distance can be implemented in any way that achieves the above objective; this embodiment is not limited to any particular method.
[0056] Optionally, if the color distance of the pixel is not greater than a preset threshold (e.g., 0.5), it means that the initial color of the pixel is the same as or close to the target color. The value of the transparency channel of the pixel is set to 0. In this way, when the transparency of the pixel is adjusted according to the value of the transparency channel, the pixel becomes a transparent pixel, that is, it no longer displays color, thus achieving color removal.
[0057] If the color distance of a pixel is greater than a preset threshold, it means that the initial color of the pixel is not the same as or close to the target color. Therefore, color removal of the pixel is not necessary. At least one of the following three methods can be used to set the value of the pixel's alpha channel:
[0058] Method 1: Directly set the value of the pixel's transparency channel to 1, which means that the pixel is completely opaque and still presents its original color;
[0059] Method 2: Set the value of the alpha channel of the pixel to the brightness value of the pixel. The higher the brightness value of the pixel, the higher the value of the alpha channel of the pixel, that is, the less transparent it is. Conversely, the lower the brightness value of the pixel, the lower the value of the alpha channel of the pixel, that is, the less transparent it is. This can achieve color transition.
[0060] Method 3: The value of the transparency channel of the pixel is determined based on a preset formula according to the brightness value and color distance of the pixel. That is, the value of the transparency channel is calculated by comprehensively considering the brightness value and color distance of the pixel, so as to achieve better color transition.
[0061] Specifically, the value of the pixel's transparency channel is determined based on a preset formula using the pixel's brightness value and color distance. This involves obtaining the absolute value of the difference between the color distance and the brightness value, multiplying this absolute value by a first preset coefficient, and determining the value of the pixel's transparency channel using the following formula:
[0062] Alpha = a * abs(Distance - Y)
[0063] Where Alpha is the value of the alpha channel of the pixel, abs is the absolute value operator, and a is the first preset coefficient (which can be set according to actual needs).
[0064] In another embodiment, regardless of whether the color distance of the pixel is greater than a preset threshold, the value of the alpha channel of the pixel can be determined according to the above preset formula. It is only necessary to determine the first preset coefficient 'a' based on whether the color distance of the pixel is greater than the preset threshold. For example, if the color distance of the pixel is not greater than the preset threshold, the first preset coefficient 'a' can be set to 0, so the value of the alpha channel of the pixel is also 0, and the color of the pixel is removed. If the color distance of the pixel is greater than the preset threshold, the first preset coefficient 'a' can be set to a non-zero value, so the value of the alpha channel of the pixel is also not 0, and the color of the pixel will not be removed. Different color transition effects can also be achieved by adjusting the first preset coefficient 'a'.
[0065] In another embodiment, the process described above can also be divided into two steps. First, it is determined whether to retain the color of the pixel based on whether the color distance of the pixel is greater than a preset threshold. If the color distance of the pixel is not greater than the preset threshold, it is determined not to retain the color of the pixel, and the value of the transparency channel of the pixel can be set to 0. If the color distance of the pixel is greater than the preset threshold, it is determined to retain the color of the pixel, and then one of the above three methods is used to set the value of the transparency channel of the pixel.
[0066] It should be noted that the degree of preservation of the initial color of a pixel in this embodiment is not limited to being represented by the value of the pixel's alpha channel. The degree of preservation of the initial color can also be represented and adjusted by any other feasible known method.
[0067] S204. For the image to be processed, adjust the pixels according to the degree of preservation of the initial color of the pixels.
[0068] In this embodiment, after determining the degree of preservation of the initial color of the pixel, for the image to be processed, the pixel is adjusted based on the degree of preservation of the initial color of the pixel, specifically by adjusting the initial color of the pixel to meet the degree of preservation of the initial color.
[0069] Optionally, if the degree of preservation of the initial color of a pixel is represented by the value of the pixel's alpha channel, then after determining the value of the pixel's alpha channel, the pixel's transparency can be adjusted using the value of the pixel's alpha channel. If the value of the alpha channel is 0, the pixel is completely transparent, thus achieving color removal; if the value of the alpha channel is between 0 and 1, the pixel is semi-transparent, thus achieving color transition; if the value of the alpha channel is 1, the pixel is completely opaque, thus presenting the original color. After performing the above process on all pixels, the target image is finally obtained.
[0070] The image processing method provided in this embodiment determines the color distance between the initial color of a pixel in the image to be processed and the target color to be removed; determines the brightness value of the pixel; determines the degree of preservation of the initial color of the pixel based on the brightness value and the color distance; and adjusts the pixel according to the degree of preservation of the initial color for the image to be processed. By determining the degree of preservation of the initial color of a pixel based on the color distance between the initial color and the target color and the brightness value of the pixel, and adjusting the pixel based on the degree of preservation of the initial color, arbitrary target color removal can be achieved, and a smooth color transition can be realized, improving the flexibility and practicality of color removal from images.
[0071] In another alternative embodiment, such as Figure 3 As shown, Figure 3 This is a schematic flowchart of an image processing method provided in an embodiment of the present disclosure. The image processing method includes:
[0072] S301. Obtain the original image and remove the black background from the original image to obtain the image to be processed;
[0073] The process can begin by removing the black background from the original image, for example, using the Unmult plugin or other tools. This removed black background serves as the image to be processed for removing the target color (non-black). Subsequently, the target color (non-black) is removed from the image after the black background has been removed. This allows for cleaner removal of the target color and a more natural transition, avoiding the unnatural transition that occurs when only the target color is removed without removing the black background. Furthermore, the method in this embodiment can be used as an extension of the Unmult plugin, enabling the Unmult plugin to remove both the black background and the target color simultaneously.
[0074] S302. Determine the color distance between the initial color of the pixels in the image to be processed and the target color to be removed;
[0075] S303, Determine the brightness value of the pixel;
[0076] S304. Determine the value of the transparency channel of the pixel based on the brightness value and the color distance;
[0077] S305. Adjust the transparency of the pixel according to the value of the transparency channel of the pixel to obtain the target image.
[0078] S302 to S305 are the same as in the above embodiments, and will not be described again here.
[0079] Optionally, if the user only needs to remove the target color from the original image without removing the black background, the black background can be removed from the original image first, then the target color can be removed using the above method, and finally the black background can be restored. This way, the target color can be removed while retaining the black background, and the removal effect of the target color can be improved, achieving a better color transition.
[0080] Corresponding to the image processing method in the above embodiments, Figure 4 This is a structural block diagram of an image processing apparatus provided according to embodiments of the present disclosure. For ease of explanation, only the parts relevant to embodiments of the present disclosure are shown. (Refer to...) Figure 4 The image processing device 400 includes: a color distance determination unit 401, a brightness determination unit 402, an adjustment parameter determination unit 403, and an adjustment unit 404.
[0081] The color distance determination unit 401 is used to determine the color distance between the current color of a pixel in the image to be processed and the target color to be removed.
[0082] Brightness determination unit 402 is used to determine the brightness value of the pixel;
[0083] The parameter adjustment determination unit 403 is used to determine the degree of initial color retention of the pixel based on the brightness value and the color distance;
[0084] The adjustment unit 404 is used to adjust the pixels in the image to be processed according to the degree of preservation of the initial color of the pixels.
[0085] In one or more embodiments of this disclosure, the adjustment parameter determining unit 403, when determining the degree of initial color retention of the pixel based on the brightness value and the color distance, is configured to:
[0086] Based on the brightness value and the color distance, the value of the transparency channel of the pixel is determined as the degree to which the initial color of the pixel is preserved;
[0087] Accordingly, when adjusting the pixel based on the degree of preservation of the pixel's initial color, the adjustment unit 404 is used to:
[0088] The transparency of the pixel is adjusted according to the value of the pixel's alpha channel.
[0089] In one or more embodiments of this disclosure, when the adjustment parameter determining unit 403 determines the value of the transparency channel of the pixel based on the brightness value and the color distance, it is used to:
[0090] If the color distance is greater than a preset threshold, then the value of the pixel's transparency channel is set to the brightness value, or the value of the pixel's transparency channel is determined based on the brightness value and the color distance using a preset formula, or the value of the pixel's transparency channel is set to 1; or
[0091] If the color distance is not greater than a preset threshold, then the value of the pixel's transparency channel is set to 0.
[0092] In one or more embodiments of this disclosure, when the adjustment parameter determining unit 403 determines the value of the transparency channel of the pixel based on the brightness value and the color distance using a preset formula, it is used to:
[0093] Obtain the absolute value of the difference between the color distance and the brightness value, and multiply the absolute value by a first preset coefficient to determine the value of the transparency channel of the pixel.
[0094] In one or more embodiments of this disclosure, the color distance determination unit 401, when determining the color distance between the current color of a pixel in the image to be processed and the target color to be removed, is configured to:
[0095] The sum of squares of the differences between the RGB channel values of the current color and the target color is obtained, and the product of the square root of the sum of squares and a second preset coefficient is determined as the color distance.
[0096] In one or more embodiments of this disclosure, the image to be processed is an image with a black background removed, and the target color is any color other than black.
[0097] In one or more embodiments of this disclosure, the device further includes a black background removal unit for removing a black background from the original image before determining the color distance between the current color of a pixel in the image to be processed and the target color to be removed, thereby obtaining the image to be processed.
[0098] In one or more embodiments of this disclosure, the brightness determination unit 402, when determining the brightness value of the pixel, is configured to:
[0099] The brightness value of the pixel is determined based on the RGB color channel values of the current color.
[0100] The device provided in this embodiment can be used to execute the technical solutions of the above method embodiments. Its implementation principle and technical effect are similar, and will not be described again here.
[0101] refer to Figure 5 The diagram illustrates a structural schematic of an electronic device 500 suitable for implementing embodiments of the present disclosure. The electronic device 500 can be a terminal device or a server. The terminal device can include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, personal digital assistants (PDAs), tablet computers, portable media players (PMPs), and in-vehicle terminals (e.g., in-vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. Figure 5 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0102] like Figure 5 As shown, the electronic device 500 may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 508 into a random access memory (RAM) 503. The RAM 503 also stores various programs and data required for the operation of the electronic device 500. The processing unit 501, ROM 502, and RAM 503 are interconnected via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0103] Typically, the following devices can be connected to I / O interface 505: input devices 506 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 507 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 508 including, for example, magnetic tapes, hard disks, etc.; and communication devices 509. Communication device 509 allows electronic device 500 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 5 An electronic device 500 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.
[0104] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 509, or installed from a storage device 508, or installed from a ROM 502. When the computer program is executed by the processing device 501, it performs the functions defined in the methods of embodiments of this disclosure.
[0105] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0106] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0107] The aforementioned computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to perform the methods shown in the above embodiments.
[0108] Computer program code for performing the operations of this disclosure can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0109] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0110] The units described in the embodiments of this disclosure can be implemented in software or in hardware. The name of a unit does not necessarily limit the unit itself; for example, the first acquisition unit can also be described as "a unit that acquires at least two Internet Protocol addresses".
[0111] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0112] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0113] In a first aspect, according to one or more embodiments of the present disclosure, an image processing method is provided, comprising:
[0114] Determine the color distance between the current color of a pixel in the image to be processed and the target color to be removed;
[0115] Determine the brightness value of the pixel;
[0116] The degree to which the initial color of the pixel is retained is determined based on the brightness value and the color distance;
[0117] For the image to be processed, the pixels are adjusted according to the degree to which the initial color of the pixels is preserved.
[0118] According to one or more embodiments of this disclosure, determining the degree of initial color retention of the pixel based on the luminance value and the color distance includes:
[0119] Based on the brightness value and the color distance, the value of the transparency channel of the pixel is determined as the degree to which the initial color of the pixel is preserved;
[0120] Accordingly, adjusting the pixel based on the degree of preservation of the pixel's initial color includes:
[0121] The transparency of the pixel is adjusted according to the value of the pixel's alpha channel.
[0122] According to one or more embodiments of this disclosure, determining the value of the transparency channel of the pixel based on the brightness value and the color distance includes:
[0123] If the color distance is greater than a preset threshold, then the value of the pixel's transparency channel is set to the brightness value, or the value of the pixel's transparency channel is determined based on the brightness value and the color distance using a preset formula, or the value of the pixel's transparency channel is set to 1; or
[0124] If the color distance is not greater than a preset threshold, then the value of the pixel's transparency channel is set to 0.
[0125] According to one or more embodiments of this disclosure, determining the value of the transparency channel of the pixel based on the brightness value and the color distance using a preset formula includes:
[0126] Obtain the absolute value of the difference between the color distance and the brightness value, and multiply the absolute value by a first preset coefficient to determine the value of the transparency channel of the pixel.
[0127] According to one or more embodiments of this disclosure, determining the color distance between the current color of a pixel in the image to be processed and the target color to be removed includes:
[0128] The sum of squares of the differences between the RGB channel values of the current color and the target color is obtained, and the product of the square root of the sum of squares and a second preset coefficient is determined as the color distance.
[0129] According to one or more embodiments of this disclosure, the image to be processed is an image with a black background removed, and the target color is any color other than black.
[0130] According to one or more embodiments of this disclosure, before determining the color distance between the current color of a pixel in the image to be processed and the target color to be removed, the method further includes:
[0131] Obtain the original image and remove the black background from the original image to obtain the image to be processed.
[0132] According to one or more embodiments of this disclosure, determining the brightness value of the pixel includes:
[0133] The brightness value of the pixel is determined based on the RGB color channel values of the current color.
[0134] Secondly, according to one or more embodiments of the present disclosure, an image processing apparatus is provided, comprising:
[0135] The color distance determination unit is used to determine the color distance between the current color of a pixel in the image to be processed and the target color to be removed.
[0136] A brightness determination unit is used to determine the brightness value of the pixel;
[0137] The parameter determination unit is used to determine the degree of initial color retention of the pixel based on the brightness value and the color distance;
[0138] An adjustment unit is used to adjust the pixels in the image to be processed according to the degree of preservation of the initial color of the pixels.
[0139] According to one or more embodiments of this disclosure, when determining the degree of initial color retention of the pixel based on the brightness value and the color distance, the adjustment parameter determining unit is configured to:
[0140] Based on the brightness value and the color distance, the value of the transparency channel of the pixel is determined as the degree to which the initial color of the pixel is preserved;
[0141] Accordingly, when adjusting the pixel based on the degree of preservation of the pixel's initial color, the adjustment unit is used to:
[0142] The transparency of the pixel is adjusted according to the value of the pixel's alpha channel.
[0143] According to one or more embodiments of this disclosure, when the adjustment parameter determining unit determines the value of the transparency channel of the pixel based on the brightness value and the color distance, it is configured to:
[0144] If the color distance is greater than a preset threshold, then the value of the pixel's transparency channel is set to the brightness value, or the value of the pixel's transparency channel is determined based on the brightness value and the color distance using a preset formula, or the value of the pixel's transparency channel is set to 1; or
[0145] If the color distance is not greater than a preset threshold, then the value of the pixel's transparency channel is set to 0.
[0146] According to one or more embodiments of this disclosure, when the adjustment parameter determining unit determines the value of the transparency channel of the pixel based on the brightness value and the color distance using a preset formula, it is configured to:
[0147] Obtain the absolute value of the difference between the color distance and the brightness value, and multiply the absolute value by a first preset coefficient to determine the value of the transparency channel of the pixel.
[0148] According to one or more embodiments of this disclosure, the color distance determination unit, when determining the color distance between the current color of a pixel in the image to be processed and the target color to be removed, is configured to:
[0149] The sum of squares of the differences between the RGB channel values of the current color and the target color is obtained, and the product of the square root of the sum of squares and a second preset coefficient is determined as the color distance.
[0150] According to one or more embodiments of this disclosure, the image to be processed is an image with a black background removed, and the target color is any color other than black.
[0151] According to one or more embodiments of this disclosure, the device further includes a black background removal unit for removing a black background from the original image before determining the color distance between the current color of a pixel in the image to be processed and the target color to be removed, thereby obtaining the image to be processed.
[0152] According to one or more embodiments of this disclosure, the brightness determination unit, when determining the brightness value of the pixel, is configured to:
[0153] The brightness value of the pixel is determined based on the RGB color channel values of the current color.
[0154] Thirdly, according to one or more embodiments of the present disclosure, an electronic device is provided, comprising: at least one processor and a memory;
[0155] The memory stores computer-executed instructions;
[0156] The at least one processor executes computer execution instructions stored in the memory, causing the at least one processor to perform the image processing method as described in the first aspect and various possible designs of the first aspect.
[0157] Fourthly, according to one or more embodiments of the present disclosure, a computer-readable storage medium is provided, wherein computer-executable instructions are stored therein, which, when executed by a processor, implement the image processing method described in the first aspect and various possible designs of the first aspect.
[0158] Fifthly, according to one or more embodiments of the present disclosure, a computer program product is provided, including computer execution instructions that, when executed by a processor, implement the image processing method described in the first aspect and various possible designs of the first aspect.
[0159] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.
[0160] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0161] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.
Claims
1. An image processing method, characterized in that, include: Determine the color distance between the initial color of a pixel in the image to be processed and the target color to be removed; Determine the brightness value of the pixel; The degree to which the initial color of the pixel is retained is determined based on the brightness value and the color distance; For the image to be processed, the pixels are adjusted according to the degree to which the initial color of the pixels is preserved.
2. The method according to claim 1, characterized in that, Determining the degree of initial color retention of the pixel based on the brightness value and the color distance includes: Based on the brightness value and the color distance, the value of the transparency channel of the pixel is determined as the degree to which the initial color of the pixel is preserved; Accordingly, adjusting the pixel based on the degree of preservation of the pixel's initial color includes: The transparency of the pixel is adjusted according to the value of the pixel's alpha channel.
3. The method according to claim 2, characterized in that, Determining the value of the transparency channel of the pixel based on the brightness value and the color distance includes: If the color distance is greater than a preset threshold, then the value of the pixel's transparency channel is set to the brightness value, or the value of the pixel's transparency channel is determined based on the brightness value and the color distance using a preset formula, or the value of the pixel's transparency channel is set to 1; or If the color distance is not greater than a preset threshold, then the value of the pixel's transparency channel is set to 0.
4. The method according to claim 3, characterized in that, The step of determining the value of the transparency channel of the pixel based on the brightness value and the color distance using a preset formula includes: Obtain the absolute value of the difference between the color distance and the brightness value, and multiply the absolute value by a first preset coefficient to determine the value of the transparency channel of the pixel.
5. The method according to claim 1, characterized in that, Determining the color distance between the initial color of a pixel in the image to be processed and the target color to be removed includes: The sum of squares of the differences between the RGB channel values of the initial color and the target color is obtained, and the product of the square root of the sum of squares and a second preset coefficient is determined as the color distance.
6. The method according to any one of claims 1-5, characterized in that, The image to be processed is an image with the black background removed, and the target color is any color other than black.
7. The method according to claim 6, characterized in that, Before determining the color distance between the initial color of a pixel in the image to be processed and the target color to be removed, the method further includes: Obtain the original image and remove the black background from the original image to obtain the image to be processed.
8. The method according to any one of claims 1-5, characterized in that, Determining the brightness value of the pixel includes: The brightness value of the pixel is determined based on the RGB color channel values of the initial color.
9. An image processing device, characterized in that, include: The color distance determination unit is used to determine the color distance between the initial color of a pixel in the image to be processed and the target color to be removed. A brightness determination unit is used to determine the brightness value of the pixel; The parameter determination unit is used to determine the degree of initial color retention of the pixel based on the brightness value and the color distance; An adjustment unit is used to adjust the pixels in the image to be processed according to the degree of preservation of the initial color of the pixels.
10. An electronic device, characterized in that, include: At least one processor and memory; The memory stores computer-executed instructions; The at least one processor executes computer execution instructions stored in the memory, causing the at least one processor to perform the method as described in any one of claims 1-8.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, implement the method as described in any one of claims 1-8.
12. A computer program product, characterized in that, Includes computer execution instructions, which, when executed by a processor, implement the method as described in any one of claims 1-8.