Summary :: bilateralFilter

I am trying to implement a two way filter using OpenCV in Qt. So far I've done this:

void MainWindow::on_actionOpen_triggered() {
    QString fileName =
      QFileDialog::getOpenFileName(this, tr("Open Image"), ".",
                                   tr("Image Files (*.png *.jpg *.jpeg *.bmp)"));
    image = cv::imread(fileName.toAscii().data());
    emit qtimage();
}

      

where image

has a type cv::Mat

. My filter function:

cv::bilateralFilter(image, image, 0, 21, 3, 0);
QImage img = QImage((const unsigned char*)(image.data), 
                   image.cols,image.rows, QImage::Format_RGB888);
QPalette palette;
palette.setBrush(this->backgroundRole(), QBrush(img));
                 this->setPalette(palette);

      

But this gives a runtime error:

OpenCV Error: Assertion failed ((src.type() == CV_8UC1 || src.type() == CV_8UC3) && src.type() == dst.type() && src.size() == dst.size() && src.data != dst.data)
    in bilateralFilter_8u, file C:\Downloads\Software\OpenCV-2.2.0-win\OpenCV-2.2.0\modules\imgproc\src\smooth.cpp, line 1282
terminate called after throwing an instance of 'cv::Exception'
what():  C:\Downloads\Software\OpenCV-2.2.0-win\OpenCV-2.2.0\modules\imgproc\src\smooth.cpp:1282:
    error:    (-215) (src.type() == CV_8UC1 || src.type() == CV_8UC3) && src.type() == dst.type() && src.size() == dst.size() && src.data != dst.data in function bilateralFilter_8u

      

+3


source to share


1 answer


Check out the documentation :

This filter does not work in place.



You need to create a new image as an output from the double-sided filter.

+4


source







All Articles