Adaptive thresholding experiment
Hello, World!
My name is Tomohiko Koyama aka Saqoosha. I think everyone knows me as a developer of FLARToolKit. I joined JActionScripters.com too, and I hope that Japanese Flashers are exposed to the world more and more. My English is not so good. If you find a mistake, please correct me.
Recently, I researched about Thresholding algorithms. Thresholding algorithms are used to binarize and preprocess the input to find some objects within the image. FLARToolKit uses a thresholding algorithm to detect the marker.
The algorithm currently using in FLARToolKit is Global Thresholding.

Its implementation is simple and faster, but no flexibility about illumination variation. I looked for a thresholding algorithm to improve this weak point. Then found Adaptive Thresholding.
Adaptive thresholding doesn’t use constant thresholding values as with Global thresholding. Thresholding value is calculated for each pixel using surrounding pixels. It’s result is amazingly adaptive to various illumination. Please watch this video.
Upper is the source video. Left is global thresholding, and right is adaptive thresholding. The marker (square at the center) is always visible in adaptive thresholding result. It’s using BlurFilter to calculate local thresholding value. Source code is here. Online demo (requires webcam) is also uploaded. Use up and down arrow keys to simulate illumination variation.
Makc3d already implemented this method into FLARToolKit, but I think it’s required more optimization to reduce calculation time.
The future version of FLARToolKit will include Adaptive thresholding filter to adapt to various illumination.
6 Comments
One obvious optimisation would be reducing dimensions of image with draw (,matrix) instead of blur, but still the main problem remains to be increased amount of details that FLARToolKit gets to deal with, so the problem is not really in the filter.
Btw, what happened to http://saqoosha.net/en?
> mack
I saw your code and tested. Reducing processing area is very efficient way. but the result image is more complicated than constant thresholding’s. so it takes mare cpu time to labeling it. it’s not problem during when marker is detecting, but when lost the marker, search area become very large and takes long time to detect.
http://saqoosha.net/en isn’t proper url. I fixed to redirect to http://saqoosha.net/en/ . Thank you!
that was not the reduction I was talking about, but any way – what choice do we have? if the marker is lost, the entire image area has to be searched. in this case, you can have better frame rate by looking into part of whole image at a time, but this also means you will have several frames with marker undetected while still being there. or, you could use global threshold based on last known local threshold value at the marker area, but there is fairly good chance that you will not find marker with it any way. finally, what artoolkitplus folks did – randomize threshold until you find something – good and simple, but again, you have frames with marker undetected even though it is there.
[...] Study – Recreating LCD Panels / Trinitron Like Matrices by Jun Saburi Adaptive thresholding experiment by [...]
[...] Its amazing how much flow those guys have right now: beside the daily updates at the Spark Project, their own blog posts in japanese and the work on new projects, they produced in the 4 days its online already about 10 quite interesting blog posts about things like fractal painting, lcd effect, vector multiplication or adaptive thresholding. [...]
[...] (one value for all pixels). Saqoosha (the japanese creator of the FLARToolkit) did a little experiment with adaptive thresholding and based on his code I altered the FLARRasterFilter_BitmapDataThreshold [...]