WO2013013485A1 - Method and system for generating computer sketch image - Google Patents

Method and system for generating computer sketch image Download PDF

Info

Publication number
WO2013013485A1
WO2013013485A1 PCT/CN2011/084249 CN2011084249W WO2013013485A1 WO 2013013485 A1 WO2013013485 A1 WO 2013013485A1 CN 2011084249 W CN2011084249 W CN 2011084249W WO 2013013485 A1 WO2013013485 A1 WO 2013013485A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
current pixel
grayscale
grayscale image
color map
Prior art date
Application number
PCT/CN2011/084249
Other languages
French (fr)
Chinese (zh)
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 WO2013013485A1 publication Critical patent/WO2013013485A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation

Definitions

  • the present invention relates to image processing technologies, and in particular, to a method and system for generating computer sketches.
  • Sketch is a kind of image stylization.
  • the sketch in reality is a pencil-based medium, with lines to represent or the artistic form of the scene.
  • Sketch can be divided into line structure painting and fine realistic sketch.
  • Manually creating sketches requires the author to have a certain degree of artistic skills, so computer simulation of sketch painting has important application and entertainment value.
  • the technical problem to be solved by the present invention is that, in view of the above-mentioned existing sketch drawing generation technology, the defect that the sketch effect is not good and the manual interaction operation is required, and the method for generating the computer sketch drawing is provided, the sketch effect is good, and no manual interaction is needed. operating.
  • the technical solution adopted by the present invention to solve the technical problem thereof is to construct a computer sketch drawing generation method, which is characterized in that:
  • step S1 Receiving an image to be processed, and determining whether the image is a color map or a grayscale image, if it is a color map, step S2 is performed; if it is a gray scale image, step S3 is performed;
  • step S5 an N*N window including the current pixel point is opened, and the minimum gray level of all the pixel points in the N*N window is taken, and the minimum gray level is obtained.
  • N the gray value after the current pixel dot expansion processing
  • the mixing processing is one of the following: brightening mixing processing, difference mixing processing, positive film blending processing, bright light mixing processing, linear subtraction Light blending and color dodging.
  • the color map is converted into a grayscale image according to the following formula:
  • Y1 is the gray value of the current pixel of the grayscale image
  • R, G, and B are the color values of the red, green, and blue channels of the current pixel of the color map, respectively.
  • the color map is converted into a grayscale image according to the following formula:
  • Y2 is the gray value of the current pixel of the grayscale image
  • R, G, and B are the color values of the red, green, and blue channels of the current pixel of the color map, respectively.
  • the grayscale image is inverted by the following formula to obtain an inverted image:
  • Y3 is the gray value of the current pixel of the inverted view.
  • the invention also constructs a computer sketch drawing generation system, comprising:
  • a receiving and determining module configured to receive an image to be processed, and determine whether the image is a color map or a grayscale image
  • a grayscale generation module for converting a color map into a grayscale image
  • a background layer setting module configured to set the grayscale image as a background layer
  • An inverted image generation module configured to invert the grayscale image to obtain an inverted image
  • An expansion processing module configured to perform minimum grayscale expansion processing on the inverted image, and set the image after the expansion processing as a foreground layer;
  • a mixing processing module is configured to perform mixing processing on the foreground layer and the background layer to obtain a sketch image.
  • the mixing process is one of the following: brightening mixing processing, difference mixing processing, positive film mixing processing, bright light mixing processing, linear lightening mixing processing, color lightening Mixed processing.
  • the grayscale generating module converts the color map into a grayscale image according to the following formula:
  • Y1 is the gray value of the current pixel of the grayscale image
  • R, G, and B are the color values of the red, green, and blue channels of the current pixel of the color map, respectively.
  • the expansion processing performed by the expansion processing module is: opening an N*N window including a current pixel point, taking a minimum gray scale of all pixel points in the N*N window, and The minimum gradation is used as the gradation value after the current pixel is expanded, where N ⁇ 2.
  • the generation of the sketch image is completed based on the mathematical morphology, the generation process is simpler than the prior art, the implementation efficiency is higher, the sketch effect of the generated sketch image is good, and the whole generation process does not require manual Interaction.
  • FIG. 1 is a flow chart of an embodiment of a method for generating a computer sketch drawing of the present invention
  • Figure 2A is an image to be processed
  • FIG. 2B is a sketch image generated by the process of FIG. 2A using a computer sketch drawing generation method according to an embodiment of the present invention
  • Figure 3A is another image to be processed
  • FIG. 3B is a sketch image generated by the process of FIG. 3A using a computer sketch drawing generation method according to an embodiment of the present invention
  • FIG. 4 is a logical structural diagram of an embodiment of a computer sketch drawing generation system of the present invention.
  • the generating method includes steps S1-S6, which are specifically described below.
  • step S1 the image to be processed is received, and it is determined whether the image is a color map or a grayscale image. If it is a color map, step S2 is performed; if it is a grayscale image, step S3 is performed.
  • step S2 the color map is converted into a grayscale image.
  • the color map can be converted to a grayscale image according to the following formula:
  • Y1 is the gray value of the current pixel of the grayscale image
  • R, G, and B are the color values of the red, green, and blue channels of the current pixel of the color map, respectively.
  • the image processing in this application is performed pixel by pixel.
  • the formula of the gray value of the current pixel point of the obtained grayscale image can be rewritten as:
  • step S3 the grayscale image is set as a background layer.
  • step S4 the grayscale image is inverted by the following formula to obtain an inverted image:
  • Y3 is the gray value of the current pixel of the inverted view.
  • the minimum gray scale expansion process is performed on the inverted image, and the image after the expansion process is set as the foreground layer.
  • This step can be implemented by: opening a current pixel point.
  • the N*N window takes the minimum gray level of all the pixels in the N*N window, and takes the minimum gray level as the gray value after the current pixel point is expanded, where N ⁇ 2, for example, the opened window If it is 3*3, and the current pixel is the center pixel, the gray value after the current pixel expansion process can be obtained by the following operation:
  • Y4(i, j) min( min(Y3(i-1, j-1), Y3(i, j-1), Y3(i+1, j-1)),
  • Y4(i, j) is the gray value after the current pixel expansion process
  • Y3(i, j) is the gray value of the current pixel of the inverted view, that is, the gray value before the current pixel expansion process
  • Y3(i-1, j-1), Y3(i, j-1), Y3( i+1, j-1), Y3 (i-1, j), Y3(i+1, j), Y3(i-1, j+1), Y3(i, j+1), Y3(i+1, j+1) are respectively associated with Y3(i, j)
  • the gray value of the nearest pixel Through the above operation, the minimum gray level of 9 pixels in the window is obtained.
  • step S6 the foreground layer and the background layer are mixed to obtain a sketch image
  • the mixing process may select any one of the following: brightening mixing processing, difference mixing processing, and multi-layer folding
  • the mixing process, the bright light mixing process, the linear dodge mixing process, and the color dodge mixing process are preferred, and a color dodge mixing process is preferred.
  • the color dodge blending operation can be calculated by the following program:
  • Y5 is the gray value of the current pixel on the mixed result image
  • Front is the gray value of the current pixel on the foreground layer
  • Back is the gray value of the current pixel on the background layer.
  • FIG. 2A is a to-be-processed image, which is a landscape image
  • FIG. 2B is a sketch image generated by the process of FIG. 2A using the above-described computer sketching generation method, and in the generation method, a linear subtraction is adopted.
  • Mixed processing. 3A is another image to be processed, the image is a person image
  • FIG. 3B is a sketch image generated by the process of FIG. 3A using the above-described computer sketch drawing generation method, and in the generation method, the color is lightened.
  • Mixed processing Comparing FIGS. 2A and 2B, and FIGS. 3A and 3B, it can be seen that the sketch effect of the generated sketch image is good, and the entire generation process does not require manual interaction.
  • the generation system includes: a receiving and determining module 11, a grayscale generating module 12, a background layer setting module 13, and an inverted image generating module 14, The expansion processing module 15 and the mixing processing module 16.
  • the receiving and determining module 11 is configured to receive the processed image, and determine whether the image is a color map or a grayscale image; the grayscale graph generating module 12 is configured to convert the color map into a grayscale image; the background layer setting module 13 is used to set the grayscale image as a background layer; the inverse image generation module 14 is configured to invert the grayscale image to obtain an inverted image; and the expansion processing module 15 is configured to minimize the inverted image
  • the value gray scale expansion process is performed, and the image after the expansion processing is set as the foreground layer; the mixing processing module 16 is configured to perform mixing processing on the foreground layer and the background layer to obtain a sketch image.
  • the mixing processing may be one of the following: brightening mixing processing, difference mixing processing, positive film mixing processing, bright light mixing processing, linear lightening mixing processing, color lightening A mixing process in which a color lightening mixing process is preferred.
  • the expansion processing is: opening an N*N window including the current pixel point, taking the minimum gray level of all the pixel points in the N*N window, and taking the minimum gray level.
  • N the gray value after the current pixel dot expansion processing
  • the color map is converted to a grayscale map according to the following formula:
  • Y1 is the gray value of the current pixel of the grayscale image
  • R, G, and B are the color values of the red, green, and blue channels of the current pixel of the color map, respectively.
  • the color map can also be converted to a grayscale map according to the following formula:
  • Y2 is the gray value of the current pixel of the grayscale image
  • R, G, and B are the color values of the red, green, and blue channels of the current pixel of the color map, respectively. This speeds up the computer's computing speed.

Abstract

Disclosed are a method and system for generating a computer sketch image, the method comprising: S1, receiving an image to be processed, and judging whether the image is a color image or a gray scale image, if the image is a color image, then executing step S2, and if the image is a gray scale image, then executing step S3; S2, converting the color image into a gray scale image; S3, setting the gray scale image as a background image layer; S4, reversing the phase of the gray scale image to obtain a reverse phase image; S5, performing minimum gray scale expansion processing on the reverse phase image, and setting the image having undergone the expansion processing as a foreground image layer; S6, blending the foreground image layer with the background image layer to obtain a sketch image. The sketch image generated by the technical solution of the present invention has a good sketch effect, eliminating the need for manual interactive operation during the entire generation process.

Description

一种计算机素描画的生成方法和系统  Method and system for generating computer sketch drawing 技术领域Technical field
本发明涉及图像处理技术,尤其涉及一种计算机素描画的生成方法和系统。The present invention relates to image processing technologies, and in particular, to a method and system for generating computer sketches.
背景技术Background technique
素描是图像风格化的一种, 现实中的素描是以铅笔为媒介,用线条来表现或景物的艺术形式。素描可以分为线条结构画和精细写实素描两种。手工创作素描要求作者具有一定的美术功底,因此计算机模拟生成素描画具有重要的应用和娱乐价值。Sketch is a kind of image stylization. The sketch in reality is a pencil-based medium, with lines to represent or the artistic form of the scene. Sketch can be divided into line structure painting and fine realistic sketch. Manually creating sketches requires the author to have a certain degree of artistic skills, so computer simulation of sketch painting has important application and entertainment value.
目前在一些图像软件中,有素描画生成的功能, 如Photoshop的素描滤镜,但是用Photoshop自带的素描滤波操作生成的素描画的素描效果不好。还有一种方法是首先使用边缘检测算子提取图像的轮廓图,然后在滑动窗口内不断手工调整局部边缘检测参数,对轮廓进行修正,最后对生成的轮廓进行风格化线条渲染,得到最终的线条画。但这种素描画的生成方法需要加入人工的交互操作。At present, in some image software, there is a function of sketch drawing generation. Such as Photoshop's sketch filter, but the sketch of the sketch created by Photoshop's own sketch filter operation is not good. Another method is to first extract the contour map of the image by using the edge detection operator, and then manually adjust the local edge detection parameters in the sliding window to correct the contour, and finally perform stylized line rendering on the generated contour to obtain the final line. painting. However, this method of generating sketches requires manual interaction.
技术问题technical problem
本发明要解决的技术问题在于,针对上述现有素描画生成技术生成素描效果不好、需要人工交互操作的缺陷,提供一种计算机素描画的生成方法,素描效果好,且不需要人工的交互操作。The technical problem to be solved by the present invention is that, in view of the above-mentioned existing sketch drawing generation technology, the defect that the sketch effect is not good and the manual interaction operation is required, and the method for generating the computer sketch drawing is provided, the sketch effect is good, and no manual interaction is needed. operating.
技术解决方案Technical solution
本发明解决其技术问题所采用的技术方案是:构造一种计算机素描画的生成方法,其特征在于,包括:The technical solution adopted by the present invention to solve the technical problem thereof is to construct a computer sketch drawing generation method, which is characterized in that:
S1.接收待处理的图像,并判断所述图像是彩色图还是灰度图,若是彩色图,则执行步骤S2;若是灰度图,则执行步骤S3;S1. Receiving an image to be processed, and determining whether the image is a color map or a grayscale image, if it is a color map, step S2 is performed; if it is a gray scale image, step S3 is performed;
S2.将彩色图转换为灰度图;S2. Converting the color map to a grayscale image;
S3.将所述灰度图设为背景图层;S3. setting the grayscale image as a background layer;
S4.对所述灰度图进行反相得到反相图;S4. Inverting the grayscale image to obtain an inverted image;
S5.对所述反相图进行最小值灰度膨胀处理,并将膨胀处理后的图像设为前景图层;S5. performing minimum gray scale expansion processing on the inverted image, and setting the image after the expansion processing as a foreground layer;
S6.对所述前景图层和所述背景图层进行混合处理,以得到素描图像。S6. Mixing the foreground layer and the background layer to obtain a sketch image.
在本发明所述的生成方法中,在所述步骤S5中,开一个包含当前像素点的N*N窗口,取N*N窗口内所有像素点的最小值灰度,并将最小值灰度作为当前像素点膨胀处理后的灰度值,其中,N≥2。In the generating method of the present invention, in the step S5, an N*N window including the current pixel point is opened, and the minimum gray level of all the pixel points in the N*N window is taken, and the minimum gray level is obtained. As the gray value after the current pixel dot expansion processing, where N≥2.
在本发明所述的生成方法中,在所述步骤S6中,所述混合处理为下列中的一种:变亮混合处理、差值混合处理、正片叠底混合处理、亮光混合处理、线性减淡混合处理、颜色减淡混合处理。In the generating method of the present invention, in the step S6, the mixing processing is one of the following: brightening mixing processing, difference mixing processing, positive film blending processing, bright light mixing processing, linear subtraction Light blending and color dodging.
在本发明所述的生成方法中,在所述步骤S2中,根据下面的公式将彩色图转换为灰度图:In the generating method of the present invention, in the step S2, the color map is converted into a grayscale image according to the following formula:
Y1 = 0.299*R + 0.587*G + 0.114*BY1 = 0.299*R + 0.587*G + 0.114*B
其中,Y1为灰度图的当前像素点的灰度值,R、G、B分别为彩色图的当前像素点的红、绿、蓝通道的颜色值。Where Y1 is the gray value of the current pixel of the grayscale image, and R, G, and B are the color values of the red, green, and blue channels of the current pixel of the color map, respectively.
在本发明所述的生成方法中,在所述步骤S2中,根据下面的公式将彩色图转换为灰度图:In the generating method of the present invention, in the step S2, the color map is converted into a grayscale image according to the following formula:
Y2= (R*306 + G*601 + B*117 + 512) *1024Y2= (R*306 + G*601 + B*117 + 512) *1024
其中,Y2为灰度图的当前像素点的灰度值,R、G、B分别为彩色图的当前像素点的红、绿、蓝通道的颜色值。Where Y2 is the gray value of the current pixel of the grayscale image, and R, G, and B are the color values of the red, green, and blue channels of the current pixel of the color map, respectively.
在本发明所述的生成方法中,在所述步骤S4中,通过下面的公式对所述灰度图进行反相得到反相图:In the generating method of the present invention, in the step S4, the grayscale image is inverted by the following formula to obtain an inverted image:
Y3 = 255–Y2Y3 = 255–Y2
其中,Y3为反相图的当前像素点的灰度值。Where Y3 is the gray value of the current pixel of the inverted view.
本发明还构造一种计算机素描画的生成系统,包括:The invention also constructs a computer sketch drawing generation system, comprising:
接收及判断模块,用于接收待处理的图像,并判断所述图像是彩色图还是灰度图;a receiving and determining module, configured to receive an image to be processed, and determine whether the image is a color map or a grayscale image;
灰度图生成模块,用于将彩色图转换为灰度图;a grayscale generation module for converting a color map into a grayscale image;
背景图层设置模块,用于将所述灰度图设为背景图层;a background layer setting module, configured to set the grayscale image as a background layer;
反相图生成模块,用于所述灰度图进行反相得到反相图;An inverted image generation module, configured to invert the grayscale image to obtain an inverted image;
膨胀处理模块,用于对所述反相图进行最小值灰度膨胀处理,并将膨胀处理后的图像设为前景图层;An expansion processing module, configured to perform minimum grayscale expansion processing on the inverted image, and set the image after the expansion processing as a foreground layer;
混合处理模块,用于对所述前景图层和所述背景图层进行混合处理,以得到素描图像。A mixing processing module is configured to perform mixing processing on the foreground layer and the background layer to obtain a sketch image.
在本发明所述的生成系统中,所述混合处理为下列中的一种:变亮混合处理、差值混合处理、正片叠底混合处理、亮光混合处理、线性减淡混合处理、颜色减淡混合处理。In the generating system of the present invention, the mixing process is one of the following: brightening mixing processing, difference mixing processing, positive film mixing processing, bright light mixing processing, linear lightening mixing processing, color lightening Mixed processing.
在本发明所述的生成系统中,所述灰度图生成模块根据下面的公式将彩色图转换为灰度图:In the generating system of the present invention, the grayscale generating module converts the color map into a grayscale image according to the following formula:
Y1 = 0.299*R + 0.587*G + 0.114*BY1 = 0.299*R + 0.587*G + 0.114*B
其中,Y1为灰度图的当前像素点的灰度值,R、G、B分别为彩色图的当前像素点的红、绿、蓝通道的颜色值。Where Y1 is the gray value of the current pixel of the grayscale image, and R, G, and B are the color values of the red, green, and blue channels of the current pixel of the color map, respectively.
在本发明所述的生成系统中,所述膨胀处理模块所进行的膨胀处理为:开一个包含当前像素点的N*N窗口,取N*N窗口内所有像素点的最小值灰度,并将最小值灰度作为当前像素点膨胀处理后的灰度值,其中,N≥2。In the generating system of the present invention, the expansion processing performed by the expansion processing module is: opening an N*N window including a current pixel point, taking a minimum gray scale of all pixel points in the N*N window, and The minimum gradation is used as the gradation value after the current pixel is expanded, where N ≥ 2.
有益效果Beneficial effect
实施本发明的技术方案,基于数学形态学来完成素描图像的生成,相对于现有技术生成过程更加简单,实现效率更高,所生成的素描图像的素描效果好,且整个生成过程不需要人工交互操作。By implementing the technical solution of the present invention, the generation of the sketch image is completed based on the mathematical morphology, the generation process is simpler than the prior art, the implementation efficiency is higher, the sketch effect of the generated sketch image is good, and the whole generation process does not require manual Interaction.
附图说明DRAWINGS
下面将结合附图及实施例对本发明作进一步说明,附图中:The present invention will be further described below in conjunction with the accompanying drawings and embodiments, in which:
图1是本发明计算机素描画的生成方法实施例的流程图;1 is a flow chart of an embodiment of a method for generating a computer sketch drawing of the present invention;
图2A是一幅待处理图像;Figure 2A is an image to be processed;
图2B是使用本发明一个实施例的计算机素描画的生成方法对图2A处理所生成的素描图像;2B is a sketch image generated by the process of FIG. 2A using a computer sketch drawing generation method according to an embodiment of the present invention;
图3A是另一幅待处理图像;Figure 3A is another image to be processed;
图3B是使用本发明一个实施例的计算机素描画的生成方法对图3A处理所生成的素描图像;FIG. 3B is a sketch image generated by the process of FIG. 3A using a computer sketch drawing generation method according to an embodiment of the present invention; FIG.
图4是本发明计算机素描画的生成系统实施例的逻辑结构图。4 is a logical structural diagram of an embodiment of a computer sketch drawing generation system of the present invention.
本发明的实施方式Embodiments of the invention
如图1所示,在本发明计算机素描画的生成方法实施例的流程图中,该生成方法包括步骤S1-S6,下面具体说明。As shown in FIG. 1, in the flowchart of the embodiment of the method for generating computer sketches of the present invention, the generating method includes steps S1-S6, which are specifically described below.
在步骤S1中,接收待处理的图像,并判断所述图像是彩色图还是灰度图,若是彩色图,则执行步骤S2;若是灰度图,则执行步骤S3。在步骤S2中,将彩色图转换为灰度图,在一个例子中,可根据下面的公式将彩色图转换为灰度图:In step S1, the image to be processed is received, and it is determined whether the image is a color map or a grayscale image. If it is a color map, step S2 is performed; if it is a grayscale image, step S3 is performed. In step S2, the color map is converted into a grayscale image. In one example, the color map can be converted to a grayscale image according to the following formula:
Y1 = 0.299*R + 0.587*G + 0.114*BY1 = 0.299*R + 0.587*G + 0.114*B
其中,Y1为灰度图的当前像素点的灰度值,R、G、B分别为彩色图的当前像素点的红、绿、蓝通道的颜色值。在此应当说明的是,本申请中的图像处理都是逐个像素进行的。优选地,为了实现在计算机上的快速运算,可将所得到的灰度图的当前像素点的灰度值的公式改写为:Where Y1 is the gray value of the current pixel of the grayscale image, and R, G, and B are the color values of the red, green, and blue channels of the current pixel of the color map, respectively. It should be noted here that the image processing in this application is performed pixel by pixel. Preferably, in order to achieve a fast operation on the computer, the formula of the gray value of the current pixel point of the obtained grayscale image can be rewritten as:
Y2= (R*306 + G*601 + B*117 + 512) *1024Y2= (R*306 + G*601 + B*117 + 512) *1024
其中,Y2为灰度图的当前像素点的灰度值,R、G、B分别为彩色图的当前像素点的红、绿、蓝通道的颜色值。在步骤S3中,将所述灰度图设为背景图层。在步骤S4中,例如,通过下面的公式对所述灰度图进行反相得到反相图:Where Y2 is the gray value of the current pixel of the grayscale image, and R, G, and B are the color values of the red, green, and blue channels of the current pixel of the color map, respectively. In step S3, the grayscale image is set as a background layer. In step S4, for example, the grayscale image is inverted by the following formula to obtain an inverted image:
Y3 = 255–Y2Y3 = 255–Y2
其中,Y3为反相图的当前像素点的灰度值。在所述步骤S5中,对所述反相图进行最小值灰度膨胀处理,并将膨胀处理后的图像设为前景图层,该步骤可通过下面方式来实现:开一个包含当前像素点的N*N窗口,取N*N窗口内所有像素点的最小值灰度,并将最小值灰度作为当前像素点膨胀处理后的灰度值,其中,N≥2,例如,所开的窗口为3*3,且当前像素点为中心像素点,则可通过下面的运算得出当前像素点膨胀处理后的灰度值:Where Y3 is the gray value of the current pixel of the inverted view. In the step S5, the minimum gray scale expansion process is performed on the inverted image, and the image after the expansion process is set as the foreground layer. This step can be implemented by: opening a current pixel point. The N*N window takes the minimum gray level of all the pixels in the N*N window, and takes the minimum gray level as the gray value after the current pixel point is expanded, where N≥2, for example, the opened window If it is 3*3, and the current pixel is the center pixel, the gray value after the current pixel expansion process can be obtained by the following operation:
Y4(i, j) = min( min(Y3(i-1, j-1), Y3(i, j-1), Y3(i+1, j-1)),Y4(i, j) = min( min(Y3(i-1, j-1), Y3(i, j-1), Y3(i+1, j-1)),
min(Y3(i-1, j), Y3(i, j), Y3(i+1, j)),Min(Y3(i-1, j), Y3(i, j), Y3(i+1, j)),
min(Y3(i-1, j+1), Y3(i, j+1), Y3(i+1, j+1)))Min(Y3(i-1, j+1), Y3(i, j+1), Y3(i+1, j+1)))
其中,Y4(i, j)为当前像素点膨胀处理后的灰度值,Y3(i, j)为反相图的当前像素点的灰度值,也即当前像素点膨胀处理前的灰度值,Y3(i-1, j-1)、Y3(i, j-1)、Y3(i+1, j-1)、Y3(i-1, j)、Y3(i+1, j)、Y3(i-1, j+1)、Y3(i, j+1)、Y3(i+1, j+1)分别为与Y3(i, j)最邻近的像素点的灰度值。通过上面的运算也就求得了窗口内9个像素点的最小值灰度。在步骤S6中,对所述前景图层和所述背景图层进行混合处理,以得到素描图像,该混合处理可选择下列中的任何一个:变亮混合处理、差值混合处理、正片叠底混合处理、亮光混合处理、线性减淡混合处理、颜色减淡混合处理,其中,优选颜色减淡混合处理。颜色减淡混合操作可通过下面程序来进行计算:Where Y4(i, j) is the gray value after the current pixel expansion process, Y3(i, j) is the gray value of the current pixel of the inverted view, that is, the gray value before the current pixel expansion process, Y3(i-1, j-1), Y3(i, j-1), Y3( i+1, j-1), Y3 (i-1, j), Y3(i+1, j), Y3(i-1, j+1), Y3(i, j+1), Y3(i+1, j+1) are respectively associated with Y3(i, j) The gray value of the nearest pixel. Through the above operation, the minimum gray level of 9 pixels in the window is obtained. In step S6, the foreground layer and the background layer are mixed to obtain a sketch image, and the mixing process may select any one of the following: brightening mixing processing, difference mixing processing, and multi-layer folding The mixing process, the bright light mixing process, the linear dodge mixing process, and the color dodge mixing process are preferred, and a color dodge mixing process is preferred. The color dodge blending operation can be calculated by the following program:
If(Front == 255)If(Front == 255)
{{
Y5 = 255; Y5 = 255;
}}
ElseElse
{{
Y5 = min(255, (Back * 256 ) / (255-Front)); Y5 = min(255, (Back * 256 ) / (255-Front));
}}
其中,Y5为混合结果图像上当前像素点的灰度值,Front为上述前景图层上当前像素点的灰度值,Back为上述背景图层上当前像素点的灰度值。Y5 is the gray value of the current pixel on the mixed result image, Front is the gray value of the current pixel on the foreground layer, and Back is the gray value of the current pixel on the background layer.
图2A是一幅待处理图像,该图像为风景图像,图2B是使用上述的计算机素描画的生成方法对图2A处理所生成的素描图像,且在该生成方法中,采用的是线性减淡混合处理。图3A是另一幅待处理图像,该图像为人物图像,图3B是使用上述计算机素描画的生成方法对图3A处理所生成的素描图像,且在该生成方法中,采用的是颜色减淡混合处理。对比图2A和图2B,及图3A和图3B,可看出所生成的素描图像的素描效果好,且整个生成过程不需要人工交互操作。2A is a to-be-processed image, which is a landscape image, and FIG. 2B is a sketch image generated by the process of FIG. 2A using the above-described computer sketching generation method, and in the generation method, a linear subtraction is adopted. Mixed processing. 3A is another image to be processed, the image is a person image, and FIG. 3B is a sketch image generated by the process of FIG. 3A using the above-described computer sketch drawing generation method, and in the generation method, the color is lightened. Mixed processing. Comparing FIGS. 2A and 2B, and FIGS. 3A and 3B, it can be seen that the sketch effect of the generated sketch image is good, and the entire generation process does not require manual interaction.
图4是本发明计算机素描画的生成系统实施例的逻辑结构图,该生成系统包括:接收及判断模块11、灰度图生成模块12、背景图层设置模块13、反相图生成模块14、膨胀处理模块15和混合处理模块16。其中,接收及判断模块11用于收待处理的图像,并判断所述图像是彩色图还是灰度图;灰度图生成模块12用于将彩色图转换为灰度图;背景图层设置模块13用于将所述灰度图设为背景图层;反相图生成模块14用于所述灰度图进行反相得到反相图;膨胀处理模块15用于对所述反相图进行最小值灰度膨胀处理,并将膨胀处理后的图像设为前景图层;混合处理模块16用于对所述前景图层和所述背景图层进行混合处理,以得到素描图像。4 is a logical structural diagram of an embodiment of a computer sketch drawing generation system of the present invention. The generation system includes: a receiving and determining module 11, a grayscale generating module 12, a background layer setting module 13, and an inverted image generating module 14, The expansion processing module 15 and the mixing processing module 16. The receiving and determining module 11 is configured to receive the processed image, and determine whether the image is a color map or a grayscale image; the grayscale graph generating module 12 is configured to convert the color map into a grayscale image; the background layer setting module 13 is used to set the grayscale image as a background layer; the inverse image generation module 14 is configured to invert the grayscale image to obtain an inverted image; and the expansion processing module 15 is configured to minimize the inverted image The value gray scale expansion process is performed, and the image after the expansion processing is set as the foreground layer; the mixing processing module 16 is configured to perform mixing processing on the foreground layer and the background layer to obtain a sketch image.
在上述实施例的混合处理模块16中,混合处理可为下列中的一种:变亮混合处理、差值混合处理、正片叠底混合处理、亮光混合处理、线性减淡混合处理、颜色减淡混合处理,其中,优选颜色减淡混合处理。In the mixing processing module 16 of the above embodiment, the mixing processing may be one of the following: brightening mixing processing, difference mixing processing, positive film mixing processing, bright light mixing processing, linear lightening mixing processing, color lightening A mixing process in which a color lightening mixing process is preferred.
在上述实施例的膨胀处理模块15中,其中的膨胀处理为:开一个包含当前像素点的N*N窗口,取N*N窗口内所有像素点的最小值灰度,并将最小值灰度作为当前像素点膨胀处理后的灰度值,其中,N≥2。In the expansion processing module 15 of the above embodiment, the expansion processing is: opening an N*N window including the current pixel point, taking the minimum gray level of all the pixel points in the N*N window, and taking the minimum gray level. As the gray value after the current pixel dot expansion processing, where N≥2.
在一个实施例的灰度图生成模块12中, 根据下面的公式将彩色图转换为灰度图:In the grayscale map generation module 12 of one embodiment, the color map is converted to a grayscale map according to the following formula:
Y1 = 0.299*R + 0.587*G + 0.114*BY1 = 0.299*R + 0.587*G + 0.114*B
其中,Y1为灰度图的当前像素点的灰度值,R、G、B分别为彩色图的当前像素点的红、绿、蓝通道的颜色值。Where Y1 is the gray value of the current pixel of the grayscale image, and R, G, and B are the color values of the red, green, and blue channels of the current pixel of the color map, respectively.
在另一个实施例的灰度图生成模块12中, 还可根据下面的公式将彩色图转换为灰度图:In another embodiment of the grayscale map generation module 12, the color map can also be converted to a grayscale map according to the following formula:
Y2= (R*306 + G*601 + B*117 + 512) *1024Y2= (R*306 + G*601 + B*117 + 512) *1024
其中,Y2为灰度图的当前像素点的灰度值,R、G、B分别为彩色图的当前像素点的红、绿、蓝通道的颜色值。这样可加快计算机的运算速度。Where Y2 is the gray value of the current pixel of the grayscale image, and R, G, and B are the color values of the red, green, and blue channels of the current pixel of the color map, respectively. This speeds up the computer's computing speed.
以上所述仅为本发明的优选实施例而已,并不用于限制本发明,对于本领域的技术人员来说,本发明可以有各种更改和变化。凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的权利要求范围之内。 The above description is only the preferred embodiment of the present invention, and is not intended to limit the present invention, and various modifications and changes can be made to the present invention. Any modifications, equivalent substitutions, improvements, etc. within the spirit and scope of the invention are intended to be included within the scope of the appended claims.

Claims (10)

  1. 一种计算机素描画的生成方法,其特征在于,包括:A method for generating a computer sketch drawing, comprising:
    S1.接收待处理的图像,并判断所述图像是彩色图还是灰度图,若是彩色图,则执行步骤S2;若是灰度图,则执行步骤S3;S1. Receiving an image to be processed, and determining whether the image is a color map or a grayscale image, if it is a color map, step S2 is performed; if it is a gray scale image, step S3 is performed;
    S2.将彩色图转换为灰度图;S2. Converting the color map to a grayscale image;
    S3.将所述灰度图设为背景图层;S3. setting the grayscale image as a background layer;
    S4.对所述灰度图进行反相得到反相图;S4. Inverting the grayscale image to obtain an inverted image;
    S5.对所述反相图进行最小值灰度膨胀处理,并将膨胀处理后的图像设为前景图层;S5. performing minimum gray scale expansion processing on the inverted image, and setting the image after the expansion processing as a foreground layer;
    S6.对所述前景图层和所述背景图层进行混合处理,以得到素描图像。S6. Mixing the foreground layer and the background layer to obtain a sketch image.
  2. 根据权利要求1所述的生成方法,其特征在于,在所述步骤S5中,开一个包含当前像素点的N*N窗口,取N*N窗口内所有像素点的最小值灰度,并将最小值灰度作为当前像素点膨胀处理后的灰度值,其中,N≥2。The generating method according to claim 1, wherein in the step S5, an N*N window including a current pixel point is opened, and a minimum gray level of all pixels in the N*N window is taken, and The minimum gray scale is used as the gray value after the current pixel point expansion processing, where N≥2.
  3. 根据权利要求1或2所述的生成方法,其特征在于,在所述步骤S6中,所述混合处理为下列中的一种:变亮混合处理、差值混合处理、正片叠底混合处理、亮光混合处理、线性减淡混合处理、颜色减淡混合处理。The generating method according to claim 1 or 2, wherein in the step S6, the mixing processing is one of the following: a brightening mixing process, a difference mixing process, a positive film bottom mixing process, Bright blending process, linear dodge blending process, and color dodge blending process.
  4. 根据权利要求1或2所述的生成方法,其特征在于,在所述步骤S2中,根据下面的公式将彩色图转换为灰度图:The generating method according to claim 1 or 2, wherein in the step S2, the color map is converted into a grayscale image according to the following formula:
    Y1 = 0.299*R + 0.587*G + 0.114*BY1 = 0.299*R + 0.587*G + 0.114*B
    其中,Y1为灰度图的当前像素点的灰度值,R、G、B分别为彩色图的当前像素点的红、绿、蓝通道的颜色值。Where Y1 is the gray value of the current pixel of the grayscale image, and R, G, and B are the color values of the red, green, and blue channels of the current pixel of the color map, respectively.
  5. 根据权利要求1或2所述的生成方法,其特征在于,在所述步骤S2中,根据下面的公式将彩色图转换为灰度图:The generating method according to claim 1 or 2, wherein in the step S2, the color map is converted into a grayscale image according to the following formula:
    Y2= (R*306 + G*601 + B*117 + 512) *1024Y2= (R*306 + G*601 + B*117 + 512) *1024
    其中,Y2为灰度图的当前像素点的灰度值,R、G、B分别为彩色图的当前像素点的红、绿、蓝通道的颜色值。Where Y2 is the gray value of the current pixel of the grayscale image, and R, G, and B are the color values of the red, green, and blue channels of the current pixel of the color map, respectively.
  6. 根据权利要求5所述的生成方法,其特征在于,在所述步骤S4中,通过下面的公式对所述灰度图进行反相得到反相图:The generating method according to claim 5, wherein in the step S4, the grayscale image is inverted by the following formula to obtain an inverted image:
    Y3 = 255–Y2Y3 = 255–Y2
    其中,Y3为反相图的当前像素点的灰度值。Where Y3 is the gray value of the current pixel of the inverted view.
  7. 一种计算机素描画的生成系统,其特征在于,包括:A computer sketch drawing generation system, comprising:
    接收及判断模块,用于接收待处理的图像,并判断所述图像是彩色图还是灰度图;a receiving and determining module, configured to receive an image to be processed, and determine whether the image is a color map or a grayscale image;
    灰度图生成模块,用于将彩色图转换为灰度图;a grayscale generation module for converting a color map into a grayscale image;
    背景图层设置模块,用于将所述灰度图设为背景图层;a background layer setting module, configured to set the grayscale image as a background layer;
    反相图生成模块,用于所述灰度图进行反相得到反相图;An inverted image generation module, configured to invert the grayscale image to obtain an inverted image;
    膨胀处理模块,用于对所述反相图进行最小值灰度膨胀处理,并将膨胀处理后的图像设为前景图层;An expansion processing module, configured to perform minimum grayscale expansion processing on the inverted image, and set the image after the expansion processing as a foreground layer;
    混合处理模块,用于对所述前景图层和所述背景图层进行混合处理,以得到素描图像。A mixing processing module is configured to perform mixing processing on the foreground layer and the background layer to obtain a sketch image.
  8. 根据权利要求7所述的生成系统,其特征在于,所述混合处理为下列中的一种:变亮混合处理、差值混合处理、正片叠底混合处理、亮光混合处理、线性减淡混合处理、颜色减淡混合处理。The generating system according to claim 7, wherein the mixing processing is one of the following: a brightening mixing process, a difference mixing process, a positive film bottom mixing process, a bright light mixing process, and a linear lightening mixing process. , color lightening mixed processing.
  9. 根据权利要求7所述的生成系统,其特征在于,所述灰度图生成模块根据下面的公式将彩色图转换为灰度图:The generating system according to claim 7, wherein said grayscale generating module converts the color map into a grayscale image according to the following formula:
    Y1 = 0.299*R + 0.587*G + 0.114*BY1 = 0.299*R + 0.587*G + 0.114*B
    其中,Y1为灰度图的当前像素点的灰度值,R、G、B分别为彩色图的当前像素点的红、绿、蓝通道的颜色值。Where Y1 is the gray value of the current pixel of the grayscale image, and R, G, and B are the color values of the red, green, and blue channels of the current pixel of the color map, respectively.
  10. 根据权利要求7-9任一项所述的生成系统,其特征在于, 所述膨胀处理模块所进行的膨胀处理为:开一个包含当前像素点的N*N窗口,取N*N窗口内所有像素点的最小值灰度,并将最小值灰度作为当前像素点膨胀处理后的灰度值,其中,N≥2。A generating system according to any one of claims 7-9, characterized in that The expansion processing performed by the expansion processing module is: opening an N*N window including the current pixel point, taking the minimum gray level of all the pixel points in the N*N window, and expanding the minimum gray level as the current pixel point. The processed gray value, where N ≥ 2.
PCT/CN2011/084249 2011-07-26 2011-12-19 Method and system for generating computer sketch image WO2013013485A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN 201110210312 CN102332170B (en) 2011-07-26 2011-07-26 Method and system for generating computer sketch images
CN201110210312.1 2011-07-26

Publications (1)

Publication Number Publication Date
WO2013013485A1 true WO2013013485A1 (en) 2013-01-31

Family

ID=45483933

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2011/084249 WO2013013485A1 (en) 2011-07-26 2011-12-19 Method and system for generating computer sketch image

Country Status (2)

Country Link
CN (1) CN102332170B (en)
WO (1) WO2013013485A1 (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108196755A (en) * 2018-01-30 2018-06-22 腾讯科技(深圳)有限公司 Background picture display and device
CN109035377A (en) * 2018-07-20 2018-12-18 广州市普汉科技有限公司 For obtaining the embossment sketch effect image processing method for being suitable for laser engraving
CN111340689A (en) * 2020-03-02 2020-06-26 周晓明 Generation method and system for composite image
CN113689363A (en) * 2021-09-07 2021-11-23 北京顺势兄弟科技有限公司 Portrait image processing method and device, electronic equipment and storage medium
CN113781362A (en) * 2021-09-28 2021-12-10 广州四三九九信息科技有限公司 Method for restoring multi-layer mixed mode image into multiple single layers

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103685858A (en) * 2012-08-31 2014-03-26 北京三星通信技术研究有限公司 Real-time video processing method and equipment
CN103455974B (en) * 2013-05-24 2017-05-17 厦门美图网科技有限公司 Image sketching style processing method
CN103679794B (en) * 2013-12-27 2017-03-01 辽宁师范大学 The method for drafting of the three-dimensional sketch pencil drawing of simulation
CN107229905B (en) * 2017-05-05 2020-08-11 广州视源电子科技股份有限公司 Method and device for rendering color of lips and electronic equipment
CN107749045A (en) * 2017-09-21 2018-03-02 北京麒麟合盛网络技术有限公司 The sketch processing method and sketch filter of a kind of image
CN108182664A (en) * 2017-12-26 2018-06-19 努比亚技术有限公司 A kind of image processing method, mobile terminal and computer readable storage medium
CN108460825A (en) * 2018-03-15 2018-08-28 中辰远瞻(北京)照明设计有限公司 A kind of nightscape lighting scheme works figure production method
CN108846386B (en) * 2018-07-10 2022-06-24 深圳市前海手绘科技文化有限公司 Intelligent identification and correction method for hand-drawn pattern
CN111462158B (en) * 2020-03-31 2024-03-19 腾讯科技(深圳)有限公司 Image processing method and device, intelligent equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101017567A (en) * 2007-03-09 2007-08-15 李昕 Method and device for transforming digital photo to portrait sketch painting
CN101551911A (en) * 2009-05-07 2009-10-07 上海交通大学 Human face sketch portrait picture automatic generating method
CN101587593A (en) * 2009-06-19 2009-11-25 西安交通大学 A kind of method based on the stylization of true picture sketch

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2034442A1 (en) * 2007-09-06 2009-03-11 Thomson Licensing Method for non-photorealistic rendering of an image frame sequence
CN101739701B (en) * 2009-12-31 2011-12-14 湖北莲花山计算机视觉和信息科学研究院 Method for establishing painting brush sample library

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101017567A (en) * 2007-03-09 2007-08-15 李昕 Method and device for transforming digital photo to portrait sketch painting
CN101551911A (en) * 2009-05-07 2009-10-07 上海交通大学 Human face sketch portrait picture automatic generating method
CN101587593A (en) * 2009-06-19 2009-11-25 西安交通大学 A kind of method based on the stylization of true picture sketch

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108196755A (en) * 2018-01-30 2018-06-22 腾讯科技(深圳)有限公司 Background picture display and device
CN108196755B (en) * 2018-01-30 2021-02-12 腾讯科技(深圳)有限公司 Background picture display method and device
CN109035377A (en) * 2018-07-20 2018-12-18 广州市普汉科技有限公司 For obtaining the embossment sketch effect image processing method for being suitable for laser engraving
CN109035377B (en) * 2018-07-20 2022-12-13 广州市普汉科技有限公司 Image processing method for obtaining embossment sketch effect suitable for laser engraving
CN111340689A (en) * 2020-03-02 2020-06-26 周晓明 Generation method and system for composite image
CN111340689B (en) * 2020-03-02 2022-06-28 周晓明 Generation method and system for composite image
CN113689363A (en) * 2021-09-07 2021-11-23 北京顺势兄弟科技有限公司 Portrait image processing method and device, electronic equipment and storage medium
CN113689363B (en) * 2021-09-07 2024-03-29 北京顺势兄弟科技有限公司 Portrait image processing method and device, electronic equipment and storage medium
CN113781362A (en) * 2021-09-28 2021-12-10 广州四三九九信息科技有限公司 Method for restoring multi-layer mixed mode image into multiple single layers
CN113781362B (en) * 2021-09-28 2023-09-29 广州四三九九信息科技有限公司 Method for restoring multi-layer mixed mode image into multiple single layers

Also Published As

Publication number Publication date
CN102332170B (en) 2013-06-12
CN102332170A (en) 2012-01-25

Similar Documents

Publication Publication Date Title
WO2013013485A1 (en) Method and system for generating computer sketch image
WO2013040983A1 (en) Opengl-based inverted image display processing device and method
TWI281138B (en) A display driver
WO2016106818A1 (en) Image data processing method and device
WO2017193438A1 (en) Image display method and display apparatus
WO2017101176A1 (en) Liquid crystal display device
WO2016137080A1 (en) Three-dimensional character rendering system using general purpose graphic processing unit, and processing method thereof
US20080284793A1 (en) Hue and saturation control module
WO2013025219A1 (en) Creating a blended image
JPH02245793A (en) Matrix display device
JPH04288590A (en) The method and equipment for ramdac of cymk-rgb
TW201205544A (en) Image compensation apparatus and method thereof and field sequential color liquid crystal display using the same
WO2017177492A1 (en) Test device for display panel
WO2011010788A1 (en) Video call device and method
CN102436330A (en) Embedded type electronic whiteboard and realizing method thereof
WO2020119558A1 (en) Display driving method, display driving device, and display device
WO2017049436A1 (en) Method and device for arranging icons on an android device
WO2016187960A1 (en) Driving circuit and method for driving display panel thereof
JP4647735B2 (en) Method and apparatus for adjusting hue in digital color display system
AU3591400A (en) Method and system for controlling lighting
WO2013127177A1 (en) Cellphone image evaluation automation test frame and test method therefor
CN210899447U (en) 2D-3D image mixing and splicing device
WO2020118763A1 (en) Display panel driving method and device, and display device
WO2023095945A1 (en) Apparatus and method for generating synthetic data for model training
JP3774873B2 (en) Texture shading circuit

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: 11869982

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 11869982

Country of ref document: EP

Kind code of ref document: A1