CN110473272B - Oil painting generation method and device based on image, electronic equipment and storage medium - Google Patents

Oil painting generation method and device based on image, electronic equipment and storage medium Download PDF

Info

Publication number
CN110473272B
CN110473272B CN201910772674.6A CN201910772674A CN110473272B CN 110473272 B CN110473272 B CN 110473272B CN 201910772674 A CN201910772674 A CN 201910772674A CN 110473272 B CN110473272 B CN 110473272B
Authority
CN
China
Prior art keywords
pen
image
touch
processed
importance
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.)
Active
Application number
CN201910772674.6A
Other languages
Chinese (zh)
Other versions
CN110473272A (en
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.)
Xiamen Meitu Technology Co Ltd
Original Assignee
Xiamen Meitu 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 Xiamen Meitu Technology Co Ltd filed Critical Xiamen Meitu Technology Co Ltd
Priority to CN201910772674.6A priority Critical patent/CN110473272B/en
Publication of CN110473272A publication Critical patent/CN110473272A/en
Application granted granted Critical
Publication of CN110473272B publication Critical patent/CN110473272B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/048Interaction techniques based on graphical user interfaces [GUI]
    • G06F3/0487Interaction techniques based on graphical user interfaces [GUI] using specific features provided by the input device, e.g. functions controlled by the rotation of a mouse with dual sensing arrangements, or of the nature of the input device, e.g. tap gestures based on pressure sensed by a digitiser
    • G06F3/0488Interaction techniques based on graphical user interfaces [GUI] using specific features provided by the input device, e.g. functions controlled by the rotation of a mouse with dual sensing arrangements, or of the nature of the input device, e.g. tap gestures based on pressure sensed by a digitiser using a touch-screen or digitiser, e.g. input of commands through traced gestures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/001Texturing; Colouring; Generation of texture or colour
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/20Drawing from basic elements, e.g. lines or circles
    • G06T11/203Drawing of straight lines or curves

Abstract

The application provides an oil painting generation method and device based on an image, electronic equipment and a storage medium, and relates to the technical field of image processing. The method comprises the steps of obtaining a direction field diagram of an image to be processed, and determining the direction of an oil painting drawing pen touch of the image to be processed according to the direction field diagram; the method comprises the steps of obtaining an importance graph of an image to be processed, determining at least one pen-touch pen-down point and at least one pen-touch size of the image to be processed according to the importance graph, further selecting corresponding pen-touch colors according to the determined pen-touch size, performing pen-touch from the determined pen-touch pen-down point, drawing along the pen-touch direction to generate an oil painting image corresponding to the image to be processed, and being capable of being adapted to the generation of the oil painting image in various scenes.

Description

Oil painting generation method and device based on image, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of image processing technologies, and in particular, to a method and an apparatus for generating an oil painting based on an image, an electronic device, and a storage medium.
Background
As users put more and more demands on the diversification processing and the post-vision special effect of photos, in addition to the traditional image processing, there are also higher demands on the stylization of pictures, and common stylization includes: the method comprises the steps of filter processing, seasonal/scene processing, artistic processing and the like, wherein one common artistic processing is to change the effect of a photo into a painting style, including various painting styles such as crayons, colored pastels, watercolors, light colors and the like, and because the emphasis points of style functions are different, the algorithm logics of the various styles are completely different.
In the prior art, the overall logic of painting style processing is to analyze an input picture by using a stylization algorithm, and finally present a painting effect generated by stylizing a photo in front of a user by analyzing a pen drop according to the habit and preference of painters.
However, the existing stylization algorithm has a relatively ideal effect only by drawing certain fixed types of input, and the application scene is relatively limited.
Disclosure of Invention
An object of the present application is to provide an image-based oil painting generation method, apparatus, electronic device and storage medium, which can solve the problem in the prior art that an application scene is relatively limited when a corresponding oil painting image is generated based on an image, in order to overcome the disadvantages in the prior art.
In order to achieve the above purpose, the technical solutions adopted in the embodiments of the present application are as follows:
in a first aspect, an embodiment of the present application provides an oil painting generation method based on an image, including:
acquiring a direction field diagram of an image to be processed, and determining the direction of drawing a brush stroke of an oil painting of the image to be processed according to the direction field diagram; acquiring a significance diagram of an image to be processed, and determining at least one stroke drop point and at least one stroke size of the image to be processed according to the significance diagram, wherein the significance diagram represents the significance degree of each pixel point in the image to be processed; and generating an oil painting image corresponding to the image to be processed according to the direction of the pen touch, the at least one pen touch point, the at least one pen touch size and the pen touch color corresponding to each pen touch point.
Optionally, the obtaining of the importance map of the image to be processed includes: calculating and acquiring the importance value of each pixel point in the image to be processed according to the partial derivative of each pixel point in the image to be processed in the preset direction; and generating an importance graph of the image to be processed according to the importance value of each pixel point in the image to be processed.
Optionally, the determining at least one stroke size and at least one stroke pen point of the image to be processed according to the importance map includes: carrying out normalization and histogram equalization processing on the importance map to obtain a preprocessed importance map; and determining areas to be drawn associated with different importance values in the image to be processed, at least one pen-touch pen-down point and at least one pen-touch size corresponding to each area to be drawn according to the preprocessed importance graph and a preset algorithm.
Optionally, the determining, according to the preprocessed importance map and a preset algorithm, to-be-drawn regions associated with different importance values in the to-be-processed image, and at least one pen-touch pen-down point and at least one pen-touch size corresponding to each to-be-drawn region includes: according to the sequence of the importance values from low to high, obtaining a drawing area associated with the importance values, and at least one pen-touch pen-down point and at least one pen-touch size corresponding to the area to be drawn;
correspondingly, according to a stroke direction, at least one stroke point, at least one stroke size and the corresponding stroke color of each stroke point, generate the oil painting image corresponding to the image to be processed, including: and generating an oil painting image corresponding to the area to be drawn according to at least one pen touch pen-down point and at least one pen touch size corresponding to the area to be drawn and the pen touch color corresponding to each pen touch pen-down point.
Optionally, before generating the oil painting image corresponding to the image to be processed according to the direction of the pen touch, the at least one pen touch point, the at least one size of the pen touch, and the color of the pen touch corresponding to each pen touch point, the method further includes: and receiving a color matching instruction, wherein the color matching instruction comprises pen touch color information corresponding to the pen touch pen-down point.
In a second aspect, an embodiment of the present application provides an oil painting generation apparatus based on an image, including: the device comprises a first determining module, a second determining module and a generating module.
The first determining module is used for acquiring a direction field diagram of the image to be processed and determining the direction of drawing strokes of the oil painting of the image to be processed according to the direction field diagram; the second determining module is used for acquiring a significance map of the image to be processed and determining at least one stroke-down stroke point and at least one stroke size of the image to be processed according to the significance map, wherein the significance map represents the significance degree of each pixel point in the image to be processed; and the generating module is used for generating an oil painting image corresponding to the image to be processed according to the direction of the pen touch, the at least one pen touch point, the at least one pen touch size and the pen touch color corresponding to each pen touch point.
Optionally, the second determining module is specifically configured to calculate and obtain an importance value of each pixel point in the image to be processed according to a partial derivative of each pixel point in the image to be processed in a preset direction; and generating an importance graph of the image to be processed according to the importance value of each pixel point in the image to be processed.
Optionally, the second determining module is specifically configured to perform normalization and histogram equalization on the importance map, and obtain a preprocessed importance map; and determining areas to be drawn related to different importance values in the image to be processed, at least one pen-touch pen-down point and at least one pen-touch size corresponding to each area to be drawn according to the preprocessed importance graph and a preset algorithm.
Optionally, the second determining module is specifically configured to obtain, according to the order from low to high of the importance value, a drawing area associated with the importance value, at least one pen-touch-down point and at least one pen-touch size corresponding to the area to be drawn;
correspondingly, the generating module is specifically configured to generate the oil painting image corresponding to the area to be drawn according to at least one pen-touch pen-down point and at least one pen-touch size corresponding to the area to be drawn and the pen-touch color corresponding to each pen-touch pen-down point.
Optionally, the apparatus further comprises: and the receiving module is used for receiving a color matching instruction, and the color matching instruction comprises pen touch color information corresponding to the pen touch pen-down point.
In a third aspect, an embodiment of the present application provides an electronic device, including: the image-based oil painting generation method comprises a processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, when the electronic device runs, the processor and the storage medium communicate through the bus, and the processor executes the machine-readable instructions to execute the steps of the image-based oil painting generation method of the first aspect.
In a fourth aspect, an embodiment of the present application provides a storage medium, where a computer program is stored on the storage medium, and when the computer program is executed by a processor, the steps of the image-based oil painting generation method according to the first aspect are executed.
The beneficial effect of this application is:
in the method, the device, the electronic equipment and the storage medium for generating the oil painting based on the image, the direction field diagram of the image to be processed is obtained, and the direction of the oil painting of the image to be processed as the painting brush stroke is determined according to the direction field diagram; the method comprises the steps of obtaining an importance graph of an image to be processed, determining at least one pen-touch pen-down point and at least one pen-touch size of the image to be processed according to the importance graph, further selecting corresponding pen-touch colors according to the determined pen-touch size, performing pen-touch from the determined pen-touch pen-down point, drawing along the pen-touch direction to generate an oil painting image corresponding to the image to be processed, and being capable of being adapted to the generation of the oil painting image in various scenes.
Drawings
To more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and those skilled in the art can also obtain other related drawings based on the drawings without inventive efforts.
Fig. 1 is a schematic flowchart of a method for generating an oil painting based on an image according to an embodiment of the present disclosure;
fig. 2 is a schematic flowchart of another image-based oil painting generation method according to an embodiment of the present disclosure;
fig. 3 is a schematic flowchart of another image-based oil painting generation method according to an embodiment of the present disclosure;
fig. 4 is a schematic flowchart of another image-based oil painting generation method according to an embodiment of the present disclosure;
fig. 5 is a schematic flowchart of another image-based oil painting generation method according to an embodiment of the present disclosure;
fig. 6 is a schematic structural diagram of an oil painting generation apparatus based on an image according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of another image-based oil painting generation apparatus provided in the embodiment of the present application;
fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. The components of the embodiments of the present application, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the present application, presented in the accompanying drawings, is not intended to limit the scope of the claimed application, but is merely representative of selected embodiments of the application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
Fig. 1 is a schematic flowchart of a method for generating an oil painting based on an image according to an embodiment of the present application, where an execution subject of the method may be a device that can perform data processing, such as a computer, a server, a processor, and a mobile terminal, as shown in fig. 1, the method includes:
s101, obtaining a direction field diagram of the image to be processed, and determining the direction of the oil painting drawing brush strokes of the image to be processed according to the direction field diagram.
The image to be processed may be obtained by shooting through a photographing function, or may be imported through an importing manner, and the obtained image to be processed may be an image of any scene, for example, a landscape photograph, a portrait photograph, an animal photograph, and the like.
The direction field diagram of the image to be processed is used for guiding the direction of the brush stroke of the oil painting, namely the trend of the brush stroke. The direction field image can be obtained by similar gradient operators, for example, by referring to the pixel points in a certain range of each pixel point, the gradient of the pixel point is judged and global smoothing is performed, and the direction field image of the image to be processed can be obtained. The gradient of the current pixel point is usually determined by the partial derivatives of the coordinate corresponding to the current pixel point in the x-axis and y-axis directions. For example, taking the partial derivative of the pixel point a (x 1, y 1) in the x direction as an example, the simplest manner is to refer to two left and right points B (x 1-1, y 1) and C (x 1+1, y 1) of the pixel point a (x 1, y 1), and the luminance values L = Image (x 1-1, y 1) and R = Image (x 1+1, y 1) of the two left and right points are calculated respectively, that is, the partial derivative of the pixel point a (x 1, y 1) in the x direction is (R-L)/2, where Image (x, y) may be a luminance function of the Image to be processed, and similarly, the partial derivative of the pixel point a (x 1, y 1) in the y direction may also be obtained by referring to the above calculation, and this application is not described herein again. Of course, according to actual needs, more reference points may be sampled to calculate the partial derivative of the point, and the application is not limited herein.
After partial derivatives Fx and Fy of each pixel point in the x direction and the y direction are calculated in a similar mode, vectors (Fx and Fy) are the directions of each pixel point, then the Fx and the Fy are respectively subjected to Gaussian blur smoothing in a certain area, drying operation is carried out, the Fx and the Fy at each pixel point of the full image can be obtained, and then the direction field image corresponding to the full image can be obtained.
Of course, in the process of acquiring the direction field diagram of the image to be processed, parameters in the direction field may also be adjusted according to the needs of the actual application scenario, for example, a relatively orderly direction field, or a relatively disordered and arbitrary direction field may be generated by adjusting according to the preference of the user.
S102, obtaining a significance map of the image to be processed, and determining at least one stroke-down point and at least one stroke size of the image to be processed according to the significance map, wherein the significance map represents the significance degree of each pixel point in the image to be processed.
For example, when the image to be processed is a portrait, the background and the flat area may be "unimportant" areas in the image to be processed, and the area with much details or including a human face may be "important" areas in the image to be processed. The stroke falling point and the stroke size are related to the importance degree of each pixel point, each importance degree can correspond to one stroke size, and the higher the importance degree is, the smaller the radius of the corresponding stroke size is; the lower the importance degree, the larger the radius of the corresponding stroke size, that is, for the "unimportant" area, the large stroke may be selected to be painted in large blocks, and for the "important" area, the small stroke should be selected to be drawn finely.
It should be noted that the stroke size corresponding to each importance degree may be preset, and after the importance degree of each pixel is determined, the stroke size of each corresponding pixel is also determined. Of course, according to the needs of the user, the material set of the brush strokes may also be set by itself to simulate different brush stroke styles, for example, the drawing size may be selected to be larger overall to simulate an oil painting of rough wind, or smaller overall to simulate an oil painting of fine wind, which is not limited herein.
Optionally, when determining the stroke size and the stroke size of the to-be-processed image, the first stroke size, the second stroke size, the third stroke size, and the like corresponding to each of the strokes may be sequentially determined according to the importance degree of each pixel point in the to-be-processed image from low to high, where the first stroke size is greater than the second stroke size, and the second stroke size is greater than the third stroke size.
In addition, the importance degree of each pixel point may be represented by a numerical value, but not limited thereto, may also be represented by a predetermined letter, character string, or the like.
S103, generating an oil painting image corresponding to the image to be processed according to the direction of the pen touch, the at least one pen touch point, the at least one pen touch size and the pen touch color corresponding to each pen touch point.
After each stroke pen-down point is determined, the color of the pixel point at the pen-down center position of each stroke pen-down point can be used as the corresponding stroke color, and according to the determined stroke size and the corresponding stroke color, the oil painting image corresponding to the image to be processed can be generated by drawing along the stroke direction from the determined stroke pen-down point. The color of the pixel point at the center of the pen-down point of each pen-down stroke is used as the corresponding pen-down color, that is, the color of the pixel point at the corresponding position in the image to be processed is determined as the corresponding pen-down color of the pen-down point of the pen-down stroke.
It should be noted that when a plurality of pen-touch pen-down points are included, the pen-touch pen-down point, the pen-touch size, the pen-touch direction and the pen-touch color corresponding to each pen-touch pen-down point corresponding to the area with the lowest importance degree are selected first to perform drawing, after each pen-touch is completed, the area with the lowest importance is continuously searched in the remaining area to be drawn, the pen-touch pen-down point, the pen-touch size, the pen-touch direction and the pen-touch color corresponding to each pen-touch pen-down point are selected to perform drawing until the area to be drawn does not exist, and the oil-painting image corresponding to the image to be processed can be generated.
In addition, it should be noted that the above steps can be processed in RGB channels, and for the image to be processed, according to the steps S101 and S102, it can be realized that all the pen-touch points, the pen-touch sizes, the pen-touch directions, and the pen-touch order are calculated, and when drawing is performed subsequently, it is not necessary to calculate again, and it is only necessary to draw in sequence according to the previously calculated parameters, so that the oil painting image corresponding to the image to be processed can be generated, and the speed of generating the oil painting based on the image can be effectively increased.
In summary, the method for generating the oil painting based on the image, provided by the application, includes the steps of obtaining a direction field diagram of an image to be processed, and determining an oil painting stroke direction of the image to be processed according to the direction field diagram; the method comprises the steps of obtaining an importance graph of an image to be processed, determining at least one pen-touch pen-down point and at least one pen-touch size of the image to be processed according to the importance graph, further selecting corresponding pen-touch colors according to the determined pen-touch size, performing pen-touch from the determined pen-touch pen-down point, drawing along the pen-touch direction to generate an oil painting image corresponding to the image to be processed, and being capable of being adapted to the generation of the oil painting image in various scenes.
Fig. 2 is a schematic flow chart of another image-based oil painting generation method according to an embodiment of the present application. Optionally, as shown in fig. 2, the obtaining of the importance map of the image to be processed includes:
s201, calculating and acquiring the importance value of each pixel point in the image to be processed according to the partial derivative of each pixel point in the image to be processed in the preset direction.
The importance graph represents the importance degree of each pixel point in the image to be processed, the importance value of each pixel point can be used for measuring, the higher the importance degree is, the larger the corresponding importance value is, the lower the importance degree is, and the smaller the corresponding importance value is. The importance value of each pixel point can be determined by calculating the partial derivative of each pixel point in the preset direction, optionally, for each pixel point, the partial derivatives of each pixel point in the transverse and longitudinal directions with the step length of 1, 2, 4 and 8 can be calculated, then the absolute values of the 8 partial derivatives are summed, and the calculated value can be used as the importance value of each pixel point.
Of course, the calculation mode of the importance value of each pixel point is not limited in the present application, and other algorithms may be selected to implement the calculation according to the actual application scenario.
S202, generating an importance graph of the image to be processed according to the importance value of each pixel point in the image to be processed.
After the importance value of each pixel point is obtained through calculation, the importance value of each pixel point can be mapped to an image, so that an importance graph of an image to be processed can be generated, and when a corresponding oil painting image is generated according to the importance graph, the generated oil painting image material is strong in repeatability, weak in layering and closer to the real painting process of the oil painting.
Fig. 3 is a schematic flow chart of another image-based oil painting generation method according to an embodiment of the present application. Optionally, after obtaining the importance map, in order to ensure that the distribution of the number of strokes is substantially uniform for different sizes of the image to be processed, and to prevent the occurrence of only large strokes for a relatively flat image to be processed or only small strokes for a detail-rich image to be processed, as shown in fig. 3, the determining at least one stroke landing point and at least one stroke size for the image to be processed according to the importance map includes:
s301, normalization and histogram equalization processing are carried out on the significance map, and the preprocessed significance map is obtained.
S302, determining areas to be drawn related to different importance values in the image to be processed, at least one pen-touch pen-down point corresponding to each area to be drawn and at least one pen-touch size according to the preprocessed importance graph and a preset algorithm.
The importance map can be normalized first and then subjected to histogram equalization, so that the preprocessed importance map can be obtained. Alternatively, the preset algorithm may be a poisson circle distribution, the distribution of each pixel point in the preprocessed importance map may be calculated according to the poisson circle distribution, and according to the distribution of each pixel point, for an important region (a region with a larger importance value), the pen-touch pen-down points may be more densely collected, for an unimportant region (a region with a smaller importance value), the method comprises the following steps that points can be picked and dropped by a pen touch, namely, each point is thrown, according to the importance of the point, a radius which is in negative correlation with the importance is defined, and other points are not allowed to appear in the radius range of the point, so that the result that the area points with high importance are looser than the area points with dense and low importance can be obtained; in addition, according to the importance of the point, the size of the brush stroke corresponding to the point is also determined.
It should be noted that the to-be-rendered areas associated with different importance values refer to-be-rendered areas of the to-be-processed image corresponding to different importance values. Of course, the preset algorithm is not limited in this application, and may be selected by the user according to the actual application scenario.
Fig. 4 is a schematic flow chart of another image-based oil painting generation method according to an embodiment of the present application. Optionally, as shown in fig. 4, the determining, according to the preprocessed importance map and a preset algorithm, to-be-drawn regions associated with different importance values in the to-be-processed image, and at least one pen-touch drop point and at least one pen-touch size corresponding to each to-be-drawn region includes:
s401, according to the sequence of the importance values from low to high, a drawing area associated with the importance values, at least one pen-touch pen-down point corresponding to the area to be drawn and at least one pen-touch size are obtained.
Optionally, according to the importance values of the pixel points in the preprocessed importance graph, the regions to be drawn associated with different importance values, and at least one pen-touch pen-down point and at least one pen-touch size corresponding to the regions to be drawn may be obtained in the order from low to high of the importance values.
Correspondingly, according to a stroke direction, at least one stroke point, at least one stroke size and the corresponding stroke color of each stroke point, generate the oil painting image corresponding to the image to be processed, including:
s402, generating an oil painting image corresponding to the area to be drawn according to at least one pen touch pen-down point and at least one pen touch size corresponding to the area to be drawn and the pen touch color corresponding to each pen touch pen-down point.
When the oil painting image corresponding to the image to be processed is generated, the importance graph is used as a hierarchy, and the area to be drawn of the corresponding image to be processed is reduced after one stroke from the area with the lowest importance.
When drawing is carried out on the area to be drawn, the pen touch down point, the pen touch size, the pen touch direction and the pen touch color corresponding to the pen touch down point which is corresponding to the area with the lowest importance degree in the area to be drawn are selected to draw, wherein the pen touch color is adjusted to be the color consistent with the pen touch down center, after each stroke is finished, the area with the lowest importance degree is continuously searched in the rest area to be drawn, the pen touch down point, the pen touch size, the pen touch direction and the pen touch color corresponding to the pen touch down point are selected to draw, the steps of S401 and S402 are repeatedly executed, in the whole drawing process, the importance degree of the pen touch down point is high, the pen touch size is smaller and smaller, each pen touch only can influence the area with the importance degree not exceeding the pen touch center point, the whole process simulates the drawing process of a house, namely, the background or other flat areas are firstly coated with a large pen touch, and then the details of the small size in the image are gradually used for drawing, and the area to be drawn until the corresponding area to be processed, and the image can be generated.
It should be noted that, in the drawing process, the direction of the brush strokes and the colors of the brush strokes are correspondingly adjusted for each drawing, gradual transition should be made around each brush stroke, and if cross-region color jump exists, brush stroke truncation is made; in addition, the current stroke only affects the area with the importance not exceeding the center point of the stroke, and for the area with higher importance, the drawing process can be finished in the following process, and the size of the corresponding stroke is gradually reduced.
Optionally, during the whole drawing process, the radius of the actual brush size may be slightly larger than the calculated radius, so as to ensure complete coverage of the whole paper; the size contrast and the color contrast of the pen brush can be adjusted according to the preference of a user to finish different painting styles, the difference between the pen brush with the large size is increased due to the increase of the size contrast of the pen brush, and the color contrast of the pen brush is adjusted in the aspect of bright color of the painting result.
Optionally, according to the scene type of the image to be processed, the image of the "important" area in the image to be processed may be protected and modified through a preset algorithm.
For example, when the image to be processed is a photo of a person, the face region is usually an important part in the photo, and for the image to be processed including the face region, a face mask, face 118 key points and five sense organs, which are obtained through a preset deep learning algorithm, are detected to protect and modify an importance map corresponding to the image to be processed, so as to ensure that the face part clearly delineates details through a small touch; for the image without the face, optionally, the significance mask of deep learning can be used to protect the significance map to ensure that the picture body is clear and fine.
Of course, when the image to be processed is an animal photograph, optionally, the contour, the appearance feature, and the like of the animal can be obtained through a preset deep learning algorithm to protect and modify the importance map corresponding to the image to be processed, so as to ensure that the details of the animal part are clearly outlined by a small stroke, and according to an actual application scene, the corresponding preset algorithm and the corresponding image of the "important" area can be selected, which is not limited herein.
Fig. 5 is a schematic flow chart of another image-based oil painting generation method according to an embodiment of the present application. Optionally, as shown in fig. 5, before generating the oil painting image corresponding to the image to be processed according to the direction of the pen stroke, the at least one pen stroke falling point, the at least one size of the pen stroke, and the color of the pen stroke corresponding to each pen stroke falling point, the method further includes:
s501, receiving a color matching instruction, wherein the color matching instruction comprises pen touch color information corresponding to a pen touch pen-down point.
Wherein, the instruction of matching colors includes the corresponding stroke color information of stroke pen-touch pen-drop point, can be used for setting up the stroke color of each stroke, optionally, according to user's demand, the user can select corresponding stroke color to generate the oil painting image, for example, can select to let the tone of whole drawing can be slightly cold, perhaps independently adjust saturation, contrast etc. this application here and inject the colour of the oil painting image that generates.
Of course, without being limited thereto, the brush color of each brush may be determined by identifying the color of the corresponding position in the image to be processed.
Fig. 6 is a schematic structural diagram of an image-based oil painting generation apparatus provided in an embodiment of the present application, the basic principle and the generated technical effect of the apparatus are the same as those of the foregoing corresponding method embodiment, and for brief description, reference may be made to corresponding contents in the method embodiment for a part not mentioned in this embodiment. As shown in fig. 6, the apparatus includes: a first determining module 110, a second determining module 120, and a generating module 130.
The first determining module 110 is configured to obtain a direction field diagram of an image to be processed, and determine an oil painting drawing stroke direction of the image to be processed according to the direction field diagram; the second determining module 120 is configured to obtain an importance map of the image to be processed, and determine at least one stroke-down stroke point and at least one stroke size of the image to be processed according to the importance map, where the importance map represents an importance degree of each pixel point in the image to be processed; the generating module 130 is configured to generate an oil painting image corresponding to the image to be processed according to the direction of the pen touch, the at least one pen touch point, the at least one pen touch size, and the pen touch color corresponding to each pen touch point.
Optionally, the second determining module 120 is specifically configured to calculate and obtain an importance value of each pixel point in the image to be processed according to a partial derivative of each pixel point in the image to be processed in a preset direction; and generating an importance graph of the image to be processed according to the importance value of each pixel point in the image to be processed.
Optionally, the second determining module 120 is specifically configured to perform normalization and histogram equalization on the importance map, and obtain a preprocessed importance map; and determining areas to be drawn associated with different importance values in the image to be processed, at least one pen-touch pen-down point and at least one pen-touch size corresponding to each area to be drawn according to the preprocessed importance graph and a preset algorithm.
Optionally, the second determining module 120 is specifically configured to obtain, according to a sequence from low to high of the importance value, a drawing area associated with the importance value, at least one pen-down point and at least one pen size corresponding to the area to be drawn;
correspondingly, the generating module 130 is specifically configured to generate the oil painting image corresponding to the area to be drawn according to at least one pen-touch pen-down point and at least one pen-touch size corresponding to the area to be drawn and the pen-touch color corresponding to each pen-touch pen-down point.
Fig. 7 is a schematic structural diagram of another image-based oil painting generation apparatus according to an embodiment of the present application. Optionally, as shown in fig. 7, the apparatus further includes: the receiving module 140 is configured to receive a color matching instruction, where the color matching instruction includes pen touch color information corresponding to a pen touch pen-down point.
The above-mentioned apparatus is used for executing the method provided by the foregoing embodiment, and the implementation principle and technical effect are similar, which are not described herein again.
These above modules may be one or more integrated circuits configured to implement the above methods, such as: one or more Application Specific Integrated Circuits (ASICs), or one or more microprocessors (DSPs), or one or more Field Programmable Gate Arrays (FPGAs), among others. For another example, when one of the above modules is implemented in the form of a Processing element scheduler code, the Processing element may be a general-purpose processor, such as a Central Processing Unit (CPU) or other processor capable of calling program code. As another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
Fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present application. As shown in fig. 8, the electronic device may include: a processor 210, a storage medium 220, and a bus 230, wherein the storage medium 220 stores machine-readable instructions executable by the processor 210, and when the electronic device is operated, the processor 210 communicates with the storage medium 220 via the bus 230, and the processor 210 executes the machine-readable instructions to perform the steps of the above-mentioned method embodiments. The specific implementation and technical effects are similar, and are not described herein again.
Optionally, the present application further provides a storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the computer program performs the steps of the above method embodiments. The specific implementation and technical effects are similar, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one type of logical functional division, and other divisions may be realized in practice, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
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 units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
The integrated unit implemented in the form of a software functional unit may be stored in a computer readable storage medium. The software functional unit is stored in a storage medium and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device) or a processor (processor) to perform some steps of the methods according to the embodiments of the present application. And the aforementioned storage medium includes: a U disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
It is noted that, in this document, relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising a … …" does not exclude the presence of another identical element in a process, method, article, or apparatus that comprises the element.
The above description is only a preferred embodiment of the present application and is not intended to limit the present application, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application. It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures. The above description is only a preferred embodiment of the present application and is not intended to limit the present application, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims (8)

1. An oil painting generation method based on images is characterized by comprising the following steps:
acquiring a direction field diagram of an image to be processed, and determining the direction of an oil painting drawing pen touch of the image to be processed according to the direction field diagram;
acquiring an importance graph of the image to be processed, and determining at least one pen-touch pen-down point and at least one pen-touch size of the image to be processed according to the importance graph, wherein the importance graph represents the importance degree of each pixel point in the image to be processed;
generating an oil painting image corresponding to the image to be processed according to the pen touch direction, at least one pen touch point, at least one pen touch size and pen touch colors corresponding to the pen touch points;
the acquiring of the importance map of the image to be processed comprises:
calculating and acquiring the importance value of each pixel point in the image to be processed according to the partial derivative of each pixel point in the image to be processed in the preset direction;
generating an importance map of the image to be processed according to the importance value of each pixel point in the image to be processed;
the determining at least one stroke pen-down point and at least one stroke size of the image to be processed according to the importance map comprises:
carrying out normalization and histogram equalization processing on the importance map to obtain a preprocessed importance map;
and determining areas to be drawn associated with different importance values in the image to be processed, at least one pen-touch pen-down point and at least one pen-touch size corresponding to each area to be drawn according to the preprocessed importance map and a preset algorithm.
2. The method according to claim 1, wherein the determining, according to the preprocessed importance map and a preset algorithm, regions to be drawn associated with different importance values in the image to be processed, and at least one pen-touch pen-down point and at least one pen-touch size corresponding to each region to be drawn comprises:
according to the sequence of the importance values from low to high, obtaining a drawing area associated with the importance values, and at least one pen-touch pen-down point and at least one pen-touch size corresponding to the area to be drawn;
correspondingly, the generating an oil painting image corresponding to the image to be processed according to the direction of the pen touch, at least one pen touch point, at least one size of the pen touch and the color of the pen touch corresponding to each pen touch point comprises:
and generating an oil painting image corresponding to the area to be drawn according to at least one pen touch pen-down point and at least one pen touch size corresponding to the area to be drawn and the pen touch color corresponding to each pen touch pen-down point.
3. The method according to claim 1, wherein before generating the oil painting image corresponding to the image to be processed according to the direction of the brush stroke, at least one brush stroke point, at least one brush stroke size, and the brush stroke color corresponding to each brush stroke point, the method further comprises:
and receiving a color matching instruction, wherein the color matching instruction comprises pen touch color information corresponding to the pen touch pen-down point.
4. An oil painting generation device based on images, characterized by comprising: the device comprises a first determining module, a second determining module and a generating module;
the first determining module is used for acquiring a direction field diagram of an image to be processed and determining the direction of an oil painting drawing pen touch of the image to be processed according to the direction field diagram;
the second determining module is configured to obtain an importance map of the image to be processed, and determine at least one stroke-down stroke point and at least one stroke size of the image to be processed according to the importance map, where the importance map represents an importance degree of each pixel point in the image to be processed;
the generating module is configured to generate an oil painting image corresponding to the image to be processed according to the pen touch direction, the at least one pen touch point, the at least one pen touch size, and the pen touch color corresponding to each pen touch point;
the second determining module is specifically configured to calculate and obtain an importance value of each pixel point in the image to be processed according to a partial derivative of each pixel point in the image to be processed in a preset direction;
generating an importance map of the image to be processed according to the importance value of each pixel point in the image to be processed;
the second determining module is specifically configured to perform normalization and histogram equalization processing on the importance map, and obtain a preprocessed importance map;
and determining areas to be drawn associated with different importance values in the image to be processed, at least one pen-touch pen-down point and at least one pen-touch size corresponding to each area to be drawn according to the preprocessed importance map and a preset algorithm.
5. The apparatus according to claim 4, wherein the second determining module is specifically configured to obtain, according to an order from low to high of the importance value, a drawing area associated with the importance value, and at least one pen-down point and at least one pen-touch size corresponding to the area to be drawn;
correspondingly, the generating module is specifically configured to generate the oil painting image corresponding to the area to be drawn according to at least one pen-touch pen-down point and at least one pen-touch size corresponding to the area to be drawn and the pen-touch color corresponding to each pen-touch pen-down point.
6. The apparatus of claim 4, further comprising: and the receiving module is used for receiving a color matching instruction, and the color matching instruction comprises pen touch color information corresponding to the pen touch pen-down point.
7. An electronic device, comprising: a processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, when the electronic device runs, the processor and the storage medium communicate through the bus, and the processor executes the machine-readable instructions to execute the steps of the image-based oil painting generation method according to any one of claims 1 to 3.
8. A storage medium having stored thereon a computer program for performing the steps of the image-based canvas generating method according to any one of claims 1 to 3 when executed by a processor.
CN201910772674.6A 2019-08-20 2019-08-20 Oil painting generation method and device based on image, electronic equipment and storage medium Active CN110473272B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910772674.6A CN110473272B (en) 2019-08-20 2019-08-20 Oil painting generation method and device based on image, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910772674.6A CN110473272B (en) 2019-08-20 2019-08-20 Oil painting generation method and device based on image, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN110473272A CN110473272A (en) 2019-11-19
CN110473272B true CN110473272B (en) 2022-10-28

Family

ID=68513202

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910772674.6A Active CN110473272B (en) 2019-08-20 2019-08-20 Oil painting generation method and device based on image, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN110473272B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111191069A (en) * 2019-12-31 2020-05-22 联想(北京)有限公司 Image processing method and device

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101587593A (en) * 2009-06-19 2009-11-25 西安交通大学 A kind of method based on the stylization of true picture sketch
CN101937568A (en) * 2009-06-29 2011-01-05 中国移动通信集团公司 Stroke direction determining method and device
WO2016178807A1 (en) * 2015-05-05 2016-11-10 Google Inc. Painterly picture generation
CN108573506A (en) * 2017-03-13 2018-09-25 北京贝塔科技股份有限公司 Image processing method and system

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5741282B2 (en) * 2011-07-26 2015-07-01 カシオ計算機株式会社 Image processing apparatus, image processing method, and program

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101587593A (en) * 2009-06-19 2009-11-25 西安交通大学 A kind of method based on the stylization of true picture sketch
CN101937568A (en) * 2009-06-29 2011-01-05 中国移动通信集团公司 Stroke direction determining method and device
WO2016178807A1 (en) * 2015-05-05 2016-11-10 Google Inc. Painterly picture generation
CN108573506A (en) * 2017-03-13 2018-09-25 北京贝塔科技股份有限公司 Image processing method and system

Also Published As

Publication number Publication date
CN110473272A (en) 2019-11-19

Similar Documents

Publication Publication Date Title
CN106778928B (en) Image processing method and device
US9396560B2 (en) Image-based color palette generation
US9741137B2 (en) Image-based color palette generation
US9552656B2 (en) Image-based color palette generation
US9311889B1 (en) Image-based color palette generation
CN108830892B (en) Face image processing method and device, electronic equipment and computer readable storage medium
CN105354248A (en) Gray based distributed image bottom-layer feature identification method and system
US9098534B2 (en) Image display system, image display method, social network service system, and computer-readable medium
CN109544482A (en) A kind of convolutional neural networks model generating method and image enchancing method
CN112419170A (en) Method for training occlusion detection model and method for beautifying face image
WO2013106984A1 (en) Learning painting styles for painterly rendering
CN107045729A (en) A kind of image rendering method and device
CN107688824A (en) Picture match method and terminal device
CN110136198A (en) Image processing method and its device, equipment and storage medium
CN104809288A (en) Trying method or customizing nail art
CN111127309A (en) Portrait style transfer model training method, portrait style transfer method and device
CN110047122A (en) Render method, apparatus, electronic equipment and the computer readable storage medium of image
CN108494996A (en) Image processing method, device, storage medium and mobile terminal
CN106844302A (en) E-book page display method, device and terminal device
CN110990617B (en) Picture marking method, device, equipment and storage medium
CN110473272B (en) Oil painting generation method and device based on image, electronic equipment and storage medium
WO2022048414A1 (en) Image generation method, apparatus, and device, and storage medium
CN109445569A (en) Information processing method, device, equipment and readable storage medium storing program for executing based on AR
CN107644455B (en) Face image synthesis method and device
CN115967823A (en) Video cover generation method and device, electronic equipment and readable medium

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
GR01 Patent grant
GR01 Patent grant