I am learning how to write down c++ program using open cv for Gaussian filtering for image blurring.
After browsing lot of websites I found two different types of coding but both claim that those code can be used from image blurring and they applied Gauusian filter method for blurring.
Code 1: Source
int main(int argc, char** argv) {
cv::Mat image;
image = cv::imread(argv[1],cv::IMREAD_COLOR);
cv::Mat dst;
cv::Mat dst2;
cv::pyrDown(image, dst);
cv::pyrDown(dst,dst2);
cv::imshow("original image", image);
cv::imshow("1st downsample",dst);
cv::imshow("2nd downsample",dst2);
cv::waitKey();
}
Code 2: Source[Book: Hands-On GPU-Accelerated Computer Vision with OpenCV and CUDA]
int main ()
{
cv::Mat h_img1 = cv::imread("images/cameraman.tif",0);
cv::cuda::GpuMat d_img1,d_result3x3,d_result5x5,d_result7x7;
d_img1.upload(h_img1);
cv::Ptr<cv::cuda::Filter> filter3x3,filter5x5,filter7x7;
filter3x3 = cv::cuda::createGaussianFilter(CV_8UC1,CV_8UC1,cv::Size(3,3),1);
filter3x3->apply(d_img1, d_result3x3);
filter5x5 = cv::cuda::createGaussianFilter(CV_8UC1,CV_8UC1,cv::Size(5,5),1);
filter5x5->apply(d_img1, d_result5x5);
filter7x7 = cv::cuda::createGaussianFilter(CV_8UC1,CV_8UC1,cv::Size(7,7),1);
filter7x7->apply(d_img1, d_result7x7);
cv::Mat h_result3x3,h_result5x5,h_result7x7;
d_result3x3.download(h_result3x3);
d_result5x5.download(h_result5x5);
d_result7x7.download(h_result7x7);
cv::imshow("Original Image ", h_img1);
cv::imshow("Blurred with kernel size 3x3", h_result3x3);
cv::imshow("Blurred with kernel size 5x5", h_result5x5);
cv::imshow("Blurred with kernel size 7x7", h_result7x7);
cv::waitKey();
return 0;
}
My question is if both codes use for the same blurring technique using Gaussian filter why there are lot of syntactical and functional differences in two codes?