Ask Your Question

Revision history [back]

how compare pixels?

I write LBP algorithm. I need compare pixels. I do it correctly?

std::vector<int>s;
cv::Vec3b middelPixel = frame.at<cv::Vec3b>(i0 + 1, j0 + 1);
for (size_t i = i0; i < i0 + 3; i++)
{
    for (size_t j = j0; j < j0 + 3; j++)
    {
        cv::Vec3b tempPixel = frame.at<cv::Vec3b>(i, j);
        if ((int)middelPixel[0] + (int)middelPixel[1] + (int)middelPixel[2] >= (int)tempPixel[0] + (int)tempPixel[1] + (int)tempPixel[2])
            s.push_back(1);
        else
            s.push_back(0);
    }
}

{i0, j0} = {0, 0}, {0, 3}, {0, 6}....{3,0},..., {6,0}...