Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

cvtColor vs. manual conversion time

Why is cvtColort ~10 times faster than:

float coeffs[3];
coeffs[0] = 0;
coeffs[1] = 1;
coeffs[2] = 0;

gray = Mat(color.rows, color.cols, CV_8UC1);

for (int i = 0; i < color.rows; i++) {
    for (int j = 0; j < color.cols; j++) {
        gray.at<uchar>(i, j) = 0;
        for (int k = 0; k < 3; k++) {
            gray.at<uchar>(i, j) += coeffs[k] * color.at<Vec3b>(i, j)[k];
        }
    }
}

I tried changing row/col for order but it does not change the time.