CN108921916B - Method, device and equipment for coloring multi-target area in picture and storage medium - Google Patents
Method, device and equipment for coloring multi-target area in picture and storage medium Download PDFInfo
- Publication number
- CN108921916B CN108921916B CN201810717335.3A CN201810717335A CN108921916B CN 108921916 B CN108921916 B CN 108921916B CN 201810717335 A CN201810717335 A CN 201810717335A CN 108921916 B CN108921916 B CN 108921916B
- Authority
- CN
- China
- Prior art keywords
- picture
- colored
- coloring
- target
- target areas
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000004040 coloring Methods 0.000 title claims abstract description 77
- 238000000034 method Methods 0.000 title claims abstract description 57
- 238000013461 design Methods 0.000 claims abstract description 21
- 238000012545 processing Methods 0.000 claims abstract description 15
- 238000013527 convolutional neural network Methods 0.000 claims description 33
- 230000006870 function Effects 0.000 claims description 16
- 238000012549 training Methods 0.000 claims description 12
- 238000009499 grossing Methods 0.000 claims description 10
- 238000004590 computer program Methods 0.000 claims description 9
- 230000011218 segmentation Effects 0.000 claims description 4
- 230000007704 transition Effects 0.000 claims description 4
- 230000004927 fusion Effects 0.000 claims description 3
- 238000012417 linear regression Methods 0.000 claims description 3
- 238000013507 mapping Methods 0.000 claims description 3
- 239000003086 colorant Substances 0.000 abstract description 8
- 238000010586 diagram Methods 0.000 abstract description 2
- 230000008569 process Effects 0.000 description 6
- 238000012935 Averaging Methods 0.000 description 1
- 238000013528 artificial neural network Methods 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 238000009792 diffusion process Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000000605 extraction Methods 0.000 description 1
- 230000014509 gene expression Effects 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 239000011159 matrix material Substances 0.000 description 1
- 238000010606 normalization Methods 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T11/00—2D [Two Dimensional] image generation
- G06T11/40—Filling a planar surface by adding surface attributes, e.g. colour or texture
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/045—Combinations of networks
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/11—Region-based segmentation
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- General Physics & Mathematics (AREA)
- General Health & Medical Sciences (AREA)
- General Engineering & Computer Science (AREA)
- Biophysics (AREA)
- Computational Linguistics (AREA)
- Data Mining & Analysis (AREA)
- Evolutionary Computation (AREA)
- Artificial Intelligence (AREA)
- Molecular Biology (AREA)
- Computing Systems (AREA)
- Biomedical Technology (AREA)
- Life Sciences & Earth Sciences (AREA)
- Mathematical Physics (AREA)
- Software Systems (AREA)
- Health & Medical Sciences (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Processing Or Creating Images (AREA)
- Image Analysis (AREA)
Abstract
Description
技术领域technical field
本发明涉及图像处理领域,特别是涉及一种图片中多目标区域的上色方法、装置、设备及存储介质。The present invention relates to the field of image processing, in particular to a coloring method, device, device and storage medium for multi-target areas in a picture.
背景技术Background technique
在海报、宣传单等设计中,往往需要对一个画面的多个物体进行色彩的设计,而对一个物体进行色彩的设计并不是纯粹地进行纯色彩的更替,还必须考虑物体各个部件之间的颜色是否协调,若让设计师手动的设计物体的各个部件的颜色则需要花费大量的时间。In the design of posters, leaflets, etc., it is often necessary to design colors for multiple objects in a picture, and the color design of an object is not purely a pure color replacement, but also must consider the various parts of the object. Whether the colors are coordinated or not, it takes a lot of time for designers to manually design the colors of various parts of the object.
目前,已有对整张灰度图进行上色的技术,例如通过给定一张彩色图,该彩色图的颜色信息由全局直方图和饱和度定义,使用Lab色彩模型通过双线性差值将色彩调整为四分之一的分辨率在量化的ab空间中编码每个像素并且在空间上进行平均来计算彩色图的全局直方图,通过转换彩色图到HSV色彩空间,然后在空间上平均饱和度来计算饱和度,最后将计算出的全局直方图和饱和度融入到上色的网络中,网络将彩色图的颜色信息应用到整张灰度图上。这样的方法不能自由地决定图片中某一物体的颜色,对图片的色彩设计不够灵活。At present, there are technologies for coloring the entire grayscale image. For example, given a color image, the color information of the color image is defined by the global histogram and saturation, and the Lab color model is used to pass the bilinear difference value. Resize the color to quarter resolution Encode each pixel in quantized ab space and average spatially Calculate the global histogram of the colormap by converting the colormap to HSV color space and then spatially averaging Saturation is used to calculate saturation, and finally the calculated global histogram and saturation are integrated into the coloring network, which applies the color information of the color image to the entire grayscale image. Such a method cannot freely determine the color of an object in the picture, and is not flexible enough for the color design of the picture.
因此,如何实现对图片的多个目标进行不同颜色的设计,是本领域技术人员亟待解决的技术问题。Therefore, how to realize the design of different colors for multiple objects of a picture is a technical problem to be solved urgently by those skilled in the art.
发明内容SUMMARY OF THE INVENTION
有鉴于此,本发明的目的在于提供一种图片中多目标区域的上色方法、装置、设备及存储介质,可以利用多个已有的颜色协调的色彩标准图片对图片的多个目标进行不同颜色的设计。其具体方案如下:In view of this, the purpose of the present invention is to provide a coloring method, device, device and storage medium for a multi-target area in a picture, which can use a plurality of existing color-coordinated color standard pictures to color a plurality of targets in the picture. Color design. Its specific plan is as follows:
一种图片中多目标区域的上色方法,包括:A method for coloring multiple target areas in a picture, comprising:
对待上色图片进行灰度化处理,得到灰度图;Perform grayscale processing on the to-be-colored image to obtain a grayscale image;
选取对所述待上色图片进行不同颜色设计的多个色彩标准图;Selecting a plurality of color standard maps for carrying out different color designs on the picture to be colored;
通过选取的多个所述色彩标准图分别对所述灰度图进行上色;Coloring the grayscale image by selecting a plurality of the color standard images;
识别并分割出经上色后的多个目标区域;Identify and segment multiple colored target areas;
将分割后的多个目标区域融合到所述待上色图片相应的位置。The segmented target regions are fused to corresponding positions of the picture to be colored.
优选地,在本发明实施例提供的上述图片中多目标区域的上色方法中,通过选取的多个所述色彩标准图分别对所述灰度图进行上色,具体包括:Preferably, in the method for coloring the multi-target areas in the above picture provided by the embodiment of the present invention, the grayscale images are respectively colored by using a plurality of the selected color standard images, which specifically includes:
训练用于上色的卷积神经网络和用于获取色彩信息的目标网络;Train a convolutional neural network for coloring and a target network for obtaining color information;
把所述待上色图片和所述灰度图输入到所述卷积神经网络中训练;Inputting the picture to be colored and the grayscale image into the convolutional neural network for training;
将选取的多个所述色彩标准图输入到所述目标网络,获取所述色彩标准图的色彩信息并输入到所述卷积神经网络中训练;Inputting a plurality of the selected color standard maps into the target network, acquiring the color information of the color standard maps and inputting them into the convolutional neural network for training;
计算损失函数,直到所述卷积神经网络输出带所述色彩信息的多个色彩图。A loss function is calculated until the convolutional neural network outputs a plurality of colormaps with the color information.
优选地,在本发明实施例提供的上述图片中多目标区域的上色方法中,所述卷积神经网络包括十个卷积层;前三个所述卷积层用于下采样;后三个所述卷积层用于上采样;Preferably, in the method for coloring multiple target areas in the above picture provided by the embodiment of the present invention, the convolutional neural network includes ten convolutional layers; the first three convolutional layers are used for downsampling; the last three convolutional layers are used for downsampling; the convolutional layers are used for upsampling;
所述目标网络包括四个卷积层;所述目标网络的输出添加至所述卷积神经网络的第四个卷积层中。The target network includes four convolutional layers; the output of the target network is added to the fourth convolutional layer of the convolutional neural network.
优选地,在本发明实施例提供的上述图片中多目标区域的上色方法中,识别并分割出经上色后的多个目标区域,具体包括:Preferably, in the coloring method for multiple target areas in the above picture provided by the embodiment of the present invention, identifying and segmenting the colorized multiple target areas specifically includes:
通过Mask R-CNN网络识别和分割出经上色后的多个目标区域。The colored target regions are identified and segmented through the Mask R-CNN network.
优选地,在本发明实施例提供的上述图片中多目标区域的上色方法中,通过MaskR-CNN网络识别和分割出经上色后的多个目标区域,具体包括:Preferably, in the method for coloring multiple target areas in the above-mentioned pictures provided by the embodiment of the present invention, a MaskR-CNN network is used to identify and segment a plurality of target areas after coloring, which specifically includes:
利用ResNet-FPN网络从所述待上色图片提取出特征图;Extract the feature map from the picture to be colored by using the ResNet-FPN network;
利用RPN网络在所述特征图上生成候选边框,通过所述候选边框标出所述目标区域的具体位置;Use the RPN network to generate a candidate frame on the feature map, and mark the specific position of the target area through the candidate frame;
将所述候选边框输入到RoIAlign提取特征,获取与每个所述目标区域对应的掩码;The candidate frame is input into RoIAlign to extract features, and a mask corresponding to each of the target regions is obtained;
用softmax函数输出概率,得到多个例子类和1个背景类;Use the softmax function to output the probability to obtain multiple example classes and 1 background class;
对所述掩码和所述候选边框进行线性回归;perform linear regression on the mask and the candidate frame;
将上色后的所述灰度图输入到所述Mask R-CNN网络中训练,分割出经上色后的多个目标区域。The colored grayscale image is input into the Mask R-CNN network for training, and multiple colored target regions are segmented.
优选地,在本发明实施例提供的上述图片中多目标区域的上色方法中,利用RPN网络在所述特征图上生成候选边框,通过所述候选边框标出所述目标区域的具体位置,具体包括:Preferably, in the method for coloring multiple target areas in the above picture provided by the embodiment of the present invention, an RPN network is used to generate a candidate frame on the feature map, and the specific position of the target area is marked by the candidate frame, Specifically include:
将核在所述特征图上滑动;slide the kernel on the feature map;
将所述核的中心映射回所述待上色图片中,在中心处生成多种设定尺寸的候选边框,判断所述候选边框是否包括目标区域;Mapping the center of the core back to the picture to be colored, generating multiple candidate frames with a set size at the center, and judging whether the candidate frame includes the target area;
若是,则对所述候选边框进行精调,以使所述候选边框标出所述目标区域的具体位置。If so, fine-tune the candidate frame, so that the candidate frame marks the specific position of the target area.
优选地,在本发明实施例提供的上述图片中多目标区域的上色方法中,将分割后的多个目标区域融合到所述待上色图片相应的位置,具体包括:Preferably, in the method for coloring multiple target areas in the above picture provided by the embodiment of the present invention, the multiple target areas after segmentation are fused to the corresponding positions of the picture to be colored, which specifically includes:
通过平滑滤波器将分割后的多个目标区域融合到所述待上色图片相应的位置并使边缘过渡平滑。A smoothing filter is used to fuse the segmented target regions into the corresponding positions of the to-be-colored picture and smooth the edge transition.
本发明实施例还提供了一种图片中多目标区域的上色装置,包括:The embodiment of the present invention also provides a coloring device for multiple target areas in a picture, including:
灰度化处理模块,用于对待上色图片进行灰度化处理,得到灰度图;The grayscale processing module is used to perform grayscale processing on the to-be-colored image to obtain a grayscale image;
标准图选取模块,用于选取对所述待上色图片进行不同颜色设计的多个色彩标准图;A standard picture selection module, used for selecting a plurality of color standard pictures that carry out different color designs on the picture to be colored;
灰度图上色模块,用于通过选取的多个所述色彩标准图分别对所述灰度图进行上色;a grayscale image coloring module, configured to colorize the grayscale image respectively by selecting a plurality of the color standard images;
目标区域分割模块,用于识别并分割出经上色后的多个目标区域;The target area segmentation module is used to identify and segment multiple target areas after coloring;
目标区域融合模块,用于将分割后的多个目标区域融合到所述待上色图片相应的位置。The target area fusion module is used to fuse the segmented target areas into corresponding positions of the picture to be colored.
本发明实施例还提供了一种图片中多目标区域的上色设备,包括处理器和存储器,其中,所述处理器执行所述存储器中保存的计算机程序时实现如本发明实施例提供的上述图片中多目标区域的上色方法。An embodiment of the present invention further provides a coloring device for multiple target areas in a picture, including a processor and a memory, wherein the processor implements the above-mentioned as provided in the embodiment of the present invention when the processor executes the computer program stored in the memory Coloring method for multi-target areas in images.
本发明实施例还提供了一种计算机可读存储介质,用于存储计算机程序,其中,所述计算机程序被处理器执行时实现如本发明实施例提供的上述图片中多目标区域的上色方法。Embodiments of the present invention further provide a computer-readable storage medium for storing a computer program, wherein, when the computer program is executed by a processor, the method for coloring multi-target areas in the above picture as provided by the embodiments of the present invention is implemented .
本发明所提供的一种图片中多目标区域的上色方法、装置、设备及存储介质,该方法包括:对待上色图片进行灰度化处理,得到灰度图;选取对待上色图片进行不同颜色设计的多个色彩标准图;通过选取的多个色彩标准图分别对灰度图进行上色;识别并分割出经上色后的多个目标区域;将分割后的多个目标区域融合到待上色图片相应的位置。本发明利用多个已有的颜色协调的色彩标准图片对待上色图片中的多个目标区域进行上色,改变待上色图片中的多个目标区域的颜色信息,节省了大量的时间,还能让图片的色彩不过于单调,实现上色的多样性和灵活性,满足不同的设计需求。A coloring method, device, device and storage medium for multi-target areas in a picture provided by the present invention include: performing grayscale processing on the to-be-colored picture to obtain a grayscale image; selecting the to-be-colored picture for different Multiple color standard images for color design; color the grayscale image through the selected multiple color standard images; identify and segment multiple colored target areas; fuse the segmented multiple target areas into The corresponding position of the picture to be colored. The invention uses a plurality of existing color-coordinated color standard pictures to colorize a plurality of target areas in the picture to be colored, changes the color information of the plurality of target areas in the picture to be colored, saves a lot of time, and also It can make the color of the picture not too monotonous, realize the diversity and flexibility of coloring, and meet different design needs.
附图说明Description of drawings
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据提供的附图获得其他的附图。In order to explain the embodiments of the present invention or the technical solutions in the prior art more clearly, the following briefly introduces the accompanying drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only It is an embodiment of the present invention. For those of ordinary skill in the art, other drawings can also be obtained according to the provided drawings without creative work.
图1为本发明实施例提供的图片中多目标区域的上色方法的流程图;1 is a flowchart of a method for coloring multiple target areas in a picture according to an embodiment of the present invention;
图2为本发明实施例提供的图片中多目标区域的上色装置的结构示意图。FIG. 2 is a schematic structural diagram of an apparatus for coloring multiple target areas in a picture according to an embodiment of the present invention.
具体实施方式Detailed ways
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
本发明提供一种图片中多目标区域的上色方法,如图1所示,包括以下步骤:The present invention provides a method for coloring multi-target areas in a picture, as shown in Figure 1, comprising the following steps:
S101、对待上色图片进行灰度化处理,得到灰度图;S101. Perform grayscale processing on the to-be-colored image to obtain a grayscale image;
S102、选取对待上色图片进行不同颜色设计的多个色彩标准图;S102, selecting multiple color standard images for different color designs of the image to be colored;
S103、通过选取的多个色彩标准图分别对灰度图进行上色;S103, coloring the grayscale images respectively through the selected multiple color standard images;
S104、识别并分割出经上色后的多个目标区域;S104, identifying and segmenting the colored target areas;
S105、将分割后的多个目标区域融合到待上色图片相应的位置。S105 , fuse the divided multiple target regions into corresponding positions of the picture to be colored.
在本发明实施例提供的上述图片中多目标区域的上色方法中,首先对待上色图片进行灰度化处理(可利用OpenCV),得到灰度图;然后选择要对待上色图片的多个目标区域进行不同颜色设计的多个色彩标准图;将色彩标准图融合到灰度图中;之后对上色后的目标区域进行识别、分割;最后将分割出来的目标区域融合到原彩色图中。这样利用多个已有的颜色协调的色彩标准图片对待上色图片中的多个目标区域进行上色,改变待上色图片中的多个目标区域的颜色信息,节省了大量的时间,还能让图片的色彩不过于单调,实现上色的多样性和灵活性,满足不同的设计需求。In the coloring method for multiple target areas in the above-mentioned picture provided by the embodiment of the present invention, firstly, grayscale processing (OpenCV can be used) is performed on the picture to be colored to obtain a grayscale image; The target area is designed with multiple color standard maps in different colors; the color standard map is fused into the grayscale map; then the colored target area is identified and segmented; finally, the segmented target area is fused into the original color map . In this way, multiple existing color-coordinated color standard images are used to colorize multiple target areas in the image to be colored, and the color information of multiple target areas in the image to be colored can be changed, which saves a lot of time, and can also save a lot of time. Make the color of the picture not too monotonous, realize the variety and flexibility of coloring, and meet different design needs.
进一步地,在具体实施时,在本发明实施例提供的上述图片中多目标区域的上色方法中,步骤S103通过选取的多个色彩标准图分别对灰度图进行上色,具体可以包括以下步骤:Further, in the specific implementation, in the coloring method of the multi-target area in the above-mentioned picture provided by the embodiment of the present invention, step S103 colorizes the grayscale image by selecting a plurality of color standard images, which may specifically include the following: step:
步骤一、训练用于上色的卷积神经网络M和用于获取色彩信息的目标网络U;上述卷积神经网络M包括十个卷积层,前三个卷积层用于下采样,后三个卷积层用于上采样;上述目标网络U包括四个卷积层,目标网络U的输出添加至卷积神经网络M的第四个卷积层中;训练的这两个网络可以让待上色图片中各部分之间的色彩协调并且不改变图片的内容信息;Step 1: Train a convolutional neural network M for coloring and a target network U for acquiring color information; the above-mentioned convolutional neural network M includes ten convolutional layers, the first three convolutional layers are used for downsampling, and the latter are used for downsampling. Three convolutional layers are used for upsampling; the target network U above includes four convolutional layers, and the output of the target network U is added to the fourth convolutional layer of the convolutional neural network M; the two networks trained can make The color coordination between the parts of the picture to be colored does not change the content information of the picture;
步骤二、把待上色图片和灰度图输入到卷积神经网络M中训练;Step 2: Input the image to be colored and the grayscale image into the convolutional neural network M for training;
步骤三、将选取的多个色彩标准图输入到目标网络U,获取色彩标准图的色彩信息并输入到卷积神经网络M中训练;Step 3. Input the selected multiple color standard maps into the target network U, obtain the color information of the color standard maps and input them into the convolutional neural network M for training;
步骤四、计算损失函数L,直到卷积神经网络输出带色彩信息的多个色彩图(上色后的灰度图)。Step 4: Calculate the loss function L until the convolutional neural network outputs multiple color maps (colored grayscale images) with color information.
具体地,训练网络M去最小化以下目标函数,其中损失函数L表示网络的输出与真实值的距离,更新θ去最小化损失函数,X∈RH×W×1表示灰度图,Y∈RH×W×2表示待上色图片(即彩色图),C∈RH×W×2表示选取的色彩标准图,对于每一组D都包括了X、C和Y,E表示均值,H和W分别表示图片的高和宽,R表示实数域,这些映射都是由卷积神经网络M学习而来:Specifically, train the network M to minimize the following objective function, where the loss function L represents the distance between the output of the network and the true value, update θ to minimize the loss function, X∈R H×W×1 denotes the grayscale image, Y∈ R H×W×2 represents the picture to be colored (i.e. color image), C∈R H×W×2 represents the selected color standard image, for each group D includes X, C and Y, E represents the mean value, H and W represent the height and width of the image, respectively, and R represents the real number domain. These mappings are learned by the convolutional neural network M:
与上式相似,E表示均值,D表示X和Y的分布,最小化网络U的目标函数用于获取色彩:Similar to the above formula, E represents the mean, D represents the distribution of X and Y, and the objective function of minimizing the network U is used to obtain the color:
以上两个目标函数由Huber(smooth-l1)损失来定义,可以解决图片模糊的情况,提供了端到端的学习,即上述两个损失函数的一般表达式如下:The above two objective functions are defined by Huber(smooth-l 1 ) loss, which can solve the situation of blurred pictures and provide end-to-end learning, that is, the general expressions of the above two loss functions are as follows:
其中x和y为变量,将x=M(X,C;θ)或x=M(X,C;θU)和y=Y代入上式则可以得到网络M和U的目标函数。Where x and y are variables, the objective functions of networks M and U can be obtained by substituting x=M(X, C; θ) or x=M(X, C; θ U ) and y=Y into the above formula.
进一步地,在具体实施时,在本发明实施例提供的上述图片中多目标区域的上色方法中,步骤S104识别并分割出经上色后的多个目标区域,具体可以包括:通过Mask R-CNN(Regions with CNN features,边缘神经网络)识别和分割出经上色后的多个目标区域。Further, during specific implementation, in the method for coloring multiple target areas in the above-mentioned picture provided by the embodiment of the present invention, step S104 identifies and divides a plurality of target areas after coloring, which may specifically include: using Mask R -CNN (Regions with CNN features, edge neural network) to identify and segment multiple target regions after coloring.
需要说明的是,对于图片的分割方式可以有多种,本发明采用的是Mask R-CNN网络,该网络可以分为三个子网络,包括特征提取网络、候选边框生成网络及分类网络,这三个子网络之间共享特征图,能准确地识别并分类出上色后的目标区域。具体地,该网络分为class、box和mask三个损失,class表示目标的分类,box表示为目标添加边框,mask则将一个目标用同一像素表示。It should be noted that there are many ways to divide pictures. The present invention adopts the Mask R-CNN network, which can be divided into three sub-networks, including a feature extraction network, a candidate frame generation network and a classification network. The feature maps are shared among the sub-networks, which can accurately identify and classify the colored target regions. Specifically, the network is divided into three losses: class, box and mask. Class represents the classification of the target, box represents adding a frame to the target, and mask represents a target with the same pixel.
进一步地,在具体实施时,在本发明实施例提供的上述图片中多目标区域的上色方法中,通过Mask R-CNN网络识别和分割出经上色后的多个目标区域,具体可以包括以下步骤:Further, during specific implementation, in the coloring method for multiple target areas in the above-mentioned pictures provided by the embodiment of the present invention, the Mask R-CNN network is used to identify and segment a plurality of target areas after coloring, which may specifically include: The following steps:
第一步、利用ResNet-FPN网络从待上色图片提取出特征图(feature map);The first step is to use the ResNet-FPN network to extract the feature map from the image to be colored;
第二步、利用RPN网络(Region Proposal Network)在特征图上生成候选边框(Region of Interest,RoI),通过候选边框标出目标区域的具体位置;The second step is to use the RPN network (Region Proposal Network) to generate a candidate frame (Region of Interest, RoI) on the feature map, and mark the specific position of the target area through the candidate frame;
第三步、将候选边框输入到RoIAlign提取特征,获取与每个目标区域对应的掩码(mask);The third step is to input the candidate frame into RoIAlign to extract features, and obtain the mask corresponding to each target area;
第四步、用softmax函数输出概率,得到多个例子类和1个背景类;The fourth step, use the softmax function to output the probability to obtain multiple example classes and one background class;
第五步、对掩码和候选边框进行线性回归,使其更贴合目标;The fifth step is to perform linear regression on the mask and candidate frame to make it more suitable for the target;
第六步、将上色后的灰度图输入到Mask R-CNN网络中训练,分割出经上色后的多个目标区域。The sixth step is to input the colored grayscale image into the Mask R-CNN network for training, and segment the colored target regions.
进一步地,在具体实施时,在本发明实施例提供的上述图片中多目标区域的上色方法中,上述第二步中利用RPN网络在特征图上生成候选边框,通过候选边框标出目标区域的具体位置,具体可以包括以下步骤:将3×3核(kernel)在特征图上滑动;将核的中心映射回待上色图片中,在中心处生成多种设定尺寸(如9种尺寸,3种比例:1282,2562,5122;3种长宽比:1,0.5,2)的候选边框,判断候选边框是否包括目标区域;若是,则对候选边框进行精调,以使候选边框标出目标区域的具体位置。Further, in the specific implementation, in the method for coloring multiple target areas in the above-mentioned pictures provided by the embodiment of the present invention, in the above-mentioned second step, the RPN network is used to generate a candidate frame on the feature map, and the target area is marked by the candidate frame. The specific location of the image can include the following steps: slide the 3×3 kernel (kernel) on the feature map; map the center of the kernel back to the image to be colored, and generate a variety of set sizes (such as 9 sizes at the center) , 3 ratios: 128 2 , 256 2 , 512 2 ; 3 kinds of candidate frames with aspect ratios: 1, 0.5, 2), determine whether the candidate frame includes the target area; if so, fine-tune the candidate frame to make The candidate frame marks the specific location of the target area.
进一步地,在具体实施时,在本发明实施例提供的上述图片中多目标区域的上色方法中,步骤S105将分割后的多个目标区域融合到待上色图片相应的位置,具体可以包括:通过平滑滤波器将分割后的多个目标区域融合到待上色图片相应的位置并使边缘过渡平滑。Further, during specific implementation, in the method for coloring multiple target areas in the above-mentioned pictures provided by the embodiment of the present invention, step S105 fuses the divided multiple target areas into corresponding positions of the picture to be colored, which may specifically include: : Integrate the segmented target areas into the corresponding positions of the image to be colored through the smoothing filter and smooth the edge transition.
需要说明的是,使用平滑滤波器可以将分割出来的目标区域(前景图)平滑地融合到待上色图片(背景图)中,令前景图和背景图无缝衔接,具体包括以下步骤:It should be noted that, using a smoothing filter, the segmented target area (foreground image) can be smoothly merged into the image to be colored (background image), so that the foreground image and the background image are seamlessly connected, including the following steps:
提出边缘定向平滑滤波器a(u,v)对融合后的图像h进行滤波,b(u)表示滤波后的图像,表示如下:An edge-oriented smoothing filter a (u, v) is proposed to filter the fused image h, and b(u) represents the filtered image, which is expressed as follows:
其中,Ts表示原点在平滑滤波器中心空间位置集合,u=[ux,uy]T,v=[vx,vy]T是以向量形式表示的空间位置。Among them, T s represents the set of the origin in the center space of the smoothing filter, and u=[u x , u y ] T , v=[v x , v y ] T is the spatial position represented in the form of a vector.
滤波器a(u,v)表示如下:The filter a (u,v) is represented as follows:
其中,γ是一个满足条件∑a=0的归一化参数,σ是一个扩散参数,g(u)和θ(u)分别是在空间位置u处的边缘强度和边缘方向,E(g(u))是单调增函数,满足E(0)≥1,此处E(g(u))=β(g(u))+1,β>0是边缘强度参数,矩阵G(u)使得沿边缘方向权重值大于垂直边缘方向权重值。where γ is a normalization parameter satisfying the condition ∑a=0, σ is a diffusion parameter, g(u) and θ(u) are the edge strength and edge direction at the spatial position u, respectively, E(g( u)) is a monotonically increasing function, satisfying E(0)≥1, where E(g(u))=β(g(u))+1, β>0 is the edge strength parameter, and the matrix G (u) makes The weight value along the edge direction is greater than the vertical edge direction weight value.
在求取边缘定向平滑滤波器系数时,首先计算图像某一空间位置处的边缘强度和边缘方向,这两个参数可以通过Sobel算子得到。h`x,h`y是Sobel算子在水平和垂直方向处理图像h后的结果。边缘方向θ和边缘强度g表示如下:When calculating the coefficients of the edge-oriented smoothing filter, firstly calculate the edge intensity and edge direction at a certain spatial position of the image, these two parameters can be obtained by the Sobel operator. h` x , h` y are the result of Sobel operator processing the image h in the horizontal and vertical directions. The edge direction θ and edge strength g are expressed as follows:
将上式代入上述公式即可得平滑滤波器系数。The smoothing filter coefficients can be obtained by substituting the above formula into the above formula.
本发明将分割后的多个目标区域和待上色图片融合时应用平滑滤波器将两者的衔接更和谐,该平滑滤波器可以分为两部分,一部分用于寻找经上色后的目标区域在待上色图片中相对应的位置,另一部分使两者之间平滑过渡。In the present invention, a smoothing filter is applied when merging the divided target areas and the picture to be colored to make the connection between the two more harmonious. The smoothing filter can be divided into two parts, and one part is used to find the colorized target area. In the corresponding position in the picture to be colored, the other part makes a smooth transition between the two.
基于同一发明构思,本发明实施例还提供了一种图片中多目标区域的上色装置,由于该图片中多目标区域的上色装置解决问题的原理与前述一种图片中多目标区域的上色方法相似,因此该图片中多目标区域的上色装置的实施可以参见图片中多目标区域的上色方法的实施,重复之处不再赘述。Based on the same inventive concept, the embodiment of the present invention also provides a coloring device for multi-target areas in a picture, because the principle of solving the problem of the coloring device for multi-target areas in the picture is the same as that of the above-mentioned one for the multi-target areas in the picture. The coloring methods are similar, so the implementation of the coloring device for the multi-target areas in the picture can refer to the implementation of the coloring method for the multi-target areas in the picture, and the repetition will not be repeated.
在具体实施时,本发明实施例提供的图片中多目标区域的上色装置,如图2所示,具体包括:During specific implementation, the coloring device for multi-target areas in a picture provided by the embodiment of the present invention, as shown in FIG. 2 , specifically includes:
灰度化处理模块11,用于对待上色图片进行灰度化处理,得到灰度图;The
标准图选取模块12,用于选取对待上色图片进行不同颜色设计的多个色彩标准图;The standard
灰度图上色模块13,用于通过选取的多个色彩标准图分别对灰度图进行上色;The grayscale
目标区域分割模块14,用于识别并分割出经上色后的多个目标区域;The target
目标区域融合模块15,用于将分割后的多个目标区域融合到待上色图片相应的位置。The target
在本发明实施例提供的上述图片中多目标区域的上色装置中,可以通过上述四个模块的相互作用,利用多个已有的颜色协调的色彩标准图片对待上色图片中的多个目标区域进行上色,节省了大量的时间,还能让图片的色彩不过于单调,实现上色的多样性和灵活性,满足不同的设计需求。In the coloring device of the multi-target area in the above-mentioned picture provided by the embodiment of the present invention, through the interaction of the above-mentioned four modules, a plurality of existing color-coordinated color standard pictures can be used to treat a plurality of targets in the colored picture Coloring the area saves a lot of time, and also makes the color of the picture not too monotonous, realizes the diversity and flexibility of coloring, and meets different design needs.
关于上述各个模块更加具体的工作过程可以参考前述实施例公开的相应内容,在此不再进行赘述。For more specific working processes of the above-mentioned modules, reference may be made to the corresponding contents disclosed in the foregoing embodiments, which will not be repeated here.
相应的,本发明实施例还公开了一种图片中多目标区域的上色设备,包括处理器和存储器;其中,处理器执行存储器中保存的计算机程序时实现前述实施例公开的图片中多目标区域的上色方法。Correspondingly, the embodiment of the present invention also discloses a coloring device for multi-target areas in a picture, including a processor and a memory; wherein, when the processor executes the computer program stored in the memory, the multi-target in the picture disclosed in the foregoing embodiments is realized. The coloring method of the area.
关于上述方法更加具体的过程可以参考前述实施例中公开的相应内容,在此不再进行赘述。For a more specific process of the above method, reference may be made to the corresponding content disclosed in the foregoing embodiments, which will not be repeated here.
进一步的,本发明还公开了一种计算机可读存储介质,用于存储计算机程序;计算机程序被处理器执行时实现前述公开的图片中多目标区域的上色方法。Further, the present invention also discloses a computer-readable storage medium for storing a computer program; when the computer program is executed by a processor, the aforementioned method for coloring multiple target areas in a picture is implemented.
关于上述方法更加具体的过程可以参考前述实施例中公开的相应内容,在此不再进行赘述。For a more specific process of the above method, reference may be made to the corresponding content disclosed in the foregoing embodiments, which will not be repeated here.
本说明书中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其它实施例的不同之处,各个实施例之间相同或相似部分互相参见即可。对于实施例公开的装置、设备、存储介质而言,由于其与实施例公开的方法相对应,所以描述的比较简单,相关之处参见方法部分说明即可。The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments may be referred to each other. For the apparatuses, devices, and storage media disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple, and reference may be made to the descriptions of the methods for related parts.
专业人员还可以进一步意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Professionals may further realize that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two, in order to clearly illustrate the possibilities of hardware and software. Interchangeability, the above description has generally described the components and steps of each example in terms of functionality. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Skilled artisans may implement the described functionality using different methods for each particular application, but such implementations should not be considered beyond the scope of this application.
结合本文中所公开的实施例描述的方法或算法的步骤可以直接用硬件、处理器执行的软件模块,或者二者的结合来实施。软件模块可以置于随机存储器(RAM)、内存、只读存储器(ROM)、电可编程ROM、电可擦除可编程ROM、寄存器、硬盘、可移动磁盘、CD-ROM、或技术领域内所公知的任意其它形式的存储介质中。The steps of a method or algorithm described in conjunction with the embodiments disclosed herein may be directly implemented in hardware, a software module executed by a processor, or a combination of the two. A software module can be placed in random access memory (RAM), internal memory, read only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other in the technical field. in any other known form of storage medium.
本发明实施例提供的一种图片中多目标区域的上色方法、装置、设备及存储介质,该方法包括:对待上色图片进行灰度化处理,得到灰度图;选取对待上色图片进行不同颜色设计的多个色彩标准图;通过选取的多个色彩标准图分别对灰度图进行上色;识别并分割出经上色后的多个目标区域;将分割后的多个目标区域融合到待上色图片相应的位置。本发明利用多个已有的颜色协调的色彩标准图片对待上色图片中的多个目标区域进行上色,改变待上色图片中的多个目标区域的颜色信息,节省了大量的时间,还能让图片的色彩不过于单调,实现上色的多样性和灵活性,满足不同的设计需求。An embodiment of the present invention provides a coloring method, device, device, and storage medium for multiple target areas in a picture. The method includes: performing grayscale processing on a to-be-colored picture to obtain a grayscale image; Multiple color standard images designed with different colors; color the grayscale image through the selected multiple color standard images; identify and segment multiple colored target areas; fuse the segmented multiple target areas Go to the corresponding position of the picture to be colored. The invention uses a plurality of existing color-coordinated color standard pictures to colorize a plurality of target areas in the picture to be colored, changes the color information of the plurality of target areas in the picture to be colored, saves a lot of time, and also It can make the color of the picture not too monotonous, realize the diversity and flexibility of coloring, and meet different design needs.
最后,还需要说明的是,在本文中,关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。Finally, it should also be noted that in this document, relational terms are only used to distinguish one entity or operation from another, and do not necessarily require or imply any such actual existence between these entities or operations. relationship or order. Moreover, the terms "comprising", "comprising" or any other variation thereof are intended to encompass a non-exclusive inclusion such that a process, method, article or device that includes a list of elements includes not only those elements, but also includes not explicitly listed or other elements inherent to such a process, method, article or apparatus. Without further limitation, an element qualified by the phrase "comprising a..." does not preclude the presence of additional identical elements in a process, method, article or apparatus that includes the element.
以上对本发明所提供的图片中多目标区域的上色方法、装置、设备及存储介质进行了详细介绍,本文中应用了具体个例对本发明的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本发明的方法及其核心思想;同时,对于本领域的一般技术人员,依据本发明的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本发明的限制。The method, device, device and storage medium for coloring multi-target areas in pictures provided by the present invention have been described in detail above. Specific examples are used in this paper to illustrate the principles and implementations of the present invention. It is only used to help understand the method of the present invention and its core idea; at the same time, for those of ordinary skill in the art, according to the idea of the present invention, there will be changes in the specific embodiments and application scope. In summary, The contents of this specification should not be construed as limiting the present invention.
Claims (9)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810717335.3A CN108921916B (en) | 2018-07-03 | 2018-07-03 | Method, device and equipment for coloring multi-target area in picture and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810717335.3A CN108921916B (en) | 2018-07-03 | 2018-07-03 | Method, device and equipment for coloring multi-target area in picture and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN108921916A CN108921916A (en) | 2018-11-30 |
CN108921916B true CN108921916B (en) | 2022-09-16 |
Family
ID=64423458
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810717335.3A Active CN108921916B (en) | 2018-07-03 | 2018-07-03 | Method, device and equipment for coloring multi-target area in picture and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108921916B (en) |
Families Citing this family (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109635740B (en) * | 2018-12-13 | 2020-07-03 | 深圳美图创新科技有限公司 | Video target detection method and device and image processing equipment |
CN109753931A (en) * | 2019-01-04 | 2019-05-14 | 广州广电卓识智能科技有限公司 | Convolutional neural networks training method, system and facial feature points detection method |
CN109816669A (en) * | 2019-01-30 | 2019-05-28 | 云南电网有限责任公司电力科学研究院 | An Improved Mask R-CNN Image Instance Segmentation Method for Identifying Defects in Power Equipment |
CN110147778B (en) * | 2019-05-27 | 2022-09-30 | 江西理工大学 | Rare earth ore mining identification method, device, equipment and storage medium |
CN110458921B (en) * | 2019-08-05 | 2021-08-03 | 腾讯科技(深圳)有限公司 | Image processing method, device, terminal and storage medium |
CN110852176A (en) * | 2019-10-17 | 2020-02-28 | 陕西师范大学 | High-resolution three-number SAR image road detection method based on Mask-RCNN |
CN111127483B (en) * | 2019-12-24 | 2023-09-15 | 新方正控股发展有限责任公司 | Color picture processing method, device, equipment, storage medium and system |
CN113570678A (en) | 2021-01-20 | 2021-10-29 | 腾讯科技(深圳)有限公司 | Image coloring method and device based on artificial intelligence and electronic equipment |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101706965A (en) * | 2009-11-03 | 2010-05-12 | 上海大学 | Method for colorizing regional image on basis of Gaussian mixture model |
CN101872473A (en) * | 2010-06-25 | 2010-10-27 | 清华大学 | Multi-scale image natural color fusion method and device based on over-segmentation and optimization |
EP3038057A1 (en) * | 2014-12-22 | 2016-06-29 | Thomson Licensing | Methods and systems for color processing of digital images |
CN107330956A (en) * | 2017-07-03 | 2017-11-07 | 广东工业大学 | A kind of unsupervised painting methods of caricature manual draw and device |
CN107862664A (en) * | 2017-11-15 | 2018-03-30 | 广东交通职业技术学院 | A kind of image non-photorealistic rendering method and system |
-
2018
- 2018-07-03 CN CN201810717335.3A patent/CN108921916B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101706965A (en) * | 2009-11-03 | 2010-05-12 | 上海大学 | Method for colorizing regional image on basis of Gaussian mixture model |
CN101872473A (en) * | 2010-06-25 | 2010-10-27 | 清华大学 | Multi-scale image natural color fusion method and device based on over-segmentation and optimization |
EP3038057A1 (en) * | 2014-12-22 | 2016-06-29 | Thomson Licensing | Methods and systems for color processing of digital images |
CN107330956A (en) * | 2017-07-03 | 2017-11-07 | 广东工业大学 | A kind of unsupervised painting methods of caricature manual draw and device |
CN107862664A (en) * | 2017-11-15 | 2018-03-30 | 广东交通职业技术学院 | A kind of image non-photorealistic rendering method and system |
Non-Patent Citations (6)
Title |
---|
Mask R-CNN;Kaiming He 等;《2017 IEEE International Conference on Computer Vision》;20171225;第2980-2988页 * |
一种利用回归神经网络黑白图像着色算法研究;余梓唐;《计算机应用研究》;20120430;第29卷(第4期);第1595-1597页 * |
基于卷积神经网络的多波段融合图像彩色化方法;韩泽等;《测试技术学报》;20180630(第03期);第201-206页 * |
基于图像分割和色彩扩展的灰度图像彩色化方法;朱黎博等;《微型电脑应用》;20090520(第05期);第4-6页 * |
基于融合图像特征库的夜视图像彩色化研究;何永强等;《激光与红外》;20121220(第12期);第1393-1397页 * |
基于视觉感知的图像处理方法研究;向遥;《中国优秀博硕士学位论文全文数据库(博士)信息科技辑》;20111215;第33-43页 * |
Also Published As
Publication number | Publication date |
---|---|
CN108921916A (en) | 2018-11-30 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108921916B (en) | Method, device and equipment for coloring multi-target area in picture and storage medium | |
JP7564962B2 (en) | IMAGE PROCESSING METHOD, IMAGE PROCESSING APPARATUS AND NON-TRANSITORY STORAGE MEDIUM | |
Liu et al. | Robust color guided depth map restoration | |
CN107844750A (en) | A kind of water surface panoramic picture target detection recognition methods | |
CN110427932B (en) | Method and device for identifying multiple bill areas in image | |
US20200133182A1 (en) | Defect classification in an image or printed output | |
CN107507217B (en) | Method and device for making certificate photo and storage medium | |
CN107452010A (en) | A kind of automatically stingy nomography and device | |
CN108961349A (en) | A kind of generation method, device, equipment and the storage medium of stylization image | |
CN107704857A (en) | A kind of lightweight licence plate recognition method and device end to end | |
CN107220949A (en) | The self adaptive elimination method of moving vehicle shade in highway monitoring video | |
CN103914699A (en) | Automatic lip gloss image enhancement method based on color space | |
CN111275139A (en) | Handwritten content removal method, handwritten content removal device, and storage medium | |
CN113744142B (en) | Image restoration method, electronic device and storage medium | |
CN111310746B (en) | Text line detection method, model training method, device, server and medium | |
JP2009230233A (en) | Stripe pattern detection system, stripe pattern detection method, and program for stripe pattern detection | |
CN113592776A (en) | Image processing method and device, electronic device and storage medium | |
Bach et al. | Controlling explanatory heatmap resolution and semantics via decomposition depth | |
CN107564009A (en) | Outdoor scene Segmentation of Multi-target method based on depth convolutional neural networks | |
CN110782424A (en) | Image fusion method and device, electronic equipment and computer readable storage medium | |
CN110443252A (en) | A kind of character detecting method, device and equipment | |
CN116342519A (en) | Image processing method based on machine learning | |
CN110211190B (en) | Method and device for training camera self-motion parameter estimation model and storage medium | |
CN115631210A (en) | Edge detection method and device | |
CN102074025B (en) | Image stylized drawing method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |