Quantcast
Viewing all articles
Browse latest Browse all 53

Grayscale to Lbp image

[Actual output](/upfiles/137882303996361.png) [Desired output](/upfiles/13788229926776895.jpg) 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(i,j); int pp=0; int po=7; if(cp<=(int)greyMat.at(i,j+1)) pp+=pow(2,po); po--; if(cp<=(int)greyMat.at(i+1,j+1)) pp+=pow(2,po); po--; if(cp<=(int)greyMat.at(i+1,j)) pp+=pow(2,po); po--; if(cp<=(int)greyMat.at(i+1,j-1)) pp+=pow(2,po); po--; if(cp<=(int)greyMat.at(i,j-1)) pp+=pow(2,po); po--; if(cp<=(int)greyMat.at(i-1,j-1)) pp+=pow(2,po); po--; if(cp<=(int)greyMat.at(i-1,j)) pp+=pow(2,po); po--; if(cp<=(int)greyMat.at(i-1,j+1)) pp+=1*pow(2,po); po--; lbp.at(i,j)=pp; } } return 0; }

Viewing all articles
Browse latest Browse all 53

Trending Articles