MSER+NMS文本區(qū)域檢測

1.MSER
MSER最大穩(wěn)定極值區(qū)域(MSER-Maximally Stable Extremal Regions),該算法是2002提出的,主要是基于分水嶺的思想來做圖像中斑點(diǎn)的檢測。

原理:MSER對一幅已經(jīng)處理成灰度的圖像做二值化處理,這個(gè)處理的閾值從0到255遞增,這個(gè)閾值的遞增類似于在一片土地上做水平面的上升,隨著水平面上升,高高低低凹凸不平的土地區(qū)域就會不斷被淹沒,這就是分水嶺算法,而這個(gè)高低不同,就是圖像中灰度值的不同。而在一幅含有文字的圖像上,有些區(qū)域(比如文字)由于顏色(灰度值)是一致的,因此在水平面(閾值)持續(xù)增長的一段時(shí)間內(nèi)都不會被覆蓋,直到閾值漲到文字本身的灰度值時(shí)才會被淹沒,這些區(qū)域就叫做最大穩(wěn)定極值區(qū)域。


公式

其中,Qi表示閾值為i時(shí)的某一連通區(qū)域,Δ 為灰度閾值的微小變化量,q(i) 為閾值是 i 時(shí)的區(qū)域 Qi 的變化率。
當(dāng)q(i) 為局部極小值時(shí),則Qi 為最大穩(wěn)定極值區(qū)域。

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()參數(shù)設(shè)置:
_delta 變化量q(i)
_min_area 修剪小于minarea的區(qū)域
_max_area 修剪大于maxArea的面積
_max_variation 修剪該區(qū)域的大小與其子區(qū)域相似
_min_diversity 對于彩色圖像,追溯至截止MSER,其分集小于最小分集
_max_evolution 對于彩色圖像,改進(jìn)的步驟
_area_threshold 對于彩色圖像,區(qū)域閾值導(dǎo)致重新初始化
_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]]]]]]]]]) 

結(jié)果圖:
image.png

注釋:參考網(wǎng)站
參考官網(wǎng):
https://docs.opencv.org/3.4/d3/d28/classcv_1_1MSER.html
https://blog.csdn.net/wsp_1138886114/article/details/100135824

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容