how compare pixels?

asked 2019-01-26 04:36:04 -0500

Sartogersofortotropher gravatar image

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}...

edit retag flag offensive close merge delete

Comments

2

have a look here

you should do this on single channel (grayscale) images, not on bgr ones.

you also have to spare the "middle" element, since that's already the center pixel (that's actually wrong above !)

but if you do it like this, don't forget, that you have to spare 3 pixels, at the right / bottom border of your image !

berak gravatar imageberak ( 2019-01-26 04:56:26 -0500 )edit

@berak, Thank you!!!

Sartogersofortotropher gravatar imageSartogersofortotropher ( 2019-01-26 06:50:01 -0500 )edit