| 
UID:114173
注册时间2011-03-28最后登录2011-05-29在线时间10小时
发帖28搜Ta的帖子精华0
金钱280威望38贡献值0好评度28
访问TA的空间加好友用道具
     | 
 
本人是一名大四学生,毕业设计选了与嵌入式有关的课题——基于嵌入式的图像处理算法研究。老师让我设计一个在开发板上运行的图像处理软件。我就用Qt进行了设计,在加入并调用 图像锐化 sharp() 子函数是出现了一下问题(该子函数不是自己写的):
 Program received signal SIGSEGV, Segmentation fault.sharp()子函数如下:0x0804c048 in ImageProcessing::sharp() ()
 
 
 void ImageProcessing::sharp(){    int w = sourceImage.width();    int h = sourceImage.height();    if(NULL == sourceImageData)//判断是否需要读取数据    {        std::complex<double>*sourceImageData = new std::complex<double>[w*h];        readImage(sourceImageData,sourceImage);    }    //拷贝一份数据便与计算    std::complex<double>*buffer = new std::complex<double>[w*h];    memcpy(buffer,sourceImageData,sizeof(std::complex<double>)*w*h);    //根据模板进行计算    //为了简化编码忽略了图像边界(i=0 or h,h=0 or w),对于整体效果没有影响    int i,j;    std::complex<double>k;    for(i=1;i<h-1;i++)    {        for(j=1;j<w-1;j++)        {            k = buffer[i*w+j];            k = std::complex<double>(k.real()*5,0);            k -=buffer[(i-1)*w+j];            k -= buffer[i*w+j-1];            k -=buffer[i*w+j+1];            k -=buffer[(i+1)*w+j];            sourceImageData[i*w+j] = k;        }    }    writeImage(sourceImage,sourceImageData,1);    destinationlabel->setPixmap(QPixmap::fromImage(sourceImage));    }
该函数是ImageProcessing的槽函数, sourceImageData在ImageProcessing定义:
 
        ……自己分析觉得可能是 sourceImageData指针为初始化的问题。std::complex <double>*sourceImageData;
 
 但是如果进行如下初始化后,问题仍然存在:
 
           sourceImageData = new std::complex <double>(NULL);问题变为:
 
           Program received signal SIGSEGV, Segmentation fault.0x013662d8 in XCreateGC () from /usr/lib/i386-linux-gnu/libX11.so.6
 
 
 注:程序在加入这段代码前是可以执行 的,而且加入后编译 也没有 任何问题,只有在执行中调用该函数时出现错误 。 跪求各位大侠指点,小弟不胜感激!!!!!!!!!!
 
 |