OpenCV primitive algorithms in C