I'm new to c++, and I'm trying to implement A vessel segmentation technique using "Separate Header and Implementation Files" like:
http://www.cppforschool.com/tutorial/separate-header-and-implementation-files.html
My question is, in the main file how to initialize with all 0's the empty 3D matrix.
Main.cpp
#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;
}
Match.cpp
#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));///
}
}
}
}
filter.h
#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
In the main.cpp file, we don't know how to initialize the 3D matrix with all 0's
int main(){
filter match_kernel;
match_kernel.kernel(& mascara);