optimized cv::countNonZero