Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

LBP with HSV is not working.

So I tried to use the bytefish code again and tried to run it for color images, HSV, RGB, but the result does not show up well. What I did is load in the image as RGB. Pass the CV_8UC3 as Vec3b. Use the ELBP to compute individual bit for R, G, and B as shown below. But the image looks bad either as HSV or RGB. RGB gets a distance result with Kullback but the image does not match. HSV gets negative value which is not supposed to happen. Does this code not work for color images?

void lbp::ELBP(const Mat& src, Mat& dst, int radius, int neighbors) {
    switch(src.type()) {
        case CV_8UC3: ELBPA_<cv::Vec3b>(src, dst, radius, neighbors); break;
    }
}

for(int i=radius; i < src.rows-radius;i++) {
            for(int j=radius;j < src.cols-radius;j++) {
                for(int k=0; k<3; k++)
                {
                float t = w1*src.at<_Tp>(i+fy,j+fx)[k] + w2*src.at<_Tp>(i+fy,j+cx)[k] + w3*src.at<_Tp>(i+cy,j+fx)[k] + w4*src.at<_Tp>(i+cy,j+cx)[k];
                // we are dealing with floating point precision, so add some little tolerance
                dst.at<cv::Vec3b>(i-radius,j-radius)[k] += ((t > src.at<_Tp>(i,j)[k]) && (abs(t-src.at<_Tp>(i,j)[k]) > std::numeric_limits<float>::epsilon())) << n;
                }
            }
        }

image description