CN106709964B - Sketch generation method and device based on gradient correction and multidirectional texture extraction - Google Patents

Sketch generation method and device based on gradient correction and multidirectional texture extraction Download PDF

Info

Publication number
CN106709964B
CN106709964B CN201611111134.6A CN201611111134A CN106709964B CN 106709964 B CN106709964 B CN 106709964B CN 201611111134 A CN201611111134 A CN 201611111134A CN 106709964 B CN106709964 B CN 106709964B
Authority
CN
China
Prior art keywords
image
texture
map
gradient
segmentation
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.)
Expired - Fee Related
Application number
CN201611111134.6A
Other languages
Chinese (zh)
Other versions
CN106709964A (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.)
Henan University of Technology
Original Assignee
Henan University of Technology
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 Henan University of Technology filed Critical Henan University of Technology
Priority to CN201611111134.6A priority Critical patent/CN106709964B/en
Publication of CN106709964A publication Critical patent/CN106709964A/en
Application granted granted Critical
Publication of CN106709964B publication Critical patent/CN106709964B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • 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
    • G06T5/00Image enhancement or restoration
    • G06T5/20Image enhancement or restoration using local operators
    • G06T5/30Erosion or dilatation, e.g. thinning
    • 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
    • G06T5/00Image enhancement or restoration
    • G06T5/70Denoising; Smoothing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/90Dynamic range modification of images or parts thereof
    • G06T5/92Dynamic range modification of images or parts thereof based on global image properties
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20172Image enhancement details
    • G06T2207/20182Noise reduction or smoothing in the temporal domain; Spatio-temporal filtering
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20212Image combination
    • G06T2207/20221Image fusion; Image merging

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Image Processing (AREA)
  • Image Analysis (AREA)

Abstract

The invention provides a sketch generating method and a sketch generating device based on gradient correction and multidirectional texture extraction, wherein the method carries out gray level transformation on an input image to obtain a gray level image; processing the gray level image to obtain a preprocessed image, and performing image segmentation processing on the preprocessed image to obtain a segmentation image; carrying out gradient processing on the gray level image to obtain gradient information; determining the texture trend of each segmentation area of the segmentation map according to the gradient information; generating a white noise image according to an input image; combining the texture trend of each segmentation area of the segmentation map and the white noise map to generate a texture map; processing an input image to obtain a contour map; and fusing the texture map and the contour map to generate a sketch map. The invention uses multi-directional texture, so that the generated sketch is close to the real hand drawing sketch effect, and the sketch effect is richer and more vivid.

Description

Sketch generation method and device based on gradient correction and multidirectional texture extraction
Technical Field
The invention belongs to the technical field of image processing, and particularly relates to a sketch generating method and device based on gradient correction and multidirectional texture extraction.
Background
The personal dynamic updating in the friend circle, the self-timer playing and the like can see the shadow of the image; meanwhile, a large number of images are browsed, shared and downloaded on the internet, and corresponding image processing technologies are receiving more and more attention. In image processing technology, stylizing processing of an image, addition of an artistic effect, and the like are highly favored. Sketch painting is a relatively common and basic expression mode in image art. However, for the artificial creation of sketch painting, the creator must have certain art skill and design ability, and the individual art level will also greatly affect the expression effect of the final sketch painting. Although some professional image processing software such as Photoshop and the like can obtain quite good image processing effect, the professional image processing software has certain technical capability requirements on users. Of course, the operation steps are relatively complicated and complicated, and the efficiency is not high. Therefore, the fast and efficient erythropoietin drawing by means of a computer has important application prospect. The computer can quickly and automatically generate the hand-drawn image of the pencil, and has important application and entertainment values.
In the existing pixel drawing generation method, the texture generation method is relatively complex and has low running speed; in addition, the texture generation cannot effectively take into consideration the overall gradation and contrast effect of the sketch effect.
A Master academic paper 'study of pencil drawing simulation method based on image', written as Sundadan, discloses a method for simulating pencil drawing texture by applying a motion blur method. The method mainly applies a motion blur filter to simulate the texture of a pencil on the basis of determining the texture direction and generating a white noise image. When the grain trend is determined, one direction is selected as a main body direction to represent the grain trend. However, a sketch in a single texture direction is likely to cause information loss, and the overall mood of the sketch cannot be well highlighted.
Disclosure of Invention
The invention aims to provide a sketch generating method and a sketch generating device based on gradient correction and multidirectional texture extraction, which are used for solving the problem that the current sketch generating method uses a single texture direction to cause information loss and unreal pictures.
In order to solve the technical problem, the invention provides a sketch generating method based on gradient correction and multi-directional texture extraction, which comprises nine method schemes:
the first method scheme comprises the following steps:
1) carrying out gray level conversion on an input image to obtain a gray level image;
2) processing the gray level image to obtain a preprocessed image, and performing image segmentation processing on the preprocessed image to obtain a segmentation image;
3) carrying out gradient processing on the gray level image to obtain gradient information; determining the texture trend of each segmentation area of the segmentation map according to the gradient information;
4) generating a white noise image according to an input image;
5) combining the texture trend of each segmentation area of the segmentation map and the white noise map to generate a texture map;
6) processing an input image to obtain a contour map;
7) and fusing the texture map and the contour map to generate a sketch map.
In the second method, on the basis of the first method, the method further comprises the step of processing the gray image to obtain a preprocessed image by using multi-scale morphological open-close reconstruction operation:
the multi-scale morphological open-close reconstruction operation is to use structural elements with different sizes to perform morphological open-close reconstruction operation on the gray level image, and add the processing results to obtain an average to obtain a preprocessed image;
the multi-scale structuring element is defined as follows:
Figure BDA0001172388860000021
whereinN is a scale parameter of the scale structural element and is a positive number, and n is made to be 3 in the method; b is a basic structural element;
Figure BDA0001172388860000022
representing the etching operation in the morphological treatment; the meaning of the above formula is that large structural elements are obtained by the progressive corrosion of small structural elements.
The third method scheme is that on the basis of the first method scheme, the method further comprises the step of performing watershed image segmentation processing on the preprocessed image to obtain a segmentation map:
performing morphological gradient treatment on the pretreatment image to generate a morphological gradient image; a morphological gradient map, a dilation map of the pre-processed image, an erosion map of the pre-processed image;
performing morphology opening reconstruction and morphology closing reconstruction operation on the preprocessed graph, and performing filtering smoothing to obtain a filtering smoothing graph;
calculating a foreground mark and a background mark according to the filtering smooth image;
and modifying the morphological gradient image according to the foreground mark and the background mark, and performing watershed segmentation to obtain a segmentation image.
In a fourth embodiment of the method, on the basis of the third embodiment of the method, the step of calculating the foreground marker and the background marker includes:
obtaining a local maximum binary image of the filtering smooth image, performing morphological opening and closing operation on the local maximum binary image to smooth edges, removing local minimum regions with the number of pixels smaller than 20 in the image, and removing isolated pixel points to obtain a foreground marking image;
calculating a threshold value of the filtering smooth image by using a maximum between-class variance Otsu method, and then carrying out binarization to obtain a binary image; the thresholding by the maximum between-class variance Otsu method comprises the following steps:
let the gray scale range of the filtered smoothed image be {0,1,2,3.. l }, and the number of pixels of the gray scale i be niRecording the total number of pixels of the image as
Figure BDA0001172388860000031
The probability of the occurrence of a pixel with a gray level of i is:
Selecting a threshold t e [1, l-1 ]]The threshold t divides the gray pixels of the image into C1{0,1,2.. eta.,. t } and C2Two parts, C, { t +1, t +21、C2The probabilities of occurrence are:
Figure BDA0001172388860000033
the corresponding mean values are respectively:
Figure BDA0001172388860000034
the overall gray level mean of the image is:
Figure BDA0001172388860000035
the maximum between-class variance of the two regions divided by the threshold is:
Figure BDA0001172388860000036
adopting a traversal method to determine the t is the [1, l-1 ]]Within a range of (b), is obtained such that
Figure BDA0001172388860000037
The maximum threshold value t is the calculated threshold value;
and (4) carrying out distance transformation and watershed segmentation on the binary image to obtain a watershed image serving as a background mark.
In the fifth method, on the basis of the first method, the gradient information is a tangent value of a gradient angle:
tanθ=[Fy/Fx]
wherein Fx is a gradient value in the horizontal direction obtained after the gray image is subjected to gradient processing; fy is a gradient value in the vertical direction obtained after the gray image is subjected to gradient processing; θ is the gradient angle, and tan θ is the tangent of the gradient angle.
In a sixth method, on the basis of the first method, the determining the texture trend of each partition area of the partition map includes:
comparing the tangent value of the gradient angle corresponding to each pixel in each segmentation area with zero: if the tangent value of the gradient angle of the pixel is larger than zero, recording that the texture direction of the pixel is 45 degrees; otherwise, recording the texture direction of the pixel point as-45 degrees; namely:
Figure BDA0001172388860000041
wherein, IinputIs an input pixel, NiIs the ith division area, IinputTan theta is the gradient tangent value of the input pixel, IoutputTheta is the texture direction of the output pixel;
counting the number of pixel points in the 45-degree texture direction and the-45-degree texture direction in the same partition area, and recording the pixel points as num1 and num2 respectively; namely:
Figure BDA0001172388860000042
wherein, num1 has the initial value: num1 ═ 0; the initial value of num2 is: num2 ═ 0;
comparing the sizes of num1 and num 2: if num1 is greater than num2, the texture direction of the partition is 45 degrees; if num1 is less than or equal to num2, the texture direction of the partition is-45 degrees; namely:
Figure BDA0001172388860000043
wherein N isiAnd θ is the texture direction of the segmented area i.
A seventh method, based on the first method, further includes the steps of converting the input image from the RGB color space to the HSV color space, extracting the V component, and adding white noise in combination with the segmentation map and the V component to generate a white noise map:
calculating an average luminance value R of each divided region on the extracted V component mapi,RiRepresenting the ith divided region;
comparing the pixel point of each region in the brightness image with the region average value, and solving a new pixel value according to the following formula:
Figure BDA0001172388860000051
T1=k1·(1-Iinput),k1∈[0,1.0]
T2=k2·(1-Iinput),k2∈[0,1.0]
wherein, IinputFor the brightness value of the input pixel, IoutputIs the luminance value of the output pixel; i isoutput1For the brightness value I at the input pixelinputLess than or equal to the average value R of all pixels in the region iiThe brightness value I of the output pixeloutputTaking the value of (A); i isoutput2For the brightness value I at the input pixelinputGreater than the average value R of all pixels in the region iiThe brightness value I of the output pixeloutputTaking the value of (A); two variable values in the T1 and T2 formulas; p is a random number, and the value range is as follows: p ∈ (0, 1); riIs the average brightness value of all pixels in the region I, Imax1、Imax2The maximum luminance value of the output noise is usually 1; i is a constant that can be defined by the user as desired, in this method, let I equal to 0.2, where k1 and k2 are two empirical values, k1 equal to 0.7, and k2 equal to 0.3.
And a eighth method, on the basis of the first method, the texture map is generated by filtering with a motion blur filter in combination with the texture trend and the white noise map of each segmentation area of the segmentation map.
Method scheme nine, on the basis of method scheme one, the contour map is generated by performing neon processing on an input image.
In addition, the invention also provides a sketch generating device based on gradient correction and multidirectional texture extraction, which comprises the following modules:
a module for performing gray scale conversion on an input image to obtain a gray scale image;
a module for processing the gray level image to obtain a preprocessed image and performing image segmentation processing on the preprocessed image to obtain a segmentation image;
the gradient processing module is used for carrying out gradient processing on the gray level image to obtain gradient information; a module for determining the texture trend of each segmentation area of the segmentation map according to the gradient information;
a module for generating a white noise image from an input image;
a module for generating a texture map by combining the texture trend of each segmentation region of the segmentation map and a white noise map;
a module for processing the input image to obtain a contour map;
and a module for fusing the texture map and the contour map to generate a sketch map.
The invention has the beneficial effects that:
the invention carries out gray level transformation and gradient processing on an input image, and carries out image segmentation on a gray level image to obtain a segmentation image; obtaining the texture direction according to the gradient processing and the segmentation graph; adding white noise to an input image, and generating a texture map according to the texture direction; processing the input graph to obtain a contour graph; and fusing the texture map and the contour map to generate a sketch map.
On the basis of simplifying the generation process of simulating the sketch texture by using the traditional line integral convolution method, the method does not use a texture map in a single direction, but uses multi-directional texture, so that the generated sketch is close to the real hand drawing sketch effect, has more layering, and has richer and more fresh sketch effect; in addition, the gray level image is subjected to image segmentation before texture direction is determined and white noise is added, areas with different characteristics in the image are processed separately, and different characteristics of each area are processed, so that the image has better layering and shading effects, and the overall information of the image is better expressed.
Drawings
FIG. 1 is a flow chart of a method of the present invention;
FIG. 2 is an original input image;
FIG. 3 is a grayscale diagram;
FIG. 4 is a graph after a multi-scale morphological open-close reconstruction operation;
FIG. 5 is a fragmentary view;
FIG. 6 is a generated graph after white noise is added;
FIG. 7 is a resultant directional texture map;
FIG. 8 is an extracted contour map;
FIG. 9 is a sketch generated.
Detailed Description
The following describes embodiments of the present invention in further detail with reference to the accompanying drawings.
The sketch generating method based on gradient correction and multidirectional texture extraction comprises the following steps:
1. and performing gray scale transformation on the original image as an input image to obtain a gray scale image.
2. And (4) carrying out multi-scale morphological open-close reconstruction operation to process the gray-scale image to obtain a preprocessed image.
The multi-scale morphological open-close reconstruction operation is to use structural elements with different sizes to perform morphological open-close reconstruction operation on the gray level image, and add and average the processing results to obtain a preprocessed image. In the multi-scale morphological open-close reconstruction operation, the multi-scale structural elements are defined as follows:
Figure BDA0001172388860000061
wherein n is a scale parameter of the scale structural element and is a positive number, and n is made to be 3 in the method; b is a basic structural element;
Figure BDA0001172388860000071
representing the etching operation in the morphological treatment; the meaning of the above formula is that large structural elements are obtained by the progressive corrosion of small structural elements.
3. The method comprises the following steps of carrying out marker-based watershed image segmentation processing on a preprocessed image to obtain a segmentation image, and specifically comprising the following steps:
1) performing morphological gradient treatment on the pretreatment image to generate a morphological gradient image;
wherein, the morphological gradient map is a swelling map of the preprocessed image-a corrosion map of the preprocessed image;
2) performing morphology opening reconstruction and morphology closing reconstruction operation on the preprocessed graph, and performing filtering smoothing to obtain a filtering smoothing graph;
3) calculating a foreground mark and a background mark according to the filtering smooth image;
and solving a local maximum binary image of the filtering smooth image, performing morphological opening and closing operation on the local maximum binary image to smooth edges, removing local minimum regions with the number of pixels smaller than 20 in the image, and removing isolated pixel points to obtain a foreground marking image.
And (4) solving a threshold value of the filtered smooth image by using a maximum between-class variance Otsu method, and then carrying out binarization to obtain a binary image. The maximum between-class variance Otsu method is used for solving the threshold value as follows:
let the gray scale range of the filtered smoothed image be {0,1,2,3.. l }, and the number of pixels of the gray scale i be niRecording the total number of pixels of the image asThe probability of occurrence of a pixel with a gray level i is:
Figure BDA0001172388860000073
selecting a threshold t e [1, l-1 ]]The threshold t divides the gray pixels of the image into C1{0,1,2.. eta.,. t } and C2Two parts, C, { t +1, t +21、C2The probabilities of occurrence are:
Figure BDA0001172388860000074
the corresponding mean values are respectively:
Figure BDA0001172388860000075
the overall gray level mean of the image is:
Figure BDA0001172388860000076
the maximum between-class variance of the two regions divided by the threshold is:
Figure BDA0001172388860000077
adopting a traversal method to determine the t is the [1, l-1 ]]Within a range of (b), is obtained such that
Figure BDA0001172388860000081
The maximum threshold t is the desired threshold.
And (4) carrying out distance transformation and watershed segmentation on the binary image to obtain a watershed image serving as a background mark.
4) And modifying the morphological gradient map according to the foreground mark and the background mark, and performing watershed segmentation. And modifying the gradient map obtained in the second step and the foreground mark and the background mark obtained in the fourth step by using a forced modification technology to serve as marks for watershed segmentation, and performing watershed segmentation to obtain a segmentation map. And counting the number of the segmented regions, and eliminating the segmentation lines by using median filtering.
4. Gradient processing is carried out on the gray image, the gradient value in the horizontal direction of the gray image is represented as Fx, the gradient value in the vertical direction of the gray image is represented as Fy, and the tangent value of the gradient angle is obtained:
tanθ=[Fy/Fx]
wherein Fx is a gradient value in the horizontal direction obtained after the gray image is subjected to gradient processing; fy is a gradient value in the vertical direction obtained after the gray image is subjected to gradient processing; θ is the gradient angle, and tan θ is the tangent of the gradient angle.
5. And obtaining the texture method of each segmentation area according to the result of the previous step of gradient processing. The texture direction is an important means for representing sketch information, and the texture direction which is more common in the real sketch is between 30 degrees and 60 degrees or between-30 degrees and-60 degrees; experiments and comparisons herein have selected 45 degrees and-45 degrees as the direction of the texture. The specific method comprises the following steps:
1) comparing the tangent value of the gradient angle corresponding to each pixel in each segmentation area with zero: if the tangent value of the gradient angle of the pixel is larger than zero, recording that the texture direction of the pixel is 45 degrees; otherwise, recording the texture direction of the pixel point as-45 degrees; namely:
wherein, IinputIs an input pixel, NiIs the ith division area, IinputTan theta is the gradient tangent value of the input pixel, IoutputTheta is the texture direction of the output pixel;
2) counting the number of pixel points in the 45-degree texture direction and the-45-degree texture direction in the same partition area, and recording the pixel points as num1 and num2 respectively; namely:
wherein, num1 has the initial value: num1 ═ 0; the initial value of num2 is: num2 ═ 0;
3) comparing the sizes of num1 and num 2: if num1 is greater than num2, the texture direction of the partition is 45 degrees; if num1 is less than or equal to num2, the texture direction of the partition is-45 degrees; namely:
Figure BDA0001172388860000091
wherein N isiAnd θ is the texture direction of the segmented area i.
6. Converting an input image from an RGB color space to an HSV color space, and extracting a V component diagram; and combining the segmentation map and the V component map to generate a white noise image. The white noise adding method comprises the following steps:
1) calculating an average luminance value R of each divided region on the extracted V component mapi,RiRepresenting the ith divided region;
2) comparing the pixel point of each region in the brightness image with the region average value, and solving a new pixel value according to the following formula:
Figure BDA0001172388860000092
T1=k1·(1-Iinput),k1∈[0,1.0]
T2=k2·(1-Iinput),k2∈[0,1.0]
wherein, IinputFor the brightness value of the input pixel, IoutputIs the luminance value of the output pixel; i isoutput1For the brightness value I at the input pixelinputLess than or equal to the average value R of all pixels in the region iiThe brightness value I of the output pixeloutputTaking the value of (A); i isoutput2For the brightness value I at the input pixelinputGreater than the average value R of all pixels in the region iiThe brightness value I of the output pixeloutputTaking the value of (A); two variable values in the T1 and T2 formulas; p is a random number, and the value range is as follows: p ∈ (0, 1); riIs the average brightness value of all pixels in the region I, Imax1、Imax2The maximum luminance value of the output noise is usually 1; i is a constant that can be defined by the user as desired, in this method, let I equal to 0.2, where k1 and k2 are two empirical values, k1 equal to 0.7, and k2 equal to 0.3.
3) And dividing the image added with the white noise into a white noise image in a 45-degree texture direction and a white noise image in a-45-degree texture direction according to the texture direction. The blank areas in the white noise map obtained by the segmentation are all filled with white.
7. And filtering by a motion blur filter according to the texture trend of each segmentation area of the segmentation map and the white noise map to generate the texture map.
A Motion Blur (Motion Blur) filter is an effect filter for capturing a Motion state of an object, and performs a Blur process on an image in a specific direction and with a specific intensity. The motion blur effect produced by the motion filter has good similarity to the pencil texture, and the method is applied to simulate the pencil texture.
And filtering and generating the segmented white noise map by using a motion blur filter respectively. Wherein the code in MATLAB for generating the predefined template of the motion filter is:
h=fspecial('motion',len,phi)
wherein phi is the filtering direction of the motion blur filtering, and the texture direction is taken; len is the strength of the motion filtering, and len is 10; the segmented white noise map is filtered using a predefined template of the motion filter.
8. And carrying out neon processing on the input image to obtain a contour map.
9. And performing point multiplication on the two direction texture maps, namely the texture map and the contour map, after the motion blur filtering, and fusing to generate a final texture map.
In the embodiment, a profile of a sketch image is obtained by using a neon processing method; as another embodiment, an edge detection operator based on a first derivative may be used to detect a contour of an input image by calculating a gradient value of the image, such as a Candy operator, a Sobel operator, and a Prewitt operator, so as to extract the contour of the input image.
In addition, the invention also provides a sketch generating device based on gradient correction and multidirectional texture extraction, which comprises the following modules:
a module for performing gray scale conversion on an input image to obtain a gray scale image;
a module for processing the gray level image to obtain a preprocessed image and performing image segmentation processing on the preprocessed image to obtain a segmentation image;
the gradient processing module is used for carrying out gradient processing on the gray level image to obtain gradient information; a module for determining the texture trend of each segmentation area of the segmentation map according to the gradient information;
a module for generating a white noise image from an input image;
a module for generating a texture map by combining the texture trend of each segmentation region of the segmentation map and a white noise map;
a module for processing the input image to obtain a contour map;
and a module for fusing the texture map and the contour map to generate a sketch map.
The sketch generating device based on gradient correction and multi-directional texture extraction is a computer solution, namely a software framework, based on the corresponding method flow, and the various modules are processing processes or programs corresponding to the method flow. The apparatus will not be described in detail since the description of the above method is sufficiently clear and complete.

Claims (9)

1. The sketch generating method based on gradient correction and multi-directional texture extraction is characterized by comprising the following steps of:
1) carrying out gray level conversion on an input image to obtain a gray level image;
2) processing the gray level image to obtain a preprocessed image, and performing image segmentation processing on the preprocessed image to obtain a segmentation image;
3) carrying out gradient processing on the gray level image to obtain gradient information; determining the texture trend of each segmentation area of the segmentation map according to the gradient information;
4) generating a white noise image according to an input image;
5) combining the texture trend of each segmentation area of the segmentation map and the white noise map to generate a texture map;
6) processing an input image to obtain a contour map;
7) fusing the texture map and the contour map to generate a sketch map;
determining the texture trend of each segmented region of the segmentation map comprises the following steps:
comparing the tangent value of the gradient angle corresponding to each pixel in each segmentation area with zero: if the tangent value of the gradient angle of the pixel is larger than zero, recording that the texture direction of the pixel is 45 degrees; otherwise, recording the texture direction of the pixel point as-45 degrees; namely:
Figure FDA0002213441420000011
wherein, IinputIs an input pixel, NiIs the ith division area, IinputTan theta is the gradient tangent value of the input pixel, IoutputTheta is the texture direction of the output pixel;
counting the number of pixel points in the 45-degree texture direction and the-45-degree texture direction in the same partition area, and recording the pixel points as num1 and num2 respectively; namely:
Figure FDA0002213441420000012
wherein, num1 has the initial value: num1 ═ 0; the initial value of num2 is: num2 ═ 0;
comparing the sizes of num1 and num 2: if num1 is greater than num2, the texture direction of the partition is 45 degrees; if num1 is less than or equal to num2, the texture direction of the partition is-45 degrees; namely:
Figure FDA0002213441420000021
wherein N isiAnd θ is the texture direction of the segmented area i.
2. The sketch generating method based on gradient modification and multidirectional texture extraction as claimed in claim 1, further comprising a step of processing the gray-scale image to obtain a preprocessed image by using a multi-scale morphological on-off reconstruction operation:
the multi-scale morphological open-close reconstruction operation is to use structural elements with different sizes to perform morphological open-close reconstruction operation on the gray level image, and add the processing results to obtain an average to obtain a preprocessed image;
the multi-scale structuring element is defined as follows:
Figure FDA0002213441420000022
wherein n is a scale parameter of the scale structural element and is a positive number, and n is made to be 3 in the method; b is a basic structural element;
Figure FDA0002213441420000023
representing the etching operation in the morphological treatment; the meaning of the above formula is that large structural elements are obtained by the progressive corrosion of small structural elements.
3. The sketch generating method based on gradient modification and multi-directional texture extraction as claimed in claim 1, further comprising a step of performing watershed image segmentation processing on the pre-processed image to obtain a segmentation map:
performing morphological gradient treatment on the pretreatment image to generate a morphological gradient image; a morphological gradient map, a dilation map of the pre-processed image, an erosion map of the pre-processed image;
performing morphology opening reconstruction and morphology closing reconstruction operation on the preprocessed graph, and performing filtering smoothing to obtain a filtering smoothing graph;
calculating a foreground mark and a background mark according to the filtering smooth image;
and modifying the morphological gradient image according to the foreground mark and the background mark, and performing watershed segmentation to obtain a segmentation image.
4. The sketch generation method based on gradient modification and multi-directional texture extraction as claimed in claim 3, wherein the calculating the foreground mark and the background mark comprises:
obtaining a local maximum binary image of the filtering smooth image, performing morphological opening and closing operation on the local maximum binary image to smooth edges, removing local minimum regions with the number of pixels smaller than 20 in the image, and removing isolated pixel points to obtain a foreground marking image;
calculating a threshold value of the filtering smooth image by using a maximum between-class variance Otsu method, and then carrying out binarization to obtain a binary image; the threshold value calculation by the maximum between-class variance Otsu method comprises the following steps:
let the gray scale range of the filtered smoothed image be {0,1,2,3.. l }, and the number of pixels of the gray scale i be niRecording the total number of pixels of the image asThe probability of occurrence of a pixel with a gray level i is:
Figure FDA0002213441420000032
selecting a threshold t e [1, l-1 ]]The threshold t divides the gray pixels of the image into C1{0,1,2.. eta.,. t } and C2Two parts, C, { t +1, t +21、C2The probabilities of occurrence are:
Figure FDA0002213441420000033
the corresponding mean values are respectively:
Figure FDA0002213441420000034
the overall gray level mean of the image is:
Figure FDA0002213441420000035
the maximum between-class variance of the two regions divided by the threshold is:
Figure FDA0002213441420000036
adopting a traversal method to determine the t is the [1, l-1 ]]Within a range of (b), is obtained such that
Figure FDA0002213441420000037
The maximum threshold value t is the calculated threshold value;
and (4) carrying out distance transformation and watershed segmentation on the binary image to obtain a watershed image serving as a background mark.
5. The sketch generating method based on gradient modification and multi-directional texture extraction as claimed in claim 1, wherein the gradient information is a tangent value of a gradient angle:
tanθ=[Fy/Fx]
wherein Fx is a gradient value in the horizontal direction obtained after the gray image is subjected to gradient processing; fy is a gradient value in the vertical direction obtained after the gray image is subjected to gradient processing; θ is the gradient angle, and tan θ is the tangent of the gradient angle.
6. The sketch generating method based on gradient modification and multi-directional texture extraction as claimed in claim 1, further comprising the steps of converting the input image from an RGB color space to an HSV color space, extracting V components, and adding white noise in combination with the segmentation map and the V components to generate a white noise map:
calculating an average luminance value R of each divided region on the extracted V component mapi,RiRepresenting the ith divided region;
comparing the pixel point of each region in the brightness image with the region average value, and solving a new pixel value according to the following formula:
T1=k1·(1-Iinput),k1∈[0,1.0]
T2=k2·(1-Iinput),k2∈[0,1.0]
wherein, IinputFor the brightness value of the input pixel, IoutputIs the luminance value of the output pixel; i isoutput1For the brightness value I at the input pixelinputLess than or equal to the average value R of all pixels in the region iiThe brightness value I of the output pixeloutputTaking the value of (A); i isoutput2For the brightness value I at the input pixelinputGreater than the average of all pixels in region iMean value RiThe brightness value I of the output pixeloutputTaking the value of (A); two variable values in the T1 and T2 formulas; p is a random number, and the value range is as follows: p ∈ (0, 1); riIs the average brightness value of all pixels in the region I, Imax1、Imax2The maximum luminance value of the output noise is usually 1; i is a constant that can be defined by the user as desired, in this method, let I equal to 0.2, where k1 and k2 are two empirical values, k1 equal to 0.7, and k2 equal to 0.3.
7. The method of claim 1, wherein the texture map is generated by filtering with a motion blur filter according to a texture trend and a white noise map of each segment of the segmentation map.
8. The sketch generating method based on gradient modification and multi-directional texture extraction as claimed in claim 1, wherein the outline is generated by neon processing an input image.
9. Sketch generating device based on gradient correction and multidirectional texture extraction is characterized by comprising the following modules:
a module for performing gray scale conversion on an input image to obtain a gray scale image;
a module for processing the gray level image to obtain a preprocessed image and performing image segmentation processing on the preprocessed image to obtain a segmentation image;
the gradient processing module is used for carrying out gradient processing on the gray level image to obtain gradient information; a module for determining the texture trend of each segmentation area of the segmentation map according to the gradient information;
a module for generating a white noise image from an input image;
a module for generating a texture map by combining the texture trend of each segmentation region of the segmentation map and a white noise map;
a module for processing the input image to obtain a contour map;
a module for fusing the texture map and the contour map to generate a sketch map;
determining the texture trend of each segmented region of the segmentation map comprises the following steps:
comparing the tangent value of the gradient angle corresponding to each pixel in each segmentation area with zero: if the tangent value of the gradient angle of the pixel is larger than zero, recording that the texture direction of the pixel is 45 degrees; otherwise, recording the texture direction of the pixel point as-45 degrees; namely:
wherein, IinputIs an input pixel, NiIs the ith division area, IinputTan theta is the gradient tangent value of the input pixel, IoutputTheta is the texture direction of the output pixel;
counting the number of pixel points in the 45-degree texture direction and the-45-degree texture direction in the same partition area, and recording the pixel points as num1 and num2 respectively; namely:
Figure FDA0002213441420000052
wherein, num1 has the initial value: num1 ═ 0; the initial value of num2 is: num2 ═ 0;
comparing the sizes of num1 and num 2: if num1 is greater than num2, the texture direction of the partition is 45 degrees; if num1 is less than or equal to num2, the texture direction of the partition is-45 degrees; namely:
Figure FDA0002213441420000053
wherein N isiAnd θ is the texture direction of the segmented area i.
CN201611111134.6A 2016-12-06 2016-12-06 Sketch generation method and device based on gradient correction and multidirectional texture extraction Expired - Fee Related CN106709964B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611111134.6A CN106709964B (en) 2016-12-06 2016-12-06 Sketch generation method and device based on gradient correction and multidirectional texture extraction

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611111134.6A CN106709964B (en) 2016-12-06 2016-12-06 Sketch generation method and device based on gradient correction and multidirectional texture extraction

Publications (2)

Publication Number Publication Date
CN106709964A CN106709964A (en) 2017-05-24
CN106709964B true CN106709964B (en) 2020-02-18

Family

ID=58937567

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611111134.6A Expired - Fee Related CN106709964B (en) 2016-12-06 2016-12-06 Sketch generation method and device based on gradient correction and multidirectional texture extraction

Country Status (1)

Country Link
CN (1) CN106709964B (en)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108182664A (en) * 2017-12-26 2018-06-19 努比亚技术有限公司 A kind of image processing method, mobile terminal and computer readable storage medium
CN109102513A (en) * 2018-08-15 2018-12-28 黄淮学院 A kind of partitioning algorithm of the medical image based on mathematical morphology
CN109840928B (en) * 2019-01-31 2023-10-17 北京达佳互联信息技术有限公司 Knitting image generation method and device, electronic equipment and storage medium
CN110097549A (en) * 2019-05-08 2019-08-06 广州中国科学院沈阳自动化研究所分所 Based on morphologic land, water and air boundary line detecting method, system, medium and equipment
CN111950357A (en) * 2020-06-30 2020-11-17 北京航天控制仪器研究所 Marine water surface garbage rapid identification method based on multi-feature YOLOV3
CN112884639B (en) * 2021-02-03 2022-10-11 上海艾麒信息科技股份有限公司 Method, system and medium for converting photograph into pencil drawing
CN113763506A (en) * 2021-07-28 2021-12-07 北京印刷学院 Method for generating artistic stippling image with custom pixels
CN114612355A (en) * 2022-03-02 2022-06-10 影石创新科技股份有限公司 Oil painting stylization method, device, equipment and medium for image
CN115798396A (en) * 2022-11-29 2023-03-14 卡莱特云科技股份有限公司 LED screen brightness gradient correction method, device and system
CN115908458B (en) * 2023-03-09 2023-05-12 国家海洋局南海标准计量中心 Deep sea area interference fringe extraction method, device and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101571952A (en) * 2009-06-18 2009-11-04 北京航空航天大学 Method for segmenting video object based on fixed period regional compensation
CN102663766A (en) * 2012-05-04 2012-09-12 云南大学 Non-photorealistic based art illustration effect drawing method

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101571952A (en) * 2009-06-18 2009-11-04 北京航空航天大学 Method for segmenting video object based on fixed period regional compensation
CN102663766A (en) * 2012-05-04 2012-09-12 云南大学 Non-photorealistic based art illustration effect drawing method

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
基于形态学和分水岭算法的数字图像分割;陈洁;《硕士学位论文》;20120427;说明书第17,24-25,27,41-42页 *
基于灰度和彩色铅笔画的研究与实现;闫利伟;《硕士学位论文》;20120501;说明书第14-17,21-22页 *

Also Published As

Publication number Publication date
CN106709964A (en) 2017-05-24

Similar Documents

Publication Publication Date Title
CN106709964B (en) Sketch generation method and device based on gradient correction and multidirectional texture extraction
Hao et al. Low-light image enhancement with semi-decoupled decomposition
Fu et al. Clearing the skies: A deep network architecture for single-image rain removal
CN106780576B (en) RGBD data stream-oriented camera pose estimation method
CN108875935B (en) Natural image target material visual characteristic mapping method based on generation countermeasure network
CN107516316B (en) Method for segmenting static human body image by introducing focusing mechanism into FCN
CN111243050B (en) Portrait simple drawing figure generation method and system and painting robot
US20150310305A1 (en) Learning painting styles for painterly rendering
CN103578084A (en) Color image enhancement method based on bright channel filtering
CN104616308A (en) Multiscale level set image segmenting method based on kernel fuzzy clustering
CN112418216A (en) Method for detecting characters in complex natural scene image
CN109961416B (en) Business license information extraction method based on morphological gradient multi-scale fusion
CN103914862A (en) Pencil sketch simulating method based on edge tangent stream
CN114066871B (en) Method for training new coronal pneumonia focus area segmentation model
Dong et al. Real-time image-based Chinese ink painting rendering
AU2018226403B2 (en) Brush stroke generation with deep neural networks
CN111243051A (en) Portrait photo-based stroke generating method, system and storage medium
CN105574814A (en) Portrait paper-cut special effect generation method
CN113392854A (en) Image texture feature extraction and classification method
CN101599172A (en) The illumination compensation splitting method of the text image of inhomogeneous illumination
Zang et al. Artistic preprocessing for painterly rendering and image stylization
Uchida et al. Stylized line-drawing of 3D models using CNN with line property encoding
Kim Image enhancement using patch-based principal energy analysis
CN107784626B (en) Three-dimensional digital concave-convex relief generating method based on single image
CN114429426B (en) Low-illumination image quality improvement method based on Retinex model

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20200218

Termination date: 20201206

CF01 Termination of patent right due to non-payment of annual fee