欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來到入門教程網(wǎng)!

C語言

當(dāng)前位置:主頁 > 軟件編程 > C語言 >

opencv3/C++圖像濾波實(shí)現(xiàn)方式

來源:本站原創(chuàng)|時(shí)間:2020-01-10|欄目:C語言|點(diǎn)擊: 次

圖像濾波在opencv中可以有多種實(shí)現(xiàn)形式

自定義濾波

如使用3×3的掩模:

對(duì)圖像進(jìn)行處理.

使用函數(shù)filter2D()實(shí)現(xiàn)

#include<opencv2/opencv.hpp>
using namespace cv;

int main()
{
 //函數(shù)調(diào)用filter2D功能
 Mat src,dst;
 src = imread("E:/image/image/daibola.jpg");
 if(!src.data)
 {
  printf("can not load image \n");
  return -1;
 }
 namedWindow("input", CV_WINDOW_AUTOSIZE);
 imshow("input", src);
 src.copyTo(dst);
 Mat kernel = (Mat_<int>(3,3)<<1,1,1,1,1,-1,-1,-1,-1);
 double t = (double)getTickCount();
 filter2D(src, dst, src.depth(), kernel);
 std::cout<<((double)getTickCount()-t)/getTickFrequency()<<std::endl;
 namedWindow("output", CV_WINDOW_AUTOSIZE);
 imshow("output", dst);
 printf("%d",src.channels());
 waitKey();
 return 0;
}

通過像素點(diǎn)操作實(shí)現(xiàn)

#include<opencv2/opencv.hpp>
using namespace cv;
int main()
{
 Mat src, dst;
 src = imread("E:/image/image/daibola.jpg");
 CV_Assert(src.depth() == CV_8U);
 if(!src.data)
 {
  printf("can not load image \n");
  return -1;
 }
 namedWindow("input", CV_WINDOW_AUTOSIZE);
 imshow("input",src);
 src.copyTo(dst);
 for(int row = 1; row<(src.rows - 1); row++)
 {
  const uchar* previous = src.ptr<uchar>(row - 1);
  const uchar* current = src.ptr<uchar>(row);
  const uchar* next = src.ptr<uchar>(row + 1);
  uchar* output = dst.ptr<uchar>(row);
  for(int col = src.channels(); col < (src.cols - 1)*src.channels(); col++)
  {
   *output = saturate_cast<uchar>(1 * current[col] + previous[col] - next[col] + current[col - src.channels()] - current[col + src.channels()]);
   output++;
  }
 }
 namedWindow("output", CV_WINDOW_AUTOSIZE);
 imshow("output",dst);
 waitKey();
 return 0;
}

特定形式濾波

常用的有:

blur(src,dst,Size(5,5));均值濾波

GaussianBlur(src,dst,Size(5,5),11,11);高斯濾波

medianBlur(src,dst,5);中值濾波(應(yīng)對(duì)椒鹽噪聲)

bilateralFilter(src,dst,2,0.5,2,4);雙邊濾波(保留邊緣)

#include<opencv2/opencv.hpp>
using namespace cv;

int main()
{
 Mat src, dst;
 src = imread("E:/image/image/daibola.jpg");
 CV_Assert(src.depth() == CV_8U);
 if(!src.data)
 {
  printf("can not load image \n");
  return -1;
 }
 namedWindow("input", CV_WINDOW_AUTOSIZE);
 imshow("input",src);
 src.copyTo(dst);
 //均值濾波
 blur(src,dst,Size(5,5));
 //中值濾波
 //medianBlur(src,dst,5);

 namedWindow("output", CV_WINDOW_AUTOSIZE);
 imshow("output",dst);

 waitKey();
 return 0;
}

以上這篇opencv3/C++圖像濾波實(shí)現(xiàn)方式就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持我們。

上一篇:解決codeblocks斷點(diǎn)不停無效的問題

欄    目:C語言

下一篇:opencv3/C++視頻中疊加透明圖片的實(shí)現(xiàn)

本文標(biāo)題:opencv3/C++圖像濾波實(shí)現(xiàn)方式

本文地址:http://mengdiqiu.com.cn/a1/Cyuyan/89.html

網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫(kù)服務(wù)器

如果侵犯了您的權(quán)利,請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有