MATLAB几何均值滤波
生活随笔
收集整理的這篇文章主要介紹了
MATLAB几何均值滤波
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
% 幾何均值濾波
clc,clear,close all % 清理命令區、清理工作區、關閉顯示圖形
warning off % 消除警告
feature jit off % 加速代碼運行
im = imread('brain.bmp'); % 原圖像
im = imnoise(im,'gaussian',0,1e-3); % 原圖像 + 白噪聲im1 = geometry_fspecial(im,3,3); % 應用幾何均值濾波
figure('color',[1,1,1])
subplot(121),imshow(im,[]),title('original image')
colormap(jet) % 顏色
shading interp % 消隱
subplot(122),imshow(im1,[]),title('幾何均值濾波')
colormap(jet) % 顏色
shading interp % 消隱
function im2 = geometry_fspecial(im,m,n)
%函數對輸入圖像進行兒何均值濾波
% 函數輸入:
% x:輸入二維圖像矩陣
% m,n:濾波掩膜尺寸
% 函數輸出
% im2:輸出圖像矩陣,數據類型與輸人相同if ~isa(im,'double')im1 = double(im)/255;else im1 = im;endim2 = exp( imfilter(log(im1),ones(m,n),'replicate') ).^(1/m/n); % 幾何均值濾波im2 = im2uint8(im2); % 數據類型轉換
end
總結
以上是生活随笔為你收集整理的MATLAB几何均值滤波的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 马云的B2B B2C 和C2C的“三合一
- 下一篇: 激光雷达障碍物检测:点云聚类算法