CN114612355A - Oil painting stylization method, device, equipment and medium for image - Google Patents

Oil painting stylization method, device, equipment and medium for image Download PDF

Info

Publication number
CN114612355A
CN114612355A CN202210200113.0A CN202210200113A CN114612355A CN 114612355 A CN114612355 A CN 114612355A CN 202210200113 A CN202210200113 A CN 202210200113A CN 114612355 A CN114612355 A CN 114612355A
Authority
CN
China
Prior art keywords
image
gradient
pixel point
color channel
oil painting
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
CN202210200113.0A
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.)
Insta360 Innovation Technology Co Ltd
Original Assignee
Insta360 Innovation 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 Insta360 Innovation Technology Co Ltd filed Critical Insta360 Innovation Technology Co Ltd
Priority to CN202210200113.0A priority Critical patent/CN114612355A/en
Publication of CN114612355A publication Critical patent/CN114612355A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/50Image enhancement or restoration using two or more images, e.g. averaging or subtraction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/13Edge detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10024Color image

Landscapes

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

Abstract

The embodiment of the application relates to the field of image processing, and discloses a method and a device for stylizing an oil painting of an image, electronic equipment and a medium. Wherein the method comprises the following steps: extracting a brightness component from an image to be processed to obtain a first image; adding random white noise in the first image to obtain a second image; performing gradient extraction on the second image by using a gradient algorithm to obtain a first gradient map of the second image; and superposing the first gradient map on the image to be processed to obtain a target image with an oil painting style. When the oil painting style of the image is stylized, the processing process is simple, the calculation efficiency is high, and the oil painting style is vivid.

Description

Oil painting stylization method, device, equipment and medium for image
Technical Field
The embodiment of the application relates to the technical field of image processing, in particular to a method, a device, equipment and a medium for stylizing oil paintings of images.
Background
The oil painting is a painting seed made of quick-drying vegetable oil blended with pigment on canvas, linen, paper board or template, and has the artistic characteristics of rich colors, fine and vivid picture, strong pigment smearing sense and strong stereoscopic impression.
With the rapid development of smart phones, mobile phone photographing applications and stylized filter technologies thereof are widely popular in the market.
In the process of implementing the embodiment of the present application, the inventors of the present application find that: the current image processing technology of the mobile phone needs a complex processing flow and also needs a three-dimensional graph rendering technology when the oil painting is automatically generated, so that the time and cost consumed when the image is processed are huge, and the performance is slow; or the oil painting effect is generated by stacking a plurality of Gaussian filtered image layers, and the obtained oil painting is usually fuzzy and not vivid enough.
Disclosure of Invention
The embodiment of the application aims to provide an oil painting stylization method, device, equipment and medium for an image, which are simple in processing process, high in calculation efficiency and vivid in oil painting style.
In order to solve the technical problem, the embodiment of the application adopts the following technical scheme:
in a first aspect, an embodiment of the present application provides a method for stylizing an oil painting of an image, including:
extracting a brightness component from an image to be processed to obtain a first image;
adding random white noise in the first image to obtain a second image;
performing gradient extraction on the second image by using a gradient algorithm to obtain a first gradient map of the second image;
and superposing the first gradient map on the image to be processed to obtain a target image with an oil painting style.
In some embodiments, after the obtaining the second image, before performing gradient extraction on the second image by using a gradient algorithm to obtain a first gradient map of the second image, the method further comprises:
constructing a tangential flow graph corresponding to the first image, wherein the tangential flow graph comprises tangents corresponding to all pixel points in the first image;
and performing line integral convolution processing on each pixel point in the second image along the corresponding tangential direction to obtain a third image.
In some embodiments, the constructing a tangential flow graph corresponding to the first image, the tangential flow graph including tangents of respective pixel points in the first image, comprises:
extracting a second gradient map of the first image by using a gradient algorithm, wherein the second gradient map comprises a horizontal gradient and a vertical gradient corresponding to each pixel point in the first image;
constructing a structure tensor matrix of corresponding pixel points in the second gradient image according to the horizontal gradient and the vertical gradient corresponding to each pixel point in the first image;
calculating an eigenvalue of the structure tensor matrix to obtain an eigenvector corresponding to the structure tensor matrix;
taking the direction vertical to the feature vector as the tangential direction of each pixel point in the first image;
and calculating the tangential direction of each pixel point in the first image to obtain a tangential flow graph corresponding to the first image.
In some embodiments, the performing gradient extraction on the second image by using a gradient algorithm to obtain a first gradient map of the second image includes:
obtaining a first convolution kernel according to the edge detection operator;
performing normalization processing on the first convolution kernel to obtain a second convolution kernel;
and performing convolution processing on the second image by using the second convolution kernel to obtain a first gradient map of the second image.
In some embodiments, the obtaining a first convolution kernel according to an edge detection operator includes:
and rotating the edge detection operator by a first angle to obtain a first convolution kernel.
In some embodiments, after the gradient extracting the second image by using a gradient algorithm to obtain a first gradient map of the second image, the method further comprises:
and multiplying the gray value of each pixel point in the first gradient map by a constant larger than 1 to obtain the brightness gain of each pixel point in the first gradient map.
In some embodiments, the superimposing the first gradient map on the image to be processed to obtain the target image with the oil painting style includes:
acquiring pixel values of each color channel of each pixel point in the image to be processed;
and superposing the pixel value of each color channel of each pixel point and the brightness gain of the corresponding pixel point in the first gradient map to obtain a target image with an oil painting style.
In some embodiments, after the superimposing the first gradient map on the image to be processed to obtain the target image with the oil painting style, the method further includes:
acquiring a first color channel pixel value, a second color channel pixel value and a third color channel pixel value of the target image;
searching a corresponding mapping value in a color lookup table according to the first color channel pixel value, the second color channel pixel value and the third color channel pixel value;
and updating the first color channel pixel value, the second color channel pixel value and the third color channel pixel value according to the mapping value.
In a second aspect, an embodiment of the present application further provides an oil painting stylization apparatus for an image, where the apparatus includes:
the extraction module is used for extracting a brightness component from an image to be processed to obtain a first image;
the adding module is used for adding random white noise in the first image to obtain a second image;
the gradient extraction module is used for carrying out gradient extraction on the second image by utilizing a gradient algorithm to obtain a first gradient map of the second image;
and the superposition module is used for superposing the first gradient map on the image to be processed to obtain a target image with an oil painting style.
In a third aspect, the present application further provides an electronic device, including:
at least one processor, and
a memory communicatively connected to the processor, the memory storing instructions executable by the at least one processor to enable the at least one processor to perform the method according to the first aspect.
In a fourth aspect, the present application further provides a non-transitory computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, which, when executed by an electronic device, cause the electronic device to perform the method according to any one of the first aspect.
The beneficial effects of the embodiment of the application are as follows: different from the situation of the prior art, the method, the device, the equipment and the medium for stylizing the oil painting of the image, provided by the embodiment of the application, extract the brightness component from the image to be processed to obtain the first image, and then add random white noise into the first image to obtain the second image, so that a plurality of reliefs with bright and dark colors can be superposed on the random position on the image to be processed; gradient extraction is carried out on the second image by utilizing a gradient algorithm to obtain a first gradient map of the second image, and the relief of the edge of the object in the image can be obtained; superposing the first gradient map on the image to be processed to obtain a target image with an oil painting style; the embossment is superposed at a random position in the image, and the edge of the object in the image is provided with the embossment, so that the target image has a stereoscopic impression, the oil painting style is vivid, the whole processing process is simple, and the calculation efficiency is high.
Drawings
One or more embodiments are illustrated by way of example in the accompanying drawings, which correspond to the figures in which like reference numerals refer to similar elements and which are not to scale unless otherwise specified.
FIG. 1 is a schematic flow chart diagram of one embodiment of a method for stylizing an oil painting of an image of the present application;
FIG. 2 is a schematic illustration of a first image of a method of stylizing a painting of an image of the present application;
FIG. 3 is a schematic illustration of a second image of the oil stylization method of the present application image;
FIG. 4 is a schematic diagram of a tangential flow graph of the oil stylization method of the present application image;
FIG. 5 is a schematic illustration of a third image of the oil stylization method of the present application image;
FIG. 6 is a schematic diagram of a first gradient map of a painting stylization method of an image of the present application;
FIG. 7 is a schematic illustration of a target image of the oil stylization method of the present application image;
FIG. 8 is a schematic illustration of a color-filled target image of the canvas stylization method of an image of the present application;
FIG. 9 is a schematic diagram of an embodiment of a painting stylization apparatus of the present application;
FIG. 10 is a schematic diagram of the structure of yet another embodiment of a painting stylization apparatus of the present disclosure;
fig. 11 is a schematic hardware structure diagram of a controller according to an embodiment of the electronic device of the present application.
Detailed Description
The present application will be described in detail with reference to specific examples. The following examples will assist those skilled in the art in further understanding the present application, but are not intended to limit the present application in any way. It should be noted that various changes and modifications can be made by one skilled in the art without departing from the spirit of the application. All falling within the scope of protection of the present application.
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of and not restrictive on the broad application.
It should be noted that, if not conflicted, the various features of the embodiments of the present application may be combined with each other within the scope of protection of the present application. Additionally, while functional block divisions are performed in device schematics, with logical sequences shown in flowcharts, in some cases, steps shown or described may be performed in a different order than the block divisions in devices, or in flowcharts. Further, the terms "first," "second," "third," and the like, as used herein do not limit the order of data and execution, but merely distinguish between identical or similar items that have substantially the same function or effect.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in the description of the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the present application. As used herein, the term "and/or" includes any and all combinations of one or more of the associated listed items.
In addition, the technical features mentioned in the embodiments of the present application described below may be combined with each other as long as they do not conflict with each other.
The oil painting stylization method and device for the image can be applied to electronic equipment, and it can be understood that the electronic equipment comprises a controller and an image acquisition device. The controller is used as a main control center, the processing process is simple, the calculation efficiency is high, and the style of the oil painting is vivid.
The image acquisition device can be a camera module and is used for providing a photographing function for a user and taking an image obtained after photographing as an image to be processed.
The image capturing device may also be other devices, such as a device that obtains an image from an application program, or a device that obtains an image in a screenshot manner, which is not limited herein.
Referring to fig. 1, a flowchart of an embodiment of a method for stylizing an oil painting applied to an image of the present application is shown, where the method may be executed by a controller in an electronic device, and the method includes steps S101 to S104.
S101: a luminance component is extracted from an image to be processed to obtain a first image.
After an image to be processed is acquired through an image acquisition device, extracting a brightness component from the image to be processed, wherein the image to be processed can be an RGB color image, and when the brightness component is extracted, the RGB color image can be converted into a color and brightness separation color space from an RGB color space, wherein the RGB color space is one of primary color spaces, and the primary color spaces can comprise an RGB color space, a CMY color space, a CMYK color space, a CIE XYZ color space and the like; the color and light separation color space may include a hue class color space such as a YCC/YUV color space, a Lab color space, and the like. In the color-luminance separation color space, the luminance component is extracted to obtain a first image, and as shown in fig. 2, the first image obtained by extracting the luminance component from the image to be processed is a gray scale image. By extracting the luminance component, which is a single channel, to calculate the gradient, the calculation cost can be greatly saved.
It can be understood that some conventional luminance component extraction methods in the art are adopted to extract the luminance component from the image to be processed, and are not described herein again.
S102: and adding random white noise in the first image to obtain a second image.
One of the characteristics of the oil painting is that the picture has relief, the relief is generated by the unevenness of the canvas after the pigment is dried in the air, and when a light source irradiates the canvas, the oil painting can generate a bright and dark clear stereoscopic impression which is the visual relief. Therefore, in order to make the image generate the relief feeling of the oil painting, it is necessary to superimpose some reliefs on the random positions of the first image, in order to superimpose some reliefs on the random positions of the image, random white noise may be added in the first image to obtain the second image, in some embodiments, the adding random white noise in the first image to obtain the second image may include:
acquiring a gray value of a pixel point of the first image;
taking a random gray value within a preset gray value range;
if the gray value of the pixel point of the first image is smaller than the random gray value, the gray value of the pixel point of the first image is reserved;
and if the gray value of the pixel point of the first image is not less than the random gray value, increasing the gray value of the pixel point of the first image.
Specifically, the first image is represented by a gray scale mode, in which the image is represented by a single tone, the color of one pixel is represented by eight bits, and 256 levels (color levels) of gray tones (including black and white) can be represented in total, that is, 256 lightness of gray. Thus, the preset gray scale value range can be represented by [0,255], representing the transition color level from black → gray → white. The first image is an 8-bit black and white image, i.e. each pixel of the first image is represented by eight bits, thus obtaining a grey value for each pixel of the first image. Assuming that the gray value of the current pixel point is v and the preset gray value range is [0,255], taking a random gray value t in the preset gray value range; if v is less than t, the gray value of the current pixel point is kept unchanged as v, namely the updated gray value v1 of the current pixel point is equal to v; if v is greater than or equal to t, increasing the gray value of the current pixel point, for example, the updated gray value v1 of the current pixel point is 1.1 × v +10, so that v1 and v are in a linear relationship.
For example, if the gray value v of the current pixel point is 45, the brightness of the current pixel point is darker, the random gray value t is 60, and v is less than t, then the updated gray value v1 of the current pixel point is 45, so that white noise is less at a darker position of the picture; if the gray value v of the current pixel point is 70, the brightness of the current pixel point is brighter, if the random gray value t is 60, v is greater than t, and the updated gray value v1 of the current pixel point is 1.1 v +10, 1.1 v 70+10, 87, so that the brighter position of the picture has more white noise and brighter white noise brightness. And after traversing each pixel point in the first image, updating the gray value of each pixel point so as to obtain a second image. As shown in fig. 3, after random white noise is added to the first image of fig. 2, a second image having many noise points thereon is obtained.
By adding random white noise to the first image, the second image is made to visually present a more bright local noise and a less bright local noise, so that a bright-dark stereoscopic impression is presented on the second image, that is, a relief is generated at a random position of the second image.
After obtaining the second image with the embossment generated at the random position, in order to make the second image smooth as a whole, i.e. the embossment (random white noise) is smooth, thereby realizing that the streamline pen touch feeling is generated at any position of the picture, the method may further comprise:
constructing a tangential flow graph corresponding to the first image, wherein the tangential flow graph comprises tangents corresponding to all pixel points in the first image;
and performing line integral convolution processing on each pixel point in the second image along the corresponding tangential direction to obtain a third image.
Specifically, an Edge directed Flow (ETF) graph needs to be constructed to perform a smoothing operation, which is Line Integral Convolution (LIC).
The LIC algorithm can effectively represent a two-dimensional vector field, can clearly and intuitively reflect the speed direction of each pixel point and can express the details of the vector field, and the LIC algorithm principle can be summarized as utilizing a one-dimensional low-pass convolution kernel to carry out convolution on white noise textures along the flow line direction in a bidirectional symmetrical mode to finally synthesize the vector textures. The streamline direction is the tangential direction of the application, the set of the tangential directions of all pixel points in the second image is a tangential flow graph, and the tangential flow graph can represent that each pixel point in the second image is subjected to line integral convolution processing in a specific mode, so that when the line integral convolution processing is carried out, a tool of the tangential flow graph needs to be constructed firstly.
Constructing a tangential flow graph corresponding to the first image, where the tangential flow graph includes tangents corresponding to respective pixel points in the first image, and may include:
extracting a second gradient map of the first image by using a gradient algorithm, wherein the second gradient map comprises a horizontal gradient and a vertical gradient corresponding to each pixel point in the first image;
constructing a structure tensor matrix of corresponding pixel points in the second gradient image according to the horizontal gradient and the vertical gradient corresponding to each pixel point in the first image;
calculating an eigenvalue of the structure tensor matrix to obtain an eigenvector corresponding to the structure tensor matrix;
taking the direction vertical to the feature vector as the tangential direction of each pixel point in the first image;
and calculating the tangential direction of each pixel point in the first image to obtain a tangential flow graph corresponding to the first image.
Specifically, first, a second gradient map of the first image is extracted by using a gradient algorithm, which may adopt a gradient algorithm such as Sobel (Sobel), to extract the second gradient map of the first image, that is, to extract a horizontal gradient (gradient in the x direction) g of each pixel point of the first imagexAnd a vertical gradient (gradient in the y-direction) gy. Then, according to the horizontal gradient g corresponding to each pixel point in the first imagexAnd a vertical gradient gyAnd constructing a structure tensor matrix of each pixel point of the second gradient map
Figure BDA0003528991260000091
And then calculating two eigenvalues of the structure tensor matrix by using the following formula 1:
Figure BDA0003528991260000092
wherein E ═ gx 2,F=gxgy,G=gy 2,λ1Taking the first eigenvalue of "+" for "+" in equation 1, λ2A second characteristic value of minus is taken for plus or minus in formula 1; thus, the first eigenvalue λ is obtained1>Second eigenvalue lambda2. Aiming at the current pixel point in the first image, the two corresponding feature vectors are respectively calculated by the following formula 2:
Figure BDA0003528991260000093
wherein, the feature vector v of the current pixel point1Greater than the feature vector v2Then will be associated with the feature vector v1The vertical direction is taken as the tangential direction of the current pixel point, and the straight line where the tangential direction is located can be calculated according to the following formula 3:
Figure BDA0003528991260000094
wherein, t1And t2The straight line on which the tangent lies is determined.
According to the tangential calculation mode, calculating the tangential direction of each pixel point of the first image, obviously, the tangential direction comprises the positive direction and the negative direction, combining the tangential direction of each pixel point to obtain a tangential flow graph corresponding to the first image, wherein the obtained tangential flow graph is shown in fig. 4, and the tangential flow graph comprises the tangential direction corresponding to each pixel point in the first image.
And after obtaining the tangential flow graph, obtaining the tangential direction of each pixel point in the tangential flow graph, and then performing line integral convolution processing on each pixel point in the second image along the corresponding tangential direction to obtain a third image.
Further, each pixel point in the second image is subjected to line integral convolution processing along the corresponding tangential direction, that is, convolution operation can be performed on any pixel point in the second image along the tangential direction corresponding to the pixel point, that is, weighted summation is performed on pixel points passing along the tangential direction corresponding to the pixel point, and the pixel value of the current pixel point is obtained. For example, if the convolution radius is 4, the tangential streamline length is 4, and then when the current pixel O is smoothed, the current pixel O is taken as a reference, and the tangential direction is taken as a direction, the other 4 pixels covered by the tangential streamline length are found, if the current tangential direction of the current pixel O is a horizontal direction, when the convolution operation is performed, the pixel a1 is found along the positive direction of the horizontal direction of the current pixel 0, and the pixel B1 is found in the opposite direction of the horizontal direction of the current pixel 0; then, the tangential direction of the pixel point a1 and the tangential direction of the pixel point B1 are determined, for example, the tangential direction of the pixel point a1 is the upper left side in the horizontal direction, and the tangential direction of the pixel point B1 is the upper right side in the horizontal direction, then, on the basis of the pixel point a1, the pixel point a2 is found along the upper left side in the horizontal direction of the pixel point a1, and the pixel point B2 is found along the upper right side in the horizontal direction of the pixel point B1, and so on, so as to obtain the current pixel point O, the tangential positive and negative directions of the tangential direction of the current pixel point 0 are respectively found, 4 pixel points covered by the curve with the tangential streamline length of 4 are respectively found, the current pixel point 0 is added, 9 pixel points are counted, and the weights of the 9 pixel points are obtained in the second image, and then the weights of the nine pixel points are weighted and summed, so as to obtain the smooth result of the current pixel point O.
The above-mentioned line integral convolution processing is repeatedly performed on each pixel point in the second image along the corresponding tangential direction, so as to realize the smoothing processing on the second image, as shown in fig. 5, after performing smoothing iteration on the second image for 2 times, a smoothing result is obtained as shown in fig. 5.
By smoothing the second image, the second image is smoothed as a whole and white noise is smoothed, so that a smooth relief can be obtained.
S103: and performing gradient extraction on the second image by using a gradient algorithm to obtain a first gradient map of the second image.
In this embodiment, the gradient algorithm is used to perform gradient extraction on the second image to obtain the second image in the first gradient map of the second image, which may be the smoothed second image (i.e., the third image) or the second image without being smoothed, and therefore, in essence, the gradient algorithm is used to perform gradient extraction on the smoothed second image (i.e., the third image) or the second image without being smoothed to obtain the first gradient map of the second image.
In one embodiment, as shown in fig. 5, the second image or the obtained smoothed second image (i.e. the third image) is a grayscale image, and another feature of the oil painting is that the edge of the object in the image is in relief, so that, in order to make the edge of the object in the second image or the third image in relief, performing gradient extraction on the second image or the third image by using a gradient algorithm to obtain the first gradient map of the second image or the third image may include:
obtaining a first convolution kernel according to the edge detection operator;
performing normalization processing on the first convolution kernel to obtain a second convolution kernel;
and performing convolution processing on the second image by using the second convolution kernel to obtain a first gradient map of the second image.
Specifically, commonly used edge detection operators include Roberts (Roberts) operator, Sobel (Sobel) operator, Laplace (Laplace) operator, and so on, wherein the Sobel operator is Sobel (Sobel) operator, and the Sobel operator is mainly used for edge detection, and in the edge detection technology, the Sobel operator is a discrete difference operator for calculating an approximate value of the gray scale of the image brightness function, and when the operator is used at any point of the image, a corresponding gray scale vector or a normal vector thereof will be generated. A first convolution kernel can be obtained according to the sobel operator, where the first convolution kernel is a convolution kernel with a kernel size r equal to 3, that is, a 3 × 3 matrix, and is shown as the following matrix 1:
-1 0 1
-2 0 2
-1 0 1
then, the first convolution kernel is normalized, that is, the sum of all positive terms in the matrix of the first convolution kernel is 1, and the sum of all negative terms is-1, so as to obtain a second convolution kernel, where the second convolution kernel is represented by the following matrix 2:
-0.25 0 0.25
-0.5 0 0.5
-0.25 0 0.25
then, performing convolution processing on the second image or the third image by using the second convolution kernel to obtain a first gradient map of the second image or the third image, specifically: and expressing the second image or the third image by using a matrix x to be processed, wherein the value of the matrix x to be processed is a pixel point of the second image or the third image, and performing convolution processing on the matrix x to be processed by using a second convolution kernel so as to extract a first gradient map of the second image or the third image (the smoothed second image).
In some embodiments, in order to make the relief of the object on the image appear in an oblique direction, the edge detection operator may be rotated by a first angle to obtain a first rotated convolution kernel, where the first angle may be 45 °, after the matrix 1 of the first convolution kernel is rotated by 45 °, the obtained first rotated convolution kernel is normalized to obtain a second convolution kernel, and the matrix x to be processed is convolved by the second convolution kernel, so as to extract the first gradient map of the second image or the third image (the smoothed second image). The third convolution kernel is shown as matrix 3 below:
-1.1875 -0.9209 0
-0.9209 0 0.9209
0 0.9209 1.1875
the edge detection operator is rotated by a first angle to obtain a first rotated convolution kernel, the first rotated convolution kernel is normalized to obtain a second convolution kernel, the kernel size of the first convolution kernel can be selected from other sizes, for example, r is 5, the thickness of the relief can be controlled, the first rotated convolution kernel is normalized to obtain a second convolution kernel, the second convolution kernel is used for performing convolution processing on the second image or the third image to obtain a first gradient map of the second image or the third image, and in the first gradient map shown in fig. 6, the edge of the object in the first gradient map can be seen to have the relief sense.
In some embodiments, after the gradient extracting the second image by using a gradient algorithm to obtain a first gradient map of the second image, the method further comprises:
and multiplying the gray value of each pixel point in the first gradient map by a constant larger than 1 to obtain the brightness gain of each pixel point in the first gradient map.
Specifically, in order to control the brightness of the embossment, a constant k is set, where k is greater than 1, for example, k is 4, the gray value of each pixel in the first gradient map is multiplied by k, and the obtained final gray value of each pixel is used as the final brightness gain, for example, if the gray value of the pixel p in the first gradient map is 20 and the gray value of 20 is multiplied by a constant k is 4, the obtained final gray value of 20 × 4 is 80, so that the final gray value image of the pixel p becomes 80, the gray values of other pixels are processed in the manner of the pixel p, and the obtained final first gradient map visually looks brighter relative to the first gradient map when the gray value of the pixel p is 20.
S104: and superposing the first gradient map on the image to be processed to obtain a target image with an oil painting style.
In some embodiments, the superimposing the first gradient map on the image to be processed to obtain the target image with the oil painting style may include:
acquiring pixel values of each color channel of each pixel point in the image to be processed;
and superposing the pixel value of each color channel of each pixel point and the brightness gain of the corresponding pixel point in the first gradient map to obtain a target image with an oil painting style.
Specifically, the pixel values of each color channel of each pixel point of the image to be processed are obtained, for example, the pixel values of the pixel point c in the R channel, the G channel, and the B channel are (10,20,30), and the luminance gain is +10, then, during the superposition, the pixel values are superposed on the R channel, the G channel, and the B channel, and the obtained pixel values are (10+10,20+10,30+10), so that the relief is superposed on the image to be processed, and the target image with stereoscopic impression as shown in fig. 7 is obtained.
In some embodiments, after the first gradient map is superimposed on the image to be processed according to the characteristics of full color and gorgeous color of the oil painting to obtain the target image with the oil painting style, the method may further include:
acquiring a first color channel pixel value, a second color channel pixel value and a third color channel pixel value of the target image;
searching a corresponding mapping value in a color lookup table according to the first color channel pixel value, the second color channel pixel value and the third color channel pixel value;
and updating the first color channel pixel value, the second color channel pixel value and the third color channel pixel value according to the mapping value.
Specifically, a first color channel pixel value, a second color channel pixel value, and a third color channel pixel value of the target image are obtained, the first color channel corresponds to an R channel, the second color channel corresponds to a G channel, and the third color channel corresponds to a B channel, for example, when the pixel values of three color channels in the target color are RGB (10,20,30), a mapping value corresponding to RGB (10,20,30) is looked up in the color lookup table, for example, when the mapping value is (20,20,30), the color of the target image is full and bright, then the first color channel pixel value, the second color channel pixel value, and the third color channel pixel value are updated according to the mapping value, so that the pixel values of three channels of the target image are updated to RGB (20,20, 30). As shown in fig. 8, a target image with a canvas style, which is full in color and bright in color, is obtained compared with the original image to be processed.
According to the embodiment of the application, the brightness component is extracted from the image to be processed to obtain the first image, then random white noise is added into the first image to obtain the second image, so that some embossments can be superposed on the random position on the image to be processed; according to the first image, smoothing the second image to obtain a third image, so that the image is smooth as a whole and white noise is smooth, and a smooth embossment is obtained; gradient extraction is carried out on the second image by utilizing a gradient algorithm to obtain a first gradient map of the second image, and the relief of the edge of the object in the image can be obtained; superposing the first gradient map on the image to be processed to obtain a target image with an oil painting style; the embossment is superposed at a random position in the image, and the edge of the object in the image is provided with the embossment, so that the target image has a stereoscopic impression, the oil painting style is vivid, the whole processing process is simple, and the calculation efficiency is high.
An embodiment of the present application further provides an oil painting stylization apparatus for an image, please refer to fig. 9, which shows a structure of the oil painting stylization apparatus for an image according to the embodiment of the present application, where the oil painting stylization apparatus 900 for an image includes:
an extracting module 901, configured to extract a luminance component from an image to be processed to obtain a first image;
an adding module 902, configured to add random white noise to the first image to obtain a second image;
a gradient extraction module 903, configured to perform gradient extraction on the second image by using a gradient algorithm to obtain a first gradient map of the second image;
and an overlaying module 904, configured to overlay the first gradient map on the image to be processed, so as to obtain a target image with an oil painting style.
According to the embodiment of the application, the brightness component is extracted from the image to be processed to obtain the first image, then random white noise is added into the first image to obtain the second image, so that some embossments can be superposed on the random position on the image to be processed; according to the first image, smoothing the second image to obtain a third image, so that the image is smooth as a whole and white noise is smooth, and a smooth embossment is obtained; gradient extraction is carried out on the second image by utilizing a gradient algorithm to obtain a first gradient map of the second image, and the relief of the edge of the object in the image can be obtained; superposing the first gradient map on the image to be processed to obtain a target image with an oil painting style; the embossment is superposed at a random position in the image, and the edge of the object in the image is provided with the embossment, so that the target image has a stereoscopic impression, the oil painting style is vivid, the whole processing process is simple, and the calculation efficiency is high.
In some embodiments, the apparatus 900 further comprises a smoothing module 905 further configured to:
constructing a tangential flow graph corresponding to the first image, wherein the tangential flow graph comprises tangents corresponding to all pixel points in the first image;
and performing line integral convolution processing on each pixel point in the second image along the corresponding tangential direction to obtain a third image.
In some embodiments, the smoothing module 905 is further configured to:
extracting a second gradient map of the first image by using a gradient algorithm, wherein the second gradient map comprises a horizontal gradient and a vertical gradient which correspond to each pixel point in the first image;
constructing a structure tensor matrix of corresponding pixel points in the second gradient image according to the horizontal gradient and the vertical gradient corresponding to each pixel point in the first image;
calculating an eigenvalue of the structure tensor matrix to obtain an eigenvector corresponding to the structure tensor matrix;
taking the direction vertical to the feature vector as the tangential direction of each pixel point in the first image;
and calculating the tangential direction of each pixel point in the first image to obtain a tangential flow graph corresponding to the first image.
In some embodiments, the gradient extraction module 903 is further configured to:
obtaining a first convolution kernel according to the edge detection operator;
performing normalization processing on the first convolution kernel to obtain a second convolution kernel;
and performing convolution processing on the third image by using the second convolution kernel to obtain a first gradient map of the third image.
In some embodiments, the gradient extraction module 903 is further configured to:
and rotating the edge detection operator by a first angle to obtain a first convolution kernel.
In some embodiments, as shown in fig. 10, the oil painting stylization apparatus 900 of the image further includes a gain module 906 for:
and multiplying the gray value of each pixel point in the first gradient map by a constant larger than 1 to obtain the brightness gain of each pixel point in the first gradient map.
In some embodiments, the overlay module 904 is further configured to:
acquiring pixel values of each color channel of each pixel point in the image to be processed;
and superposing the pixel value of each color channel of each pixel point and the brightness gain of the corresponding pixel point in the first gradient map to obtain a target image with an oil painting style.
In some embodiments, as shown in fig. 10, the oil painting stylization apparatus 900 of the image further comprises a look-up table module 907 for:
acquiring a first color channel pixel value, a second color channel pixel value and a third color channel pixel value of the target image;
searching a corresponding mapping value in a color lookup table according to the first color channel pixel value, the second color channel pixel value and the third color channel pixel value;
and updating the first color channel pixel value, the second color channel pixel value and the third color channel pixel value according to the mapping value.
It should be noted that the above-mentioned apparatus can execute the method provided by the embodiments of the present application, and has corresponding functional modules and beneficial effects for executing the method. For technical details which are not described in detail in the device embodiments, reference is made to the methods provided in the embodiments of the present application.
Fig. 11 is a schematic diagram of a hardware structure of a controller in an embodiment of an electronic device, as shown in fig. 11, the controller includes:
one or more processors 111, memory 112. Fig. 11 illustrates one processor 111 and one memory 112.
The processor 111 and the memory 112 may be connected by a bus or other means, and fig. 11 illustrates the connection by the bus as an example.
The memory 112, as a non-volatile computer-readable storage medium, may be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as program instructions/modules corresponding to the oil painting stylization method of the image in the embodiment of the present application (for example, the extracting module 901, the adding module 902, the gradient extracting module 903, the superimposing module 904, the smoothing module 905, the gain module 906, and the table look-up module 907 shown in fig. 9 to 10). The processor 111 executes various functional applications of the controller and data processing, i.e., the oil painting stylizing method of the image of the above-described method embodiment, by running the nonvolatile software program, instructions, and modules stored in the memory 112.
The memory 112 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to use of the person entry and exit detection apparatus, and the like. Further, the memory 112 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some embodiments, the memory 112 may optionally include memory located remotely from the processor 111, which may be connected to the electronic device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The one or more modules are stored in the memory 112 and, when executed by the one or more processors 111, perform the method for oil stylizing an image in any of the above-described method embodiments, e.g., performing the above-described method steps S101-S104 of fig. 1; the functions of the modules 901 and 907 in fig. 9-10 are implemented.
The product can execute the method provided by the embodiment of the application, and has the corresponding functional modules and beneficial effects of the execution method. For technical details that are not described in detail in this embodiment, reference may be made to the methods provided in the embodiments of the present application.
Embodiments of the present application provide a non-transitory computer-readable storage medium, which stores computer-executable instructions, which are executed by one or more processors, such as one processor 111 in fig. 11, and enable the one or more processors to perform the oil painting stylizing method of an image in any of the above method embodiments, for example, performing the above-described method steps S101 to S104 in fig. 1; the functions of modules 901-907 in fig. 9-10 are implemented.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
Through the above description of the embodiments, those skilled in the art will clearly understand that the embodiments may be implemented by software plus a general hardware platform, and may also be implemented by hardware. It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware related to instructions of a computer program, which can be stored in a computer readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, and not to limit it; within the idea of the invention, also technical features in the above embodiments or in different embodiments may be combined, steps may be implemented in any order, and there are many other variations of the different aspects of the invention as described above, which are not provided in detail for the sake of brevity; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.

Claims (11)

1. A method of stylizing an oil painting of an image, the method comprising:
extracting a brightness component from an image to be processed to obtain a first image;
adding random white noise in the first image to obtain a second image;
performing gradient extraction on the second image by using a gradient algorithm to obtain a first gradient map of the second image;
and superposing the first gradient map on the image to be processed to obtain a target image with an oil painting style.
2. The method of claim 1, wherein after the obtaining the second image, before performing gradient extraction on the second image by using a gradient algorithm to obtain the first gradient map of the second image, the method further comprises:
constructing a tangential flow graph corresponding to the first image, wherein the tangential flow graph comprises tangents corresponding to all pixel points in the first image;
and performing line integral convolution processing on each pixel point in the second image along the corresponding tangential direction to obtain a third image.
3. The method of claim 2, wherein constructing a tangential flow graph corresponding to the first image, the tangential flow graph including tangents to respective pixel points in the first image comprises:
extracting a second gradient map of the first image by using a gradient algorithm, wherein the second gradient map comprises a horizontal gradient and a vertical gradient corresponding to each pixel point in the first image;
constructing a structure tensor matrix of corresponding pixel points in the second gradient image according to the horizontal gradient and the vertical gradient corresponding to each pixel point in the first image;
calculating an eigenvalue of the structure tensor matrix to obtain an eigenvector corresponding to the structure tensor matrix;
taking the direction vertical to the feature vector as the tangential direction of each pixel point in the first image;
and calculating the tangential direction of each pixel point in the first image to obtain a tangential flow graph corresponding to the first image.
4. The method of claim 1, wherein the performing gradient extraction on the second image by using a gradient algorithm to obtain a first gradient map of the second image comprises:
obtaining a first convolution kernel according to the edge detection operator;
performing normalization processing on the first convolution kernel to obtain a second convolution kernel;
and performing convolution processing on the second image by using the second convolution kernel to obtain a first gradient map of the second image.
5. The method of claim 4, wherein obtaining the first convolution kernel according to the edge detection operator comprises:
and rotating the edge detection operator by a first angle to obtain a first convolution kernel.
6. The method of claim 1, wherein after the gradient extracting the second image by using a gradient algorithm to obtain a first gradient map of the second image, the method further comprises:
and multiplying the gray value of each pixel point in the first gradient map by a constant larger than 1 to obtain the brightness gain of each pixel point in the first gradient map.
7. The method according to claim 1, wherein the superimposing the first gradient map on the image to be processed to obtain the target image with the oil painting style comprises:
acquiring pixel values of each color channel of each pixel point in the image to be processed;
and superposing the pixel value of each color channel of each pixel point and the brightness gain of the corresponding pixel point in the first gradient map to obtain a target image with an oil painting style.
8. The method according to any one of claims 1 to 7, wherein after the superimposing the first gradient map on the image to be processed to obtain the target image with oil painting style, the method further comprises:
acquiring a first color channel pixel value, a second color channel pixel value and a third color channel pixel value of the target image;
searching a corresponding mapping value in a color lookup table according to the first color channel pixel value, the second color channel pixel value and the third color channel pixel value;
and updating the first color channel pixel value, the second color channel pixel value and the third color channel pixel value according to the mapping value.
9. An apparatus for stylizing an oil painting of an image, the apparatus comprising:
the extraction module is used for extracting a brightness component from an image to be processed to obtain a first image;
the adding module is used for adding random white noise in the first image to obtain a second image;
the gradient extraction module is used for carrying out gradient extraction on the second image by utilizing a gradient algorithm to obtain a first gradient map of the second image;
and the superposition module is used for superposing the first gradient map on the image to be processed to obtain a target image with an oil painting style.
10. An electronic device, characterized in that the electronic device comprises:
at least one processor, and
a memory communicatively coupled to the processor, the memory storing instructions executable by the at least one processor to enable the at least one processor to perform the method of any of claims 1-8.
11. A non-transitory computer-readable storage medium having stored thereon computer-executable instructions that, when executed by an electronic device, cause the electronic device to perform the method of any of claims 1-8.
CN202210200113.0A 2022-03-02 2022-03-02 Oil painting stylization method, device, equipment and medium for image Pending CN114612355A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210200113.0A CN114612355A (en) 2022-03-02 2022-03-02 Oil painting stylization method, device, equipment and medium for image

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210200113.0A CN114612355A (en) 2022-03-02 2022-03-02 Oil painting stylization method, device, equipment and medium for image

Publications (1)

Publication Number Publication Date
CN114612355A true CN114612355A (en) 2022-06-10

Family

ID=81860151

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210200113.0A Pending CN114612355A (en) 2022-03-02 2022-03-02 Oil painting stylization method, device, equipment and medium for image

Country Status (1)

Country Link
CN (1) CN114612355A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103489204A (en) * 2013-05-15 2014-01-01 许昌学院 Method for automatically drawing two-dimensional color pencil drawings
CN103914862A (en) * 2014-03-10 2014-07-09 上海大学 Pencil sketch simulating method based on edge tangent stream
CN106709964A (en) * 2016-12-06 2017-05-24 河南工业大学 Gradient correction and multi-direction texture extraction-based sketch generation method and device
CN107038708A (en) * 2017-04-21 2017-08-11 西安电子科技大学 Application of the image recognition algorithm in paper-cut effect
CN110675463A (en) * 2019-08-23 2020-01-10 河南工业大学 Local color pencil drawing generation method and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103489204A (en) * 2013-05-15 2014-01-01 许昌学院 Method for automatically drawing two-dimensional color pencil drawings
CN103914862A (en) * 2014-03-10 2014-07-09 上海大学 Pencil sketch simulating method based on edge tangent stream
CN106709964A (en) * 2016-12-06 2017-05-24 河南工业大学 Gradient correction and multi-direction texture extraction-based sketch generation method and device
CN107038708A (en) * 2017-04-21 2017-08-11 西安电子科技大学 Application of the image recognition algorithm in paper-cut effect
CN110675463A (en) * 2019-08-23 2020-01-10 河南工业大学 Local color pencil drawing generation method and device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
张亚莉: "中国油画的民族化研究", 31 March 2019, 北京工业大学出版社, pages: 29 - 30 *
霍文英等: "基于光照方向的图像浮雕生成算法", 武汉轻工大学学报, vol. 36, no. 4, 31 December 2017 (2017-12-31), pages 54 - 58 *

Similar Documents

Publication Publication Date Title
CN105915909B (en) A kind of high dynamic range images layered compression method
CN107369133B (en) Face image beautifying method and device
EP3409006A1 (en) Unified multi-image fusion approach
Sidike et al. Adaptive trigonometric transformation function with image contrast and color enhancement: Application to unmanned aerial system imagery
Hessel et al. An extended exposure fusion and its application to single image contrast enhancement
CN107665482B (en) Video data real-time processing method and device for realizing double exposure and computing equipment
CN108027961A (en) Method and apparatus for inverse tone mapping (ITM)
CN110298812B (en) Image fusion processing method and device
JP2021531571A (en) Certificate image extraction method and terminal equipment
Liu et al. Image contrast enhancement based on intensity expansion-compression
CN108230256A (en) Image processing method, device, computer installation and computer readable storage medium
CN113039576A (en) Image enhancement system and method
CN108024105A (en) Image color adjusting method, device, electronic equipment and storage medium
CN111489322A (en) Method and device for adding sky filter to static picture
Lee et al. Correction of the overexposed region in digital color image
Parihar et al. A comprehensive analysis of fusion-based image enhancement techniques
CN115082328A (en) Method and apparatus for image correction
CN113963007A (en) Image processing method and device
CN117496019A (en) Image animation processing method and system for driving static image
Zhao et al. Learning tone curves for local image enhancement
CN114612355A (en) Oil painting stylization method, device, equipment and medium for image
CN111127618A (en) Texture toning method and device during real-time rendering
Vazquez-Corral et al. Angular-based preprocessing for image denoising
CN113781330B (en) Image processing method, device and electronic system
CN107464273B (en) Method and device for realizing image style brush

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