在opencv里生成每层的高斯金字塔程序推出

在Opencv里,计算图像的特征,生成高斯金字塔,出现退出现象。

//初始化金字塔结构体
void initPyr(GaussPyr *p)
{
for (int j= 0; j< 9; j++)
p->lev[j] = cvCreateImage(PyrSize[i], IPL_DEPTH_64F, 1);
}

运行:
GaussPyr Pyr_I;
initPyr(&Pyr_I);
Gscale(&Pyr_I,Intensity,9,1.6);会报错推出,下面是Gscale函数:

//计算并产生一幅图的高斯金字塔 每层的图像
void Gscale(GaussPyr *p, IplImage *data, int level, double sigma)
{
for (int i = 0; i < level; i++)
{
if (i == 0)
cvSmooth(data, p->lev[0], CV_GAUSSIAN, 5, 5, sigma, 0);
else
{
IplImage *tem = cvCreateImage(PyrSize[i - 1], IPL_DEPTH_64F, 1);
cvSmooth(p->lev[i - 1], tem, CV_GAUSSIAN, 5, 5, sigma, 0);
for (int a = 0; a < PyrSize[i].height; a++)
{
for (int b = 0; b < PyrSize[i].width; b++)
{
//请问下面这行代码,在i,j没有遍历完就意外退出程序
((double *)(p->lev[i]->imageData + a * p->lev[i]->widthStep))[b] = ((double )(tem->imageData + 2 * atem->widthStep))[2 * b];
}
}
//cout << count << endl;
//cout << PyrSize[i].height << endl;
}
}
}


图像金字塔(高斯金字塔,拉普拉斯金字塔)