Grayscale to Lbp image
Actual output Desired output Hi friends i am trying to implement paper on Rapid texture Based Moving Object Detection So in this the first step is to convert grayscale image to lbp image so i have written the following code but it is not producing the desired output So Please if anybody having proper code provide it or state correction in my code.
int main() {
Mat img = cv::imread("im1.jpg");
if (img.empty())
{
std::cout << "Cannot open image!" << std::endl;
return -1;
}
Mat greyMat;
cvtColor(img, greyMat, CV_BGR2GRAY);
Mat lbp=greyMat.clone();
long row=greyMat.rows;
long col=greyMat.cols;
for(int i=1;i<greyMat.rows;i++)
{
for(int j=1;j<greyMat.cols;j++)
{
int cp=(int)greyMat.at<uchar>(i,j);
int pp=0;
int po=7;
if(cp<=(int)greyMat.at<uchar>(i,j+1))
pp+=pow(2,po);
po--;
if(cp<=(int)greyMat.at<uchar>(i+1,j+1))
pp+=pow(2,po);
po--;
if(cp<=(int)greyMat.at<uchar>(i+1,j))
pp+=pow(2,po);
po--;
if(cp<=(int)greyMat.at<uchar>(i+1,j-1))
pp+=pow(2,po);
po--;
if(cp<=(int)greyMat.at<uchar>(i,j-1))
pp+=pow(2,po);
po--;
if(cp<=(int)greyMat.at<uchar>(i-1,j-1))
pp+=pow(2,po);
po--;
if(cp<=(int)greyMat.at<uchar>(i-1,j))
pp+=pow(2,po);
po--;
if(cp<=(int)greyMat.at<uchar>(i-1,j+1))
pp+=1*pow(2,po);
po--;
lbp.at<uchar>(i,j)=pp;
}
}
return 0;
}
Please avoid hashtags in your tags, since this creates doubles which is inefficient for the forum search. Also, dont open the same topic 3 times.
can you a bit more explicit about what is wrong with the output ?
here's the code from the facerecognizer
are you trying something similar to this ?
Sorry this is my first time so got confused with tags.
@berak I have sample input and output.But after executing i am getting different output. will u please give ur Email Id so that i can mail u images and code.
you can even attach images here ;) just re-edit your question, there's a button-bar there, the image one is the middle one
sure, we can start a private ([email protected]) discussion.
but you'll want as much help as possible from people on this site, too, don't you ?