OpenCV 3.0.0 MSER Binary Mask
来源:互联网 发布:c语言大于号怎么打 编辑:程序博客网 时间:2024/06/03 23:44
Refer from http://stackoverflow.com/questions/28515084/opencv-3-0-0-mser-binary-mask
I am trying to use MSER algorithm in OpenCV 3.0.0 beta to extract text regions from an image. At the end I need a binary mask with the detected MSER regions, but the algorithm only provides contours. I tried to draw these contours but I don't get the expected result.
This is the code I use:
void mserExtractor (const Mat& image, Mat& mserOutMask){ Ptr<MSER> mserExtractor = MSER::create(); vector<vector<cv::Point>> mserContours; vector<cv::Rect> mserBbox; mserExtractor->detectRegions(image, mserContours, mserBbox); for( int i = 0; i<mserContours.size(); i++ ) { drawContours(mserOutMask, mserContours, i, Scalar(255, 255, 255), 4); }}
This is the result:
The problem is that non-convex regions are filled by lines crossing the actual MSER region. I would like just the list of pixels in the region like I get from MATLABdetectMSERFeatures
:
Any ideas how to get the filled region from the contours (or to get the MSER mask in other ways)?
1 Answer
I found the solution! Just loop over all the points and draw them!
void mserExtractor (const Mat& image, Mat& mserOutMask){ Ptr<MSER> mserExtractor = MSER::create(); vector<vector<cv::Point>> mserContours; vector<KeyPoint> mserKeypoint; vector<cv::Rect> mserBbox; mserExtractor->detectRegions(image, mserContours, mserBbox); for (vector<cv::Point> v : mserContours){ for (cv::Point p : v){ mserOutMask.at<uchar>(p.y, p.x) = 255; } }}
- OpenCV 3.0.0 MSER Binary Mask
- opencv中 MSER 源码赏析
- opencv 中将 MSER 修改成 Hierarchical MSER 方法
- MSER
- 使用OpenCV的一个MSER/MSCR实现
- opencv MSER(最大极值稳定区域)
- opencv MSER(最大极值稳定区域)
- opencv MSER(最大极值稳定区域)
- MSER slower in 3.0.0 than 2.4.X (Bug #4478)
- Opencv——mask
- opencv mask的格式
- opencv中mask操作
- opencv中的mask参数
- Opencv简单编程--mask
- OpenCV生成不规则mask
- opencv的mask
- OpenCV中掩膜操作(mask)实例
- Opencv中mask的作用
- VC维
- 【Html】认识<hr>标签,添加水平横线
- iOS开发——高德地图调研(路线规划,周边搜索,)
- CAAnimationGroup的简单使用
- (1)轻松构建DuiLib HelloWorld By DuiCreator(上)
- OpenCV 3.0.0 MSER Binary Mask
- Android中handler的用法实例
- ORA-19602: cannot backup or copy active file in NOARCHIVELOG mode
- Feature Selection with caret’s Genetic Algorithm Option
- 畅通工程(搜索水题)
- mipi差分信号原理
- servlet&jsp 各种乱码问题
- linux环境变量
- 《python爬虫学习》:Cookie的使用