我是c ++的新手,我正在尝试使用“单独的标题和实现文件”来实现A血管分割技术,如:
http://www.cppforschool.com/tutorial/separate-header-and-implementation-files.html
我的问题是,在主文件中如何使用全0来初始化空的3D矩阵。
Main.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));///
}
}
}
}
Match.cpp
#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
filter.h
int main(){
filter match_kernel;
match_kernel.kernel(& mascara);
在 main.cpp 文件中,我们不知道如何用全0来初始化3D矩阵
COUNTBLANK