Rewrote the code to more recent OpenCV standard. Working on tresholding in CIELab space.