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

Image processing method and device and electronic equipment Download PDF

Info

Publication number
CN117689593A
CN117689593A CN202311710309.5A CN202311710309A CN117689593A CN 117689593 A CN117689593 A CN 117689593A CN 202311710309 A CN202311710309 A CN 202311710309A CN 117689593 A CN117689593 A CN 117689593A
Authority
CN
China
Prior art keywords
value
transparency
pixel point
color value
adjusted
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311710309.5A
Other languages
Chinese (zh)
Inventor
欧阳晖勇
马群立
吴玉虎
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Mobvoi Information Technology Co ltd
Original Assignee
Shanghai Mobvoi Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Mobvoi Information Technology Co ltd filed Critical Shanghai Mobvoi Information Technology Co ltd
Priority to CN202311710309.5A priority Critical patent/CN117689593A/en
Publication of CN117689593A publication Critical patent/CN117689593A/en
Pending legal-status Critical Current

Links

Landscapes

  • Image Processing (AREA)

Abstract

The embodiment of the invention discloses an image processing method, an image processing device and electronic equipment. And calculating the transparency value of each pixel point according to a preset background color value and the initial color value of each pixel point to adjust the transparency of each pixel point so as to obtain an intermediate image, and determining the pixel point to be adjusted in the intermediate image according to the transparency value so as to adjust the color value and/or the transparency of the pixel point to be adjusted so as to obtain a target image. Thereby, an effect of eliminating edges and jaggies can be achieved.

Description

Image processing method and device and electronic equipment
Technical Field
The present invention relates to the field of image processing, and in particular, to an image processing method, an image processing device, and an electronic device.
Background
Image processing refers to a technique in which images are analyzed by a computer to achieve a desired result. The method utilizes the technologies of mathematical operation, point operation, conversion, modeling and the like to carry out the processes of smoothing, filtering, sharpening, compressing, encoding, enhancing, restoring and the like on the image so as to improve the quality of the image, extract the information in the image and facilitate the subsequent image analysis.
The image matting is a common image processing technology, and is mainly applied to the production of movies, television dramas, advertisements and animations, and is characterized in that a curtain is used as a background, a person or other images needing to be scratched are placed in front of the curtain in the shooting process, then the curtain background is replaced by other backgrounds by software in the post production, and the background is identified based on color difference by the matting technology.
Disclosure of Invention
The invention aims to provide an image processing method, an image processing device and electronic equipment, which can eliminate edges and saw teeth in image processing, so that the effect of processed images is better.
In a first aspect, an embodiment of the present invention provides an image processing method, including:
acquiring an image to be processed;
acquiring initial color values of all pixel points in the image to be processed;
calculating the transparency value of each pixel point according to a preset background color value and the initial color value of each pixel point so as to adjust the transparency of each pixel point to obtain an intermediate image;
determining pixel points to be adjusted in the intermediate image according to the transparency value;
and adjusting the color value and/or the transparency of the pixel point to be adjusted to acquire a target image.
In some embodiments, the calculating the transparency value of each pixel according to the predetermined background color value and the initial color value of each pixel to adjust the transparency of each pixel to obtain the intermediate image includes:
acquiring a first value according to an initial color value of a pixel point in the image to be processed, wherein the first value is a difference value between the first color value and a larger value in the second color value and the third color value;
acquiring a second numerical value according to the color value of the pixel point in the preset background, wherein the second numerical value is the difference value between the first color value and the larger value of the second color value and the third color value;
calculating the transparency value of the pixel point according to the first numerical value and the second numerical value through a smooth step function; and
according to the transparency value, the transparency of each pixel point is adjusted to obtain the intermediate image;
the first color value is one of a red color value, a green color value and a blue color value, and the second color value and the third color value are the other two colors except the first color value.
In some embodiments, the transparency of the pixel point is obtained by the following formula calculation:
α=smoothstep(K 2 ,0.0,K 1 )
wherein K is 1 Is of a first value, K 2 For the second value, α is the transparency value and smoothstep is the smooth step function.
In some embodiments, the calculating, by the smoothing step function, the transparency value of the pixel point according to the first value and the second value is specifically:
in response to the first value being greater than or equal to the second value, α=0;
in response to the first value being less than or equal to 0, α=1;
in response to the first value being greater than 0 and less than the second value, 0 < alpha < 1.
In some embodiments, the determining the pixel to be adjusted in the intermediate image according to the transparency value specifically includes:
and selecting the points with transparency values larger than 0 and smaller than 1 as pixel points to be adjusted.
In some embodiments, the adjusting the color value and/or the transparency of the pixel to be adjusted to obtain the target image includes:
acquiring a first area corresponding to the pixel point to be adjusted, wherein the first area is a square area taking the pixel point to be adjusted as the center;
adjusting the color values of the pixel points to be adjusted in the first area according to the transparency values corresponding to the pixel points in the area to be adjusted so as to obtain a second area;
and determining the color value of the pixel point to be adjusted according to the predetermined first convolution kernel and the color value of each pixel point in the second region.
In some embodiments, the adjusting the color value of the pixel to be adjusted in the first area according to the transparency value corresponding to each pixel in the area to be adjusted includes:
and determining a color value corresponding to the pixel point with the maximum transparency value in the first area as the color value of the pixel point to be adjusted.
In some embodiments, the adjusting the color value and/or the transparency of the pixel to be adjusted to obtain the target image includes:
acquiring a third area corresponding to the pixel point to be adjusted, wherein the third area is a square area taking the pixel point to be adjusted as the center;
and determining the transparency value of the pixel point to be adjusted according to the predetermined second convolution kernel and the transparency value of each pixel point in the third region.
In a second aspect, an embodiment of the present invention provides an image processing apparatus, including:
an image acquisition unit for acquiring an image to be processed;
the color value acquisition unit is used for acquiring initial color values of all pixel points in the image to be processed;
the intermediate image acquisition unit is used for calculating the transparency value of each pixel point according to a preset background color value and the initial color value of each pixel point so as to adjust the transparency of each pixel point to acquire an intermediate image;
the pixel point to be adjusted determining unit is used for determining the pixel point to be adjusted in the intermediate image according to the transparency value;
and the target image acquisition unit is used for adjusting the color value and/or the transparency of the pixel point to be adjusted so as to acquire a target image.
In a third aspect, an embodiment of the present invention provides an electronic device, including a memory for storing one or more computer program instructions, and a processor, wherein the one or more computer program instructions are executed by the processor to implement the method of any of the first aspects.
According to the technical scheme, the transparency value of each pixel point is calculated according to the preset background color value and the initial color value of each pixel point to adjust the transparency of each pixel point so as to obtain an intermediate image, and the pixel point to be adjusted in the intermediate image is determined according to the transparency value so as to adjust the color value and/or the transparency of the pixel point to be adjusted so as to obtain a target image. Thereby, an effect of eliminating edges and jaggies can be achieved.
Drawings
The above and other objects, features and advantages of the present invention will become more apparent from the following description of embodiments of the present invention with reference to the accompanying drawings, in which:
FIG. 1 is a general flow chart of image processing of an embodiment of the present invention;
FIG. 2 is a flow chart of acquiring an intermediate image according to an embodiment of the present invention;
FIG. 3 is a smoothed step function image of an embodiment of the present invention;
FIG. 4 is a flowchart of adjusting pixel point color values according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of determining an adjusted color value according to an embodiment of the present invention;
FIG. 6 is a flowchart for adjusting the transparency of a pixel point according to an embodiment of the invention;
FIG. 7 is a diagram of a transparency value after an adjustment is determined according to an embodiment of the present invention;
fig. 8 is a schematic diagram of an image processing apparatus according to an embodiment of the present invention;
fig. 9 is a schematic diagram of an electronic device according to an embodiment of the invention.
Detailed Description
The present application is described below based on examples, but the present application is not limited to only these examples. In the following detailed description of the present application, certain specific details are set forth in detail. The present application will be fully understood by those skilled in the art without a description of these details. Well-known methods, procedures, flows, components and circuits have not been described in detail so as not to obscure the nature of the present application.
Moreover, those of ordinary skill in the art will appreciate that the drawings are provided herein for illustrative purposes and that the drawings are not necessarily drawn to scale.
Unless the context clearly requires otherwise, the words "comprise," "comprising," and the like throughout the application are to be construed as including but not being exclusive or exhaustive; that is, it is the meaning of "including but not limited to".
In the description of the present application, it should be understood that the terms "first," "second," and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. Furthermore, in the description of the present application, unless otherwise indicated, the meaning of "a plurality" is two or more.
In the current matting method, edges and serrations are two relatively common defects. Edge defects refer to the fact that in the process of matting, edges of foreground objects are unclear or virtual edges exist due to color or brightness differences between the background and the foreground objects, and edges are generated when illumination is uneven or the background is impure. However, there may be variations and non-uniformities in color and brightness in the actual scene, resulting in an algorithm that cannot directly identify edges.
The saw-tooth defect refers to the fact that the saw-tooth-like shape of the foreground object appears due to the limitation of an algorithm or the problem of improper processing in the process of the image matting, and the saw-tooth defect is mainly caused by the fact that the algorithm excessively emphasizes the recognition and cutting of edges in the process of the image matting, and ignores the overall shape of the object. The presence of complex textures and details on the foreground object can also lead to the generation of saw tooth defects.
Fig. 1 is a flowchart of an image processing method according to an embodiment of the present invention. As shown in fig. 1, the image processing method includes the steps of:
step S100, obtaining an image to be processed.
In this embodiment, the acquired image to be processed is an image that needs to be scratched.
In some embodiments, the image to be processed is a background color image taken through the background of the curtain. For example, the image to be processed is an image photographed against a green curtain, an image photographed against a red curtain, or the like.
It should be understood that the background color of the image to be processed is not limited in the embodiment of the present invention, and may be a background of various colors, and meanwhile, the image to be processed may also be an image captured by a background of a curtain, which is not limited in the embodiment of the present invention.
Step 200, obtaining an initial color value of each pixel point in the image to be processed. Specifically, the method for obtaining the color value can be using image editing software, an online tool, a programming library and hardware equipment. The embodiments of the present invention are not limited in this regard, as appropriate methods and formats may be selected and converted into appropriate color codes based on the needs of the different images and scenes. Wherein the initial color values comprise a red value, a green value and a blue value, and are represented by RGB (a, b, c), wherein a represents the red value, b represents the green value, c represents the blue value, and a, b and c are integers which are more than or equal to 0 and less than or equal to 255. The different values of a, b, c may constitute different colors, e.g. RGB (255, 0) for red and RGB (0, 255) for blue. All pixels of the image to be processed correspond to an initial color value. It should be noted that, in the embodiment of the present invention, the RGB raw values (i.e. the values between 0 and 255) are used as examples for RGB processing, but the embodiment of the present invention is not limited thereto, and in some embodiments, when the graphics processor processes the RGB values, the RGB value range 0 to 255 may be converted into the floating point value range 0.0 to 1.0, and the object to be processed is the color value of the floating point value.
And step S300, calculating the transparency value of each pixel point according to the preset background color value and the initial color value of each pixel point so as to adjust the transparency of each pixel point to obtain an intermediate image.
Fig. 2 is a flowchart of acquiring an intermediate image according to an embodiment of the present invention, including the steps of:
step S310, obtaining a first value according to the initial color value of the pixel point in the image to be processed, where the first value is a difference value between the first color value and a larger value of the second color value and the third color value.
After the image to be processed is obtained, each pixel point of the image to be processed is obtained, and an initial color value is obtained, wherein the initial color value is RGB, R represents a red value (red), G represents a green value (green), and B represents a blue value (blue). Further, the initial color value includes a first color value, a second color value, and a third color value, wherein the first color value is one of a red color value, a green color value, and a blue color value, and the second color value and the third color value are two other color values except the first color value. For example, the first color value may be a green value, where one of the second color value and the third color value is a red value and the other is a blue value.
The larger value of the second color value and the third color value is obtained, and then the larger value is subtracted from the first color value to be used as a first numerical value. For example, for a pixel point color value of RGB (25, 30, 45), let g=30, a second color value of red, r=25, a third color value of blue, b=45, and the larger of the second and third color values of blue 45, the difference between the first and blue values is equal to-15.
Step S320, obtaining a second value according to the color value of the pixel point in the predetermined background, where the second value is a difference value between the first color value and a larger value of the second color value and the third color value.
Wherein the predetermined background is preset, and the color value of the predetermined background is set to be close to the color value of the image to be processed. For example, for an image to be processed captured by a green curtain, the color values of the respective pixels of the predetermined background may be RGB (0, 255, 0). Similar to step S310, for the predetermined pixel point of the background, a first color value, a second color value, and a third color value are acquired. The larger value of the second color value and the third color value is obtained, and then the larger value is subtracted from the first color value to be used as a second numerical value. When the predetermined background color value is RGB (0, 255, 0) and the first color value is green, the second value is 255.
And step S330, calculating the transparency value of the pixel point according to the first numerical value and the second numerical value through a smooth step function.
The calculating the transparency value of the pixel point through the smooth step function specifically comprises the following steps:
α=smoothstep(K 2 ,0.0,K 1 )
wherein K is 1 Is of a first value, K 2 For the second value, α is the transparency value and smoothstep is the smooth step function. By smoothing the step function, one value can be slowly shifted from one range to another, achieving a smooth transition effect. To achieve a smooth visual effect.
The smooth step function image is shown in FIG. 3, with the ordinate representing the transparency value and the abscissa representing the first value K 1 . For the smooth step function, respond to K 1 ≥K 2 α=0; in response to K 1 Less than or equal to 0, alpha=1; in response to 0 < K 1 <K 2 ,0<α<1。
Specifically, when the color of the pixel point tends to be the same as the background color, the first value is greater than or equal to the second value, i.e. K 1 ≥K 2 Let α=0 set it to be completely transparent. When the color of the pixel point is greatly different from the background color, the first value is less than or equal to 0, namely K 1 Let α=1 set it to be completely opaque. When the pixel isWhen the color value is similar to the background color but lower, the first value is between 0 and the second value, i.e. 0 < K 1 <K 2 The transparency value thereof is set to be greater than 0 and less than 1 according to the degree thereof, specifically, the closer it is to the background color, the lower the transparency value.
For example, the first value of 45 and the second value of 30 for a certain pixel point are obtained by the calculation in S310 and S320. The transparency value of the pixel is smoothstep (30,0.0, 45), and the transparency of the pixel is 0 through the definition of the smooth step function, and if the first value of another pixel is 30 and the second value is 45, the transparency value of the pixel is greater than 0 and less than 1.
And step 340, adjusting the transparency of each pixel point according to the transparency value to obtain the intermediate image.
After the transparency value of each pixel point is obtained in step S330, the obtained transparency value is used as a new transparency value of each pixel point in the image to be processed, and the obtained image is called an intermediate image. For example, the original transparency value of the pixel point a is 1, and after calculation, the new transparency value is 0.5, the transparency value of the pixel point a is adjusted to 0.5, and so on, the transparency values of all the points are adjusted in the above manner, so as to obtain the intermediate image.
And step 400, determining pixel points to be adjusted in the intermediate image according to the transparency value.
Specifically, the pixel point to be adjusted of the intermediate image is determined according to the transparency value to be: and selecting the points with transparency values larger than 0 and smaller than 1 as pixel points to be adjusted. This is because the points with transparency of 0 are completely transparent, while the points with transparency of 1 are completely opaque, and there is no edge or jaggy at these points, so only the points with transparency values greater than 0 and less than 1 need to be adjusted to eliminate edges and jaggies.
And S500, adjusting the color value and/or the transparency of the pixel point to be adjusted to acquire a target image.
In an alternative implementation, the color value of the pixel to be adjusted is adjusted to obtain the target image.
Fig. 4 is a flowchart of adjusting pixel color values according to an embodiment of the invention. As shown in fig. 4, the flowchart for adjusting the color value of the pixel point includes the following steps:
step S510, obtaining a first area corresponding to the pixel to be adjusted, where the first area is a square area with the pixel to be adjusted as a center.
Firstly, determining the size of a region, for example, 3×3,5×5, for one pixel, then taking the pixel to be adjusted as a center point to obtain a region with a corresponding size, called a first region, and repeating the above operations for all the pixels to be processed to obtain a first region corresponding to a plurality of pixels.
Step S520, adjusting the color value of the pixel to be adjusted in the first area according to the transparency value corresponding to each pixel in the area to be adjusted to obtain a second area.
The adjusting of the color value of the pixel point to be adjusted specifically comprises the following steps: and determining a color value corresponding to the pixel point with the maximum transparency value in the first area as the color value of the pixel point to be adjusted. And replacing the value of the original pixel to be adjusted with the color value corresponding to the pixel with the maximum transparency value. This step is mainly because the point with a large transparency value means that the difference between the first color value and the maximum value of the second color value and the third color value is smallest, that is, the relative value of the first color value is smallest, that is, the first color value of the point, that is, the same color value as the predetermined background is smallest, is filled into the pixel point to be adjusted, the effect of eliminating the edge of the color as the predetermined background is achieved by weakening the same color as the predetermined background, and the obtained area is referred to as the second area.
Step S530, determining the color value of the pixel to be adjusted according to the predetermined first convolution kernel and the color value of each pixel in the second area.
And carrying out convolution processing on the first convolution kernel preset by the system and the pixel points of the second area to obtain the pixel color value to be adjusted. The pixel to be adjusted and surrounding pixels are mixed in a certain proportion by using a convolution kernel mode, and the color value obtained by the method can remove the edge of the background color.
FIG. 5 is a schematic diagram of determining an adjusted color value according to an embodiment of the present invention. As shown in fig. 5, the convolution kernel may be of any size, and a first convolution kernel of 3*3 is taken as an example to describe the first convolution kernel 52, which is a convolution kernel according to an embodiment of the present invention, and the first area 51 is a 3*3 square area centered on the pixel to be adjusted. Wherein (a, b, c) represents the red value of the pixel as a, the green value as b, and the blue value as c. The second region 53 has been obtained by processing the color values of the pixel points to be adjusted in step S320. The next step is to perform convolution processing, i.e. weighted average processing, on the color value of the second area 53 and the first convolution kernel 52, where the final result is the color value of the pixel to be processed. In the first area 51 and the second area 53, three values in each grid represent color values of the pixel point, that is, a red value, a green value, and a blue value.
Specifically, the color value of the second area 53 and the first convolution kernel 52 are convolved, that is, the color value of each pixel point is multiplied by each value of the first convolution kernel 52, and then all the multiplied results are added to obtain the color value of the pixel point to be processed. When the color values need to be convolved, the red value, the green value and the blue value are processed through the first convolution kernel 52, and the obtained result of each color is taken as a final result. And taking all the pixel points to be processed, which are obtained through the adjustment of the color values, as the pixel points of the new image to obtain a processed image, wherein the processed image eliminates the color edges.
In another optional implementation manner, the transparency value of the pixel point to be adjusted is adjusted to obtain the target image.
Fig. 6 is a flowchart of adjusting transparency of a pixel point according to an embodiment of the invention. As shown in fig. 6, the flowchart for adjusting the transparency of the pixel point includes the following steps:
step S540, obtaining a third area corresponding to the pixel to be adjusted, where the third area is a square area with the pixel to be adjusted as a center. Firstly, for a pixel point, determining the size of a region, for example, 3×3,5×5, and then taking the pixel point as a center point to obtain a region with a corresponding size, which is called a third region. Repeating the operation on all the pixel points to be processed to obtain a plurality of third areas corresponding to the pixel points.
Step S550, determining the value of the pixel point to be adjusted according to the predetermined second convolution kernel and the transparency value of each pixel point in the third area.
And carrying out convolution processing on a second convolution kernel preset by the system and the pixel points of the third region to obtain the transparency of the pixel to be adjusted. The pixel to be adjusted and surrounding pixels are mixed in a certain proportion by using a convolution kernel mode, and the transparency value obtained by the method can remove saw teeth.
FIG. 7 is a diagram of a transparency value after an adjustment is determined according to an embodiment of the present invention. As shown in fig. 7, the second convolution kernel 71 may have any size, and the second convolution kernel 71 of 3*3 is described below as an example, and processing may be performed in a similar manner for convolution kernels of other sizes, such as 5×5,7×7 convolution kernels. The second convolution kernel 71 in the figure is a convolution kernel according to an embodiment of the present disclosure, and the third area 72 is a 3*3 square area centered on the pixel to be adjusted. A second convolution kernel 71 and a third area 72 are obtained, and the transparency value of the third area 72 and the second convolution kernel 71 are subjected to convolution processing, and the finally obtained result is used as the transparency value of the pixel point to be processed.
Specifically, the transparency of the third area 72 and the second convolution kernel 71 are subjected to convolution processing, that is, the transparency of each pixel point is multiplied by each value of the second convolution kernel 71, and then all the multiplied results are added to obtain the transparency value of the pixel point to be processed. And taking all the pixel points to be processed as the pixel points of the new image by adjusting the transparency value to obtain a processed image, wherein the processed image eliminates saw teeth.
In yet another optional implementation manner, the color value and the transparency value of the pixel point to be adjusted are adjusted simultaneously to obtain the target image. Specifically, the color value of the pixel to be adjusted is adjusted first and then the transparency value of the pixel to be adjusted is adjusted, or the transparency value of the pixel to be adjusted is adjusted first and then the color value of the pixel to be adjusted is adjusted, which is not limited in the embodiment of the present invention, and the adjustment mode is not repeated.
And taking all the pixel points to be processed, which are obtained through adjustment of the color value and the transparency value, as the pixel points of the new image to obtain a processed image, wherein the processed image eliminates color edges and saw teeth.
According to the embodiment of the invention, the transparency value of each pixel point is calculated according to the preset background color value and the initial color value of each pixel point to adjust the transparency of each pixel point so as to obtain an intermediate image, and the pixel point to be adjusted in the intermediate image is determined according to the transparency value so as to adjust the color value and/or the transparency of the pixel point to be adjusted so as to obtain a target image. Thereby, an effect of eliminating edges and jaggies can be achieved.
Fig. 8 is a schematic diagram of an image processing apparatus according to an embodiment of the present invention. As shown in fig. 8, the image processing apparatus of the present invention includes an image acquisition unit 81, a color value acquisition unit 82, an intermediate image acquisition unit 83, a pixel point to be adjusted determination unit 84, a target image acquisition unit 85. The image obtaining unit 81 is configured to obtain an image to be processed, the color value obtaining unit 82 is configured to obtain an initial color value of each pixel in the image to be processed, the intermediate image obtaining unit 83 is configured to calculate a transparency value of each pixel according to a predetermined background color value and the initial color value of each pixel so as to adjust transparency of each pixel to obtain an intermediate image, the pixel to be adjusted determining unit 84 is configured to determine a pixel to be adjusted in the intermediate image according to the transparency value, and the target image obtaining unit 85 is configured to adjust the color value and/or transparency of the pixel to be adjusted to obtain a target image.
In some embodiments, the intermediate image acquisition unit comprises:
the first numerical value calculation unit is used for obtaining a first numerical value according to the initial color value of the pixel point in the image to be processed, wherein the first numerical value is a difference value between the first color value and a larger value in the second color value and the third color value;
the second value calculation unit is used for obtaining a second value according to the color value of the pixel point in the preset background, wherein the second value is the difference value between the first color value and the larger value in the second color value and the third color value;
a smoothing step function unit, configured to calculate a transparency value of the pixel point according to the first value and the second value through a smoothing step function; and
the transparency adjusting unit is used for adjusting the transparency of each pixel point according to the transparency value so as to obtain the intermediate image;
the first color value is one of a red color value, a green color value and a blue color value, and the second color value and the third color value are the other two colors except the first color value.
In some embodiments, the transparency of the pixel point is obtained by the following formula calculation:
α=smoothstep(K 2 ,0.0,K 1 )
wherein K is 1 Is of a first value, K 2 For the second value, α is the transparency value and smoothstep is the smooth step function.
In some embodiments, the smoothing step function unit is specifically:
in response to the first value being greater than or equal to the second value, α=0;
in response to the first value being less than or equal to 0, α=1;
in response to the first value being greater than 0 and less than the second value, 0 < alpha < 1.
In some embodiments, the pixel point to be adjusted determining unit is configured to:
a point with a transparency value between 0 and 1 is selected as the pixel point to be adjusted.
In some embodiments, the target image acquisition unit comprises:
acquiring a first area corresponding to the pixel point to be adjusted, wherein the first area is a square area taking the pixel point to be adjusted as the center;
adjusting the color value of the pixel point to be adjusted in the first area according to the transparency value corresponding to each pixel point in the first area to obtain a second area;
and determining the color value of the pixel point to be adjusted according to the predetermined first convolution kernel and the color value of each pixel point in the second region.
In some embodiments, the adjusting the color value of the pixel to be adjusted in the first area according to the transparency value corresponding to each pixel in the first area to obtain the second area includes:
and determining a color value corresponding to the pixel point with the maximum transparency value in the first area as the color value of the pixel point to be adjusted.
In some embodiments, the target image acquisition unit comprises:
a third region obtaining unit, configured to obtain a third region corresponding to the pixel to be adjusted, where the third region is a square region with the pixel to be adjusted as a center;
and the transparency value calculation unit is used for determining the transparency value of the pixel point to be adjusted according to the preset second convolution kernel and the transparency value of each pixel point in the third area.
According to the embodiment of the invention, the transparency value of each pixel point is calculated according to the preset background color value and the initial color value of each pixel point to adjust the transparency of each pixel point so as to obtain an intermediate image, and the pixel point to be adjusted in the intermediate image is determined according to the transparency value so as to adjust the color value and/or the transparency of the pixel point to be adjusted so as to obtain a target image. Thereby, an effect of eliminating edges and jaggies can be achieved.
Fig. 9 is a schematic diagram of an electronic device according to an embodiment of the invention. As shown in fig. 9, the electronic device shown in fig. 9 is a general address query device, which includes a general computer hardware structure including at least a processor 91 and a memory 92. The processor 91 and the memory 92 are connected by a bus 93. The memory 92 is adapted to store instructions or programs executable by the processor 91. The processor 91 may be a separate microprocessor or may be a collection of one or more microprocessors. Thus, the processor 91 implements processing of data and control of other devices by executing instructions stored by the memory 92 to perform the method flows of embodiments of the present invention as described above. A bus 93 connects the above components together, while connecting the above components to a display controller 94 and display devices and input/output (I/O) devices 95. Input/output (I/O) devices 95 may be mice, keyboards, modems, network interfaces, touch input devices, somatosensory input devices, printers, and other devices which are well known in the art. Typically, input/output devices 95 are connected to the system through input/output (I/O) controllers 96.
According to the embodiment of the invention, the transparency value of each pixel point is calculated according to the preset background color value and the initial color value of each pixel point to adjust the transparency of each pixel point so as to obtain an intermediate image, and the pixel point to be adjusted in the intermediate image is determined according to the transparency value so as to adjust the color value and/or the transparency of the pixel point to be adjusted so as to obtain a target image. Thereby, an effect of eliminating edges and jaggies can be achieved.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, apparatus (device) or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may employ a computer program product embodied on one or more computer-readable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations of methods, apparatus (devices) and computer program products according to embodiments of the application. It will be understood that each of the flows in the flowchart may be implemented by computer program instructions.
These computer program instructions may be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows.
These computer program instructions may also be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows.
Another embodiment of the present invention is directed to a non-volatile storage medium storing a computer readable program for causing a computer to perform some or all of the method embodiments described above.
That is, it will be understood by those skilled in the art that all or part of the steps in implementing the methods of the embodiments described above may be implemented by specifying relevant hardware by a program, where the program is stored in a storage medium, and includes several instructions for causing a device (which may be a single-chip microcomputer, a chip or the like) or a processor (processor) to perform all or part of the steps in the methods of the embodiments described herein. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The foregoing description is only of the preferred embodiments of the present application and is not intended to limit the same, but rather, various modifications and variations may be made by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc. that fall within the spirit and principles of the present application are intended to be included within the scope of the present application.

Claims (10)

1. An image processing method, the method comprising:
acquiring an image to be processed;
acquiring initial color values of all pixel points in the image to be processed;
calculating the transparency value of each pixel point according to a preset background color value and the initial color value of each pixel point so as to adjust the transparency of each pixel point to obtain an intermediate image;
determining pixel points to be adjusted in the intermediate image according to the transparency value;
and adjusting the color value and/or the transparency of the pixel point to be adjusted to acquire a target image.
2. The method of claim 1, wherein calculating the transparency value of each pixel based on the predetermined background color value and the initial color value of each pixel to adjust the transparency of each pixel to obtain the intermediate image comprises:
acquiring a first value according to an initial color value of a pixel point in the image to be processed, wherein the first value is a difference value between the first color value and a larger value in the second color value and the third color value;
acquiring a second numerical value according to the color value of the pixel point in the preset background, wherein the second numerical value is the difference value between the first color value and the larger value of the second color value and the third color value;
calculating the transparency value of the pixel point according to the first numerical value and the second numerical value through a smooth step function; and
according to the transparency value, the transparency of each pixel point is adjusted to obtain the intermediate image;
the first color value is one of a red color value, a green color value and a blue color value, and the second color value and the third color value are the other two colors except the first color value.
3. The method of claim 2, wherein the transparency of the pixel is obtained by calculation by the following formula:
α=smoothstep(K 2 ,0.0,K 1 )
wherein K is 1 Is of a first value, K 2 For the second value, α is the transparency value and smoothstep is the smooth step function.
4. A method according to claim 3, wherein the calculating the transparency value of the pixel point according to the first and second values by means of a smooth step function is specifically:
in response to the first value being greater than or equal to the second value, α=0;
in response to the first value being less than or equal to 0, α=1;
in response to the first value being greater than 0 and less than the second value, 0 < alpha < 1.
5. The method according to claim 4, wherein the determining the pixel to be adjusted in the intermediate image according to the transparency value specifically includes:
and selecting the points with transparency values larger than 0 and smaller than 1 as pixel points to be adjusted.
6. The method according to claim 1, wherein said adjusting the color value and/or the transparency of the pixel to be adjusted to obtain the target image comprises:
acquiring a first area corresponding to the pixel point to be adjusted, wherein the first area is a square area taking the pixel point to be adjusted as the center;
adjusting the color value of the pixel point to be adjusted in the first area according to the transparency value corresponding to each pixel point in the first area to obtain a second area;
and determining the color value of the pixel point to be adjusted according to the predetermined first convolution kernel and the color value of each pixel point in the second region.
7. The method of claim 6, wherein adjusting the color value of the pixel to be adjusted in the first area according to the transparency value corresponding to each pixel in the first area to obtain the second area comprises:
and determining a color value corresponding to the pixel point with the maximum transparency value in the first area as the color value of the pixel point to be adjusted.
8. The method according to claim 1 or 6, wherein said adjusting the color value and/or the transparency of the pixel to be adjusted to obtain the target image comprises:
acquiring a third area corresponding to the pixel point to be adjusted, wherein the third area is a square area taking the pixel point to be adjusted as the center;
and determining the transparency value of the pixel point to be adjusted according to the predetermined second convolution kernel and the transparency value of each pixel point in the third region.
9. An image processing apparatus, characterized in that the apparatus comprises:
an image acquisition unit for acquiring an image to be processed;
the color value acquisition unit is used for acquiring initial color values of all pixel points in the image to be processed;
the intermediate image acquisition unit is used for calculating the transparency value of each pixel point according to a preset background color value and the initial color value of each pixel point so as to adjust the transparency of each pixel point to acquire an intermediate image;
the pixel point to be adjusted determining unit is used for determining the pixel point to be adjusted in the intermediate image according to the transparency value;
and the target image acquisition unit is used for adjusting the color value and/or the transparency of the pixel point to be adjusted so as to acquire a target image.
10. An electronic device comprising a memory and a processor, wherein the memory is configured to store one or more computer program instructions, wherein the one or more computer program instructions are executed by the processor to implement the method of any of claims 1-8.
CN202311710309.5A 2023-12-12 2023-12-12 Image processing method and device and electronic equipment Pending CN117689593A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311710309.5A CN117689593A (en) 2023-12-12 2023-12-12 Image processing method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311710309.5A CN117689593A (en) 2023-12-12 2023-12-12 Image processing method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN117689593A true CN117689593A (en) 2024-03-12

Family

ID=90134795

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311710309.5A Pending CN117689593A (en) 2023-12-12 2023-12-12 Image processing method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN117689593A (en)

Similar Documents

Publication Publication Date Title
CN108876743B (en) Image rapid defogging method, system, terminal and storage medium
CN104486552B (en) A kind of method and electronic equipment obtaining image
Duan et al. Fast tone mapping for high dynamic range images
CN106485668A (en) Mthods, systems and devices for overexposure correction
JP6818463B2 (en) Image processing equipment, image processing methods and programs
WO2016139260A9 (en) Method and system for real-time noise removal and image enhancement of high-dynamic range images
CN113301408B (en) Video data processing method and device, electronic equipment and readable storage medium
CN108182671B (en) Single image defogging method based on sky area identification
CN113301409B (en) Video synthesis method and device, electronic equipment and readable storage medium
JP5703255B2 (en) Image processing apparatus, image processing method, and program
US11651480B2 (en) Systems and methods for selective enhancement of objects in images
CN111489322A (en) Method and device for adding sky filter to static picture
JP4477618B2 (en) Reliable image sharpening method
US20200106944A1 (en) Systems And Methods Of Image Enhancement
CN111091122B (en) Training and detecting method and device for multi-scale characteristic convolutional neural network
CN115937186A (en) Textile defect identification method and system
JP5914046B2 (en) Image processing apparatus and image processing method
US7424147B2 (en) Method and system for image border color selection
CN109754372A (en) A kind of image defogging processing method and processing device
CN115690130B (en) Image processing method and device
CN117689593A (en) Image processing method and device and electronic equipment
AU2016273984A1 (en) Modifying a perceptual attribute of an image using an inaccurate depth map
US11625886B2 (en) Storage medium storing program, training method of machine learning model, and image generating apparatus
CN112700485B (en) Image depth information extraction method
JP2007243987A (en) Image processing method, image processing system, and image processing program

Legal Events

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