Advertisement
Guest User

Untitled

a guest
Nov 20th, 2014
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. #include <opencv2/core/core.hpp>
  2. #include <opencv2/imgproc/imgproc.hpp>
  3. #include <opencv2/highgui/highgui.hpp>
  4. #include <math.h>
  5.  
  6. using namespace cv;
  7. int pos_kernel_size=21;
  8. int pos_sigma= 5;
  9. int pos_lm = 50;
  10. int pos_th = 0;
  11. int pos_gamma= 0;
  12. int pos_psi = 90;
  13.  
  14. Mat src_f;
  15. Mat dest;
  16.  
  17. void Process(int , void *)
  18. {
  19. int kernel_size=(pos_kernel_size-1)/2;
  20.  
  21. Size KernalSize(kernel_size,kernel_size);
  22. double Sigma = pos_sigma;
  23. double Lambda = 0.5+pos_lm/100.0;
  24. double Theta = pos_th*CV_PI/180;
  25. double psi = pos_psi*CV_PI/180;;
  26. double Gamma = pos_gamma;
  27.  
  28. Mat kernel = getGaborKernel(KernalSize, Sigma, Theta, Lambda,Gamma,psi);
  29. filter2D(src_f, dest, CV_32F, kernel);
  30. imshow("Process window", dest);
  31. Mat Lkernel(kernel_size*20, kernel_size*20, CV_32F);
  32. resize(kernel, Lkernel, Lkernel.size());
  33. Lkernel /= 2.;
  34. Lkernel += 0.5;
  35. imshow("Kernel", Lkernel);
  36. Mat mag;
  37. pow(dest, 2.0, mag);
  38. imshow("Mag", mag);
  39. }
  40.  
  41. int main(int argc, char** argv)
  42. {
  43. Mat image = imread("Gabor.bmp",0);
  44. cv::imshow("Src", image);
  45.  
  46. image.convertTo(src_f, CV_32F, 1.0/255, 0);
  47.  
  48. if (!pos_kernel_size%2)
  49. {
  50. pos_kernel_size+=1;
  51. }
  52. cv::namedWindow("Process window", 1);
  53. cv::createTrackbar("Sigma", "Process window", &pos_sigma, pos_kernel_size, Process);
  54. cv::createTrackbar("Lambda", "Process window", &pos_lm, 100, Process);
  55. cv::createTrackbar("Theta", "Process window", &pos_th, 180, Process);
  56. cv::createTrackbar("Psi", "Process window", &pos_psi, 360, Process);
  57. cv::createTrackbar("Gamma", "Process window", &pos_gamma, 100, Process);
  58. Process(0,0);
  59. waitKey(0);
  60. return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement