LBP with HSV is not working. [closed]
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;
}
}
}
I want to do a similar texture comparison but with color and shape, not just gray image with shape only. Well, it is calculated base on 3 different channels from k=0 to k=2. But it seems this code does not work for the color images, I might have to find another one.
On second thought, maybe my image is correct but I need a different histogram comparison this time.
Man, there's no color and shape analysis, does it mean it's not doable?
hmm ? what is not doable ?
btw, what exactly are you trying to compare ? textures ? faces ?
if you want colour involved, maybe you need a different mechanism than lbp, e.g. filter convolutions ?
(machine learning is large, you barely scratched the surface...)
Right well, I am thinking of doing Gabor filter, but does it apply for color images (color + shape)? For 2D textures, not faces.
yes, gabor filters will work with color images.
Just a small remark, I notice you keep telling us you are reading in RGB images. Keep in mind that OpenCV reads in BGR images, certainly when you will be matching seperate channels, so that results will not be as expected from a RGB image. Like @berak said, you might need something else here.