you can avoid division by 255 here. just replace line 78 by accuracy = (float)cv::countNonZero(_p_labels_temp == _o_labels_temp)/_p_labels_temp.rows;