Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

why the result of filter2D function is correct on cpu and wrong on gpu??

The processing on the GPU give me wrong result and noise(not randomly). This is my code :

Mat ker(3,3,CV_8S);

// gain=0 ker.at<char>(0,0)=-(1+gain),ker.at<char>(0,1)=-(1+gain),ker.at<char>(0,2)=-(1+gain); ker.at<char>(1,0)=-(1+gain),ker.at<char>(1,1)=(1+gain)8,ker.at<char>(1,2)=-(1+gain); ker.at<char>(2,0)=-(1+gain),ker.at<char>(2,1)=-(1+gain),ker.at<char>(2,2)=-(1+gain); Mat test(taille,taille,CV_8UC1,125); for(int x=0;x<taille;x++) {="" for(int="" y="0;y&lt;taille;y++)" {="" test.at<uchar="">(y,x)=((x%2)^(y%2))255; //corect test.at<uchar>(y,x)=x+y; } } Mat res; Mat temp; test.copyTo((temp,test)); GpuMat resgpu(test);

test.copyTo(res,test);
filter2D(res,res,res.depth(),ker);
filter2D(resgpu,resgpu,resgpu.depth(),ker);

vector<int> compression_params; compression_params.push_back(CV_IMWRITE_JPEG_QUALITY ); compression_params.push_back(100);

imwrite("aze.jpg",test,compression_params);
imwrite("aze_filtre.jpg",res,compression_params);
imwrite("aze_filtre_gpu.jpg",Mat(resgpu),compression_params);

// correct:cpu: image description:

//wrong:gpu: image description

why the result of filter2D function is correct on cpu and wrong on gpu??

The processing on the GPU give me wrong result and noise(not randomly). This is my code :

Mat ker(3,3,CV_8S);

// gain=0 ker.at<char>(0,0)=-(1+gain),ker.at<char>(0,1)=-(1+gain),ker.at<char>(0,2)=-(1+gain); ker.at<char>(1,0)=-(1+gain),ker.at<char>(1,1)=(1+gain)8,ker.at<char>(1,2)=-(1+gain); ker.at<char>(1,0)=-(1+gain),ker.at<char>(1,1)=(1+gain)*8,ker.at<char>(1,2)=-(1+gain); ker.at<char>(2,0)=-(1+gain),ker.at<char>(2,1)=-(1+gain),ker.at<char>(2,2)=-(1+gain); Mat test(taille,taille,CV_8UC1,125); for(int x=0;x<taille;x++) { for(int x=0;x<taille;x++) {="" for(int="" y="0;y&lt;taille;y++)" {="" test.at<uchar="">(y,x)=((x%2)^(y%2))255; //corect y=0;y<taille;y++) { // test.at<uchar>(y,x)=((x%2)^(y%2))*255; //corect test.at<uchar>(y,x)=x+y; } } Mat res; Mat temp; test.copyTo((temp,test)); GpuMat resgpu(test);

resgpu(test);
test.copyTo(res,test);
filter2D(res,res,res.depth(),ker);
filter2D(resgpu,resgpu,resgpu.depth(),ker);

vector<int> compression_params; compression_params.push_back(CV_IMWRITE_JPEG_QUALITY ); compression_params.push_back(100);

compression_params.push_back(100);
imwrite("aze.jpg",test,compression_params);
imwrite("aze_filtre.jpg",res,compression_params);
imwrite("aze_filtre_gpu.jpg",Mat(resgpu),compression_params);

// correct:cpu:

image description:

//wrong:gpu: wrong:gpu:

image description