Ask Your Question
0

after applying cv::xphoto::bm3dDenoising ; imshow is giving insertion error

asked 2018-07-28 14:09:57 -0600

nobot gravatar image

updated 2018-07-30 00:05:29 -0600

I am simply trying to apply bm3dDenoising filter, below is my code

img = imread("/home/odroid/Downloads/t2.bmp");
cvtColor(img, gray, COLOR_BGR2GRAY);

    Mat img, gray, gray1,gray2
    float h = 1;
    int templateWindowSize = 4;
    int searchWindowSize = 16;
    int blockMatchingStep1 = 2500;
    int blockMatchingStep2 = 400;
    int groupSize = 8;
    int slidingStep = 1;
    float beta = 2.0f;
    int normType = cv::NORM_L2;
    int step = cv::xphoto::BM3D_STEPALL;
    int transformType = cv::xphoto::HAAR ;

imshow("b4_gray_image", gray);              //1

cv::xphoto::bm3dDenoising (gray, gray1, gray2, h, templateWindowSize, searchWindowSize, blockMatchingStep1, blockMatchingStep2, groupSize, slidingStep, beta, normType, step, transformType);

imshow("after_gray_image", gray);           //2
imshow("dst1", gray1);                              //3
imshow("dst2", gray2);                              //4
waitKey();

return 0;

When I am compiling it doesn't give error, but during runtime its giving the following assertion error

terminate called after throwing an instance of 'cv::Exception' what(): OpenCV(3.4.2) /home/odroid/Desktop/is2/opencv/modules/highgui/src/window.cpp:356: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow' It would be very helpful to point out my mistake !!

TIA

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2018-07-28 15:14:30 -0600

LBerger gravatar image

updated 2018-07-28 15:41:32 -0600

before calling bm3dDenoising, you must init gray1 (InputOupuArray array for in place computation):

    gray1 = Mat::zeros(img.size(), CV_8UC1);
    cv::xphoto::bm3dDenoising(gray, gray1, gray2, h, templateWindowSize, searchWindowSize, blockMatchingStep1, blockMatchingStep2, groupSize, slidingStep, beta, normType, step, transformType);

but I think there is a problem in code : you give BM3D_STEPALL then I think code should be :

case BM3D_STEPALL:
    _basic.create(srcSize, type);
    _dst.create(srcSize, type);
    break;

Doc is here and BM3D_ALL does it mean you can get result BM3D_STEP1 and BM3D_STEP2 ?

May be you can post an issue.

edit flag offensive delete link more
0

answered 2018-07-31 00:06:11 -0600

nobot gravatar image

Thank you, it seems there is no more compilation error after initialization of gray1, but the algorithm's output is somehow not getting better. Is it because of the wrong parameters or because of the input image. Like the gray image and the filtered image are almost same.

The output is in the below picture-- picture

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-07-28 14:09:57 -0600

Seen: 590 times

Last updated: Jul 31 '18