Ask Your Question

# Leo_'s profile - activity

 2018-11-27 15:20:59 -0500 received badge ● Popular Question (source) 2018-07-29 09:02:11 -0500 received badge ● Notable Question (source) 2017-09-17 12:52:04 -0500 received badge ● Popular Question (source) 2016-01-31 15:45:27 -0500 received badge ● Student (source) 2015-10-13 16:51:16 -0500 commented answer Comparing 2 LBPs Great answer. Implemented this and getting great results. 2015-10-13 16:51:09 -0500 commented answer Comparing 2 LBPs Great answer. Implemented this and getting great results. 2015-10-13 16:50:38 -0500 received badge ● Scholar (source) 2015-10-12 11:25:13 -0500 asked a question Comparing 2 LBPs I am using code from bytefish.de to generate my LBPs. If I generate 2 LBPs and their corresponding histograms, what is the best way to compare them? This is my code so far: #include "lbp.hpp" #include "histogram.hpp" #include #include "opencv2/highgui/highgui.hpp" #include "opencv2/imgproc/imgproc.hpp" using namespace cv; int main() { //template image Mat temp = imread("Template.jpg",1); //image to be compared to Mat match = imread("Match.jpg",1); Mat dst,dst2; // image after preprocessing Mat lbp,lbp2; // lbp image Mat hist,hist2; //Convert to gray cvtColor(temp, dst, 6); cvtColor(match, dst2, 6); //remove noise GaussianBlur(dst, dst, Size(5,5), 5, 3, BORDER_CONSTANT); GaussianBlur(dst2, dst2, Size(5,5), 5, 3, BORDER_CONSTANT); //gets the lbp lbp::ELBP(dst,lbp,1,8); lbp::ELBP(dst2,lbp2,1,8); // normalize(lbp2, lbp2, 0, 255, NORM_MINMAX, CV_8UC1); //normalize(lbp, lbp, 0, 255, NORM_MINMAX, CV_8UC1); //get histograms lbp::histogram(lbp,hist,255); lbp::histogram(lbp2,hist2,255); //comparing the 2 LBP histograms double compareHist = cv::norm(hist-hist2); cout< void lbp::OLBP_(const Mat& src, Mat& dst) { dst = Mat::zeros(src.rows-2, src.cols-2, CV_8UC1); for(int i=1;i(i,j); unsigned char code = 0; code |= (src.at<_Tp>(i-1,j-1) > center) << 7; code |= (src.at<_Tp>(i-1,j) > center) << 6; code |= (src.at<_Tp>(i-1,j+1) > center) << 5; code |= (src.at<_Tp>(i,j+1) > center) << 4; code |= (src.at<_Tp>(i+1,j+1) > center) << 3; code |= (src.at<_Tp>(i+1,j) > center) << 2; code |= (src.at<_Tp>(i+1,j-1) > center) << 1; code |= (src.at<_Tp>(i,j-1) > center) << 0; dst.at(i-1,j-1) = code; } } } template void lbp::ELBP_(const Mat& src, Mat& dst, int radius, int neighbors) { neighbors = max(min(neighbors,31),1); // set bounds... // Note: alternatively you can switch to the new OpenCV Mat_ // type system to define an unsigned int matrix... I am probably // mistaken here, but I didn't see an unsigned int representation // in OpenCV's classic typesystem... dst = Mat::zeros(src.rows-2*radius, src.cols-2*radius, CV_32SC1); for(int n=0; n(radius) * cos(2.0*M_PI*n/static_cast(neighbors)); float y = static_cast(radius) * -sin(2.0*M_PI*n/static_cast(neighbors)); // relative indices int fx = static_cast(floor(x)); int fy = static_cast(floor(y)); int cx = static_cast(ceil(x)); int cy = static_cast(ceil(y)); // fractional part float ty = y - fy; float tx = x - fx; // set interpolation weights float w1 = (1 - tx) * (1 - ty); float w2 = tx * (1 - ty); float w3 = (1 - tx) * ty; float w4 = tx * ty; // iterate through your data for(int i=radius; i < src.rows-radius;i++) { for(int j=radius;j < src.cols-radius;j++) { float t = w1*src.at<_Tp>(i+fy,j+fx) + w2*src.at<_Tp>(i+fy,j+cx) + w3*src.at<_Tp>(i+cy,j+fx) + w4*src.at<_Tp>(i+cy,j+cx); // we are dealing with floating point precision, so add some little tolerance dst.at(i-radius,j-radius) += ((t > src.at<_Tp>(i,j)) && (abs(t-src.at<_Tp>(i,j)) > std::numeric_limits::epsilon())) << n; } } } } template void lbp::VARLBP_(const Mat& src, Mat& dst, int radius, int neighbors) { max(min(neighbors,31),1); // set bounds dst = Mat::zeros(src.rows-2*radius, src.cols-2*radius, CV_32FC1); //! result // allocate some memory for temporary on-line variance calculations Mat _mean = Mat::zeros(src ... 2015-10-04 10:04:41 -0500 received badge ● Enthusiast 2015-10-03 12:02:52 -0500 commented question Texture Matching using LBP/H? C++ @theodore there are some coins without text or numbers. So I need to do texture matching. 2015-10-03 11:34:52 -0500 asked a question Texture Matching using LBP/H? C++ I have a question about LBPs, but firstly let me explain what I am trying to do. I am trying to match coins using LBPs. I have an input coin and I want to compare it with other coins and see if the coin is of the same denomination. Attached below are 3 images: R1 - the input image - the one to be compared to R1T - needs to be compared to R1 R2T - needs to be compared to R1 I have found a very good source here: Local Binary Patterns All my code needs to simply do is say that R1T is a match and R2T is not a match. How can I implement something like this? Thanks Images: Thumbnails R1 R1T R2T 2015-09-21 07:58:41 -0500 received badge ● Supporter (source) 2015-09-21 07:30:14 -0500 commented answer Template Matching for Coins Thank you for the articles. I will have a look at them. I have updated my question by adding a few images. Maybe to clarify in what I am asking. 2015-09-21 07:27:52 -0500 received badge ● Editor (source) 2015-09-21 04:34:48 -0500 asked a question Template Matching for Coins I am undertaking a project that will automatically count values of coins from an input image. So far I have segmented the coins using some pre-processing with edge detection and using the Hough-Transform. My question is how do I proceed from here? I need to do some template matching on the segmented images based on some previously stored features. How can I go about doing this. I have also read about something called K-Nearest Neighbours and I feel it is something I should be using. But I am not too sure how to go about using it. Research articles I have followed: 2015-09-20 04:01:14 -0500 commented question Matching HOG Images with OpenCV in C++ @LorenaGdL basically I want to input an image with various different coins and I want it to identify each coin correctly and perhaps give a total value of the coins on screen. Basically I've segmented each coin using a hough transform, however how do I say that that coin (segmented) is actually a 10c or 50c etc? 2015-09-12 16:06:21 -0500 commented question Matching HOG Images with OpenCV in C++ @LorenaGdL What would you suggest instead of HOG? 2015-09-10 00:46:46 -0500 asked a question Matching HOG Images with OpenCV in C++ I have currently implemented a way to calculate HOG descriptors using cv::HOGDescriptor() . I have done this for two images and calculated a similarity index between the two images using a basic distance measure. A good match is something I define as a similarity value below 50. A perfect match has a similarity value of 0 However, when comparing these two almost identical images, I get confusing results (i.e. a high value). Below attached is my code and the 2 images. Can anyone please tell me what is going wrong? i.e. Why is there a high similarity value when the images are very similar.  #include #include #include #include #include "opencv2/ocl/ocl.hpp" #include "opencv2/highgui/highgui.hpp" using namespace std; using namespace cv; int main() { Mat image(imread("R2.jpg",1)); resize(image, image, Size(64,128) ); Mat img; cvtColor(image, img, CV_RGB2GRAY); Mat image2(imread("R2-roi.jpg",1)); resize(image2, image2, Size(64,128) ); Mat img2; cvtColor(image2, img2, CV_RGB2GRAY); vector features; vector locations; vector features2; vector locations2; HOGDescriptor *hog = new HOGDescriptor(); HOGDescriptor *hog2 = new HOGDescriptor(); hog->compute(img,features,Size(32,32), Size(0,0),locations); cout<compute(img2,features2,Size(32,32), Size(0,0),locations2); cout<(i,0)=features.at(i); Mat Hogfeat2; Hogfeat2.create(features2.size(),1,CV_32FC1); for(int i=0; i(i,0)=features2.at(i); double distance=0; for(int i=0; i(i,0) - Hogfeat2.at(i,0)); } cout << distance <