Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <opencv2/core/core.hpp>
- #include "filter.h"
- #include <iostream>
- using namespace std;
- using namespace cv;
- int main(){
- filter match_kernel;
- match_kernel.kernel(& mascara);
- return 0;
- }
- #include <iostream>
- #include <string>
- #include <math.h>
- #include <opencv2/core/core.hpp>
- #include <fstream>
- #include "filter.h"
- #define PI 3.14159265359
- using namespace std;
- void filter::kernel(float *mascara){
- using namespace cv;
- int center=7;
- int sizes[] = {15, 15, 12};
- double angi=(PI/12.0);
- double mi=0.0;
- int counter=0;
- int x=0;
- int y=0;
- double u=0.0;
- double v=0.0;
- double cof=0.0;
- Mat matriz(3, sizes,CV_32FC1, mascara);
- counter=0;
- mi=0;
- for (int z = 0; z < 12; z++){
- Mat masc = Mat::zeros(15,15, CV_32FC1);
- counter = 0;
- mi = 0.0;
- for (int i = 0; i < 15; i++){
- for (int j = 0; j < 15; j++){
- x=i-center;
- y=j-center;
- u=x*cos(z*angi)+y*sin(z*angi);
- v=-x*sin(z*angi)+y*cos(z*angi);
- if(abs(u)<=6.0 && abs(v)<=4.5){
- cof=-exp(-pow(u,2.0)/(8.0));
- matriz.at<float>(i, j, z)=cof;
- masc.at<float>(i, j)=1.0;
- mi += cof;
- counter += 1;
- }
- }
- }
- mi=mi/counter;
- cout<<"mi"<<mi <<endl;
- for(int i = 0; i < 15; i++){
- for(int j = 0; j < 15; j++){
- matriz.at<float>(i, j, z)=(masc.at<float>(i, j))*round(10.0*(matriz.at<float>(i, j, z)-mi));///
- }
- }
- }
- }
- #include <opencv2/core/core.hpp>
- #ifndef __FILTER_H__
- #define __FILTER_H__
- using namespace std;
- class filter{
- public:
- filter(){}
- void kernel(float *mascara);
- private:
- cv::mascara=Scalar::all(0);
- };
- #endif
- int main(){
- filter match_kernel;
- match_kernel.kernel(& mascara);
Add Comment
Please, Sign In to add comment