*Sorry for the shilling, but here’s my upcoming project:*

*https://plusplusone.herokuapp.com*

*Please register your email address if you’re interested in it.*

This is implementation of Chen, Huizhong, et al. “Robust Text Detection in Natural Images with Edge-Enhanced Maximally Stable Extremal Regions.” [1]. Partly based on the sample available on Matlab [2].

Partly motivated by the fact that the example given from the Matlab site [2] contains **helperGrowEdges** and **helperStrokeWidth** functions which sources are sadly only available for owners of the newest Matlab. Thus I decided to implement those functions based on the literature and some of my own assumptions (e.g. pruning only the 8 neighbours, etc).

After reading thru the original literature [1], here’s how the algorithm works in a nutshell:

- Create
**Maximally Stable Extremal Regions** (**MSER**) as basic region candidate for the text. The reason is that MSER is fairly robust to view point, lighting, and scale changes. It is also based on the assumption that texts in real life are normally distinct enough from the background.
- However, since MSER is sensitive to blurring (thus some regions might spill over to neighbouring ones), an
**Edge-Enhanced MSER** is introduced to counter against that issue. It’s basically MSER region with pruning around the edge pixels along the gradient direction.
- Additional geometric filtering is applied, in my case a connected component labelling is used, in order to remove blobs that don’t match the given criteria (e.g. min area, eccentricity, etc)
- Create a
**distance transformed matrix** from the Edge-Enhanced MSER
- And compute
**stroke width image** from the distance transformed matrix. This is achieved by propagating the maximum value around the ridges of the matrix, to neighbours which have lower values recursively.
- Lastly, the resulting connected components are filtered based on the ratio of component’s standard deviation and mean values.

Here’s the sample original image:

And here’s the sample result, with the stroke width image on the right hand side, and the Tesseract-deciphered texts placed next to the detected candidate text region.

My code is available here: https://github.com/subokita/Robust-Text-Detection/tree/master. It requires C++11, OpenCV, and Tesseract libraries.

References:

[1] Chen, Huizhong, et al. “Robust Text Detection in Natural Images with Edge-Enhanced Maximally Stable Extremal Regions.” Image Processing (ICIP), 2011 18th IEEE International Conference on. IEEE, 2011.

[2] Automatically Detect and Recognize Text in Natural Images

### Like this:

Like Loading...

Awesome work! I’ve barely started getting my hands dirty with Octave’s vlfeat package. The mser filter they provide works marvelous, but as you’ve stated in this post, matlab has those two undocumented commands. I’ve been “trying” (more like blindly hacking) to come up with a pure Octave solution but to no avail. Have you tried taking a stab at this problem in the Octave domain? Best,

Rodrigo

Sadly at first, I did try to port the thing using Octave.

And since I’m fairly new to Octave, and found out that many functions on Matlab are not available on Octave (whether it’s because it’s not ported yet, or it’s copyright issue), thus i decided to shift my focus to OpenCV, which I’m bit more familiar with.

I really wish that Matlab would just release their older version (e.g. 2012 ver), for free or something, and without any support. Octave is lagging way behind at times.

Absolutely right, kind of a shame that their products are all closed and costly.

Just got your project up and running and I’d like to merge some of the auto-box-detection functionality implemented here:

https://github.com/mmackh/MAImagePickerController-of-InstaPDF/blob/master/instaoverlay/MAImagePickerController/MAImagePickerControllerAdjustViewController.mm

which references this SO post:

http://stackoverflow.com/questions/8667818/opencv-c-obj-c-detecting-a-sheet-of-paper-square-detection

If you’re interested, I can keep you posted, and if so (and if you don’t mind) I’d like to shoot over some questions related to opencv (as I’m a novice in the area of computer vision & image processing). Farewell!

Yeah, please keep me posted. But sadly since I’m busy with my day job, and with long commute time, I probably won’t be able to reply as frequent. Maybe I have more free time during weekends.

Actually, i have the matlab 2014a … but this function ( helperGrowEdges) still not working.

any suggestions please?

Sadly I never have matlab, so I don’t even know if it even works in the first place.

Saburo, thanks for posting this code. It can be difficult to find good OpenCV examples that are non-trivial. This MSER style segmentation of regions is kind of like my most recent blog post which shows OpenCV code for image segmentation based on superpixel segmentation merging. Have a looksie at http://www.modejong.com/blog/post14_OpenCV_segmentation/index.html if you are interested.