CN114419006A - A method and system for removing text watermark from grayscale video that changes with background - Google Patents

A method and system for removing text watermark from grayscale video that changes with background Download PDF

Info

Publication number
CN114419006A
CN114419006A CN202210073703.1A CN202210073703A CN114419006A CN 114419006 A CN114419006 A CN 114419006A CN 202210073703 A CN202210073703 A CN 202210073703A CN 114419006 A CN114419006 A CN 114419006A
Authority
CN
China
Prior art keywords
watermark
area
background
image
grayscale
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.)
Granted
Application number
CN202210073703.1A
Other languages
Chinese (zh)
Other versions
CN114419006B (en
Inventor
黄凯
李君惠
姜山
何聪
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sichuan Jiuzhou ATC Technology Co Ltd
Original Assignee
Sichuan Jiuzhou ATC Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Sichuan Jiuzhou ATC Technology Co Ltd filed Critical Sichuan Jiuzhou ATC Technology Co Ltd
Priority to CN202210073703.1A priority Critical patent/CN114419006B/en
Publication of CN114419006A publication Critical patent/CN114419006A/en
Application granted granted Critical
Publication of CN114419006B publication Critical patent/CN114419006B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/50Image enhancement or restoration using two or more images, e.g. averaging or subtraction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/70Denoising; Smoothing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/194Segmentation; Edge detection involving foreground-background segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10016Video; Image sequence
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20212Image combination
    • G06T2207/20221Image fusion; Image merging

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Quality & Reliability (AREA)
  • Image Processing (AREA)
  • Editing Of Facsimile Originals (AREA)

Abstract

本发明公开了一种随背景变化的灰度视频文字类水印去除方法及系统,包括获取待处理灰度视频,对待处理灰度视频中的原始图像进行预处理,得到初步定位的水印区域;根据所述初步定位的水印区域,采用两路水印检测处理法对所述初步定位的水印区域进行水印检测处理,得到两路中间结果;对所述两路中间结果进行运算,生成水印模板,得到背景区域和精确定位的水印区域;使用所述背景区域对所述精确定位的水印区域进行填充,得到水印去除后的图像。本发明解决随背景变化的灰度视频文字类水印去除问题,针对灰度成像的视频实时去除特定位置的水印,并克服水印会根据图像的明暗变化而发生的变化。本发明可为人工智能领域数据标记和训练提供干净的数据。

Figure 202210073703

The invention discloses a method and a system for removing grayscale video text watermarks that change with background, including acquiring grayscale video to be processed, preprocessing original images in the grayscale video to be processed, and obtaining a watermark area for preliminary positioning; The watermark area of the preliminary location is subjected to watermark detection processing on the watermark area of the preliminary location by using a two-way watermark detection processing method, and two intermediate results are obtained; the intermediate results of the two channels are calculated to generate a watermark template, and a background is obtained. region and precisely positioned watermark region; using the background region to fill the precisely positioned watermark region to obtain an image after watermark removal. The invention solves the problem of removing grayscale video text watermarks that change with the background, removes the watermarks at specific positions in real time for grayscale imaging videos, and overcomes the changes of the watermarks that occur according to the light and dark changes of the images. The present invention can provide clean data for data labeling and training in the field of artificial intelligence.

Figure 202210073703

Description

一种随背景变化的灰度视频文字类水印去除方法及系统A method and system for removing text-like watermark from grayscale video that changes with background

技术领域technical field

本发明涉及水印去除技术领域,具体涉及一种随背景变化的灰度视频文字类水印去除方法及系统。The invention relates to the technical field of watermark removal, in particular to a method and system for removing grayscale video text watermarks that change with background.

背景技术Background technique

在视频图像应用领域经常会使用灰度成像,各种灰度成像的视频带有视频注释、日期、时间等水印,这类水印在此统称为文字类水印。这些水印有几个主要的特点:第一水印是变化的,比如时间会变化;第二水印的明暗是变化的,比如背景呈深色,水印呈浅色;背景呈浅色,水印呈深色;第三水印具有细长的线条,水印和背景相互交融;第四水印自身灰度值保持一致。In the field of video image applications, grayscale imaging is often used, and various grayscale images have watermarks such as video annotations, dates, and times. Such watermarks are collectively referred to as text watermarks herein. These watermarks have several main characteristics: the first watermark is changing, such as time changes; the second watermark is light and dark, such as the background is dark, the watermark is light; the background is light, the watermark is dark ; The third watermark has slender lines, and the watermark and the background blend with each other; the gray value of the fourth watermark itself remains the same.

近年来利用人工智能算法处理视频和图像越来越普遍,比如目标检测、目标分类等。人工智能算法尤其是最近几年流行的有监督深度学习算法是基于大量数据进行工作的。首先搭建神经网络,然后将标注好的训练集数据输入网络进行训练得到训练好的模型,最后使用训练好的模型进行实时工作。In recent years, it has become more and more common to use artificial intelligence algorithms to process videos and images, such as object detection and object classification. Artificial intelligence algorithms, especially the supervised deep learning algorithms that have become popular in recent years, work based on large amounts of data. First build a neural network, then input the labeled training set data into the network for training to obtain a trained model, and finally use the trained model for real-time work.

数据获取对深度学习来说是很重要但是也是一件不容易的事情,特别是一些专业和小众的领域,在互联网很难找到相关的数据资源。将一些现有的视频和图像收集起来加以利用,比如用来进行模型训练是非常明智和有效的方式。但是很多时候我们获得的图像或者视频都有水印,这些水印对训练集的标注和后期的训练形成干扰,降低了项目推进的效率。Data acquisition is very important for deep learning, but it is not easy, especially in some professional and niche fields, it is difficult to find relevant data resources on the Internet. It is a very sensible and effective way to collect some existing videos and images and use them, for example, for model training. However, many times the images or videos we obtain have watermarks. These watermarks interfere with the labeling of the training set and later training, reducing the efficiency of project advancement.

现有的去水印技术可以分为两大类,一类是基于机器学习的算法,另一类是传统的算法。基于机器学习的算法大多要用到训练数据。现有的传统的去水印算法大多是基于静态的图像,需要手动去标识水印,或者使用较复杂的算法检测水印再用水印附近的区域去填充水印区域。模板匹配检测水印是针对水印样式固定不变的情况,水印样式是变化的时候无法使用传统的模板匹配是检测水印。还有一种去水印方法比较直接,直接将水印部分进行覆盖添加新的水印,或者将水印部分进行模糊处理,这种方法对背景技术种提到的模型训练没有帮助。本文种提到的文字类水印是跟背景相互交融,也就是说文字的镂空部分是背景,不能单纯的将水印连带镂空背景一起抹去,这样会使得去水印之后的图像看起来非常突兀。Existing watermarking techniques can be divided into two categories, one is based on machine learning algorithms, and the other is traditional algorithms. Most machine learning-based algorithms use training data. Most of the existing traditional watermark removal algorithms are based on static images, and need to manually identify the watermark, or use a more complex algorithm to detect the watermark and then fill the watermark area with the area near the watermark. The template matching detection watermark is aimed at the situation that the watermark style is fixed and unchanged. When the watermark style is changed, the traditional template matching can not be used to detect the watermark. Another method for removing watermarks is relatively straightforward, directly covering the watermark part to add a new watermark, or blurring the watermark part, which is not helpful for the model training mentioned in the background art. The text watermark mentioned in this article is blended with the background, that is to say, the hollow part of the text is the background. You cannot simply erase the watermark together with the hollow background, which will make the image after removing the watermark look very abrupt.

然后,以上现有的水印去除技术并不适应于随背景变化的灰度视频文字类水印去除,无法解决针对灰度成像的视频实时去除特定位置的水印;且很难快速对视频或者图像进行快速批量处理。Then, the above existing watermark removal technologies are not suitable for the removal of text watermarks in grayscale videos that change with the background, and cannot solve the problem of removing watermarks at specific locations in real time for grayscale imaging videos; and it is difficult to quickly remove video or images. Batch processing.

发明内容SUMMARY OF THE INVENTION

本发明所要解决的技术问题是现有的水印去除技术并不适应于随背景变化的灰度视频文字类水印去除,无法解决针对灰度成像的视频实时去除特定位置的水印。本发明目的在于提供一种随背景变化的灰度视频文字类水印去除方法及系统,通过该方法解决随背景变化的灰度视频文字类水印去除问题,针对灰度成像的视频实时去除特定位置的水印,并克服水印会根据图像的明暗变化而发生的变化;另外,可以批量获得除去水印的干净数据。The technical problem to be solved by the present invention is that the existing watermark removal technology is not suitable for the grayscale video text watermark removal that changes with the background, and cannot solve the problem of real-time removal of watermarks in specific positions for grayscale imaging videos. The object of the present invention is to provide a method and system for removing grayscale video text watermarks that change with the background, through which the problem of removing grayscale video text watermarks that change with the background can be solved, and the grayscale imaging video can be removed in real time at a specific location. Watermark, and overcome the change of watermark according to the light and dark of the image; In addition, clean data with watermark removed can be obtained in batches.

本发明通过下述技术方案实现:The present invention is achieved through the following technical solutions:

第一方面,本发明提供了一种随背景变化的灰度视频文字类水印去除方法,该方法包括:In a first aspect, the present invention provides a method for removing a grayscale video text watermark that changes with the background, the method comprising:

获取待处理灰度视频,对待处理灰度视频中的原始图像进行预处理,得到初步定位的水印区域;Obtain the grayscale video to be processed, and preprocess the original image in the grayscale video to be processed to obtain the watermark area for preliminary positioning;

根据所述初步定位的水印区域,采用两路水印检测处理法对所述初步定位的水印区域进行水印检测处理(即精确定位),得到两路中间结果;对所述两路中间结果进行运算(求交集),生成水印模板,提取所述水印模板中相同像素值个数最多的像素作为精确定位的水印区域,同时得到背景区域;其中,精确定位的水印区域以外的区域即是背景区域;According to the preliminarily positioned watermark area, a two-way watermark detection processing method is used to perform watermark detection processing on the preliminarily positioned watermark area (that is, precise positioning) to obtain two-way intermediate results; Seek the intersection), generate a watermark template, extract the pixel with the largest number of identical pixel values in the watermark template as a watermark area for precise positioning, and obtain a background area simultaneously; wherein, the area other than the precisely positioned watermark area is the background area;

使用所述背景区域对所述精确定位的水印区域进行填充,得到水印去除后的图像。The precisely positioned watermark area is filled with the background area to obtain an image after watermark removal.

工作原理是:现有的传统水印去除技术并不适应于随背景变化的灰度视频文字类水印去除,无法解决针对灰度成像的视频实时去除特定位置的水印;而基于机器学习的算法大多要用到训练数据。因此,本发明设计了一种随背景变化的灰度视频文字类水印去除方法,包括首先,获取待处理水印图像,并对所述待处理水印图像进行预处理,得到初步定位的水印区域;其中图像预处理,包含水印区域初步定位以及噪声滤除;水印区域初步定位主要作用是减少计算量,其次可以减少背景对阈值分割的干扰;噪声滤除是为了减少对边缘检测的干扰。其次,在初步定位的水印区域内对水印进行精确定位,生成水印模板;然后,根据水印模板对水印区域进行填充,去除水印;最后,进行图像后处理,改善水印去除后水印区域边界处出现的割裂感。The working principle is: the existing traditional watermark removal technology is not suitable for the removal of grayscale video text watermarks that change with the background, and cannot solve the problem of real-time removal of watermarks in specific locations for grayscale imaging videos; and most algorithms based on machine learning require Use training data. Therefore, the present invention designs a grayscale video text watermark removal method that changes with the background, including: first, acquiring a watermark image to be processed, and preprocessing the watermark image to be processed to obtain a preliminary positioned watermark area; wherein Image preprocessing includes preliminary positioning of the watermark area and noise filtering; the primary function of the preliminary positioning of the watermark area is to reduce the amount of calculation, and secondly, it can reduce the interference of the background to the threshold segmentation; the noise filtering is to reduce the interference to the edge detection. Secondly, the watermark is precisely positioned in the preliminary positioned watermark area, and a watermark template is generated; then, the watermark area is filled according to the watermark template to remove the watermark; finally, the image post-processing is performed to improve the watermark appearing at the boundary of the watermark area after the watermark is removed. Fragmentation.

本发明流程合理,解决随背景变化的灰度视频文字类水印去除问题,针对灰度成像的视频实时去除特定位置的水印,并克服水印会根据图像的明暗变化而发生的变化;另外,可以批量获得除去水印的干净数据。The method of the invention has a reasonable process, solves the problem of removing the grayscale video text watermark that changes with the background, removes the watermark in a specific position in real time for the grayscale imaging video, and overcomes the change of the watermark according to the light and dark changes of the image; in addition, it can be batched Get clean data with watermark removed.

进一步地,所述的对所述待处理水印图像进行预处理包括水印区域初步定位和噪声滤除处理。Further, the preprocessing of the watermark image to be processed includes preliminary positioning of the watermark area and noise filtering.

进一步地,所述水印区域初步定位是对水印进行初步定位,前提是水印的位置不发生变化。特定位置的水印只需要基于水印的中心画一个矩形框即可,矩形框的长边要超过水印整体的长度,短边是水印宽度的3倍,确保背景在初定位中的占比高于水印,同时也尽可能地减小运算量。Further, the preliminary positioning of the watermark area is to perform preliminary positioning of the watermark, provided that the position of the watermark does not change. The watermark in a specific position only needs to draw a rectangular frame based on the center of the watermark. The long side of the rectangular frame should exceed the overall length of the watermark, and the short side should be 3 times the width of the watermark, so as to ensure that the proportion of the background in the initial positioning is higher than that of the watermark. , and at the same time reduce the amount of computation as much as possible.

进一步地,所述的采用两路水印检测处理法对所述初步定位的水印区域进行水印检测处理,具体包括:Further, the two-way watermark detection processing method is used to perform watermark detection processing on the preliminary positioned watermark area, which specifically includes:

第一路水印检测处理:对所述初步定位的水印区域采用sobel边缘检测法分别对水平和垂直方向进行边缘检测,得到水平边缘和垂直边缘;并将水平边缘和垂直边缘叠加,得到叠加后的边缘图像;对叠加后的边缘图像进行自适应阈值分割,得到第一二值图像;对得到的第一二值图像进行形态学膨胀得到膨胀结果,对膨胀的结果与第二路中间结果做运算,得到第一路中间结果,即第一路水印模板;The first watermark detection processing: the sobel edge detection method is used to detect the edges in the horizontal and vertical directions respectively for the watermark area of the preliminary positioning, so as to obtain the horizontal edge and the vertical edge; and superimpose the horizontal edge and the vertical edge to obtain the superimposed edge. edge image; perform adaptive threshold segmentation on the superimposed edge image to obtain the first binary image; perform morphological expansion on the obtained first binary image to obtain the expansion result, and perform an operation on the expansion result and the second intermediate result , get the first intermediate result, that is, the first watermark template;

第二路水印检测处理:检测所述初步定位的水印区域的水印灰度值,以所述水印灰度值作为阈值,进行阈值分割,得到第二二值图像;并对得到的第二二值图像进行形态学膨胀,得到第二路中间结果,即第二路水印模板。The second watermark detection process: detecting the grayscale value of the watermark in the initially positioned watermark area, and using the grayscale value of the watermark as a threshold to perform threshold segmentation to obtain a second binary image; The image is morphologically expanded to obtain the second intermediate result, that is, the second watermark template.

以上采用两路水印检测处理法是基于如下设计考虑:第一路水印检测处理是根据边缘求解水印区域,这是考虑到水印与背景差异明显,水印的边缘很容易找到,所以先根据边缘用第一路水印检测处理求得水印区域,但是这个过程中背景可能会对水印存在一定的干扰,所以接下来结合了第二路水印检测处理;第二路水印检测处理是根据水印灰度值找水印区域,这是基于水印灰度值是一直的,但是背景区域个别灰度值会被误认为是水印,这样单独基于水印灰度值利用第二路水印检测处理效果也不是那么好。因此,本发明考虑结合边缘求解和水印灰度值求解两种检测方式,来增加检测水印置信度,使检测出的水印区域更加精准。The above two-way watermark detection processing method is based on the following design considerations: the first watermark detection processing is to solve the watermark area according to the edge. This is considering that the watermark is obviously different from the background, and the edge of the watermark is easy to find. Therefore, first use the first method according to the edge. One watermark detection process obtains the watermark area, but the background may interfere with the watermark in this process, so the second watermark detection process is combined next; the second watermark detection process is to find the watermark according to the grayscale value of the watermark This is based on the same gray value of the watermark, but the individual gray values of the background area will be mistaken for a watermark, so the second watermark detection processing effect based on the gray value of the watermark alone is not so good. Therefore, the present invention considers two detection methods combining edge solution and watermark gray value solution to increase the watermark detection confidence and make the detected watermark area more accurate.

在两路水印检测处理法中均加入了形态学膨胀的处理,其中对第一路边缘图像进行形态学膨胀的原因是水印具有一定的宽度,膨胀可以填充边缘线条间的镂空,也可以将漏掉的边缘尽可能包含进来,遵循宁可误将背景当作水印不可将水印误当成背景的原则。对第二路的分割结果进行膨胀的原因也遵循了宁可误将背景当作水印不可将水印误当成背景的原则,尽可能少的将水印当成背景。Morphological expansion is added to the two watermark detection processing methods. The reason for the morphological expansion of the edge image of the first channel is that the watermark has a certain width. The lost edges should be included as much as possible, following the principle that it is better to mistake the background as a watermark than to mistake the watermark as the background. The reason for expanding the segmentation result of the second channel also follows the principle that it is better to mistake the background as a watermark and not mistake the watermark as the background, and use the watermark as the background as little as possible.

进一步地,所述第一路中间结果的水印区域为1或255,背景区域为0。Further, the watermark area of the first intermediate result is 1 or 255, and the background area is 0.

第一路水印检测处理进行自适应分割和形态学膨胀之后选择二值图像的中心点为锚点,按照初步定位的水印区域的长宽等比例缩小3倍画一个小的矩形框,同样在第二路的中间结果的二值图像上的相同位置画相同大小的小矩形框。对这两个小矩形框求两次交集:两次求交中第二路的中间结果的小矩形区域的像素值保持不变,第一路的小矩形区域的像素值在第一次求交的时候保持不变,第二次求交的时候将像素值取反。统计这两次交集之后像素值为1或255的像素个数,查看个数多的那次求交对应的第一路二值图像的小矩形区域的像素值是否取反,若取反则对第一路的形态学膨胀之后的二值图像像素值进行求反得到第一路的中间结果,若没有取反则直接将第一路形态学膨胀之后的二值图像作为第一路中间结果。In the first watermark detection process, after adaptive segmentation and morphological expansion, the center point of the binary image is selected as the anchor point, and a small rectangular frame is drawn according to the length and width of the preliminary positioned watermark area by 3 times. Draw a small rectangular box of the same size at the same position on the binary image of the intermediate result of the two-way. Find the intersection of these two small rectangular boxes twice: the pixel value of the small rectangular area of the intermediate result of the second road in the two intersections remains unchanged, and the pixel value of the small rectangular area of the first road is intersected in the first time. It remains unchanged when the second intersection is performed, and the pixel value is inverted when the second intersection is performed. Count the number of pixels with a pixel value of 1 or 255 after the two intersections, and check whether the pixel value of the small rectangular area of the first binary image corresponding to the intersection with the largest number is reversed. The pixel value of the binary image after the morphological expansion of the first channel is negated to obtain the intermediate result of the first channel.

第二路水印检测处理在求取水印的灰度值之后,以该灰度值为阈值进行阈值分割。求取初步定位的水印区域图像灰度值的平均值,将其与水印灰度值进行比较,选择对应的阈值分割的参数保证分割后水印的值为1或255,背景的值为0。In the second watermark detection process, after obtaining the grayscale value of the watermark, threshold segmentation is performed using the grayscale value as the threshold value. Obtain the average value of the gray value of the image in the preliminary positioned watermark area, compare it with the gray value of the watermark, and select the corresponding threshold segmentation parameters to ensure that the value of the watermark after segmentation is 1 or 255, and the value of the background is 0.

进一步地,所述水印灰度值的检测采用滑窗方式进行确定。Further, the detection of the gray value of the watermark is determined in a sliding window manner.

进一步地,该方法水印去除后,还包括图像后处理,采用alpha融合法将水印去除前初步定位的水印区域和水印去除后相对应的水印区域进行alpha融合,并叠加到背景区域的图像上。其中,水印去除后相对应的水印区域是水印去除后与水印去除前初步定位的水印区域完全一致的区域。Further, after the watermark is removed, the method also includes post-processing of the image, using the alpha fusion method to perform alpha fusion on the watermark area initially positioned before the watermark removal and the corresponding watermark area after the watermark removal, and superimpose it on the image in the background area. Wherein, the corresponding watermark area after the watermark removal is an area that is completely consistent with the watermark area initially positioned before the watermark removal after the watermark removal.

进一步地,所述alpha融合法进行融合的权重采用高斯系数。Further, a Gaussian coefficient is used as the weight for fusion performed by the alpha fusion method.

第二方面,本发明又提供了一种随背景变化的灰度视频文字类水印去除系统,该系统支持所述的一种随背景变化的灰度视频文字类水印去除方法;该系统包括获取单元、预处理单元、水印检测单元、水印去除单元和图像后处理单元;In a second aspect, the present invention further provides a background-changing grayscale video text watermark removal system, the system supports the background-changing grayscale video text watermark removal method; the system includes an acquisition unit , a preprocessing unit, a watermark detection unit, a watermark removal unit and an image post-processing unit;

所述获取单元,用于获取待处理灰度视频;The obtaining unit is used to obtain the grayscale video to be processed;

所述预处理单元,用于对待处理灰度视频中的原始图像进行预处理,得到初步定位的水印区域;The preprocessing unit is used to preprocess the original image in the grayscale video to be processed to obtain a watermark area that is initially positioned;

所述水印检测单元,用于根据所述初步定位的水印区域,采用两路水印检测处理法对所述初步定位的水印区域进行水印检测处理(即精确定位),得到两路中间结果;对所述两路中间结果进行运算(求交集),生成水印模板;提取所述水印模板中相同像素值个数最多的像素作为精确定位的水印区域,同时得到背景区域;其中,精确定位的水印区域以外的区域即是背景区域;The watermark detection unit is configured to perform watermark detection processing (that is, precise positioning) on the preliminary positioned watermark region by using a two-way watermark detection processing method according to the preliminary positioned watermark region, and obtain two-way intermediate results; The above-mentioned two-way intermediate results are operated (for intersection) to generate a watermark template; the pixels with the largest number of identical pixel values in the watermark template are extracted as the watermark area of precise positioning, and the background area is obtained simultaneously; wherein, outside the watermark area of precise positioning The area is the background area;

所述水印去除单元,用于使用所述背景区域对所述精确定位的水印区域进行填充,得到水印去除后的图像;The watermark removing unit is used to fill the precisely positioned watermark area by using the background area to obtain an image after watermark removal;

所述图像后处理单元,用于采用alpha融合法将水印去除前初步定位的水印区域和水印去除后相对应的水印区域进行alpha融合,并叠加到背景区域的图像上。The image post-processing unit is used to perform alpha fusion between the watermark area preliminarily positioned before watermark removal and the corresponding watermark area after watermark removal by using the alpha fusion method, and superimpose it on the image in the background area.

进一步地,所述水印检测单元包括第一路水印检测处理子单元、第二路水印检测处理子单元和计算子单元;Further, the watermark detection unit includes a first watermark detection processing subunit, a second watermark detection processing subunit and a calculation subunit;

所述第一路水印检测处理子单元,用于对所述初步定位的水印区域采用sobel边缘检测法分别对水平和垂直方向进行边缘检测,得到水平边缘和垂直边缘;并将水平边缘和垂直边缘叠加,得到叠加后的边缘图像;对叠加后的边缘图像进行自适应阈值分割,得到第一二值图像;对得到的第一二值图像进行形态学膨胀得到膨胀结果,对膨胀的结果与第二路中间结果做运算,得到第一路中间结果,即第一路水印模板;Described first road watermark detection processing subunit, is used to adopt sobel edge detection method to carry out edge detection to horizontal and vertical directions respectively to the watermark area of described preliminary positioning, obtains horizontal edge and vertical edge; superimpose to obtain the superimposed edge image; perform adaptive threshold segmentation on the superimposed edge image to obtain the first binary image; perform morphological expansion on the obtained first binary image to obtain the expansion result, and compare the expansion result with the first binary image. Perform operations on the intermediate results of the two channels to obtain the intermediate results of the first channel, that is, the first channel watermark template;

所述第二路水印检测处理子单元,用于检测所述初步定位的水印区域的水印灰度值,以所述水印灰度值作为阈值,进行阈值分割,得到第二二值图像;并对得到的第二二值图像进行形态学膨胀,得到第二路中间结果,即第二路水印模板;The second watermark detection processing sub-unit is used to detect the grayscale value of the watermark in the preliminary positioned watermark area, and use the grayscale value of the watermark as a threshold to perform threshold segmentation to obtain a second binary image; and The obtained second binary image is morphologically expanded to obtain the second intermediate result, that is, the second watermark template;

所述计算子单元,用于对所述第一路中间结果和第二路中间结果进行运算(求交集),生成水印模板。The calculation subunit is configured to perform an operation on the intermediate result of the first path and the intermediate result of the second path (seek an intersection) to generate a watermark template.

本发明与现有技术相比,具有如下的优点和有益效果:Compared with the prior art, the present invention has the following advantages and beneficial effects:

1、本发明流程合理,解决随背景变化的灰度视频文字类水印去除问题,针对灰度成像的视频实时去除特定位置的水印,并克服水印会根据图像的明暗变化而发生的变化;另外,可以批量获得除去水印的干净数据。1. The process of the present invention is reasonable, solves the problem of removing the grayscale video text watermark that changes with the background, removes the watermark at a specific position in real time for the video of grayscale imaging, and overcomes the change that the watermark will occur according to the light and dark changes of the image; In addition, Clean data with watermark removed can be obtained in batches.

2、在很多领域通常会用到灰度成像,人工智能技术在这些领域的使用越来越频繁,数据收集和标记对人工智能至关重要,本发明可以为数据标记和训练提供干净的数据。2. Grayscale imaging is usually used in many fields. Artificial intelligence technology is used more and more frequently in these fields. Data collection and labeling are crucial to artificial intelligence. The present invention can provide clean data for data labeling and training.

附图说明Description of drawings

此处所说明的附图用来提供对本发明实施例的进一步理解,构成本申请的一部分,并不构成对本发明实施例的限定。在附图中:The accompanying drawings described herein are used to provide further understanding of the embodiments of the present invention, and constitute a part of the present application, and do not constitute limitations to the embodiments of the present invention. In the attached image:

图1为本发明一种随背景变化的灰度视频文字类水印去除方法流程图。FIG. 1 is a flowchart of a method for removing a grayscale video text watermark that changes with the background of the present invention.

图2为本发明一种随背景变化的灰度视频文字类水印去除方法中两路水印检测流程图。FIG. 2 is a flow chart of two-way watermark detection in a method for removing text watermark from grayscale video that changes with background according to the present invention.

图3为本发明水印灰度值检测的滑窗示意图。FIG. 3 is a schematic diagram of a sliding window for detecting grayscale values of watermarks according to the present invention.

图4为本发明alpha融合法融合模板示意图。FIG. 4 is a schematic diagram of the fusion template of the alpha fusion method of the present invention.

图5为本发明alpha融合法融合模板叠加到图像上的示意图。FIG. 5 is a schematic diagram of superimposing a fusion template on an image by an alpha fusion method of the present invention.

图6为本发明滑窗像素值个数统计示意图。FIG. 6 is a schematic diagram of statistics of the number of pixel values of the sliding window according to the present invention.

图7为本发明一种随背景变化的灰度视频文字类水印去除系统结构示意图。FIG. 7 is a schematic structural diagram of a system for removing grayscale video text watermarks that changes with the background of the present invention.

具体实施方式Detailed ways

为使本发明的目的、技术方案和优点更加清楚明白,下面结合实施例和附图,对本发明作进一步的详细说明,本发明的示意性实施方式及其说明仅用于解释本发明,并不作为对本发明的限定。In order to make the purpose, technical solutions and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the embodiments and the accompanying drawings. as a limitation of the present invention.

实施例1Example 1

如图1至图6所示,本发明一种随背景变化的灰度视频文字类水印去除方法,如图1所示,该方法包括:As shown in FIG. 1 to FIG. 6 , a method for removing a grayscale video text watermark that changes with the background of the present invention, as shown in FIG. 1 , includes:

获取待处理灰度视频,对待处理灰度视频中的原始图像进行预处理,得到初步定位的水印区域;Obtain the grayscale video to be processed, and preprocess the original image in the grayscale video to be processed to obtain the watermark area for preliminary positioning;

根据所述初步定位的水印区域,采用两路水印检测处理法对所述初步定位的水印区域进行水印检测处理(即精确定位),得到两路中间结果;对所述两路中间结果进行运算(求交集),生成水印模板;提取所述水印模板中相同像素值个数最多的像素作为精确定位的水印区域,同时得到背景区域;其中,精确定位的水印区域以外的区域即是背景区域;According to the preliminarily positioned watermark area, a two-way watermark detection processing method is used to perform watermark detection processing on the preliminarily positioned watermark area (that is, precise positioning) to obtain two-way intermediate results; Find the intersection), generate a watermark template; extract the pixel with the largest number of identical pixel values in the watermark template as the watermark area of the precise positioning, and obtain the background area simultaneously; wherein, the area other than the watermark area of the precise positioning is the background area;

使用所述背景区域对所述精确定位的水印区域进行填充,得到水印去除后的图像。The precisely positioned watermark area is filled with the background area to obtain an image after watermark removal.

具体地,所述的对所述待处理水印图像进行预处理包括水印区域初步定位和噪声滤除处理;水印区域初步定位主要作用是减少计算量,其次可以减少背景对阈值分割的干扰。噪声滤除是为了减少对边缘检测的干扰。Specifically, the preprocessing of the to-be-processed watermark image includes preliminary positioning of the watermark area and noise filtering processing; the main function of the preliminary positioning of the watermark area is to reduce the amount of calculation, and secondly, it can reduce the interference of the background to the threshold segmentation. Noise filtering is to reduce interference with edge detection.

其中,所述水印区域初步定位是对水印进行初步定位,前提条件是该水印出现在画面的固定区域,比如中心,边角等位置。Wherein, the preliminary positioning of the watermark area is to perform preliminary positioning of the watermark, and the premise is that the watermark appears in a fixed area of the picture, such as the center, corner and other positions.

具体地,水印检测是本方法的核心之一。如图2所示,输入预处理之后的初步定位的水印区域,然后采用两路水印检测处理法对所述初步定位的水印区域进行水印检测处理。采用两路水印检测处理法是基于如下设计考虑:第一路水印检测处理是根据边缘求解水印区域,这是考虑到水印与背景差异明显,水印的边缘很容易找到,所以先根据边缘用第一路水印检测处理求得水印区域,但是这个过程中背景可能会对水印存在一定的干扰,所以接下来结合了第二路水印检测处理;第二路水印检测处理是根据水印灰度值找水印区域,这是基于水印灰度值是一直的,但是背景区域个别灰度值会被误认为是水印,这样单独基于水印灰度值利用第二路水印检测处理效果也不是那么好。因此,本发明考虑结合边缘求解和水印灰度值求解两种检测方式,来增加检测水印置信度,使检测出的水印区域更加精准。Specifically, watermark detection is one of the cores of this method. As shown in FIG. 2 , the pre-processed pre-positioned watermark area is input, and then a two-way watermark detection processing method is used to perform watermark detection processing on the pre-positioned watermark area. The two-way watermark detection processing method is based on the following design considerations: the first watermark detection process is to solve the watermark area according to the edge. This is considering that the watermark is obviously different from the background, and the edge of the watermark is easy to find. Therefore, first use the first watermark according to the edge. The watermark detection process obtains the watermark area, but the background may interfere with the watermark in this process, so the second watermark detection process is combined next; the second watermark detection process is to find the watermark area according to the watermark gray value. , which is based on the same gray value of the watermark, but individual gray values in the background area will be mistaken as watermarks, so the second watermark detection processing effect based on the gray value of the watermark alone is not so good. Therefore, the present invention considers two detection methods combining edge solution and watermark gray value solution to increase the watermark detection confidence and make the detected watermark area more accurate.

具体地:specifically:

第一路水印检测处理:对所述初步定位的水印区域采用sobel边缘检测法分别对水平和垂直方向进行边缘检测,得到水平边缘和垂直边缘;并将水平边缘和垂直边缘叠加,得到叠加后的边缘图像;对叠加后的边缘图像进行自适应阈值分割,得到第一二值图像;对得到的第一二值图像进行形态学膨胀得到膨胀结果,对膨胀的结果与第二路中间结果做运算,得到第一路中间结果,即第一路水印模板;The first watermark detection processing: the sobel edge detection method is used to detect the edges in the horizontal and vertical directions respectively for the watermark area of the preliminary positioning, so as to obtain the horizontal edge and the vertical edge; and superimpose the horizontal edge and the vertical edge to obtain the superimposed edge. edge image; perform adaptive threshold segmentation on the superimposed edge image to obtain the first binary image; perform morphological expansion on the obtained first binary image to obtain the expansion result, and perform an operation on the expansion result and the second intermediate result , get the first intermediate result, that is, the first watermark template;

第二路水印检测处理:检测所述初步定位的水印区域的水印灰度值,以所述水印灰度值作为阈值,进行阈值分割,得到第二二值图像;并对得到的第二二值图像进行形态学膨胀,得到第二路中间结果,即第二路水印模板。具体实施:首先检测水印灰度值,将初步定位的水印区域的中心位置设置为锚点,如图3所示的虚线框的中心点。以锚点为中心设置一个包含水印的小滑窗,该滑窗的高度应不高于水印的高度,来确保检测出的边缘最大程度不包含背景中的物体边缘。对以锚点为中心的滑窗区域进行sobel边缘检测,检测水平和垂直边缘并叠加,然后以滑窗的宽度的步长分别向左和右滑动一个滑窗,并用相同的方法求取边缘,得到3个边缘模板。对3个边缘模板进行形态学闭操作,缝合边缘之间的小缝隙和小的断裂,然后分别统计边缘覆盖下原图的灰度值,并将某个灰度值对应的像素个数统计为图6所示,然后将个数num从大到小排序。三个列表表示为L1,L2,L3。对应的列表的最多像素值的个数和像素值对表示为(NumMax1,VMax1),(NumMax2,VMax 2),(NumMax3,VMax 3),NumMaxi表示列表Li中相同像素值最多的像素个数,对应的像素值为VMax i。如果VMax 1、VMax 2、VMax 3中大于等于两个数字相同,则认为该值为水印的像素值。如果相同的值小于两个,也就是VMax 1、VMax 2、VMax 3都不相同,则继续往左和往右滑动滑块,统计滑块对应的边缘覆盖下的各像素值个数,直到生成的列表Li中NumMaxi对应的像素值VMax i相同的个数大于等于3个,则取个数最多的列表对应的相同像素值为边缘的灰度值。比如现在有5个列表,有3个列表中的NumMax对应的VMax都相同,则认为像素值VMax为水印的像素值。如果生成的列表中最多像素对应的像素值相同的列表个数有两个或两个以上相同,比如最多像素个数NumMax对应的像素值为v1的列表有3个,最多像素个数NumMax对应的像素值为v2的列表也有3个,则继续滑动滑块直到出现唯一的最多的满足要求的列表个数。从实践上看,基本上使用三个滑窗就可以鲁棒确定水印灰度值。The second watermark detection process: detecting the grayscale value of the watermark in the initially positioned watermark area, and using the grayscale value of the watermark as a threshold to perform threshold segmentation to obtain a second binary image; The image is morphologically expanded to obtain the second intermediate result, that is, the second watermark template. Specific implementation: First, the gray value of the watermark is detected, and the center position of the preliminary positioned watermark area is set as the anchor point, such as the center point of the dashed box as shown in FIG. 3 . A small sliding window containing the watermark is set centered on the anchor point. The height of the sliding window should not be higher than the height of the watermark to ensure that the detected edges do not include the edges of objects in the background to the greatest extent. Sobel edge detection is performed on the sliding window area centered on the anchor point, horizontal and vertical edges are detected and superimposed, and then a sliding window is slid left and right respectively with the step size of the width of the sliding window, and the edge is obtained by the same method, Get 3 edge templates. Perform the morphological closing operation on the three edge templates, stitch the small gaps and small breaks between the edges, and then count the gray values of the original image covered by the edges respectively, and count the number of pixels corresponding to a gray value as As shown in Figure 6, the number num is then sorted from large to small. The three lists are denoted L1, L2, L3. The maximum number of pixel values and pixel value pairs of the corresponding list are expressed as (NumMax1, VMax1), (NumMax2, VMax 2), (NumMax3, VMax 3), and NumMaxi represents the maximum number of pixels with the same pixel value in the list Li, The corresponding pixel value is VMax i. If VMax 1, VMax 2, and VMax 3 are greater than or equal to the same two numbers, the value is considered to be the pixel value of the watermark. If the same value is less than two, that is, VMax 1, VMax 2, and VMax 3 are not the same, continue to slide the slider to the left and right to count the number of pixel values covered by the edge corresponding to the slider, until the generation of The same number of pixel values VMax i corresponding to NumMaxi in the list Li is greater than or equal to 3, then the same pixel value corresponding to the list with the largest number is taken as the gray value of the edge. For example, there are 5 lists now, and the VMax corresponding to NumMax in the 3 lists is the same, then the pixel value VMax is considered to be the pixel value of the watermark. If the generated list has two or more lists with the same pixel value corresponding to the maximum number of pixels, for example, there are 3 lists with the pixel value v1 corresponding to the maximum number of pixels NumMax, and the maximum number of pixels NumMax corresponds to the list. There are also 3 lists with pixel value v2, then continue to slide the slider until there is a unique and maximum number of lists that meet the requirements. From a practical point of view, basically three sliding windows can be used to robustly determine the watermark gray value.

其中,所述第一路中间结果的水印区域为1或255,背景区域为0。Wherein, the watermark area of the first intermediate result is 1 or 255, and the background area is 0.

在上述处理的基础上,将两路得到的中间结果(第一路中间结果、第二路中间结果)进行求交集的运算,交集则为进一步缩小的水印轮廓,即水印模板。On the basis of the above processing, an intersection operation is performed on the intermediate results obtained by the two paths (the first intermediate result and the second intermediate result), and the intersection is a further reduced watermark outline, that is, a watermark template.

因为水印跟随背景在变化,所以水印跟背景是有明显的差异的,因此第一路水印检测处理可以将水印的边缘检测出来,同时也会检测出背景的物体边缘。通过自适应阈值分割可以降低背景边缘的干扰,因为水印的边缘梯度很多时候比背景都要大。第二路水印检测处理进行阈值分割,其原理是类间方差最大化,这里分为水印和背景两类。在预处理阶段对水印进行了初步的定位,将背景区域缩小到水印的周围,可以很大程度上避免大面积的背景跟水印属于同一类从而使得水印分割失败。将两路的结果求交集,可去掉大部分背景在边缘和类间方差上的干扰,同时增加求得的水印的鲁棒性。Because the watermark changes with the background, there is an obvious difference between the watermark and the background. Therefore, the first watermark detection process can detect the edge of the watermark, and also detect the edge of the object in the background. The interference of the background edge can be reduced by adaptive threshold segmentation, because the edge gradient of the watermark is often larger than that of the background. The second watermark detection process performs threshold segmentation, and its principle is to maximize the variance between classes, which is divided into two categories: watermark and background. In the preprocessing stage, the watermark is preliminarily positioned, and the background area is reduced to the surrounding of the watermark, which can largely avoid the failure of watermark segmentation due to the large area of the background belonging to the same category as the watermark. The intersection of the results of the two paths can remove most of the background interference on the edge and inter-class variance, and at the same time increase the robustness of the obtained watermark.

具体地,所述的使用所述背景区域对所述精确定位的水印区域进行填充,即进行水印去除;这是对求交的之后的水印模板进行膨胀,然后使用opencv自带的inpaint函数结合膨胀之后的水印模板进行水印去除,原理是将背景区域的像素填充到水印区域。这里对水印模板进行膨胀的思想是尽可能减少遗漏边缘的情况,即使误将边缘周围的背景加入到边缘里来,也可以通过下一步背景填充来弥补。Specifically, the use of the background area to fill the precisely positioned watermark area, that is, to remove the watermark; this is to expand the watermark template after the intersection, and then use the inpaint function that comes with opencv to combine the expansion After the watermark template is removed, the principle is to fill the pixels of the background area into the watermark area. The idea of expanding the watermark template here is to minimize the case of missing edges. Even if the background around the edge is added to the edge by mistake, it can be compensated by the next step of background filling.

为了进一步的对本实施例进行说明,该方法水印去除后,还包括图像后处理,采用alpha融合法将水印去除前初步定位的水印区域和水印去除后相对应的水印区域进行alpha融合,并叠加到背景区域的图像上。其中,水印去除后相对应的水印区域是水印去除后与水印去除前初步定位的水印区域完全一致的区域。这是考虑到对水印区域进行水印去除之后可能会导致副作用:背景区域的会有一些地方被误检测为水印区域,从而在进行填充之后会导致该区域跟背景出现割裂感。图像后处理使用alpha融合,将水印去除前初步定位的水印区域和水印去除后相对应的水印区域进行alpha融合,融合的权重采用高斯系数,alpha融合模板如图4所示,alpha融合模板叠加到图像上的示意图如图5所示。In order to further illustrate this embodiment, after the watermark is removed, the method also includes image post-processing, using the alpha fusion method to perform alpha fusion on the watermark area initially positioned before the watermark removal and the corresponding watermark area after the watermark removal, and superimpose on the on the image in the background area. Wherein, the corresponding watermark area after the watermark removal is an area that is completely consistent with the watermark area initially positioned before the watermark removal after the watermark removal. This is to take into account the possible side effects of removing the watermark from the watermark area: some parts of the background area will be mistakenly detected as the watermark area, which will cause the area to be separated from the background after filling. The image post-processing uses alpha fusion, and alpha fusion is performed on the watermark area initially positioned before watermark removal and the corresponding watermark area after watermark removal. Gaussian coefficients are used for the fusion weight. The alpha fusion template is shown in Figure 4. A schematic diagram on the image is shown in Figure 5.

工作原理是:现有的传统水印去除技术并不适应于随背景变化的灰度视频文字类水印去除,无法解决针对灰度成像的视频实时去除特定位置的水印;而基于机器学习的算法大多要用到训练数据。因此,本发明设计了一种随背景变化的灰度视频文字类水印去除方法,包括首先,获取待处理水印图像,并对所述待处理水印图像进行预处理,得到初步定位的水印区域;其中图像预处理,包含水印区域初步定位以及噪声滤除;水印区域初步定位主要作用是减少计算量,其次可以减少背景对阈值分割的干扰;噪声滤除是为了减少对边缘检测的干扰。其次,在初步定位的水印区域内对水印进行精确定位,生成水印模板;然后,根据水印模板对水印区域进行填充,去除水印;最后,进行图像后处理,改善水印去除后水印区域边界处出现的割裂感。The working principle is: the existing traditional watermark removal technology is not suitable for the removal of grayscale video text watermarks that change with the background, and cannot solve the problem of real-time removal of watermarks in specific locations for grayscale imaging videos; and most algorithms based on machine learning require Use training data. Therefore, the present invention designs a grayscale video text watermark removal method that changes with the background, including: first, acquiring a watermark image to be processed, and preprocessing the watermark image to be processed to obtain a preliminary positioned watermark area; wherein Image preprocessing includes preliminary positioning of the watermark area and noise filtering; the primary function of the preliminary positioning of the watermark area is to reduce the amount of calculation, and secondly, it can reduce the interference of the background to the threshold segmentation; the noise filtering is to reduce the interference to the edge detection. Secondly, the watermark is precisely positioned in the preliminary positioned watermark area, and a watermark template is generated; then, the watermark area is filled according to the watermark template to remove the watermark; finally, the image post-processing is performed to improve the watermark appearing at the boundary of the watermark area after the watermark is removed. Fragmentation.

本发明流程合理,解决随背景变化的灰度视频文字类水印去除问题,针对灰度成像的视频实时去除特定位置的水印,并克服水印会根据图像的明暗变化而发生的变化;另外,可以批量获得除去水印的干净数据。The method of the invention has a reasonable process, solves the problem of removing the grayscale video text watermark that changes with the background, removes the watermark in a specific position in real time for the grayscale imaging video, and overcomes the change of the watermark according to the light and dark changes of the image; in addition, it can be batched Get clean data with watermark removed.

在很多领域通常会用到灰度成像,人工智能技术在这些领域的使用越来越频繁,数据收集和标记对人工智能至关重要,本发明可以为数据标记和训练提供干净的数据。Grayscale imaging is usually used in many fields, and artificial intelligence technology is used more and more frequently in these fields. Data collection and labeling are crucial to artificial intelligence. The present invention can provide clean data for data labeling and training.

实施例2Example 2

如图7所示,本实施例与实施例1的区别在于,本实施例提供了一种随背景变化的灰度视频文字类水印去除系统,该系统支持实施例1所述的一种随背景变化的灰度视频文字类水印去除方法;该系统包括获取单元、预处理单元、水印检测单元、水印去除单元和图像后处理单元;As shown in FIG. 7 , the difference between this embodiment and Embodiment 1 is that this embodiment provides a grayscale video text watermark removal system that changes with the background, and the system supports the background-dependent watermark described in Embodiment 1 A modified grayscale video text watermark removal method; the system includes an acquisition unit, a preprocessing unit, a watermark detection unit, a watermark removal unit and an image post-processing unit;

所述获取单元,用于获取待处理灰度视频;The obtaining unit is used to obtain the grayscale video to be processed;

所述预处理单元,用于对待处理灰度视频中的原始图像进行预处理,得到初步定位的水印区域;The preprocessing unit is used to preprocess the original image in the grayscale video to be processed to obtain a watermark area that is initially positioned;

所述水印检测单元,用于根据所述初步定位的水印区域,采用两路水印检测处理法对所述初步定位的水印区域进行水印检测处理(即精确定位),得到两路中间结果;对所述两路中间结果进行运算(求交集),生成水印模板;提取所述水印模板中相同像素值个数最多的像素作为精确定位的水印区域,同时得到背景区域;其中,精确定位的水印区域以外的区域即是背景区域;The watermark detection unit is configured to perform watermark detection processing (that is, precise positioning) on the preliminary positioned watermark region by using a two-way watermark detection processing method according to the preliminary positioned watermark region, and obtain two-way intermediate results; The above-mentioned two-way intermediate results are operated (for intersection) to generate a watermark template; the pixels with the largest number of identical pixel values in the watermark template are extracted as the watermark area of precise positioning, and the background area is obtained simultaneously; wherein, outside the watermark area of precise positioning The area is the background area;

所述水印去除单元,用于使用所述背景区域对所述精确定位的水印区域进行填充,得到水印去除后的图像;The watermark removing unit is used to fill the precisely positioned watermark area by using the background area to obtain an image after watermark removal;

所述图像后处理单元,用于采用alpha融合法将水印去除前初步定位的水印区域和水印去除后相对应的水印区域进行alpha融合,并叠加到背景区域的图像上。The image post-processing unit is used to perform alpha fusion between the watermark area preliminarily positioned before watermark removal and the corresponding watermark area after watermark removal by using the alpha fusion method, and superimpose it on the image in the background area.

本实施例中,所述水印检测单元包括第一路水印检测处理子单元、第二路水印检测处理子单元和计算子单元;In this embodiment, the watermark detection unit includes a first watermark detection processing subunit, a second watermark detection processing subunit and a calculation subunit;

所述第一路水印检测处理子单元,用于对所述初步定位的水印区域采用sobel边缘检测法分别对水平和垂直方向进行边缘检测,得到水平边缘和垂直边缘;并将水平边缘和垂直边缘叠加,得到叠加后的边缘图像;对叠加后的边缘图像进行自适应阈值分割,得到第一二值图像;对得到的第一二值图像进行形态学膨胀得到膨胀结果,对膨胀的结果与第二路中间结果做运算,得到第一路中间结果,即第一路水印模板;Described first road watermark detection processing subunit, is used to adopt sobel edge detection method to carry out edge detection to horizontal and vertical directions respectively to the watermark area of described preliminary positioning, obtains horizontal edge and vertical edge; superimpose to obtain the superimposed edge image; perform adaptive threshold segmentation on the superimposed edge image to obtain the first binary image; perform morphological expansion on the obtained first binary image to obtain the expansion result, and compare the expansion result with the first binary image. Perform operations on the intermediate results of the two channels to obtain the intermediate results of the first channel, that is, the first channel watermark template;

所述第二路水印检测处理子单元,用于检测所述初步定位的水印区域的水印灰度值,以所述水印灰度值作为阈值,进行阈值分割,得到第二二值图像;并对得到的第二二值图像进行形态学膨胀,得到第二路中间结果,即第二路水印模板;The second watermark detection processing sub-unit is used to detect the grayscale value of the watermark in the preliminary positioned watermark area, and use the grayscale value of the watermark as a threshold to perform threshold segmentation to obtain a second binary image; and The obtained second binary image is morphologically expanded to obtain the second intermediate result, that is, the second watermark template;

所述计算子单元,用于对所述第一路中间结果和第二路中间结果进行运算(求交集),生成水印模板。The calculation subunit is configured to perform an operation on the intermediate result of the first path and the intermediate result of the second path (seek an intersection) to generate a watermark template.

其他各个单元的执行过程按照实施例1所述的一种随背景变化的灰度视频文字类水印去除方法流程步骤执行即可,此实施例中不再一一赘述。The execution process of the other units may be executed according to the flow and steps of the method for removing a grayscale video text watermark that changes with the background described in Embodiment 1, which will not be repeated in this embodiment.

本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。As will be appreciated by those skilled in the art, the embodiments of the present application may be provided as a method, a system, or a computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.

本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present application. It will be understood that each flow and/or block in the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to the processor of a general purpose computer, special purpose computer, embedded processor or other programmable data processing device to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing device produce Means for implementing the functions specified in a flow or flow of a flowchart and/or a block or blocks of a block diagram.

这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory result in an article of manufacture comprising instruction means, the instructions The apparatus implements the functions specified in the flow or flow of the flowcharts and/or the block or blocks of the block diagrams.

这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded on a computer or other programmable data processing device to cause a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process such that The instructions provide steps for implementing the functions specified in the flow or blocks of the flowcharts and/or the block or blocks of the block diagrams.

以上所述的具体实施方式,对本发明的目的、技术方案和有益效果进行了进一步详细说明,所应理解的是,以上所述仅为本发明的具体实施方式而已,并不用于限定本发明的保护范围,凡在本发明的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。The specific embodiments described above further describe the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above descriptions are only specific embodiments of the present invention, and are not intended to limit the scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.

Claims (10)

1.一种随背景变化的灰度视频文字类水印去除方法,其特征在于,该方法包括:1. a grayscale video text class watermark removal method that changes with background, is characterized in that, this method comprises: 获取待处理灰度视频,对待处理灰度视频中的原始图像进行预处理,得到初步定位的水印区域;Obtain the grayscale video to be processed, and preprocess the original image in the grayscale video to be processed to obtain the watermark area for preliminary positioning; 根据所述初步定位的水印区域,采用两路水印检测处理法对所述初步定位的水印区域进行水印检测处理,得到两路中间结果;对所述两路中间结果进行运算,生成水印模板;提取所述水印模板中相同像素值个数最多的像素作为精确定位的水印区域,同时得到背景区域;According to the preliminarily positioned watermark area, a two-way watermark detection processing method is used to perform watermark detection processing on the preliminarily positioned watermark area to obtain two-way intermediate results; perform operations on the two-way intermediate results to generate a watermark template; extract The pixel with the largest number of identical pixel values in the watermark template is used as the watermark area for precise positioning, and the background area is obtained simultaneously; 使用所述背景区域对所述精确定位的水印区域进行填充,得到水印去除后的图像。The precisely positioned watermark area is filled with the background area to obtain an image after watermark removal. 2.根据权利要求1所述的一种随背景变化的灰度视频文字类水印去除方法,其特征在于,所述的对所述待处理水印图像进行预处理包括水印区域初步定位和噪声滤除处理。2. a kind of gray-scale video text watermark removal method that changes with background according to claim 1, is characterized in that, described preprocessing to described to-be-processed watermark image comprises watermark area preliminary location and noise filtering deal with. 3.根据权利要求2所述的一种随背景变化的灰度视频文字类水印去除方法,其特征在于,所述水印区域初步定位是对水印进行初步定位,初步定位的水印类型包括在图像的边角类型。3. a kind of grayscale video text class watermark removal method that changes with background according to claim 2, is characterized in that, described watermark area preliminary location is to carry out preliminary location to watermark, and the watermark type of preliminary location is included in the watermark of image. Corner type. 4.根据权利要求1所述的一种随背景变化的灰度视频文字类水印去除方法,其特征在于,所述的采用两路水印检测处理法对所述初步定位的水印区域进行水印检测处理,具体包括:4. a kind of grayscale video text class watermark removal method that changes with background according to claim 1, is characterized in that, described adopting two-way watermark detection processing method carries out watermark detection processing to the watermark area of described preliminary positioning , including: 第一路水印检测处理:对所述初步定位的水印区域采用sobel边缘检测法分别对水平和垂直方向进行边缘检测,得到水平边缘和垂直边缘;并将水平边缘和垂直边缘叠加,得到叠加后的边缘图像;对叠加后的边缘图像进行自适应阈值分割,得到第一二值图像;对得到的第一二值图像进行形态学膨胀得到膨胀结果,对膨胀的结果与第二路中间结果做运算,得到第一路中间结果;The first watermark detection processing: the sobel edge detection method is used to detect the edges in the horizontal and vertical directions respectively for the watermark area of the preliminary positioning, so as to obtain the horizontal edge and the vertical edge; and superimpose the horizontal edge and the vertical edge to obtain the superimposed edge. edge image; perform adaptive threshold segmentation on the superimposed edge image to obtain the first binary image; perform morphological expansion on the obtained first binary image to obtain the expansion result, and perform an operation on the expansion result and the second intermediate result , get the first intermediate result; 第二路水印检测处理:检测所述初步定位的水印区域的水印灰度值,以所述水印灰度值作为阈值,进行阈值分割,得到第二二值图像;并对得到的第二二值图像进行形态学膨胀,得到第二路中间结果。The second watermark detection process: detecting the grayscale value of the watermark in the initially positioned watermark area, and using the grayscale value of the watermark as a threshold to perform threshold segmentation to obtain a second binary image; The image is morphologically inflated to obtain a second-pass intermediate result. 5.根据权利要求4所述的一种随背景变化的灰度视频文字类水印去除方法,其特征在于,所述第一路中间结果的水印区域为1或255,背景区域为0。5 . The method for removing grayscale video text watermark that changes with background according to claim 4 , wherein the watermark area of the first intermediate result is 1 or 255, and the background area is 0. 6 . 6.根据权利要求4所述的一种随背景变化的灰度视频文字类水印去除方法,其特征在于,所述水印灰度值的检测采用滑窗方式进行确定。6 . The method for removing a text watermark in grayscale video that changes with the background according to claim 4 , wherein the detection of the grayscale value of the watermark adopts a sliding window method to determine. 7 . 7.根据权利要求1所述的一种随背景变化的灰度视频文字类水印去除方法,其特征在于,该方法水印去除后,还包括图像后处理,采用alpha融合法将水印去除前初步定位的水印区域和水印去除后相对应的水印区域进行alpha融合,并叠加到背景区域的图像上。7. a kind of grayscale video text class watermark removal method that changes with background according to claim 1, is characterized in that, after this method watermark is removed, also comprises image post-processing, adopts alpha fusion method to be preliminary positioned before watermark is removed The watermark area and the corresponding watermark area after watermark removal are alpha-fused and superimposed on the image in the background area. 8.根据权利要求7所述的一种随背景变化的灰度视频文字类水印去除方法,其特征在于,所述alpha融合法进行融合的权重采用高斯系数。8 . The method for removing text-like watermarks from grayscale video according to claim 7 , wherein the alpha fusion method uses Gaussian coefficients as the weight for fusion. 9 . 9.一种随背景变化的灰度视频文字类水印去除系统,其特征在于,该系统支持如权利要求1至8中任一所述的一种随背景变化的灰度视频文字类水印去除方法;该系统包括获取单元、预处理单元、水印检测单元、水印去除单元和图像后处理单元;9. a grayscale video text class watermark removal system that changes with background, it is characterized in that, this system supports a kind of grayscale video text class watermark removal method that changes with background as described in any one of claim 1 to 8 ; The system includes an acquisition unit, a preprocessing unit, a watermark detection unit, a watermark removal unit and an image post-processing unit; 所述获取单元,用于获取待处理灰度视频;The obtaining unit is used to obtain the grayscale video to be processed; 所述预处理单元,用于对待处理灰度视频中的原始图像进行预处理,得到初步定位的水印区域;The preprocessing unit is used to preprocess the original image in the grayscale video to be processed to obtain a watermark area that is initially positioned; 所述水印检测单元,用于根据所述初步定位的水印区域,采用两路水印检测处理法对所述初步定位的水印区域进行水印检测处理,得到两路中间结果;对所述两路中间结果进行运算,生成水印模板;提取所述水印模板中相同像素值个数最多的像素作为精确定位的水印区域,同时得到背景区域;The watermark detection unit is configured to perform watermark detection processing on the preliminary positioned watermark area by using a two-way watermark detection processing method according to the preliminary positioned watermark area, and obtain two-way intermediate results; Perform operations to generate a watermark template; extract the pixel with the largest number of identical pixel values in the watermark template as a precisely positioned watermark area, and simultaneously obtain a background area; 所述水印去除单元,用于使用所述背景区域对所述精确定位的水印区域进行填充,得到水印去除后的图像;The watermark removing unit is used to fill the precisely positioned watermark area by using the background area to obtain an image after watermark removal; 所述图像后处理单元,用于采用alpha融合法将水印去除前初步定位的水印区域和水印去除后相对应的水印区域进行alpha融合,并叠加到背景区域的图像上。The image post-processing unit is used to perform alpha fusion between the watermark area preliminarily positioned before watermark removal and the corresponding watermark area after watermark removal by using the alpha fusion method, and superimpose it on the image in the background area. 10.根据权利要求9所述的一种随背景变化的灰度视频文字类水印去除系统,其特征在于,所述水印检测单元包括第一路水印检测处理子单元、第二路水印检测处理子单元和计算子单元;10. The grayscale video text watermark removal system that changes with the background according to claim 9, wherein the watermark detection unit comprises a first watermark detection processing subunit, a second watermark detection processing subunit units and computational subunits; 所述第一路水印检测处理子单元,用于对所述初步定位的水印区域采用sobel边缘检测法分别对水平和垂直方向进行边缘检测,得到水平边缘和垂直边缘;并将水平边缘和垂直边缘叠加,得到叠加后的边缘图像;对叠加后的边缘图像进行自适应阈值分割,得到第一二值图像;对得到的第一二值图像进行形态学膨胀得到膨胀结果,对膨胀的结果与第二路中间结果做运算,得到第一路中间结果;Described first road watermark detection processing subunit, is used to adopt sobel edge detection method to carry out edge detection to horizontal and vertical directions respectively to the watermark area of described preliminary positioning, obtains horizontal edge and vertical edge; superimpose to obtain the superimposed edge image; perform adaptive threshold segmentation on the superimposed edge image to obtain the first binary image; perform morphological expansion on the obtained first binary image to obtain the expansion result, and compare the expansion result with the first binary image. Perform operations on the intermediate results of the second channel to obtain the intermediate results of the first channel; 所述第二路水印检测处理子单元,用于检测所述初步定位的水印区域的水印灰度值,以所述水印灰度值作为阈值,进行阈值分割,得到第二二值图像;并对得到的第二二值图像进行形态学膨胀,得到第二路中间结果;The second watermark detection processing sub-unit is used to detect the grayscale value of the watermark in the preliminary positioned watermark area, and use the grayscale value of the watermark as a threshold to perform threshold segmentation to obtain a second binary image; and The obtained second binary image is morphologically expanded to obtain the second intermediate result; 所述计算子单元,用于对所述第一路中间结果和第二路中间结果进行运算,生成水印模板。The calculation subunit is configured to perform operations on the first intermediate result and the second intermediate result to generate a watermark template.
CN202210073703.1A 2022-01-21 2022-01-21 A method and system for removing text watermarks from grayscale video that changes with background Active CN114419006B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210073703.1A CN114419006B (en) 2022-01-21 2022-01-21 A method and system for removing text watermarks from grayscale video that changes with background

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210073703.1A CN114419006B (en) 2022-01-21 2022-01-21 A method and system for removing text watermarks from grayscale video that changes with background

Publications (2)

Publication Number Publication Date
CN114419006A true CN114419006A (en) 2022-04-29
CN114419006B CN114419006B (en) 2025-05-30

Family

ID=81276194

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210073703.1A Active CN114419006B (en) 2022-01-21 2022-01-21 A method and system for removing text watermarks from grayscale video that changes with background

Country Status (1)

Country Link
CN (1) CN114419006B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115049840A (en) * 2022-08-11 2022-09-13 合肥高维数据技术有限公司 Screen shot watermark identification method, storage medium and electronic equipment
CN115049837A (en) * 2022-08-11 2022-09-13 合肥高维数据技术有限公司 Characteristic diagram interference removing method and screen shot watermark identification method comprising same

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106709866A (en) * 2016-11-18 2017-05-24 北京智慧眼科技股份有限公司 Method and device for removing mesh watermark from identification photo, face verification method and device
CN110163786A (en) * 2019-04-02 2019-08-23 阿里巴巴集团控股有限公司 A kind of method, device and equipment removing watermark
CN111192190A (en) * 2019-12-31 2020-05-22 北京金山云网络技术有限公司 Method and device for eliminating image watermark and electronic equipment
CN113129326A (en) * 2021-06-17 2021-07-16 苏州高视半导体技术有限公司 Self-adaptive threshold segmentation method of gray level image

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106709866A (en) * 2016-11-18 2017-05-24 北京智慧眼科技股份有限公司 Method and device for removing mesh watermark from identification photo, face verification method and device
CN110163786A (en) * 2019-04-02 2019-08-23 阿里巴巴集团控股有限公司 A kind of method, device and equipment removing watermark
CN111192190A (en) * 2019-12-31 2020-05-22 北京金山云网络技术有限公司 Method and device for eliminating image watermark and electronic equipment
CN113129326A (en) * 2021-06-17 2021-07-16 苏州高视半导体技术有限公司 Self-adaptive threshold segmentation method of gray level image

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
李旋;: "图像文本定位算法的研究与设计", 信息系统工程, no. 02, 20 February 2015 (2015-02-20), pages 136 - 139 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115049840A (en) * 2022-08-11 2022-09-13 合肥高维数据技术有限公司 Screen shot watermark identification method, storage medium and electronic equipment
CN115049837A (en) * 2022-08-11 2022-09-13 合肥高维数据技术有限公司 Characteristic diagram interference removing method and screen shot watermark identification method comprising same
CN115049840B (en) * 2022-08-11 2022-11-08 合肥高维数据技术有限公司 Screen shot watermark identification method, storage medium and electronic device
CN115049837B (en) * 2022-08-11 2022-11-18 合肥高维数据技术有限公司 Characteristic diagram interference removing method and screen shot watermark identification method comprising same

Also Published As

Publication number Publication date
CN114419006B (en) 2025-05-30

Similar Documents

Publication Publication Date Title
CN109961049B (en) Cigarette brand identification method under complex scene
CN108961217B (en) Surface defect detection method based on regular training
WO2018103608A1 (en) Text detection method, device and storage medium
CN111310760B (en) Oracle Bone Inscription Text Detection Method Combining Local Prior Features and Deep Convolution Features
CN110826389B (en) Gait recognition method based on attention 3D frequency convolutional neural network
CN110008962B (en) A Weakly Supervised Semantic Segmentation Method Based on Attention Mechanism
CN103870818B (en) Smog detection method and device
CN108564120B (en) Feature point extraction method based on deep neural network
CN110910420A (en) Moving target detection tracking method based on image stream
CN111754531A (en) Image instance segmentation method and apparatus
Chen et al. Single depth image super-resolution using convolutional neural networks
CN101106716A (en) A shed image division processing method
CN114419006A (en) A method and system for removing text watermark from grayscale video that changes with background
CN114565675A (en) A method for removing dynamic feature points in the front end of visual SLAM
CN106682571A (en) Skin color segmentation and wavelet transformation-based face detection method
CN103514610B (en) A kind of moving Object Segmentation method of stationary background
Sun et al. Uni6dv2: Noise elimination for 6d pose estimation
CN112686265A (en) Hierarchic contour extraction-based pictograph segmentation method
CN110472490A (en) Based on the action identification method and device, storage medium and terminal for improving VGGNet
CN113409327B (en) An improved instance segmentation method based on sorting and semantic consistency constraints
CN105913434B (en) A kind of positioning of leucocyte and iterative splitting approach
CN112270683A (en) IHC digital preview image identification and organization foreground segmentation method and system
CN116342589B (en) Cross-field scratch defect continuity detection method and system
CN111931689A (en) An online method for extracting discriminative features of video satellite data
CN113657137A (en) Data processing method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant