日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

bilareralFilter双边滤波函数

發布時間:2025/4/16 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 bilareralFilter双边滤波函数 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

C++: void **bilateralFilte**r(InputArray src, OutputArray dst, int d, double sigmaColor, double sigmaSpace, int borderType=BORDER_DEFAULT )??
表示對圖像進行雙邊濾波,它能很好地對圖像進行濾波,去除噪聲的能力很好,并且增強邊緣,但是運行慢相對于其他的濾波器?
參數的詳解:?
src:表示輸入的圖像?
OutputArray dst:表示輸出的圖像?
int類型的d,表示在過濾過程中每個像素鄰域的直徑。如果這個值我們設其為非正數,那么OpenCV會從第五個參數sigmaSpace來計算出它來。?
double類型的sigmaColor,顏色空間濾波器的sigma值。這個參數的值越大,就表明該像素鄰域內有更寬廣的顏色會被混合到一起,產生較大的半相等顏色區域。?
double類型的sigmaSpace坐標空間中濾波器的sigma值,坐標空間的標注方差。他的數值越大,意味著越遠的像素會相互影響,從而使更大的區域足夠相似的顏色獲取相同的顏色。當d>0,d指定了鄰域大小且與sigmaSpace無關。否則,d正比于sigmaSpace。?
int類型的borderType,用于推斷圖像外部像素的某種邊界模式。注意它有默認值BORDER_DEFAULT。

簡單地說它是以被處理像素與其周圍像素的距離作為權重而進行的一種加權平均過程。?
高斯距離權值為:?

其中,d(ξ,x)=d(ξ-x)=||ξ-x||表示的是兩個像素ξ和x之間的距離。?
但該權值僅僅考慮的是距離,而對像素本身的亮度信息沒有考慮,因此高斯濾波的結果是使整幅圖像都模糊了,即圖像的邊緣信息(高頻部分)被嚴重削弱了。我們知道當圖像中鄰域像素亮度與被處理像素的亮度差異很大時,鄰域像素與該像素的關系很小的,即兩者相似性很差。因此雙邊濾波還考慮了領域像素的亮度信息,通過計算相似度來賦予領域像素一定的權重,下面就是高斯相似度的權值:

其中,σ(f(ξ),f(x))=||f(ξ)-f(x)||表示兩個像素亮度之差。最終的雙邊濾波的公式為:

其中,,Σ表示的是鄰域范圍,及濾波內核大小,f(ξ)表示原圖。

代碼詳解:

<ol start="1" class="dp-cpp" style="padding: 0px; border: none; color: rgb(92, 92, 92); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; line-height: 26px; margin: 0px 0px 1px 45px !important;"><li class="alt" style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 102, 153); font-weight: bold; background-color: inherit;">void</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?cv::adaptiveBilateralFilter(?InputArray?_src,?OutputArray?_dst,?Size?ksize,??</span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">??????????????????????????????????<span class="datatypes" style="margin: 0px; padding: 0px; border: none; color: rgb(46, 139, 87); font-weight: bold; background-color: inherit;">double</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?sigmaSpace,?</span><span class="datatypes" style="margin: 0px; padding: 0px; border: none; color: rgb(46, 139, 87); font-weight: bold; background-color: inherit;">double</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?maxSigmaColor,?Point?anchor,?</span><span class="datatypes" style="margin: 0px; padding: 0px; border: none; color: rgb(46, 139, 87); font-weight: bold; background-color: inherit;">int</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?borderType?)??</span></span></li><li class="alt" style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">{??</span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????<span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">//得到輸入圖像矩陣和與其尺寸類型一致的輸出圖像矩陣</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li><li class="alt" style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????Mat?src?=?_src.getMat();??</span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????_dst.create(src.size(),?src.type());??</span></li><li class="alt" style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????Mat?dst?=?_dst.getMat();??</span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????<span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">//該算法只能處理8位二進制的灰度圖像和三通道的彩色圖像</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li><li class="alt" style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????CV_Assert(src.type()?==?CV_8UC1?||?src.type()?==?CV_8UC3);??</span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????<span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">//得到濾波內核的錨點</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li><li class="alt" style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????anchor?=?normalizeAnchor(anchor,ksize);??</span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????<span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 102, 153); font-weight: bold; background-color: inherit;">if</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(?src.depth()?==?CV_8U?)??</span></span></li><li class="alt" style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????adaptiveBilateralFilter_8u(?src,?dst,?ksize,?sigmaSpace,?maxSigmaColor,?anchor,?borderType?);??</span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????<span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 102, 153); font-weight: bold; background-color: inherit;">else</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li><li class="alt" style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????CV_Error(?CV_StsUnsupportedFormat,??</span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"Adaptive?Bilateral?filtering?is?only?implemented?for?8u?images"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?);??</span></span></li><li class="alt" style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">} ?</span></li></ol> 在這里我們以處理 8 為二進制圖像為例,因此它調用了 bilateralFilter_8u 函數:

  • static?void??
  • bilateralFilter_8u(?const?Mat&?src,?Mat&?dst,?int?d,??
  • ????double?sigma_color,?double?sigma_space,??
  • ????int?borderType?)??
  • {??
  • ??
  • ????int?cn?=?src.channels();????????//得到圖像的通道數,即是灰度圖像還是彩色圖像??
  • ????int?i,?j,?maxk,?radius;??
  • ????Size?size?=?src.size();?????????//得到圖像的大小尺寸??
  • ????//處理之前再次檢查圖像中的相關信息是否正確??
  • ????CV_Assert(?(src.type()?==?CV_8UC1?||?src.type()?==?CV_8UC3)?&&??
  • ??????????????src.type()?==?dst.type()?&&?src.size()?==?dst.size()?&&??
  • ??????????????src.data?!=?dst.data?);??
  • ????//如果在函數調用時給出的高斯公式中的兩個σ值小于0,則為1??
  • ????if(?sigma_color?<=?0?)??
  • ????????sigma_color?=?1;??
  • ????if(?sigma_space?<=?0?)??
  • ????????sigma_space?=?1;??
  • ????//計算兩個高斯公式中的系數,即e指數部分的分母??
  • ????double?gauss_color_coeff?=?-0.5/(sigma_color*sigma_color);??
  • ????double?gauss_space_coeff?=?-0.5/(sigma_space*sigma_space);??
  • ??
  • ????if(?d?<=?0?)?//如果調用雙邊濾波函數時給出的濾波內核大小小于等于0??
  • ????????radius?=?cvRound(sigma_space*1.5);??????//根據σd來自動給出內核的半徑??
  • ????else????????????//否則得到內核的半徑??
  • ????????radius?=?d/2;??
  • ????radius?=?MAX(radius,?1);????????//保證內核半徑大于1??
  • ????d?=?radius*2?+?1;???????//重新得到內核大小尺寸??
  • ????//為了在圖像邊界處得到更好的處理效果,需要對圖像四周邊界做適當的處理??
  • ????//把原圖的四周都加寬為內核半徑的寬度,而加寬部分的像素值由borderType值決定??
  • ????//待處理的圖像由src換成了temp??
  • ????Mat?temp;??
  • ????copyMakeBorder(?src,?temp,?radius,?radius,?radius,?radius,?borderType?);??
  • ??
  • #if?defined?HAVE_IPP?&&?(IPP_VERSION_MAJOR?>=?7)??
  • ????if(?cn?==?1?)??
  • ????{??
  • ????????bool?ok;??
  • ????????IPPBilateralFilter_8u_Invoker?body(temp,?dst,?sigma_color?*?sigma_color,?sigma_space?*?sigma_space,?radius,?&ok?);??
  • ????????parallel_for_(Range(0,?dst.rows),?body,?dst.total()/(double)(1<<16));??
  • ????????if(?ok?)?return;??
  • ????}??
  • #endif??
  • ??
  • ????//無論是距離權值還是相似度權值都是事先計算后,并保持在相應的矢量中??
  • ????vector<float>?_color_weight(cn*256);??????//保持相似度權值的矢量??
  • ????vector<float>?_space_weight(d*d);?????//保持距離權值的矢量??
  • ????vector<int>?_space_ofs(d*d);??????????????//距離的偏移量??
  • ????//得到各個矢量的第一個數據的地址指針??
  • ????float*?color_weight?=?&_color_weight[0];??
  • ????float*?space_weight?=?&_space_weight[0];??
  • ????int*?space_ofs?=?&_space_ofs[0];??
  • ??
  • ????//?initialize?color-related?bilateral?filter?coefficients??
  • ????//計算亮度相似度權值??
  • ????/*如果是灰度圖像,亮度是從0~255,因此兩個灰度值的差值也是在0~255之間,事先計算這些值把它們保持在color_weight中,當要用到相似度權值時,只要知道兩個灰度值的差值,通過color_weight,就很容易得到權值;而如果是彩色圖像,則是把一個像素中的紅、綠、藍三色加在一起后得到一個差值,而不是一個像素分別有紅、綠、藍三個差值,因此彩色圖像兩個像素的差值范圍是在0~256×3之間。*/??
  • ????for(?i?=?0;?i?<?256*cn;?i++?)??
  • ????????color_weight[i]?=?(float)std::exp(i*i*gauss_color_coeff);???????//高斯公式??
  • ??
  • ????//?initialize?space-related?bilateral?filter?coefficients??
  • ????//計算距離權值??
  • ????for(?i?=?-radius,?maxk?=?0;?i?<=?radius;?i++?)??
  • ????{??
  • ????????j?=?-radius;??
  • ??
  • ????????for(?;j?<=?radius;?j++?)??
  • ????????{??
  • ????????????double?r?=?std::sqrt((double)i*i?+?(double)j*j);????????//距離范數??
  • ????????????if(?r?>?radius?)?????????//如果距離大于內核半徑,則拋棄該值??
  • ????????????????continue;??
  • ????????????space_weight[maxk]?=?(float)std::exp(r*r*gauss_space_coeff);????//高斯公式??
  • ????????????//得到偏移量,在后面通過該偏移量來找到相應的像素??
  • ????????????space_ofs[maxk++]?=?(int)(i*temp.step?+?j*cn);??
  • ????????}??
  • ????}??
  • ????//通過實例化BilateralFilter_8u_Invoker類計算得到雙邊濾波的結果??
  • ????BilateralFilter_8u_Invoker?body(dst,?temp,?radius,?maxk,?space_ofs,?space_weight,?color_weight);??
  • ????parallel_for_(Range(0,?size.height),?body,?dst.total()/(double)(1<<16));??
  • } ?
  • BilateralFilter_8u_Invoker 類中的 operator()

  • virtual?void?operator()?(const?Range&?range)?const??
  • {??
  • ????int?i,?j,?cn?=?dest->channels(),?k;??
  • ????Size?size?=?dest->size();??
  • ????#if?CV_SSE3??
  • ?????……略……??
  • ????#endif??
  • ??
  • ????for(?i?=?range.start;?i?<?range.end;?i++?)??
  • ????{??
  • ????????const?uchar*?sptr?=?temp->ptr(i+radius)?+?radius*cn;?//得到原圖數據指針??
  • ????????uchar*?dptr?=?dest->ptr(i);??//輸出圖像指針??
  • ??
  • ????????if(?cn?==?1?)???????//灰度圖像??
  • ????????{??
  • ????????????for(?j?=?0;?j?<?size.width;?j++?)??
  • ????????????{??
  • ????????????????float?sum?=?0,?wsum?=?0;??
  • ????????????????int?val0?=?sptr[j];?//內核的中心像素,即待處理的像素值??
  • ????????????????k?=?0;??
  • ????????????????#if?CV_SSE3??
  • ????????????????……略……??
  • ????????????????#endif??
  • ????????????????//遍歷這個內核??
  • ????????????????for(?;?k?<?maxk;?k++?)??
  • ????????????????{??
  • ????????????????????int?val?=?sptr[j?+?space_ofs[k]];???//得到鄰域像素值??
  • ????????????????????//計算公式3中的k中的一個值??
  • ????????????????????float?w?=?space_weight[k]*color_weight[std::abs(val?-?val0)];??
  • ????????????????????//計算公式3中的分子部分??
  • ????????????????????sum?+=?val*w;??
  • ????????????????????//計算公式3中的分母部分??
  • ????????????????????wsum?+=?w;??
  • ????????????????}??
  • ????????????????//?overflow?is?not?possible?here?=>?there?is?no?need?to?use?CV_CAST_8U??
  • ????????????????//得到處理后的結果??
  • ????????????????dptr[j]?=?(uchar)cvRound(sum/wsum);??
  • ????????????}??
  • ????????}??
  • ????????else????????//彩色圖像??
  • ????????{??
  • ????????????assert(?cn?==?3?);??
  • ????????????for(?j?=?0;?j?<?size.width*3;?j?+=?3?)??
  • ????????????{??
  • ????????????????float?sum_b?=?0,?sum_g?=?0,?sum_r?=?0,?wsum?=?0;??
  • ????????????????int?b0?=?sptr[j],?g0?=?sptr[j+1],?r0?=?sptr[j+2];??
  • ????????????????k?=?0;??
  • ????????????????#if?CV_SSE3??
  • ????????????????……略……??
  • ????????????????#endif??
  • ??
  • ????????????????for(?;?k?<?maxk;?k++?)??
  • ????????????????{??
  • ????????????????????const?uchar*?sptr_k?=?sptr?+?j?+?space_ofs[k];??//得到鄰域像素??
  • ????????????????????//分別得到鄰域像素中的藍、綠、紅分量??
  • ????????????????????int?b?=?sptr_k[0],?g?=?sptr_k[1],?r?=?sptr_k[2];??
  • ????????????????????//計算公式3中的k值,??
  • ????????????????????//其中相似度權值中的像素差值是紅、綠、藍分量差值之和??
  • ????????????????????float?w?=?space_weight[k]*color_weight[std::abs(b?-?b0)?+??
  • ?????????????????????????????????????????????????????std::abs(g?-?g0)?+?std::abs(r?-?r0)];??
  • ????????????????????//利用公式3分別得到紅、綠、藍三個分量值??
  • ????????????????????sum_b?+=?b*w;?sum_g?+=?g*w;?sum_r?+=?r*w;??
  • ????????????????????wsum?+=?w;??
  • ????????????????}??
  • ????????????????wsum?=?1.f/wsum;??
  • ????????????????b0?=?cvRound(sum_b*wsum);??
  • ????????????????g0?=?cvRound(sum_g*wsum);??
  • ????????????????r0?=?cvRound(sum_r*wsum);??
  • ????????????????dptr[j]?=?(uchar)b0;?dptr[j+1]?=?(uchar)g0;?dptr[j+2]?=?(uchar)r0;??
  • ????????????}??
  • ????????}??
  • ????}??
  • }??
  • Opencv中的雙邊濾波的源碼分析就到這里,另外根據Opencv的文檔中介紹,兩個高斯公式的σ可以相同,而且如果σ小于10,則濾波效果不明顯,如果大于150,則會有強烈的卡通效果。當實時處理時,內核尺寸d推薦為5;如果在非實時處理情況下,而且有較強的噪聲時,d9效果會較好。



    MATLAB代碼:

    clear all; close all; clc;img=imread('lena.jpg'); img=mat2gray(img); [m n]=size(img); imshow(img);r=10; %模板半徑 imgn=zeros(m+2*r+1,n+2*r+1); imgn(r+1:m+r,r+1:n+r)=img; imgn(1:r,r+1:n+r)=img(1:r,1:n); %擴展上邊界 imgn(1:m+r,n+r+1:n+2*r+1)=imgn(1:m+r,n:n+r); %擴展右邊界 imgn(m+r+1:m+2*r+1,r+1:n+2*r+1)=imgn(m:m+r,r+1:n+2*r+1); %擴展下邊界 imgn(1:m+2*r+1,1:r)=imgn(1:m+2*r+1,r+1:2*r); %擴展左邊界sigma_d=2; sigma_r=0.1; [x,y] = meshgrid(-r:r,-r:r); w1=exp(-(x.^2+y.^2)/(2*sigma_d^2)); %以距離作為自變量高斯濾波器h=waitbar(0,'wait...'); for i=r+1:m+rfor j=r+1:n+r w2=exp(-(imgn(i-r:i+r,j-r:j+r)-imgn(i,j)).^2/(2*sigma_r^2)); %以周圍和當前像素灰度差值作為自變量的高斯濾波器w=w1.*w2;s=imgn(i-r:i+r,j-r:j+r).*w;imgn(i,j)=sum(sum(s))/sum(sum(w));endwaitbar(i/m); end close(h)figure; imshow(mat2gray(imgn(r+1:m+r,r+1:n+r)));
    opencv代碼:

    #include "cv.h" #include "highgui.h" #include <iostream>using namespace std; using namespace cv;int main(int argc, char* argv[]) {Mat src = imread("misaka.jpg");Mat dst;//參數是按順序寫的//高斯濾波//src:輸入圖像//dst:輸出圖像//Size(5,5)模板大小,為奇數//x方向方差//Y方向方差GaussianBlur(src,dst,Size(5,5),0,0);imwrite("gauss.jpg",dst);//中值濾波//src:輸入圖像//dst::輸出圖像//模板寬度,為奇數medianBlur(src,dst,3);imwrite("med.jpg",dst);//均值濾波//src:輸入圖像//dst:輸出圖像//模板大小//Point(-1,-1):被平滑點位置,為負值取核中心blur(src,dst,Size(3,3),Point(-1,-1));imwrite("mean.jpg",dst);//雙邊濾波//src:輸入圖像//dst:輸入圖像//濾波模板半徑//顏色空間標準差//坐標空間標準差bilateralFilter(src,dst,5,10.0,2.0);imwrite("bil.jpg",dst);waitKey();return 0; }

    《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀

    總結

    以上是生活随笔為你收集整理的bilareralFilter双边滤波函数的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。