std::min and std::max are always available in C++ code; please, use them. Also, OpenCV declares MIN and MAX macros.