美文网首页OpenCV
MSER+NMS文本区域检测

MSER+NMS文本区域检测

作者: 佑___ | 来源:发表于2020-05-29 18:37 被阅读0次

1.MSER
MSER最大稳定极值区域(MSER-Maximally Stable Extremal Regions),该算法是2002提出的,主要是基于分水岭的思想来做图像中斑点的检测。

原理:MSER对一幅已经处理成灰度的图像做二值化处理,这个处理的阈值从0到255递增,这个阈值的递增类似于在一片土地上做水平面的上升,随着水平面上升,高高低低凹凸不平的土地区域就会不断被淹没,这就是分水岭算法,而这个高低不同,就是图像中灰度值的不同。而在一幅含有文字的图像上,有些区域(比如文字)由于颜色(灰度值)是一致的,因此在水平面(阈值)持续增长的一段时间内都不会被覆盖,直到阈值涨到文字本身的灰度值时才会被淹没,这些区域就叫做最大稳定极值区域。


公式

其中,Qi表示阈值为i时的某一连通区域,Δ 为灰度阈值的微小变化量,q(i) 为阈值是 i 时的区域 Qi 的变化率。
当q(i) 为局部极小值时,则Qi 为最大稳定极值区域。

Detailed Description

Maximally stable extremal region extractor.
The class encapsulates all the parameters of the MSER extraction algorithm (see wiki article).

  • there are two different implementation of MSER: one for grey image, one for color image
  • the grey image algorithm is taken from: [157] ; the paper claims to be faster than union-find method; it actually get 1.5~2m/s on my centrino L7200 1.2GHz laptop.
  • the color image algorithm is taken from: [71] ; it should be much slower than grey image method ( 3~4 times ); the chi_table.h file is taken directly from paper's source code which is distributed under GPL.
  • (Python) A complete example showing the use of the MSER detector can be found at samples/python/mser.py

cv2.MSER_create()参数设置:
_delta 变化量q(i)
_min_area 修剪小于minarea的区域
_max_area 修剪大于maxArea的面积
_max_variation 修剪该区域的大小与其子区域相似
_min_diversity 对于彩色图像,追溯至截止MSER,其分集小于最小分集
_max_evolution 对于彩色图像,改进的步骤
_area_threshold 对于彩色图像,区域阈值导致重新初始化
_min_margin 对于彩色图像,忽略太小的边距
_edge_blur_size 边缘模糊的光圈大小

Full constructor for MSER detector.
Parameters
_delta it compares (sizei−sizei−delta)/sizei−delta
_min_area prune the area which smaller than minArea
_max_area prune the area which bigger than maxArea
_max_variation prune the area have similar size to its children
_min_diversity for color image, trace back to cut off mser with diversity less than min_diversity
_max_evolution for color image, the evolution steps
_area_threshold for color image, the area threshold to cause re-initialize
_min_margin for color image, ignore too small margin
_edge_blur_size for color image, the aperture size for edge blur

 cv::MSER::create(int  _delta = 5, 
                  int  _min_area = 60, 
                  int  _max_area = 14400, 
                  double _max_variation = 0.25, 
                  double  _min_diversity = .2, 
                  int  _max_evolution = 200, 
                  double  _area_threshold = 1.01, 
                  double _min_margin = 0.003, 
                  int _edge_blur_size = 5 )


 Python:
 retval =  cv.MSER_create([, _delta[, _min_area[, _max_area[, _max_variation[, _min_diversity[, _max_evolution[, _area_threshold[, _min_margin[, _edge_blur_size]]]]]]]]]) 
结果图: image.png

注释:参考网站
参考官网:
https://docs.opencv.org/3.4/d3/d28/classcv_1_1MSER.html
https://blog.csdn.net/wsp_1138886114/article/details/100135824

相关文章

网友评论

    本文标题:MSER+NMS文本区域检测

    本文链接:https://www.haomeiwen.com/subject/cnsfzhtx.html