[go: up one dir, main page]

WO2018153264A1 - Image processing method and apparatus - Google Patents

Image processing method and apparatus Download PDF

Info

Publication number
WO2018153264A1
WO2018153264A1 PCT/CN2018/075676 CN2018075676W WO2018153264A1 WO 2018153264 A1 WO2018153264 A1 WO 2018153264A1 CN 2018075676 W CN2018075676 W CN 2018075676W WO 2018153264 A1 WO2018153264 A1 WO 2018153264A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
stroke
pixel
texture
determining
Prior art date
Application number
PCT/CN2018/075676
Other languages
French (fr)
Chinese (zh)
Other versions
WO2018153264A9 (en
Inventor
雷宇
金宇林
伏英娜
Original Assignee
迈吉客科技(北京)有限公司
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 迈吉客科技(北京)有限公司 filed Critical 迈吉客科技(北京)有限公司
Publication of WO2018153264A1 publication Critical patent/WO2018153264A1/en
Publication of WO2018153264A9 publication Critical patent/WO2018153264A9/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10004Still image; Photographic image

Definitions

  • the present invention relates to the field of image processing technologies, and in particular, to a method and an apparatus for image processing.
  • the stylization of the pencil drawing of the picture is an important direction of non-realistic drawing.
  • the purpose is to process the pictures in the real world and get a pencil drawing effect similar to artificial hand-painting.
  • a pencil drawing style picture of an original picture is mainly generated by an edge extraction method. Specifically, edge extraction is performed on the original image, and the image edge of the original image is output as a result.
  • the pencil drawing style picture obtained in the prior art lacks the brush stroke texture of the pencil drawing, and cannot reflect the characteristics of the original picture, such as light and dark contrast, and the pencil drawing effect is poor.
  • the embodiment of the invention provides a method and a device for image processing, which can improve the pencil drawing effect of a pencil drawing style picture.
  • an embodiment of the present invention provides a method for image processing, including: presetting at least one stroke texture;
  • the method further includes: presetting a correspondence between the gray level and the stroke texture;
  • the determining the stroke texture corresponding to each of the at least one image region comprises:
  • the determining the stroke texture corresponding to each of the at least one image region comprises:
  • the determining a stroke direction of the pixel in the contour image includes:
  • the first convolution result of the current pixel is convoluted by a predetermined number of directions, and a second convolution result of each direction of the current pixel in the preset number of directions is obtained.
  • a direction corresponding to a maximum value of the second convolution results of the preset number of directions is used as a stroke direction of the current pixel.
  • the method further includes:
  • the pencil drawing style image is colored according to the color information.
  • an apparatus for image processing including:
  • a saving unit for saving at least one stroke texture
  • a graying unit for performing grayscale processing on the original image to generate a grayscale image corresponding to the original image
  • An extracting unit configured to extract an edge of the grayscale image, and generate a contour image corresponding to the grayscale image
  • a dividing unit configured to divide the contour image into at least one image region according to a gray value of each pixel in the grayscale image
  • a determining unit configured to determine a stroke texture corresponding to each image region in the at least one image region
  • a generating unit configured to fill the stroke texture corresponding to the image region into the corresponding image region, and generate an image of a pencil drawing style corresponding to the original image.
  • the apparatus further includes: a setting unit, configured to set a correspondence relationship between the gray level and the stroke texture;
  • the determining unit is configured to determine a gray level of the image region according to a gray value of each pixel in the image region, and determine the image according to the correspondence relationship and a gray level of the image region The stroke texture corresponding to the region.
  • the determining unit is configured to determine a stroke direction of each pixel in the contour image, and determine a stroke direction of the stroke texture corresponding to the image region according to a stroke direction of the pixel, according to the image region The stroke direction of the stroke of the texture determines the stroke texture corresponding to the image area.
  • the determining unit includes:
  • a convolution subunit configured to perform full-picture convolution on the grayscale image to obtain a first convolution result of each pixel
  • Determining a subunit configured to convolve a first number of directions of the current convolution result of the current pixel for each pixel, and obtain a second of each direction of the current pixel in the preset number of directions As a result of the convolution, a direction corresponding to a maximum value of the second convolution results of the preset number of directions is taken as a stroke direction of the current pixel.
  • the apparatus further includes: a coloring unit configured to acquire color information of the original image, and color the image of the pencil drawing style according to the color information.
  • an embodiment of the present invention provides a storage controller, including a processor and a memory.
  • the memory is configured to store an execution instruction of the method of image processing described above;
  • the processor is configured to execute the execution instruction stored by the memory.
  • the gray image of the original image is extracted, and the corresponding contour image is generated according to the gray image to form a basic outline of the last generated pencil drawing style image, and the contour image is divided according to the gray level of each pixel.
  • Each image area is filled with a corresponding stroke texture in the image area, so that the finally generated pencil-painted image is more full on the basis of the basic contour, closer to the real pencil drawing, and provides the pencil-style picture corresponding to the original image. Pencil drawing effect.
  • FIG. 1 is a flowchart of a method for image processing according to an embodiment of the present invention
  • FIG. 2 is a flowchart of another method for image processing according to an embodiment of the present invention.
  • FIG. 3 is a schematic diagram of an apparatus for image processing according to an embodiment of the present invention.
  • FIG. 4 is a schematic diagram of another apparatus for image processing according to an embodiment of the present invention.
  • FIG. 5 is a schematic diagram of still another apparatus for image processing according to an embodiment of the present invention.
  • FIG. 6 is a schematic diagram of still another apparatus for image processing according to an embodiment of the present invention.
  • an embodiment of the present invention provides a method for image processing, which may include the following steps:
  • Step 101 preset at least one stroke texture
  • Step 102 Perform grayscale processing on the original image to generate a grayscale image corresponding to the original image.
  • Step 103 Extract an edge of the grayscale image, and generate a contour image corresponding to the grayscale image.
  • Step 104 Dividing the contour image into at least one image region according to a gray value of each pixel in the grayscale image
  • Step 105 Determine a stroke texture corresponding to each of the image regions
  • Step 106 Fill the corresponding brush stroke texture corresponding to each of the image regions into the corresponding image region, and generate an image of a pencil drawing style corresponding to the original image.
  • the gray image of the original image is extracted, and the corresponding contour image is generated according to the gray image to form a basic outline of the last generated pencil drawing style image, and the contour image is divided according to the gray level of each pixel.
  • Each image area is filled with a corresponding stroke texture in the image area, so that the finally generated pencil-painted image is more full on the basis of the basic contour, closer to the real pencil drawing, and provides the pencil-style picture corresponding to the original image. Pencil drawing effect.
  • the method further includes: presetting a correspondence between the gray level and the brush texture in order to further improve the pencil drawing effect of the pencil drawing style image corresponding to the original image;
  • Determining a stroke texture corresponding to each of the image regions including:
  • each stroke texture may be preset according to the line density.
  • the line density of the first stroke texture is within a preset first range
  • the line density of the second stroke texture is at a preset second.
  • the line density of the third stroke texture is within a preset third range.
  • the image region may be divided into gradation levels according to the gradation value of each pixel in the image region.
  • the gray value range corresponding to the gray level 1 is [0, 70]
  • the gray value range corresponding to the gray level 2 is (70, 150)
  • the gray value range corresponding to the gray level 3 is ( 150, 255], wherein, when determining the gradation value of the image region, the average value of the gradation values of the respective pixels of the image region may be used as the gradation value of the image region.
  • each pixel of the image region A The average value of the gray value is 90
  • the gray level of the image area A is gray level 2.
  • the stroke texture corresponding to the gray level 2 is the second stroke texture.
  • the gray value range is The smaller the maximum value, the higher the line density of the corresponding stroke texture.
  • the stroke texture of each image region is determined by the magnitude of the gray value of each image region, so that the darker region is filled with the stroke texture with a larger line density, so that the stroke texture of each image region is more
  • the style close to the real pencil drawing further enhances the pencil drawing effect of the pencil-style image corresponding to the original image.
  • the lines that can be set in each stroke texture have a certain stroke direction, for example: from bottom left to top right, from top left to bottom right, from top right to bottom left, from bottom right to top left.
  • the starting end color of the line is deeper than the end point.
  • the stroke direction is from the bottom left to the upper right line, the lower left color is darker, and the upper right color is lighter.
  • the determining the stroke texture corresponding to each of the image regions comprises:
  • a stroke texture corresponding to each of the image regions is determined according to a stroke direction of a stroke texture corresponding to each of the image regions.
  • the stroke direction of the stroke texture corresponding to each image region when determining the stroke direction of the stroke texture corresponding to each image region, it may be determined according to the number of pixels corresponding to each stroke direction in the current image region, specifically, the stroke with the largest number of corresponding pixels
  • the direction is the stroke direction of the current image area.
  • the stroke direction of 10 pixels is the stroke direction 1
  • the stroke direction of 20 pixels is the stroke direction 2
  • the stroke direction of 300 pixels is the stroke direction 3
  • the target stroke texture with the same stroke direction of the stroke texture corresponding to the current image region may be found from the preset at least one stroke texture, and the target stroke texture is As the stroke texture corresponding to the current image area.
  • the stroke direction of each pixel in the image area is embodied by the filled stroke texture, so that the pencil drawing effect of the generated pencil drawing style image is better.
  • the determining a stroke direction of each of the pixels in the contour image comprises: performing a full-image convolution on the grayscale image to obtain a first convolution result of each pixel;
  • the first convolution result of the current pixel is convoluted by a predetermined number of directions, and a second convolution result of each direction of the current pixel in the preset number of directions is obtained.
  • a direction corresponding to a maximum value of the second convolution results of the preset number of directions is used as a stroke direction of the current pixel.
  • each stroke texture carries information of a stroke direction, that is, a line in each stroke texture has a certain direction, for example, the stroke direction of the stroke texture 1 is from the lower left to the upper right.
  • the gray image of the image to be processed is subjected to full-image convolution to obtain a light-dark relationship between each pixel.
  • the mean direction of the stroke direction can also be hashed to ensure that the image does not change repeatedly.
  • the stroke direction of the pixel A when determining the stroke direction of the pixel A, it can be realized by setting three stroke textures in advance, wherein the stroke direction of the stroke texture 1 is the stroke direction 1, and the stroke direction of the stroke texture 2 For the stroke direction 2, the stroke direction of the stroke texture 3 is the stroke direction 3. Determining a second convolution result 1 of pixel A in direction 1, determining a second convolution result 2 of pixel A in direction 2, determining a second convolution result 3 of pixel A in direction 3, if these three responses Among the values, the second convolution result 2 is the largest, then the direction 2 corresponding to the second convolution result 2 is the stroke direction of the pixel A.
  • the method may further include: determining a convolution kernel of each pixel, determining a gradient value of each pixel in the contour image; for each pixel, according to a stroke direction of the current pixel, the current pixel.
  • the convolution kernel in the stroke direction and the gradient values of the surrounding pixels of the current pixel enhance the response of the current pixel in the corresponding stroke direction, and also reduce the noise caused by the gradient calculation.
  • the method further includes:
  • the pencil drawing style image is colored according to the color information.
  • the color information of the original image may be RGB information of each pixel in the original image.
  • an embodiment of the present invention provides a method for image processing, which may include the following steps:
  • Step 201 At least one stroke texture is preset, and each stroke texture is set with a corresponding stroke direction.
  • each stroke texture may include two features: line density and stroke direction.
  • Stroke textures can be implemented by texture mapping.
  • the stroke texture may include pure black, pure white, and slash, wherein the line density of the lines in the pure black stroke texture is greater than the line density of the lines in the stroke texture of the slash, and the stroke texture in the slash The line density of the lines is greater than the line density of the lines in the pure white brush texture.
  • each line density can be combined with each stroke direction to form a stroke texture
  • the line density of the stroke texture 1 is the line density A
  • the stroke direction is the direction A
  • the line density of the stroke texture 2 is the line density A
  • the stroke direction is the direction B
  • the line density of the stroke texture 3 is the line density A
  • the stroke direction is the direction C, and the like.
  • various line densities can be combined with various brush stroke directions to form a plurality of brush stroke textures to satisfy various original images.
  • one implementation manner is: six stroke textures in advance, wherein the line density of the stroke texture 1 is the line density A, the stroke direction is the direction A; the line density of the stroke texture 2 is the line density A, and the stroke direction is the direction. B; stroke density 3 line density is line density B, stroke direction is direction A; stroke texture 4 line density is line density B, stroke direction is direction B; stroke texture 5 line density is line density C, stroke direction is Direction A; the line density of the stroke texture 6 is the line density C, and the stroke direction is the direction B.
  • Step 202 Pre-set the correspondence between the gray level and the stroke texture.
  • the gray level of the image is reflected by the line density on the stroke texture.
  • the gray level can be divided by the range of gray values.
  • the tone curve of the photo is matched with the gray histogram of the pencil drawing to conform to the gray distribution rule of the pencil drawing, and then the gray value range of the image area is combined to be classified.
  • the gray level can be divided into three levels, namely gray level 1, gray level 2, and gray level 3.
  • the line density A corresponds to the gray level 1
  • the line density B corresponds to the gray level 2
  • the line density C corresponds to the gray level 3, that is, the stroke texture 1 corresponds to the gray level 1, the stroke texture 2 and the gray level
  • the stroke texture 3 corresponds to the gray level 2
  • the stroke texture 4 corresponds to the gray level 2
  • the stroke texture 5 corresponds to the gray level 3
  • the stroke texture 6 corresponds to the gray level 3.
  • Step 203 Perform grayscale processing on the original image to generate a grayscale image corresponding to the original image.
  • Step 204 Extract an edge of the grayscale image to generate a contour image corresponding to the grayscale image.
  • the contour image can be obtained by extracting the edge of the grayscale image by the Laplacian. Then, a reasonable threshold can be set by which the process of profile picking is achieved. The area with a relatively large area is determined by the threshold, and the area with a small area may not participate in the subsequent processing.
  • Step 205 Divide the contour image into at least one image region according to the gray value of each pixel in the grayscale image.
  • the region can be divided according to the severity of the change in the gray value, and the place where the gray value is abrupt is the edge of several regions.
  • Step 206 Determine the gray level of each image area according to the gray value of each pixel in each image area.
  • the average value of the gray values of the respective pixels in the current image region may be used as the gray value of the current image region, thereby determining which gray level the current image region belongs to.
  • the gradation level of the image area A is gradation level 1.
  • Step 207 Determine the stroke direction of each pixel in the contour image.
  • the first convolution result of the current pixel is convoluted by a predetermined number of directions, and a second convolution result of each direction of the current pixel in the preset number of directions is obtained.
  • a direction corresponding to a maximum value of the second convolution results of the preset number of directions is used as a stroke direction of the current pixel.
  • Step 208 Determine the stroke direction of the stroke texture corresponding to each image region according to the stroke direction of each pixel.
  • the brush point direction is the most pixel point of the direction A, and it can be determined that the stroke direction of the stroke texture corresponding to the image area A is the direction A.
  • direction A is from bottom left to top right.
  • Step 209 Determine a stroke texture corresponding to each image region according to the correspondence relationship, the gray level of each image region, and the stroke direction of the stroke texture corresponding to each of the image regions.
  • the stroke texture corresponding to each image region is determined by two parameters of gray scale and stroke direction.
  • the stroke texture corresponding to the image area A can be the stroke texture 1 and the stroke texture 2.
  • the direction A is determined. From the stroke texture 1 and the stroke texture 2, it can be determined that the stroke texture corresponding to the image area A is the stroke texture 1.
  • Step 210 Fill the corresponding touch image texture into the corresponding image area to generate an image of the pencil drawing style corresponding to the original image.
  • the stroke texture 1 corresponding to the image area A is filled into the image area A.
  • the other image areas are also filled with corresponding stroke textures, thereby obtaining a pencil-drawn style image corresponding to the original image.
  • the method may further include: acquiring color information of the original image; and coloring the image of the pencil drawing style corresponding to the original image according to the color information.
  • the color of each pixel in the original image may be acquired, and for each pixel on the pencil drawing style image corresponding to the original image, the current pixel is colored according to the color information of the pixel on the original image corresponding to the current pixel.
  • the pixel A on the original image corresponds to the pixel C on the pencil-drawn image corresponding to the original image, and the RGB of the pixel A on the original image is acquired, and the pixel C is colored according to the RGB of the pixel A.
  • the stroke texture is preset, and the preset stroke texture is filled into the corresponding image region to generate an image of the pencil drawing style corresponding to the original image, and the calculation amount is small, and the processing speed is fast.
  • each frame in the video is separately subjected to pencil drawing processing as an original image to obtain an image of a pencil drawing style corresponding to each frame.
  • the generated brush stroke style image can have the pencil stroke style and the highlight shadow effect of the generated pencil stroke style, which is closer to the real pencil drawing, and the pencil drawing effect is better.
  • the calculation amount can be greatly reduced, the required computing resources are less, and can be implemented on a mobile terminal such as a mobile phone, which can achieve real-time effects and can obtain a better pencil drawing. effect.
  • an embodiment of the present invention provides an apparatus for image processing.
  • the device embodiment may be implemented by software, or may be implemented by hardware or a combination of hardware and software.
  • FIG. 3 a hardware structure diagram of a device for processing an image processing apparatus according to an embodiment of the present invention, except for the processor, the memory, the network interface, and the non-
  • the device in which the device is located in the embodiment may also typically include other hardware, such as a forwarding chip responsible for processing the message, and the like.
  • the CPU of the device in which it is located reads the corresponding computer program instructions in the non-volatile memory into the memory.
  • An apparatus for image processing provided by this embodiment includes:
  • a saving unit 401 configured to save at least one stroke texture
  • the gradation unit 402 is configured to perform gradation processing on the original image to generate a grayscale image corresponding to the original image;
  • An extracting unit 403 configured to extract an edge of the grayscale image, and generate a contour image corresponding to the grayscale image
  • a dividing unit 404 configured to divide the contour image into at least one image region according to a gray value of each pixel in the grayscale image
  • a determining unit 405, configured to determine a stroke texture corresponding to each of the image regions
  • the generating unit 406 is configured to fill the stroke texture corresponding to each of the image regions into the corresponding image region, and generate an image of a pencil drawing style corresponding to the original image.
  • the apparatus further includes: a setting unit 501, configured to set a correspondence between the gray level and the stroke texture ;
  • the determining unit is configured to determine a gray level of each of the image regions according to a gray value of each of the pixels in each of the image regions, according to the correspondence relationship and each of the image regions Gray scale, determining the stroke texture corresponding to each of the image regions.
  • the determining unit is configured to determine a stroke direction of each of the pixels in the contour image, and determine a stroke corresponding to each of the image regions according to a stroke direction of each of the pixels
  • the stroke direction of the texture determines the stroke texture corresponding to each of the image regions according to the stroke direction of the stroke texture corresponding to each of the image regions.
  • the determining unit includes:
  • a convolution subunit configured to perform full-picture convolution on the grayscale image to obtain a first convolution result of each pixel
  • Determining a subunit configured to convolve a first number of directions of the current convolution result of the current pixel for each pixel, and obtain a second of each direction of the current pixel in the preset number of directions As a result of the convolution, a direction corresponding to a maximum value of the second convolution results of the preset number of directions is taken as a stroke direction of the current pixel.
  • the apparatus further includes: a coloring unit 601, configured to acquire color information of the original image, according to The color information colors the image of the pencil drawing style.
  • An apparatus for image processing provided by an embodiment of the present invention can be implemented on a mobile terminal such as a mobile phone.
  • the embodiment of the present invention provides a readable medium, including an execution instruction, when the processor of the storage controller executes the execution instruction, the storage controller performs an image processing according to any one of the embodiments of the present invention. Methods.
  • An embodiment of the present invention provides a storage controller, including: a processor, a memory, and a bus;
  • the memory is configured to store an execution instruction
  • the processor is connected to the memory through the bus, and when the storage controller is running, the processor executes the execution instruction stored in the memory to make
  • the storage controller performs a method of image processing according to any one of the embodiments of the present invention.
  • the gray image of the original image is extracted, and the corresponding contour image is generated according to the gray image to form a basic outline of the last generated pencil drawing style image, and the contour is formed according to the gray level of each pixel.
  • the image is divided into individual image regions, and the corresponding brush stroke texture is filled in the image region, so that the finally generated pencil-painted image is more full on the basis of the basic contour, and is closer to the real pencil drawing, and provides the pencil drawing style corresponding to the original image.
  • the pencil drawing effect of the picture is applied to the picture.
  • the stroke texture of each image region is determined by the magnitude of the gray value of each image region, so that the darker region is filled with the stroke texture with a larger line density, so that the strokes of the respective image regions are made.
  • the texture is closer to the style of the real pencil drawing, which further enhances the pencil drawing effect of the pencil-style image corresponding to the original image.
  • the stroke direction is set in the stroke texture, and the stroke texture is filled into the corresponding image area according to the stroke direction, so that the generated pencil style image is closer to the hand drawn pencil drawing, and the pencil drawing effect is better.
  • the stroke texture is preset, and the preset stroke texture is filled into the corresponding image region to generate a pencil-drawn image corresponding to the original image, and the calculation amount is small, and the processing speed is fast.
  • the generated pencil stroke style image can have the pencil stroke and the highlight shadow effect of the generated pencil stroke style, which is closer to the real pencil drawing, and the pencil drawing effect is better.
  • the calculation amount can be greatly reduced, the required computing resources are less, and can be implemented on a mobile terminal such as a mobile phone, which can achieve real-time effects and can achieve better results. Pencil drawing effect.
  • the disclosed systems, devices, and methods may be implemented in other manners.
  • the device embodiments described above are merely illustrative.
  • the division of the unit is only a logical function division.
  • there may be another division manner for example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored or not executed.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be in an electrical, mechanical or other form.
  • the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the image processing method and apparatus of the embodiment of the present invention avoids processing of a large number of redundant image signals, and simplifies the calculation amount of image processing. It can be widely applied to smart mobile terminal devices to improve the efficiency of human-computer interaction process.

Landscapes

  • Image Generation (AREA)
  • Image Processing (AREA)
  • Processing Or Creating Images (AREA)

Abstract

An image processing method and apparatus. The method comprises: presetting at least one brushstroke texture; graying an original image to generate a grayscale image corresponding to the original image; extracting an edge of the grayscale image to generate an outline image corresponding to the grayscale image; dividing the outline image into at least one image region according to a grayscale value of each pixel in the grayscale image; determining a brushstroke texture corresponding to each image region; and filling the brushstroke texture corresponding to each image region, into the corresponding image region, so as to generate a pencil-drawing-style image corresponding to the original image. The pencil drawing effect of a pencil-drawing-style image can be improved.

Description

一种图像处理的方法及装置Method and device for image processing
本发明是要求由申请人提出的,申请日为2017年02月27日,申请号为CN201710109287.5,名称为“一种图像处理的方法及装置”的申请的优先权。以上申请的全部内容通过整体引用结合于此。The present invention claims priority from the applicant's application, which is filed on February 27, 2017, and whose application number is CN201710109287.5, entitled "A Method and Apparatus for Image Processing." The entire contents of the above application are hereby incorporated by reference in its entirety.
技术领域Technical field
本发明涉及图像处理技术领域,特别涉及一种图像处理的方法及装置。The present invention relates to the field of image processing technologies, and in particular, to a method and an apparatus for image processing.
背景技术Background technique
图片的铅笔画风格化是非真实绘制的一个重要方向,目的是对现实世界的图片进行处理,得到类似于人工手绘的铅笔画效果。The stylization of the pencil drawing of the picture is an important direction of non-realistic drawing. The purpose is to process the pictures in the real world and get a pencil drawing effect similar to artificial hand-painting.
现有技术中,主要通过边缘提取的方法来生成原始图片的铅笔画风格的图片。具体地,对原始图片进行边缘提取,将原始图片的图像边缘作为结果输出。In the prior art, a pencil drawing style picture of an original picture is mainly generated by an edge extraction method. Specifically, edge extraction is performed on the original image, and the image edge of the original image is output as a result.
通过上述描述可见,现有技术得到的铅笔画风格的图片缺少铅笔画的笔触纹理,无法体现原始图片的明暗对比等特征,铅笔画效果较差。It can be seen from the above description that the pencil drawing style picture obtained in the prior art lacks the brush stroke texture of the pencil drawing, and cannot reflect the characteristics of the original picture, such as light and dark contrast, and the pencil drawing effect is poor.
发明内容Summary of the invention
本发明实施例提供了一种图像处理的方法及装置,能够提高铅笔画风格的图片的铅笔画效果。The embodiment of the invention provides a method and a device for image processing, which can improve the pencil drawing effect of a pencil drawing style picture.
一方面,本发明实施例提供了一种图像处理的方法,包括:预先设置至少一个笔触纹理;In one aspect, an embodiment of the present invention provides a method for image processing, including: presetting at least one stroke texture;
对原始图像进行灰度化处理,生成所述原始图像对应的灰度图像;Performing grayscale processing on the original image to generate a grayscale image corresponding to the original image;
提取所述灰度图像的边缘,生成所述灰度图像对应的轮廓图像;Extracting an edge of the grayscale image to generate a contour image corresponding to the grayscale image;
根据所述灰度图像中每个像素的灰度值,将所述轮廓图像分成至少一个图像区域;Dividing the contour image into at least one image region according to a gray value of each pixel in the grayscale image;
确定所述至少一个图像区域中的每个图像区域对应的笔触纹理;Determining a stroke texture corresponding to each of the at least one image region;
将所述图像区域对应的所述笔触纹理填充到对应的所述图像区域中,生成所述原始图像对应的铅笔画风格的图像。Filling the stroke texture corresponding to the image area into the corresponding image area to generate an image of a pencil drawing style corresponding to the original image.
进一步地,该方法进一步包括:预先设置灰度等级与所述笔触纹理的对应关系;Further, the method further includes: presetting a correspondence between the gray level and the stroke texture;
所述确定所述至少一个图像区域中的每个图像区域对应的笔触纹理,包括:The determining the stroke texture corresponding to each of the at least one image region comprises:
根据所述图像区域中每个像素的灰度值,确定所述图像区域的灰度等级;Determining a gray level of the image region according to a gray value of each pixel in the image region;
根据所述对应关系和所述图像区域的灰度等级,确定所述图像区域对应的所述笔触纹理。And determining the stroke texture corresponding to the image region according to the correspondence relationship and a gray level of the image region.
所述确定所述至少一个图像区域中的每个图像区域对应的笔触纹理,包括:The determining the stroke texture corresponding to each of the at least one image region comprises:
确定所述轮廓图像中每个像素的笔触方向;Determining a stroke direction of each pixel in the contour image;
根据所述轮廓图像中每个像素的笔触方向,确定所述图像区域对应的笔触纹理的笔触方向;Determining, according to a stroke direction of each pixel in the contour image, a stroke direction of a stroke texture corresponding to the image region;
根据所述图像区域对应的笔触纹理的笔触方向,确定所述图像区域对应的笔触纹理。Determining a stroke texture corresponding to the image region according to a stroke direction of the stroke texture corresponding to the image region.
进一步地,所述确定所述轮廓图像中所述像素的笔触方向包括:Further, the determining a stroke direction of the pixel in the contour image includes:
对所述灰度图像进行全图卷积,获得每个像素的第一卷积结果;Performing full-image convolution on the grayscale image to obtain a first convolution result of each pixel;
针对每个像素,对当前像素的第一卷积结果取预设数量个方向进行卷积,获取所述当前像 素在所述预设数量个方向中每个方向的第二卷积结果,将所述预设数量个方向的第二卷积结果中的最大值对应的方向作为所述当前像素的笔触方向。For each pixel, the first convolution result of the current pixel is convoluted by a predetermined number of directions, and a second convolution result of each direction of the current pixel in the preset number of directions is obtained. A direction corresponding to a maximum value of the second convolution results of the preset number of directions is used as a stroke direction of the current pixel.
进一步地,在所述生成所述原始图像对应的铅笔画风格的图像之后,进一步包括:Further, after the generating the image of the pencil drawing style corresponding to the original image, the method further includes:
获取所述原始图像的颜色信息;Obtaining color information of the original image;
根据所述颜色信息对所述铅笔画风格的图像上色。The pencil drawing style image is colored according to the color information.
另一方面,本发明实施例提供了一种图像处理的装置,包括:In another aspect, an embodiment of the present invention provides an apparatus for image processing, including:
保存单元,用于保存至少一个笔触纹理;a saving unit for saving at least one stroke texture;
灰度化单元,用于对原始图像进行灰度化处理,生成所述原始图像对应的灰度图像;a graying unit for performing grayscale processing on the original image to generate a grayscale image corresponding to the original image;
提取单元,用于提取所述灰度图像的边缘,生成所述灰度图像对应的轮廓图像;An extracting unit, configured to extract an edge of the grayscale image, and generate a contour image corresponding to the grayscale image;
划分单元,用于根据所述灰度图像中每个像素的灰度值,将所述轮廓图像分成至少一个图像区域;a dividing unit, configured to divide the contour image into at least one image region according to a gray value of each pixel in the grayscale image;
确定单元,用于确定所述至少一个图像区域中的每个图像区域对应的笔触纹理;a determining unit, configured to determine a stroke texture corresponding to each image region in the at least one image region;
生成单元,用于将所述图像区域对应的所述笔触纹理填充到对应的所述图像区域中,生成所述原始图像对应的铅笔画风格的图像。And a generating unit, configured to fill the stroke texture corresponding to the image region into the corresponding image region, and generate an image of a pencil drawing style corresponding to the original image.
进一步地,该装置进一步包括:设置单元,用于设置灰度等级与所述笔触纹理的对应关系;Further, the apparatus further includes: a setting unit, configured to set a correspondence relationship between the gray level and the stroke texture;
所述确定单元,用于根据所述图像区域中每个像素的灰度值,确定所述图像区域的灰度等级,根据所述对应关系和所述图像区域的灰度等级,确定所述图像区域对应的所述笔触纹理。The determining unit is configured to determine a gray level of the image region according to a gray value of each pixel in the image region, and determine the image according to the correspondence relationship and a gray level of the image region The stroke texture corresponding to the region.
进一步地,所述确定单元,用于确定所述轮廓图像中每个像素的笔触方向,根据所述像素的笔触方向,确定所述图像区域对应的笔触纹理的笔触方向,根据所述图像区域对应的笔触纹理的笔触方向,确定所述图像区域对应的笔触纹理。Further, the determining unit is configured to determine a stroke direction of each pixel in the contour image, and determine a stroke direction of the stroke texture corresponding to the image region according to a stroke direction of the pixel, according to the image region The stroke direction of the stroke of the texture determines the stroke texture corresponding to the image area.
进一步地,所述确定单元,包括:Further, the determining unit includes:
卷积子单元,用于对所述灰度图像进行全图卷积,获得每个像素的第一卷积结果;a convolution subunit, configured to perform full-picture convolution on the grayscale image to obtain a first convolution result of each pixel;
确定子单元,用于针对每个像素,对当前像素的第一卷积结果取预设数量个方向进行卷积,获取所述当前像素在所述预设数量个方向中每个方向的第二卷积结果,将所述预设数量个方向的第二卷积结果中的最大值对应的方向作为所述当前像素的笔触方向。Determining a subunit, configured to convolve a first number of directions of the current convolution result of the current pixel for each pixel, and obtain a second of each direction of the current pixel in the preset number of directions As a result of the convolution, a direction corresponding to a maximum value of the second convolution results of the preset number of directions is taken as a stroke direction of the current pixel.
进一步地,该装置进一步包括:上色单元,用于获取所述原始图像的颜色信息,根据所述颜色信息对所述铅笔画风格的图像上色。Further, the apparatus further includes: a coloring unit configured to acquire color information of the original image, and color the image of the pencil drawing style according to the color information.
另一方面,本发明实施例提供了一种存储控制器,包括处理器和存储器,In another aspect, an embodiment of the present invention provides a storage controller, including a processor and a memory.
所述存储器用于存储上述的图像处理的方法的执行指令;The memory is configured to store an execution instruction of the method of image processing described above;
所述处理器用于执行所述存储器存储的所述执行指令。The processor is configured to execute the execution instruction stored by the memory.
在本发明实施例中,提取出原始图像的灰度图像,根据灰度图像生成对应的轮廓图像,形成最后生成的铅笔画风格的图像的基础轮廓,按照每个像素的灰度,将轮廓图像分成各个图像区域,在图像区域中填充上对应的笔触纹理,使得最后生成的铅笔画风格的图像在基础轮廓的基础上内容更加丰满,更加接近真实的铅笔画,提供了原始图像对应的铅笔画风格的图片的铅笔画效果。In the embodiment of the present invention, the gray image of the original image is extracted, and the corresponding contour image is generated according to the gray image to form a basic outline of the last generated pencil drawing style image, and the contour image is divided according to the gray level of each pixel. Each image area is filled with a corresponding stroke texture in the image area, so that the finally generated pencil-painted image is more full on the basis of the basic contour, closer to the real pencil drawing, and provides the pencil-style picture corresponding to the original image. Pencil drawing effect.
附图简要说明BRIEF DESCRIPTION OF THE DRAWINGS
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the embodiments or the description of the prior art will be briefly described below. Obviously, the drawings in the following description are Some embodiments of the present invention may also be used to obtain other drawings based on these drawings without departing from the art.
图1是本发明一实施例提供的一种图像处理的方法的流程图;FIG. 1 is a flowchart of a method for image processing according to an embodiment of the present invention;
图2是本发明一实施例提供的另一种图像处理的方法的流程图;2 is a flowchart of another method for image processing according to an embodiment of the present invention;
图3是本发明一实施例提供的一种图像处理的装置的示意图;FIG. 3 is a schematic diagram of an apparatus for image processing according to an embodiment of the present invention; FIG.
图4是本发明一实施例提供的另一种图像处理的装置的示意图;FIG. 4 is a schematic diagram of another apparatus for image processing according to an embodiment of the present invention; FIG.
图5是本发明一实施例提供的又一种图像处理的装置的示意图;FIG. 5 is a schematic diagram of still another apparatus for image processing according to an embodiment of the present invention; FIG.
图6是本发明一实施例提供的再一种图像处理的装置的示意图。FIG. 6 is a schematic diagram of still another apparatus for image processing according to an embodiment of the present invention.
实施本发明的方式Mode for carrying out the invention
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例,基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the drawings in the embodiments of the present invention. It is a part of the embodiments of the present invention, and not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative efforts are protected by the present invention. range.
如图1所示,本发明实施例提供了一种图像处理的方法,该方法可以包括以下步骤:As shown in FIG. 1 , an embodiment of the present invention provides a method for image processing, which may include the following steps:
步骤101:预先设置至少一个笔触纹理;Step 101: preset at least one stroke texture;
步骤102:对原始图像进行灰度化处理,生成所述原始图像对应的灰度图像;Step 102: Perform grayscale processing on the original image to generate a grayscale image corresponding to the original image.
步骤103:提取所述灰度图像的边缘,生成所述灰度图像对应的轮廓图像;Step 103: Extract an edge of the grayscale image, and generate a contour image corresponding to the grayscale image.
步骤104:根据所述灰度图像中每个像素的灰度值,将所述轮廓图像分成至少一个图像区域;Step 104: Dividing the contour image into at least one image region according to a gray value of each pixel in the grayscale image;
步骤105:确定每个所述图像区域对应的笔触纹理;Step 105: Determine a stroke texture corresponding to each of the image regions;
步骤106:将每个所述图像区域对应的所述笔触纹理填充到对应的所述图像区域中,生成所述原始图像对应的铅笔画风格的图像。Step 106: Fill the corresponding brush stroke texture corresponding to each of the image regions into the corresponding image region, and generate an image of a pencil drawing style corresponding to the original image.
在本发明实施例中,提取出原始图像的灰度图像,根据灰度图像生成对应的轮廓图像,形成最后生成的铅笔画风格的图像的基础轮廓,按照每个像素的灰度,将轮廓图像分成各个图像区域,在图像区域中填充上对应的笔触纹理,使得最后生成的铅笔画风格的图像在基础轮廓的基础上内容更加丰满,更加接近真实的铅笔画,提供了原始图像对应的铅笔画风格的图片的铅笔画效果。In the embodiment of the present invention, the gray image of the original image is extracted, and the corresponding contour image is generated according to the gray image to form a basic outline of the last generated pencil drawing style image, and the contour image is divided according to the gray level of each pixel. Each image area is filled with a corresponding stroke texture in the image area, so that the finally generated pencil-painted image is more full on the basis of the basic contour, closer to the real pencil drawing, and provides the pencil-style picture corresponding to the original image. Pencil drawing effect.
为了能够进一步提高原始图像对应的铅笔画风格的图像的铅笔画效果,在本发明一实施例中,该方法进一步包括:预先设置灰度等级与所述笔触纹理的对应关系;In an embodiment of the invention, the method further includes: presetting a correspondence between the gray level and the brush texture in order to further improve the pencil drawing effect of the pencil drawing style image corresponding to the original image;
所述确定每个所述图像区域对应的笔触纹理,包括:Determining a stroke texture corresponding to each of the image regions, including:
根据每个所述图像区域中每个所述像素的灰度值,确定每个所述图像区域的灰度等级;Determining a gray level of each of the image regions according to a gray value of each of the pixels in each of the image regions;
根据所述对应关系和每个所述图像区域的灰度等级,确定每个所述图像区域对应的所述笔触纹理。And determining the stroke texture corresponding to each of the image regions according to the correspondence relationship and a gray level of each of the image regions.
在本发明实施例中,可以按照线条密度预先设置各个笔触纹理,举例来说,第一笔触纹理的线条密度在预设的第一范围内,第二笔触纹理的线条密度在预设的第二范围内,第三笔触纹理的线条密度在预设的第三范围内。另外,可以根据图像区域中的每个像素的灰度值,对图像区域划分灰度等级。举例来说,灰度等级1对应的灰度值范围是[0,70],灰度等级2对应的灰度值范围是(70,150],灰度等级3对应的灰度值范围是(150,255],其中,在确定图像区域的灰度值时,可以将该图像区域的各个像素的灰度值的平均值作为该图像区域的灰度值。例如:图像区域A的各个像素的灰度值的平均值为90,则图像区域A的灰度等级为灰度等级2。假设灰度等级2对应的笔触纹理为第二笔触纹理。在设置对应关系是,灰度值范围中的最大值越小,对应的笔触纹理的线条密度越高。In the embodiment of the present invention, each stroke texture may be preset according to the line density. For example, the line density of the first stroke texture is within a preset first range, and the line density of the second stroke texture is at a preset second. Within the range, the line density of the third stroke texture is within a preset third range. In addition, the image region may be divided into gradation levels according to the gradation value of each pixel in the image region. For example, the gray value range corresponding to the gray level 1 is [0, 70], the gray value range corresponding to the gray level 2 is (70, 150), and the gray value range corresponding to the gray level 3 is ( 150, 255], wherein, when determining the gradation value of the image region, the average value of the gradation values of the respective pixels of the image region may be used as the gradation value of the image region. For example, each pixel of the image region A The average value of the gray value is 90, and the gray level of the image area A is gray level 2. It is assumed that the stroke texture corresponding to the gray level 2 is the second stroke texture. In the setting correspondence, the gray value range is The smaller the maximum value, the higher the line density of the corresponding stroke texture.
在本发明实施例中,通过各个图像区域的灰度值的大小来确定各个图像区域的笔触纹理,能够使得颜色较深的区域填充线条密度较大的笔触纹理,使得各个图像区域的笔触纹理更加接近真实的铅笔画的风格,进一步提高了原始图像对应的铅笔画风格的图像的铅笔画效果。In the embodiment of the present invention, the stroke texture of each image region is determined by the magnitude of the gray value of each image region, so that the darker region is filled with the stroke texture with a larger line density, so that the stroke texture of each image region is more The style close to the real pencil drawing further enhances the pencil drawing effect of the pencil-style image corresponding to the original image.
为了更加接近真实的铅笔画,可以设置在每个笔触纹理中的线条就有某个笔触方向,例如:从左下到右上、从左上到右下、从右上到左下、从右下到左上等。其中,线条的起始端颜色较终点端深。例如:笔触方向为从左下到右上的线条,左下的颜色较深,右上的颜色较浅。To get closer to the real pencil drawing, the lines that can be set in each stroke texture have a certain stroke direction, for example: from bottom left to top right, from top left to bottom right, from top right to bottom left, from bottom right to top left. Among them, the starting end color of the line is deeper than the end point. For example, the stroke direction is from the bottom left to the upper right line, the lower left color is darker, and the upper right color is lighter.
为了进一步提高原始图像对应的铅笔画风格的图像的铅笔画效果,在本发明一实施例中,所述确定每个所述图像区域对应的笔触纹理,包括:In order to further improve the pencil drawing effect of the pencil drawing style image corresponding to the original image, in an embodiment of the invention, the determining the stroke texture corresponding to each of the image regions comprises:
确定所述轮廓图像中每个所述像素的笔触方向;Determining a stroke direction of each of the pixels in the contour image;
根据每个所述像素的笔触方向,确定每个所述图像区域对应的笔触纹理的笔触方向;Determining a stroke direction of a stroke texture corresponding to each of the image regions according to a stroke direction of each of the pixels;
根据每个所述图像区域对应的笔触纹理的笔触方向,确定每个所述图像区域对应的笔触纹理。A stroke texture corresponding to each of the image regions is determined according to a stroke direction of a stroke texture corresponding to each of the image regions.
在本发明实施例中,在确定每个图像区域对应的笔触纹理的笔触方向时,可以根据当前图像区域中每个笔触方向对应的像素数来确定,具体地,将对应的像素数最多的笔触方向作为当前图像区域的笔触方向。举例来说,在图像区域A中,有10个像素的笔触方向为笔触方向1,有20个像素的笔触方向为笔触方向2,有300个像素的笔触方向为笔触方向3,那么,笔触方向为图像区域A的笔触方向。在确定出当前图像区域对应的笔触纹理的笔触方向后,可以从预先设置的至少一个笔触纹理中,找出与当前图像区域对应的笔触纹理的笔触方向相同的目标笔触纹理,将该目标笔触纹理作为当前图像区域对应的笔触纹理。In the embodiment of the present invention, when determining the stroke direction of the stroke texture corresponding to each image region, it may be determined according to the number of pixels corresponding to each stroke direction in the current image region, specifically, the stroke with the largest number of corresponding pixels The direction is the stroke direction of the current image area. For example, in the image area A, the stroke direction of 10 pixels is the stroke direction 1, the stroke direction of 20 pixels is the stroke direction 2, and the stroke direction of 300 pixels is the stroke direction 3, then the stroke direction Is the stroke direction of the image area A. After determining the stroke direction of the stroke texture corresponding to the current image region, the target stroke texture with the same stroke direction of the stroke texture corresponding to the current image region may be found from the preset at least one stroke texture, and the target stroke texture is As the stroke texture corresponding to the current image area.
在本发明实施例中,将图像区域中的每个像素的笔触方向,通过填充的笔触纹理来体现,使得生成的铅笔画风格的图像的铅笔画效果更好。In the embodiment of the present invention, the stroke direction of each pixel in the image area is embodied by the filled stroke texture, so that the pencil drawing effect of the generated pencil drawing style image is better.
在本发明一实施例中,所述确定所述轮廓图像中每个所述像素的笔触方向,包括:对所述灰度图像进行全图卷积,获得每个像素的第一卷积结果;In an embodiment of the present invention, the determining a stroke direction of each of the pixels in the contour image comprises: performing a full-image convolution on the grayscale image to obtain a first convolution result of each pixel;
针对每个像素,对当前像素的第一卷积结果取预设数量个方向进行卷积,获取所述当前像素在所述预设数量个方向中每个方向的第二卷积结果,将所述预设数量个方向的第二卷积结果中的最大值对应的方向作为所述当前像素的笔触方向。For each pixel, the first convolution result of the current pixel is convoluted by a predetermined number of directions, and a second convolution result of each direction of the current pixel in the preset number of directions is obtained. A direction corresponding to a maximum value of the second convolution results of the preset number of directions is used as a stroke direction of the current pixel.
在本发明实施例中,每个笔触纹理携带有笔触方向的信息,也就是说,每个笔触纹理中的线条具有一定的方向,例如:笔触纹理1的笔触方向为从左下到右上。In the embodiment of the present invention, each stroke texture carries information of a stroke direction, that is, a line in each stroke texture has a certain direction, for example, the stroke direction of the stroke texture 1 is from the lower left to the upper right.
在本发明实施例中,对待处理图像的灰度图像进行全图卷积,得到每个像素之间的明暗关系。在确定出笔触方向后,还可以对笔触方向做均值抽希,从而保证图像不出现反复变化的情况。In the embodiment of the present invention, the gray image of the image to be processed is subjected to full-image convolution to obtain a light-dark relationship between each pixel. After determining the direction of the stroke, the mean direction of the stroke direction can also be hashed to ensure that the image does not change repeatedly.
举例来说,针对像素A,在确定像素A的笔触方向时,可以通过以下方式来实现:预先设置三个笔触纹理,其中,笔触纹理1的笔触方向为笔触方向1,笔触纹理2的笔触方向为笔触方向2,笔触纹理3的笔触方向为笔触方向3。确定像素A在方向1上的第二卷积结果1,确定像素A在方向2上的第二卷积结果2,确定像素A在方向3上的第二卷积结果3,如果这三个响应值中,第二卷积结果2最大,那么,第二卷积结果2对应的方向2为像素A的笔触方向。For example, for the pixel A, when determining the stroke direction of the pixel A, it can be realized by setting three stroke textures in advance, wherein the stroke direction of the stroke texture 1 is the stroke direction 1, and the stroke direction of the stroke texture 2 For the stroke direction 2, the stroke direction of the stroke texture 3 is the stroke direction 3. Determining a second convolution result 1 of pixel A in direction 1, determining a second convolution result 2 of pixel A in direction 2, determining a second convolution result 3 of pixel A in direction 3, if these three responses Among the values, the second convolution result 2 is the largest, then the direction 2 corresponding to the second convolution result 2 is the stroke direction of the pixel A.
在本发明一实施例中,该方法还可以包括:确定出每个像素的卷积核,确定轮廓图像中每个像素的梯度值;针对每个像素,根据当前像素的笔触方向、当前像素的笔触方向上的卷积核以及当前像素的周边像素的梯度值,强化当前像素的在对应的笔触方向上的响应,同时也降低了梯度计算带来的噪声。In an embodiment of the invention, the method may further include: determining a convolution kernel of each pixel, determining a gradient value of each pixel in the contour image; for each pixel, according to a stroke direction of the current pixel, the current pixel The convolution kernel in the stroke direction and the gradient values of the surrounding pixels of the current pixel enhance the response of the current pixel in the corresponding stroke direction, and also reduce the noise caused by the gradient calculation.
为了使得原始图像对应的铅笔画风格的图像的效果更好,在本发明一实施例中,在所述生成所述原始图像对应的铅笔画风格的图像之后,进一步包括:In an embodiment of the present invention, after the image of the pencil drawing style corresponding to the original image is generated, the method further includes:
获取所述原始图像的颜色信息;Obtaining color information of the original image;
根据所述颜色信息对所述铅笔画风格的图像上色。The pencil drawing style image is colored according to the color information.
在本发明实施例中,原始图像的颜色信息可以是原始图像中每个像素的RGB信息。通过对原始图像对应的铅笔画风格的图像上色,可以使得该铅笔画风格的图像更加美观,也能够携带更多原始图像的信息。In an embodiment of the invention, the color information of the original image may be RGB information of each pixel in the original image. By coloring the pencil-painted image corresponding to the original image, the pencil-painted image can be made more beautiful, and can carry more original image information.
如图2所示,本发明实施例提供了一种图像处理的方法,该方法可以包括以下步骤:As shown in FIG. 2, an embodiment of the present invention provides a method for image processing, which may include the following steps:
步骤201:预先设置至少一个笔触纹理,每个笔触纹理设置有对应的笔触方向。Step 201: At least one stroke texture is preset, and each stroke texture is set with a corresponding stroke direction.
在本实施例中,每个笔触纹理可以包括两种特征:线条密度和笔触方向。In this embodiment, each stroke texture may include two features: line density and stroke direction.
笔触纹理可以通过纹理贴图的方式来实现。Stroke textures can be implemented by texture mapping.
基于线条密度,笔触纹理可以包括纯黑、纯白、斜线,其中,纯黑的笔触纹理中的线条的线条密度大于斜线的笔触纹理中的线条的线条密度,斜线的笔触纹理中的线条的线条密度大于纯白的笔触纹理中的线条的线条密度。Based on the line density, the stroke texture may include pure black, pure white, and slash, wherein the line density of the lines in the pure black stroke texture is greater than the line density of the lines in the stroke texture of the slash, and the stroke texture in the slash The line density of the lines is greater than the line density of the lines in the pure white brush texture.
其中,每种线条密度可以与各个笔触方向结合构成笔触纹理,例如:笔触纹理1的线条密度为线条密度A,笔触方向为方向A;笔触纹理2的线条密度为线条密度A,笔触方向为方向B;笔触纹理3的线条密度为线条密度A,笔触方向为方向C等。Wherein, each line density can be combined with each stroke direction to form a stroke texture, for example, the line density of the stroke texture 1 is the line density A, the stroke direction is the direction A; the line density of the stroke texture 2 is the line density A, and the stroke direction is the direction B; the line density of the stroke texture 3 is the line density A, the stroke direction is the direction C, and the like.
为了使得各种原始图像对应的铅笔画风格的图像的铅笔画效果更好,可以将各种线条密度与各种笔触方向结合,构成多种笔触纹理,以满足各种原始图像。In order to make the pencil drawing effect of the pencil drawing style image corresponding to various original images better, various line densities can be combined with various brush stroke directions to form a plurality of brush stroke textures to satisfy various original images.
举例来说,一种实现方式为:预先六个笔触纹理,其中,笔触纹理1的线条密度为线条密度A,笔触方向为方向A;笔触纹理2的线条密度为线条密度A,笔触方向为方向B;笔触纹理3的线条密度为线条密度B,笔触方向为方向A;笔触纹理4的线条密度为线条密度B,笔触方向为方向B;笔触纹理5的线条密度为线条密度C,笔触方向为方向A;笔触纹理6的线条密度为线条密度C,笔触方向为方向B。For example, one implementation manner is: six stroke textures in advance, wherein the line density of the stroke texture 1 is the line density A, the stroke direction is the direction A; the line density of the stroke texture 2 is the line density A, and the stroke direction is the direction. B; stroke density 3 line density is line density B, stroke direction is direction A; stroke texture 4 line density is line density B, stroke direction is direction B; stroke texture 5 line density is line density C, stroke direction is Direction A; the line density of the stroke texture 6 is the line density C, and the stroke direction is the direction B.
步骤202:预先设置灰度等级与笔触纹理的对应关系。Step 202: Pre-set the correspondence between the gray level and the stroke texture.
图像的灰度等级在笔触纹理上通过线条密度来反应。灰度等级可以通过灰度值范围来划分。The gray level of the image is reflected by the line density on the stroke texture. The gray level can be divided by the range of gray values.
另外,在划分灰度等级时,将照片的色调曲线与铅笔画的灰度直方图匹配,使其符合铅笔画的灰度分布规律,然后结合图像区域的灰度值范围进行分级。In addition, when dividing the gray level, the tone curve of the photo is matched with the gray histogram of the pencil drawing to conform to the gray distribution rule of the pencil drawing, and then the gray value range of the image area is combined to be classified.
举例来说,可以将灰度等级分为三级,分别是灰度等级1、灰度等级2、灰度等级3。线条密度A与灰度等级1对应、线条密度B与灰度等级2对应、线条密度C与灰度等级3对应,也就是,笔触纹理1与灰度等级1对应,笔触纹理2与灰度等级1对应,笔触纹理3与灰度等级2对应,笔触纹理4与灰度等级2对应,笔触纹理5与灰度等级3对应,笔触纹理6与灰度等级3对应。For example, the gray level can be divided into three levels, namely gray level 1, gray level 2, and gray level 3. The line density A corresponds to the gray level 1, the line density B corresponds to the gray level 2, and the line density C corresponds to the gray level 3, that is, the stroke texture 1 corresponds to the gray level 1, the stroke texture 2 and the gray level Corresponding to 1, the stroke texture 3 corresponds to the gray level 2, the stroke texture 4 corresponds to the gray level 2, the stroke texture 5 corresponds to the gray level 3, and the stroke texture 6 corresponds to the gray level 3.
步骤203:对原始图像进行灰度化处理,生成原始图像对应的灰度图像。Step 203: Perform grayscale processing on the original image to generate a grayscale image corresponding to the original image.
步骤204:提取灰度图像的边缘,生成灰度图像对应的轮廓图像。Step 204: Extract an edge of the grayscale image to generate a contour image corresponding to the grayscale image.
具体地,可以通过拉普拉斯算子提取灰度图像的边缘获得轮廓图像。然后,可以设置合理的阈值,通过该阈值实现廓线拾取的过程。通过该阈值确定出面积比较大的区域,对于面积很小的区域,可以不参与后续处理。Specifically, the contour image can be obtained by extracting the edge of the grayscale image by the Laplacian. Then, a reasonable threshold can be set by which the process of profile picking is achieved. The area with a relatively large area is determined by the threshold, and the area with a small area may not participate in the subsequent processing.
步骤205:根据灰度图像中每个像素的灰度值,将轮廓图像分成至少一个图像区域。Step 205: Divide the contour image into at least one image region according to the gray value of each pixel in the grayscale image.
具体地,可以根据灰度值的变化的剧烈程度来划分区域,灰度值突变的地方就是几个区域的边缘。Specifically, the region can be divided according to the severity of the change in the gray value, and the place where the gray value is abrupt is the edge of several regions.
步骤206:根据每个图像区域中每个像素的灰度值,确定每个图像区域的灰度等级。Step 206: Determine the gray level of each image area according to the gray value of each pixel in each image area.
具体地,可以将当前图像区域中各个像素的灰度值的平均值作为当前图像区域的灰度值,进而确定当前图像区域属于哪个灰度等级。Specifically, the average value of the gray values of the respective pixels in the current image region may be used as the gray value of the current image region, thereby determining which gray level the current image region belongs to.
举例来说,图像区域A的灰度等级为灰度等级1。For example, the gradation level of the image area A is gradation level 1.
步骤207:确定轮廓图像中每个像素的笔触方向。Step 207: Determine the stroke direction of each pixel in the contour image.
具体地,可以通过以下步骤实现:Specifically, it can be achieved by the following steps:
对所述灰度图像进行全图卷积,获得每个像素的第一卷积结果;Performing full-image convolution on the grayscale image to obtain a first convolution result of each pixel;
针对每个像素,对当前像素的第一卷积结果取预设数量个方向进行卷积,获取所述当前像素在所述预设数量个方向中每个方向的第二卷积结果,将所述预设数量个方向的第二卷积结果中的最大值对应的方向作为所述当前像素的笔触方向。For each pixel, the first convolution result of the current pixel is convoluted by a predetermined number of directions, and a second convolution result of each direction of the current pixel in the preset number of directions is obtained. A direction corresponding to a maximum value of the second convolution results of the preset number of directions is used as a stroke direction of the current pixel.
步骤208:根据每个像素的笔触方向,确定每个图像区域对应的笔触纹理的笔触方向。Step 208: Determine the stroke direction of the stroke texture corresponding to each image region according to the stroke direction of each pixel.
举例来说,图像区域A中笔触方向为方向A的像素点最多,则可以确定图像区域A对应的笔触纹理的笔触方向为方向A。例如:方向A为从左下到右上。For example, in the image area A, the brush point direction is the most pixel point of the direction A, and it can be determined that the stroke direction of the stroke texture corresponding to the image area A is the direction A. For example: direction A is from bottom left to top right.
步骤209:根据对应关系、每个图像区域的灰度等级以及每个所述图像区域对应的笔触纹理的笔触方向,确定每个图像区域对应的笔触纹理。Step 209: Determine a stroke texture corresponding to each image region according to the correspondence relationship, the gray level of each image region, and the stroke direction of the stroke texture corresponding to each of the image regions.
具体地,通过灰度等级和笔触方向两个参数来确定出每个图像区域对应的笔触纹理。Specifically, the stroke texture corresponding to each image region is determined by two parameters of gray scale and stroke direction.
举例来说,对于图像区域A,根据对应关系和图像区域A对应的灰度等级1,可以确定出图像区域A对应的笔触纹理可以是笔触纹理1和笔触纹理2。根据图像区域A对应的笔触纹理的笔触方向为方向A,从笔触纹理1和笔触纹理2中,可以确定出图像区域A对应的笔触纹理为笔触纹理1。For example, for the image area A, according to the correspondence relationship and the gray level 1 corresponding to the image area A, it can be determined that the stroke texture corresponding to the image area A can be the stroke texture 1 and the stroke texture 2. According to the stroke direction of the stroke texture corresponding to the image area A, the direction A is determined. From the stroke texture 1 and the stroke texture 2, it can be determined that the stroke texture corresponding to the image area A is the stroke texture 1.
步骤210:将每个图像区域对应的笔触纹理填充到对应的图像区域中,生成原始图像对应的铅笔画风格的图像。Step 210: Fill the corresponding touch image texture into the corresponding image area to generate an image of the pencil drawing style corresponding to the original image.
举例来说,针对图像区域A,将图像区域A对应的笔触纹理1填充到图像区域A中。其他的图像区域也填充上对应的笔触纹理,进而得到原始图像对应的铅笔画风格的图像。For example, for the image area A, the stroke texture 1 corresponding to the image area A is filled into the image area A. The other image areas are also filled with corresponding stroke textures, thereby obtaining a pencil-drawn style image corresponding to the original image.
另外,该方法还可以包括:获取原始图像的颜色信息;根据颜色信息对原始图像对应的铅笔画风格的图像上色。In addition, the method may further include: acquiring color information of the original image; and coloring the image of the pencil drawing style corresponding to the original image according to the color information.
具体地,可以获取原始图像中每个像素的颜色,针对原始图像对应的铅笔画风格的图像上的每个像素,根据当前像素对应的原始图像上的像素的颜色信息,为当前像素上色。Specifically, the color of each pixel in the original image may be acquired, and for each pixel on the pencil drawing style image corresponding to the original image, the current pixel is colored according to the color information of the pixel on the original image corresponding to the current pixel.
举例来说,原始图像上的像素A与原始图像对应的铅笔画风格的图像上的像素C对应,获取原始图像上的像素A的RGB,根据像素A的RGB为像素C上色。For example, the pixel A on the original image corresponds to the pixel C on the pencil-drawn image corresponding to the original image, and the RGB of the pixel A on the original image is acquired, and the pixel C is colored according to the RGB of the pixel A.
在本发明实施例中,预先设置笔触纹理,将预先设置的笔触纹理填充到对应的图像区域中即可生成原始图像对应的铅笔画风格的图像,计算量较小,处理速度较快。In the embodiment of the present invention, the stroke texture is preset, and the preset stroke texture is filled into the corresponding image region to generate an image of the pencil drawing style corresponding to the original image, and the calculation amount is small, and the processing speed is fast.
在本发明实施例中,由于生成原始图像对应的铅笔画风格的图像的计算量较小,处理速度较快,可以实现视频的实时铅笔画处理。具体地,分别将视频中的每一帧作为一个原始图像进行铅笔画处理,得到每一帧对应的铅笔画风格的图像。In the embodiment of the present invention, since the calculation amount of the pencil drawing style image corresponding to the original image is small, the processing speed is fast, and real-time pencil drawing processing of the video can be realized. Specifically, each frame in the video is separately subjected to pencil drawing processing as an original image to obtain an image of a pencil drawing style corresponding to each frame.
在本发明实施例中,通过预先设置的笔触纹理可以使得生成的铅笔画风格的图像具有铅笔画的笔触和高光阴影效果,更接近真实的铅笔画,铅笔画效果更好。In the embodiment of the present invention, the generated brush stroke style image can have the pencil stroke style and the highlight shadow effect of the generated pencil stroke style, which is closer to the real pencil drawing, and the pencil drawing effect is better.
在本发明实施例中,通过对笔触纹理的预先设置,可以大大减少计算量,需要的计算资源较少,能够在手机等移动终端上实现,能够达到实时的效果,并能够取得较好的铅笔画效果。In the embodiment of the present invention, by pre-setting the stroke texture, the calculation amount can be greatly reduced, the required computing resources are less, and can be implemented on a mobile terminal such as a mobile phone, which can achieve real-time effects and can obtain a better pencil drawing. effect.
如图3、图4所示,本发明实施例提供了一种图像处理的装置。装置实施例可以通过软件实现,也可以通过硬件或者软硬件结合的方式实现。从硬件层面而言,如图3所示,为本发明实施例提供的一种图像处理的装置所在设备的一种硬件结构图,除了图3所示的处理器、内存、网络接口、以及非易失性存储器之外,实施例中装置所在的设备通常还可以包括其他硬件,如负责处理报文的转发芯片等等。以软件实现为例,如图4所示,作为一个逻辑意义上的装置,是通过其所在设备的CPU将非易失性存储器中对应的计算机程序指令读取到内存中运行形成的。本实施例提供的一种图像处理的装置,包括:As shown in FIG. 3 and FIG. 4, an embodiment of the present invention provides an apparatus for image processing. The device embodiment may be implemented by software, or may be implemented by hardware or a combination of hardware and software. As shown in FIG. 3, a hardware structure diagram of a device for processing an image processing apparatus according to an embodiment of the present invention, except for the processor, the memory, the network interface, and the non- In addition to the volatile memory, the device in which the device is located in the embodiment may also typically include other hardware, such as a forwarding chip responsible for processing the message, and the like. Taking the software implementation as an example, as shown in FIG. 4, as a logical means, the CPU of the device in which it is located reads the corresponding computer program instructions in the non-volatile memory into the memory. An apparatus for image processing provided by this embodiment includes:
保存单元401,用于保存至少一个笔触纹理;a saving unit 401, configured to save at least one stroke texture;
灰度化单元402,用于对原始图像进行灰度化处理,生成所述原始图像对应的灰度图像;The gradation unit 402 is configured to perform gradation processing on the original image to generate a grayscale image corresponding to the original image;
提取单元403,用于提取所述灰度图像的边缘,生成所述灰度图像对应的轮廓图像;An extracting unit 403, configured to extract an edge of the grayscale image, and generate a contour image corresponding to the grayscale image;
划分单元404,用于根据所述灰度图像中每个像素的灰度值,将所述轮廓图像分成至少一个图像区域;a dividing unit 404, configured to divide the contour image into at least one image region according to a gray value of each pixel in the grayscale image;
确定单元405,用于确定每个所述图像区域对应的笔触纹理;a determining unit 405, configured to determine a stroke texture corresponding to each of the image regions;
生成单元406,用于将每个所述图像区域对应的所述笔触纹理填充到对应的所述图像区域中,生成所述原始图像对应的铅笔画风格的图像。The generating unit 406 is configured to fill the stroke texture corresponding to each of the image regions into the corresponding image region, and generate an image of a pencil drawing style corresponding to the original image.
基于图4所示的一种图像处理的装置,在本发明一实施例中,如图5所示,该装置进一步包括:设置单元501,用于设置灰度等级与所述笔触纹理的对应关系;An apparatus for image processing according to FIG. 4, in an embodiment of the present invention, as shown in FIG. 5, the apparatus further includes: a setting unit 501, configured to set a correspondence between the gray level and the stroke texture ;
所述确定单元,用于根据每个所述图像区域中每个所述像素的灰度值,确定每个所述图像区域的灰度等级,根据所述对应关系和每个所述图像区域的灰度等级,确定每个所述图像区域对应的所述笔触纹理。The determining unit is configured to determine a gray level of each of the image regions according to a gray value of each of the pixels in each of the image regions, according to the correspondence relationship and each of the image regions Gray scale, determining the stroke texture corresponding to each of the image regions.
在本发明一实施例中,所述确定单元,用于确定所述轮廓图像中每个所述像素的笔触方向,根据每个所述像素的笔触方向,确定每个所述图像区域对应的笔触纹理的笔触方向,根据每个所述图像区域对应的笔触纹理的笔触方向,确定每个所述图像区域对应的笔触纹理。In an embodiment of the present invention, the determining unit is configured to determine a stroke direction of each of the pixels in the contour image, and determine a stroke corresponding to each of the image regions according to a stroke direction of each of the pixels The stroke direction of the texture determines the stroke texture corresponding to each of the image regions according to the stroke direction of the stroke texture corresponding to each of the image regions.
在本发明一实施例中,所述确定单元,包括:In an embodiment of the invention, the determining unit includes:
卷积子单元,用于对所述灰度图像进行全图卷积,获得每个像素的第一卷积结果;a convolution subunit, configured to perform full-picture convolution on the grayscale image to obtain a first convolution result of each pixel;
确定子单元,用于针对每个像素,对当前像素的第一卷积结果取预设数量个方向进行卷积,获取所述当前像素在所述预设数量个方向中每个方向的第二卷积结果,将所述预设数量个方向的第二卷积结果中的最大值对应的方向作为所述当前像素的笔触方向。Determining a subunit, configured to convolve a first number of directions of the current convolution result of the current pixel for each pixel, and obtain a second of each direction of the current pixel in the preset number of directions As a result of the convolution, a direction corresponding to a maximum value of the second convolution results of the preset number of directions is taken as a stroke direction of the current pixel.
基于图4所示的一种图像处理的装置,在本发明一实施例中,如图6所示,该装置进一步包括:上色单元601,用于获取所述原始图像的颜色信息,根据所述颜色信息对所述铅笔画风格的图像上色。An apparatus for image processing according to FIG. 4, in an embodiment of the present invention, as shown in FIG. 6, the apparatus further includes: a coloring unit 601, configured to acquire color information of the original image, according to The color information colors the image of the pencil drawing style.
本发明实施例提供的一种图像处理的装置,可以在手机等移动终端上实现。An apparatus for image processing provided by an embodiment of the present invention can be implemented on a mobile terminal such as a mobile phone.
上述装置内的各单元之间的信息交互、执行过程等内容,由于与本发明方法实施例基于同一构思,具体内容可参见本发明方法实施例中的叙述,此处不再赘述。The content of the information exchange, the execution process, and the like in the above-mentioned devices are based on the same concept as the method embodiment of the present invention. For details, refer to the description in the method embodiment of the present invention, and details are not described herein again.
本发明实施例提供了一种可读介质,包括执行指令,当存储控制器的处理器执行所述执行指令时,所述存储控制器执行本发明实施例中任一所述的一种图像处理的方法。The embodiment of the present invention provides a readable medium, including an execution instruction, when the processor of the storage controller executes the execution instruction, the storage controller performs an image processing according to any one of the embodiments of the present invention. Methods.
本发明实施例提供了一种存储控制器,包括:处理器、存储器和总线;An embodiment of the present invention provides a storage controller, including: a processor, a memory, and a bus;
所述存储器用于存储执行指令,所述处理器与所述存储器通过所述总线连接,当所述存储控制器运行时,所述处理器执行所述存储器存储的所述执行指令,以使所述存储控制器执行本发明实施例中任一所述的一种图像处理的方法。The memory is configured to store an execution instruction, the processor is connected to the memory through the bus, and when the storage controller is running, the processor executes the execution instruction stored in the memory to make The storage controller performs a method of image processing according to any one of the embodiments of the present invention.
本发明各个实施例至少具有如下有益效果:Various embodiments of the present invention have at least the following beneficial effects:
1、在本发明实施例中,提取出原始图像的灰度图像,根据灰度图像生成对应的轮廓图像,形成最后生成的铅笔画风格的图像的基础轮廓,按照每个像素的灰度,将轮廓图像分成各个图像区域,在图像区域中填充上对应的笔触纹理,使得最后生成的铅笔画风格的图像在基础轮廓的基础上内容更加丰满,更加接近真实的铅笔画,提供了原始图像对应的铅笔画风格的图片的铅笔画效果。In the embodiment of the present invention, the gray image of the original image is extracted, and the corresponding contour image is generated according to the gray image to form a basic outline of the last generated pencil drawing style image, and the contour is formed according to the gray level of each pixel. The image is divided into individual image regions, and the corresponding brush stroke texture is filled in the image region, so that the finally generated pencil-painted image is more full on the basis of the basic contour, and is closer to the real pencil drawing, and provides the pencil drawing style corresponding to the original image. The pencil drawing effect of the picture.
2、在本发明实施例中,通过各个图像区域的灰度值的大小来确定各个图像区域的笔触纹理,能够使得颜色较深的区域填充线条密度较大的笔触纹理,使得各个图像区域的笔触纹理更加接近真实的铅笔画的风格,进一步提高了原始图像对应的铅笔画风格的图像的铅笔画效果。2. In the embodiment of the present invention, the stroke texture of each image region is determined by the magnitude of the gray value of each image region, so that the darker region is filled with the stroke texture with a larger line density, so that the strokes of the respective image regions are made. The texture is closer to the style of the real pencil drawing, which further enhances the pencil drawing effect of the pencil-style image corresponding to the original image.
3、在本发明实施例中,在笔触纹理中设置笔触方向,将笔触纹理按照笔触方向填充到对应的图像区域中,使得生成的铅笔画风格的图像更加接近手工绘制的铅笔画,铅笔画效果更好。3. In the embodiment of the present invention, the stroke direction is set in the stroke texture, and the stroke texture is filled into the corresponding image area according to the stroke direction, so that the generated pencil style image is closer to the hand drawn pencil drawing, and the pencil drawing effect is better.
4、在本发明实施例中,预先设置笔触纹理,将预先设置的笔触纹理填充到对应的图像区域中即可生成原始图像对应的铅笔画风格的图像,计算量较小,处理速度较快。4. In the embodiment of the present invention, the stroke texture is preset, and the preset stroke texture is filled into the corresponding image region to generate a pencil-drawn image corresponding to the original image, and the calculation amount is small, and the processing speed is fast.
5、在本发明实施例中,通过预先设置的笔触纹理可以使得生成的铅笔画风格的图像具有铅笔画的笔触和高光阴影效果,更接近真实的铅笔画,铅笔画效果更好。5. In the embodiment of the present invention, the generated pencil stroke style image can have the pencil stroke and the highlight shadow effect of the generated pencil stroke style, which is closer to the real pencil drawing, and the pencil drawing effect is better.
6、在本发明实施例中,通过对笔触纹理的预先设置,可以大大减少计算量,需要的计算资源较少,能够在手机等移动终端上实现,能够达到实时的效果,并能够取得较好的铅笔画效果。6. In the embodiment of the present invention, by pre-setting the stroke texture, the calculation amount can be greatly reduced, the required computing resources are less, and can be implemented on a mobile terminal such as a mobile phone, which can achieve real-time effects and can achieve better results. Pencil drawing effect.
需要说明的是,在本文中,诸如第一和第二之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个······”限定的要 素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同因素。It should be noted that, in this context, relational terms such as first and second are used merely to distinguish one entity or operation from another entity or operation, without necessarily requiring or implying between these entities or operations. There are any such actual relationships or sequences. Furthermore, the term "comprises" or "comprises" or "comprises" or any other variations thereof is intended to encompass a non-exclusive inclusion, such that a process, method, article, or device that comprises a plurality of elements includes not only those elements but also Other elements, or elements that are inherent to such a process, method, item, or device. In the absence of further limitations, the elements defined by the phrase "comprising a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本发明的范围。Those of ordinary skill in the art will appreciate that the elements and algorithm steps of the various examples described in connection with the embodiments disclosed herein can be implemented in electronic hardware or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the solution. A person skilled in the art can use different methods for implementing the described functions for each particular application, but such implementation should not be considered to be beyond the scope of the present invention.
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。A person skilled in the art can clearly understand that for the convenience and brevity of the description, the specific working process of the system, the device and the unit described above can refer to the corresponding process in the foregoing method embodiment, and details are not described herein again.
在本申请所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided by the present application, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. For example, the device embodiments described above are merely illustrative. For example, the division of the unit is only a logical function division. In actual implementation, there may be another division manner, for example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be in an electrical, mechanical or other form.
作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
另外,在本发明各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序校验码的介质。Functionality, if implemented as a software functional unit and sold or used as a stand-alone product, can be stored on a computer readable storage medium. Based on such understanding, the technical solution of the present invention, which is essential or contributes to the prior art, or a part of the technical solution, may be embodied in the form of a software product, which is stored in a storage medium, including The instructions are used to cause a computer device (which may be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and the like, and can store a program check code. Medium.
以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应所述以权利要求的保护范围为准。The above is only a specific embodiment of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily think of changes or substitutions within the technical scope of the present invention. It should be covered by the scope of the present invention. Therefore, the scope of the invention should be determined by the scope of the claims.
工业实用性Industrial applicability
本发明实施例的图像处理的方法和装置,避免了大量冗余图像信号的处理,精简了图像处理的运算量。可以普遍应用于智能移动终端设备,改善人机交互过程的效率。The image processing method and apparatus of the embodiment of the present invention avoids processing of a large number of redundant image signals, and simplifies the calculation amount of image processing. It can be widely applied to smart mobile terminal devices to improve the efficiency of human-computer interaction process.

Claims (11)

  1. 一种图像处理的方法,其特征在于,预先设置至少一个笔触纹理,包括:A method for image processing, characterized in that at least one stroke texture is preset, comprising:
    对原始图像进行灰度化处理,生成所述原始图像对应的灰度图像;Performing grayscale processing on the original image to generate a grayscale image corresponding to the original image;
    提取所述灰度图像的边缘,生成所述灰度图像对应的轮廓图像;Extracting an edge of the grayscale image to generate a contour image corresponding to the grayscale image;
    根据所述灰度图像中每个像素的灰度值,将所述轮廓图像分成至少一个图像区域;Dividing the contour image into at least one image region according to a gray value of each pixel in the grayscale image;
    确定所述至少一个图像区域中的每个图像区域对应的笔触纹理;Determining a stroke texture corresponding to each of the at least one image region;
    将所述图像区域对应的所述笔触纹理填充到对应的所述图像区域中,生成所述原始图像对应的铅笔画风格的图像。Filling the stroke texture corresponding to the image area into the corresponding image area to generate an image of a pencil drawing style corresponding to the original image.
  2. 根据权利要求1所述图像处理的方法,其特征在于,A method of image processing according to claim 1, wherein
    进一步包括:预先设置灰度等级与所述笔触纹理的对应关系;Further comprising: presetting a correspondence between the gray level and the stroke texture;
    所述确定所述至少一个图像区域中的每个图像区域对应的笔触纹理,包括:The determining the stroke texture corresponding to each of the at least one image region comprises:
    根据所述图像区域中每个像素的灰度值,确定所述图像区域的灰度等级;Determining a gray level of the image region according to a gray value of each pixel in the image region;
    根据所述对应关系和所述图像区域的灰度等级,确定所述图像区域对应的所述笔触纹理。And determining the stroke texture corresponding to the image region according to the correspondence relationship and a gray level of the image region.
  3. 根据权利要求1所述图像处理的方法,其特征在于,A method of image processing according to claim 1, wherein
    所述确定所述至少一个图像区域中的每个图像区域对应的笔触纹理,包括:The determining the stroke texture corresponding to each of the at least one image region comprises:
    确定所述轮廓图像中每个像素的笔触方向;Determining a stroke direction of each pixel in the contour image;
    根据所述轮廓图像中每个像素的笔触方向,确定所述图像区域对应的笔触纹理的笔触方向;Determining, according to a stroke direction of each pixel in the contour image, a stroke direction of a stroke texture corresponding to the image region;
    根据所述图像区域对应的笔触纹理的笔触方向,确定所述图像区域对应的笔触纹理。Determining a stroke texture corresponding to the image region according to a stroke direction of the stroke texture corresponding to the image region.
  4. 根据权利要求3所述图像处理的方法,其特征在于,A method of image processing according to claim 3, wherein
    所述确定所述轮廓图像中每个像素的笔触方向,包括:The determining a stroke direction of each pixel in the contour image includes:
    对所述灰度图像进行全图卷积,获得每个像素的第一卷积结果;Performing full-image convolution on the grayscale image to obtain a first convolution result of each pixel;
    针对每个像素,对当前像素的第一卷积结果取预设数量个方向进行卷积,获取所述当前像素在所述预设数量个方向中每个方向的第二卷积结果,将所述预设数量个方向的第二卷积结果中的最大值对应的方向作为所述当前像素的笔触方向。For each pixel, the first convolution result of the current pixel is convoluted by a predetermined number of directions, and a second convolution result of each direction of the current pixel in the preset number of directions is obtained. A direction corresponding to a maximum value of the second convolution results of the preset number of directions is used as a stroke direction of the current pixel.
  5. 根据权利要求1-4中任一所述图像处理的方法,其特征在于,A method of image processing according to any one of claims 1 to 4, characterized in that
    在所述生成所述原始图像对应的铅笔画风格的图像之后,进一步包括:After the generating the image of the pencil drawing style corresponding to the original image, the method further includes:
    获取所述原始图像的颜色信息;Obtaining color information of the original image;
    根据所述颜色信息对所述铅笔画风格的图像上色。The pencil drawing style image is colored according to the color information.
  6. 一种图像处理的装置,其特征在于,包括:An apparatus for image processing, comprising:
    保存单元,用于保存至少一个笔触纹理;a saving unit for saving at least one stroke texture;
    灰度化单元,用于对原始图像进行灰度化处理,生成所述原始图像对应的灰度图像;a graying unit for performing grayscale processing on the original image to generate a grayscale image corresponding to the original image;
    提取单元,用于提取所述灰度图像的边缘,生成所述灰度图像对应的轮廓图像;An extracting unit, configured to extract an edge of the grayscale image, and generate a contour image corresponding to the grayscale image;
    划分单元,用于根据所述灰度图像中每个像素的灰度值,将所述轮廓图像分成至少一个图像区域;a dividing unit, configured to divide the contour image into at least one image region according to a gray value of each pixel in the grayscale image;
    确定单元,用于确定所述至少一个图像区域中的每个图像区域对应的笔触纹理;a determining unit, configured to determine a stroke texture corresponding to each image region in the at least one image region;
    生成单元,用于将所述图像区域对应的所述笔触纹理填充到对应的所述图像区域中,生成所述原始图像对应的铅笔画风格的图像。And a generating unit, configured to fill the stroke texture corresponding to the image region into the corresponding image region, and generate an image of a pencil drawing style corresponding to the original image.
  7. 根据权利要求6所述图像处理的装置,其特征在于,The apparatus for image processing according to claim 6, wherein
    进一步包括:设置单元,用于设置灰度等级与所述笔触纹理的对应关系;The method further includes: a setting unit, configured to set a correspondence between the gray level and the stroke texture;
    所述确定单元,用于根据所述图像区域中每个像素的灰度值,确定所述图像区域的灰度等级,根据所述对应关系和所述图像区域的灰度等级,确定所述图像区域对应的所 述笔触纹理。The determining unit is configured to determine a gray level of the image region according to a gray value of each pixel in the image region, and determine the image according to the correspondence relationship and a gray level of the image region The stroke texture corresponding to the region.
  8. 根据权利要求6所述图像处理的装置,其特征在于,The apparatus for image processing according to claim 6, wherein
    所述确定单元,用于确定所述轮廓图像中每个像素的笔触方向,根据所述像素的笔触方向,确定所述图像区域对应的笔触纹理的笔触方向,根据所述图像区域对应的笔触纹理的笔触方向,确定所述图像区域对应的笔触纹理。The determining unit is configured to determine a stroke direction of each pixel in the contour image, and determine a stroke direction of the stroke texture corresponding to the image region according to a stroke direction of the pixel, according to a stroke texture corresponding to the image region The stroke direction of the image determines the stroke texture corresponding to the image area.
  9. 根据权利要求8所述图像处理的装置,其特征在于,The apparatus for image processing according to claim 8, wherein
    所述确定单元,包括:The determining unit includes:
    卷积子单元,用于对所述灰度图像进行全图卷积,获得每个像素的第一卷积结果;a convolution subunit, configured to perform full-picture convolution on the grayscale image to obtain a first convolution result of each pixel;
    确定子单元,用于针对每个像素,对当前像素的第一卷积结果取预设数量个方向进行卷积,获取所述当前像素在所述预设数量个方向中每个方向的第二卷积结果,将所述预设数量个方向的第二卷积结果中的最大值对应的方向作为所述当前像素的笔触方向。Determining a subunit, configured to convolve a first number of directions of the current convolution result of the current pixel for each pixel, and obtain a second of each direction of the current pixel in the preset number of directions As a result of the convolution, a direction corresponding to a maximum value of the second convolution results of the preset number of directions is taken as a stroke direction of the current pixel.
  10. 根据权利要求6-9中任一所述图像处理的装置,其特征在于,Apparatus for image processing according to any of claims 6-9, characterized in that
    进一步包括:上色单元,用于获取所述原始图像的颜色信息,根据所述颜色信息对所述铅笔画风格的图像上色。Further comprising: a coloring unit, configured to acquire color information of the original image, and color the image of the pencil drawing style according to the color information.
  11. 一种存储控制器,包括处理器和存储器,其特征在于,A memory controller includes a processor and a memory, wherein
    所述存储器用于存储如权利要求1至5任一所述图像处理的方法的执行指令;The memory is configured to store an execution instruction of the method of image processing according to any one of claims 1 to 5;
    所述处理器用于执行所述存储器存储的所述执行指令。The processor is configured to execute the execution instruction stored by the memory.
PCT/CN2018/075676 2017-02-27 2018-02-07 Image processing method and apparatus WO2018153264A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710109287.5 2017-02-27
CN201710109287.5A CN106846390B (en) 2017-02-27 2017-02-27 Image processing method and device

Publications (2)

Publication Number Publication Date
WO2018153264A1 true WO2018153264A1 (en) 2018-08-30
WO2018153264A9 WO2018153264A9 (en) 2018-10-11

Family

ID=59133622

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/075676 WO2018153264A1 (en) 2017-02-27 2018-02-07 Image processing method and apparatus

Country Status (2)

Country Link
CN (1) CN106846390B (en)
WO (1) WO2018153264A1 (en)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106846390B (en) * 2017-02-27 2020-10-13 迈吉客科技(北京)有限公司 Image processing method and device
CN109087371B (en) * 2018-07-16 2023-06-30 深圳市智能机器人研究院 A method and system for controlling a robot portrait
CN109523603B (en) * 2018-10-24 2022-12-02 广东智媒云图科技股份有限公司 Drawing method and device based on chap style, terminal equipment and storage medium
WO2020124603A1 (en) * 2018-12-21 2020-06-25 深圳市柔宇科技有限公司 Drawing method, drawing apparatus, and electronic device
CN110070495B (en) * 2019-02-20 2021-09-17 北京字节跳动网络技术有限公司 Image processing method and device and electronic equipment
CN110751703B (en) * 2019-10-22 2023-05-16 广东智媒云图科技股份有限公司 Winding picture generation method, device, equipment and storage medium
CN110738712B (en) * 2019-10-24 2023-07-25 广东智媒云图科技股份有限公司 Geometric pattern reconstruction method, device, equipment and storage medium
CN111784562B (en) * 2020-06-12 2024-01-26 齐鲁工业大学 An algorithm for automatic generation of line drawings
CN112070854B (en) * 2020-09-02 2023-08-08 北京字节跳动网络技术有限公司 Image generation method, device, equipment and storage medium
CN113470138B (en) * 2021-06-30 2024-05-24 维沃移动通信有限公司 Image generation method and device, electronic equipment and readable storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7567715B1 (en) * 2004-05-12 2009-07-28 The Regents Of The University Of California System and method for representing and encoding images
US20130121613A1 (en) * 2009-09-04 2013-05-16 Holger Winnemoeller Methods and Apparatus for Directional Texture Generation Using Image Warping
CN104915976A (en) * 2015-06-03 2015-09-16 厦门美图之家科技有限公司 Image processing method and system for simulating pencil sketch
CN105374007A (en) * 2015-12-02 2016-03-02 华侨大学 Generation method and generation device of pencil drawing fusing skeleton strokes and textural features
CN106023276A (en) * 2016-05-13 2016-10-12 云南大学 Pencil drawing making method and pencil drawing making device based on image processing
CN106846390A (en) * 2017-02-27 2017-06-13 迈吉客科技(北京)有限公司 A kind of method and device of image procossing

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6657642B1 (en) * 1997-07-03 2003-12-02 International Business Machines Corporation User interactive display interfaces with means for interactive formation of combination display objects representative of combined interactive functions
CN102572219B (en) * 2012-01-19 2014-12-24 西安联客信息技术有限公司 Mobile terminal and image processing method thereof
CN103793930A (en) * 2014-01-27 2014-05-14 汉王科技股份有限公司 Pencil drawing image generation method and device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7567715B1 (en) * 2004-05-12 2009-07-28 The Regents Of The University Of California System and method for representing and encoding images
US20130121613A1 (en) * 2009-09-04 2013-05-16 Holger Winnemoeller Methods and Apparatus for Directional Texture Generation Using Image Warping
CN104915976A (en) * 2015-06-03 2015-09-16 厦门美图之家科技有限公司 Image processing method and system for simulating pencil sketch
CN105374007A (en) * 2015-12-02 2016-03-02 华侨大学 Generation method and generation device of pencil drawing fusing skeleton strokes and textural features
CN106023276A (en) * 2016-05-13 2016-10-12 云南大学 Pencil drawing making method and pencil drawing making device based on image processing
CN106846390A (en) * 2017-02-27 2017-06-13 迈吉客科技(北京)有限公司 A kind of method and device of image procossing

Also Published As

Publication number Publication date
WO2018153264A9 (en) 2018-10-11
CN106846390A (en) 2017-06-13
CN106846390B (en) 2020-10-13

Similar Documents

Publication Publication Date Title
WO2018153264A1 (en) Image processing method and apparatus
CN110956654B (en) Image processing methods, devices, equipment and storage media
JP7175197B2 (en) Image processing method and device, storage medium, computer device
Du et al. Saliency-guided color-to-gray conversion using region-based optimization
US11138695B2 (en) Method and device for video processing, electronic device, and storage medium
CN108431751B (en) background removal
CN101155248B (en) Image processing apparatus, image processing method, and computer product
JPH11250267A (en) Eye position detection method, eye position detection device, and recording medium recording eye position detection program
CN110110829B (en) Two-dimensional code processing method and device
WO2017173578A1 (en) Image enhancement method and device
CN113052923A (en) Tone mapping method, tone mapping apparatus, electronic device, and storage medium
WO2019128459A1 (en) Method and device for image shadow elimination
WO2019209751A1 (en) Superpixel merging
CN114862694A (en) High dynamic range image reconstruction method and device for ensuring image quality
WO2021197230A1 (en) Three-dimensional head model constructing method, device, system, and storage medium
CN111160240A (en) Image object recognition processing method, device, intelligent device, and storage medium
Liu et al. Shadow removal of text document images using background estimation and adaptive text enhancement
CN107564085B (en) Image warping processing method, device, computing device and computer storage medium
CN109448093B (en) Method and device for generating style image
CN111462294B (en) Image processing method, electronic equipment and computer readable storage medium
CN111259744B (en) A face detection method and device based on skin model and SVM classifier
CN115661322B (en) Face texture image generation method and device
CN114820349B (en) Image processing method, device, electronic equipment and storage medium
CN112435173A (en) Image processing and live broadcasting method, device, equipment and storage medium
CN111583163B (en) AR-based face image processing method, device, equipment and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18756932

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 10.12.2019)

122 Ep: pct application non-entry in european phase

Ref document number: 18756932

Country of ref document: EP

Kind code of ref document: A1