我使用openCV
中的高斯函数使我的图像模糊/滤镜,并在模糊应用之前和之后检索图像像素的值。
问题是没有模糊和模糊的图像之间的像素值没有差异,但是高斯模糊之后的图像显示实际上是模糊的并且核矩阵的大小是3 * 3。如果有人能解决这个问题,肯定会感激,提前谢谢,这是我的代码。
#include <opencv2/highgui/highgui.hpp>
#include "opencv2/imgproc/imgproc.hpp"
#include <opencv2/core/core.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
Mat image = imread("C:/santhu/bitmap.bmp");
int rows=image.rows;
int cols=image.cols;
if (image.empty())
{
cout << "Cannot load image!" << endl;
return -1;
}
cout<<"the output for matrix of pixels";
//code to access pixel values of an image
cout<<"\nbefore blur";
for (int i = 0; i <rows; i++)
{
Vec3b *ptr = image.ptr<Vec3b>(i);
for (int j = 0; j < cols; j++)
{
Vec3b pixel = ptr[j];
//cout<<pixel<<"\t";
}
cout<<"\n";
}
imshow("Image", image);//displaying image
waitKey(0);
Mat image1=image.clone();//cloning image
GaussianBlur( image, image1, Size( 7, 7), 0, 0 );//applying Gaussian filter
cout<<"\nafter blur";
//code to access pixel values of an image
for (int i = 0; i < rows; i++)
{
Vec3b *ptr = image1.ptr<Vec3b>(i);
for (int j = 0; j < cols; j++)
{
Vec3b pixel = ptr[j];
//cout<<pixel<<"\t";
}
cout<<"\n";
}
imshow("image1:",image1);//displaying image1
waitKey(0);
}