【Opencv&Cpp】24 图像卷积--blur模糊

blur(image, dst, Size(10, 10), Point(-1, -1));

实现图像模糊到清晰的过程通常需要使用一些图像处理算法和技术,其中包括图像去噪、图像平滑、图像锐化等等。在这里,我们可以利用Qt和OpenCV库来实现这样的图像处理。 以下是一种基于Qt和OpenCV图像模糊到清晰处理的示例代码: ```cpp #include <QApplication> #include <QImage> #include <QPixmap> #include <QLabel> #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> int main(int argc, char *argv[]) { QApplication a(argc, argv); // 读入模糊图像 cv::Mat blurImage = cv::imread("blurImage.jpg"); // 进行图像去噪处理 cv::Mat dstImage; cv::fastNlMeansDenoisingColored(blurImage, dstImage, 10, 10, 7, 21); // 进行图像平滑处理 cv::GaussianBlur(dstImage, dstImage, cv::Size(5, 5), 0, 0); // 进行图像锐化处理 cv::Mat kernel = (cv::Mat_<float>(3, 3) << -1, -1, -1, -1, 9, -1, -1, -1, -1); cv::filter2D(dstImage, dstImage, -1, kernel); // 将OpenCV Mat类型的图像转为Qt QImage类型的图像 QImage qImage = QImage((const unsigned char*)(dstImage.data), dstImage.cols, dstImage.rows, dstImage.cols*dstImage.channels(), QImage::Format_RGB888).rgbSwapped(); // 显示处理后的图像 QPixmap pixmap = QPixmap::fromImage(qImage); QLabel label; label.setPixmap(pixmap); label.show(); return a.exec(); } ``` 上述代码中,我们首先读入了一张模糊图像,并使用OpenCV的快速非局部均值去噪算法对其进行去噪处理。接着,我们对去噪后的图像进行高斯平滑处理,以进一步减少图像中的噪声。最后,我们使用卷积核对图像进行锐化处理,使图像变得更加清晰。 最后,我们将处理后的图像转换为Qt中的QImage类型,并通过QLabel来显示图像
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值