Guest User

Untitled

a guest
Jan 22nd, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. #include <opencv2/core/core.hpp>
  2. #include "filter.h"
  3. #include <iostream>
  4. using namespace std;
  5. using namespace cv;
  6.  
  7.  
  8. int main(){
  9. filter match_kernel;
  10. match_kernel.kernel(& mascara);
  11.  
  12. return 0;
  13. }
  14.  
  15. #include <iostream>
  16. #include <string>
  17. #include <math.h>
  18. #include <opencv2/core/core.hpp>
  19. #include <fstream>
  20. #include "filter.h"
  21. #define PI 3.14159265359
  22. using namespace std;
  23.  
  24. void filter::kernel(float *mascara){
  25.  
  26. using namespace cv;
  27.  
  28. int center=7;
  29. int sizes[] = {15, 15, 12};
  30. double angi=(PI/12.0);
  31. double mi=0.0;
  32. int counter=0;
  33. int x=0;
  34. int y=0;
  35.  
  36. double u=0.0;
  37. double v=0.0;
  38. double cof=0.0;
  39. Mat matriz(3, sizes,CV_32FC1, mascara);
  40.  
  41. counter=0;
  42. mi=0;
  43.  
  44. for (int z = 0; z < 12; z++){
  45. Mat masc = Mat::zeros(15,15, CV_32FC1);
  46. counter = 0;
  47. mi = 0.0;
  48. for (int i = 0; i < 15; i++){
  49. for (int j = 0; j < 15; j++){
  50. x=i-center;
  51. y=j-center;
  52. u=x*cos(z*angi)+y*sin(z*angi);
  53. v=-x*sin(z*angi)+y*cos(z*angi);
  54. if(abs(u)<=6.0 && abs(v)<=4.5){
  55. cof=-exp(-pow(u,2.0)/(8.0));
  56. matriz.at<float>(i, j, z)=cof;
  57. masc.at<float>(i, j)=1.0;
  58. mi += cof;
  59. counter += 1;
  60. }
  61. }
  62. }
  63. mi=mi/counter;
  64. cout<<"mi"<<mi <<endl;
  65. for(int i = 0; i < 15; i++){
  66. for(int j = 0; j < 15; j++){
  67. matriz.at<float>(i, j, z)=(masc.at<float>(i, j))*round(10.0*(matriz.at<float>(i, j, z)-mi));///
  68. }
  69. }
  70.  
  71. }
  72. }
  73.  
  74. #include <opencv2/core/core.hpp>
  75. #ifndef __FILTER_H__
  76. #define __FILTER_H__
  77.  
  78. using namespace std;
  79. class filter{
  80. public:
  81. filter(){}
  82. void kernel(float *mascara);
  83.  
  84. private:
  85. cv::mascara=Scalar::all(0);
  86.  
  87. };
  88.  
  89. #endif
  90.  
  91. int main(){
  92. filter match_kernel;
  93. match_kernel.kernel(& mascara);
Add Comment
Please, Sign In to add comment