Mean and Median Filters
description
Transcript of Mean and Median Filters
Mean and Median Filters
指導教授:張顧耀指導教授:張顧耀學生姓名:張志坤學生姓名:張志坤學號:學號: E9406011E9406011
Chin-Kun Chang Mean and Median Filters 2
Outline
Introduction Mean Filter Median Filter Summary Demo
Chin-Kun Chang Mean and Median Filters 3
Introduction
影像濾波的定義主要分成兩種方式: 頻率域 (frequency domain) :由空間域影像透過 轉換 ( 如複利葉 , 小波 ) 而形成的影像表示空間 空間域 (spatial domain) :直接對影像上的 pixel value 做處理
g(x,y) = T[ f(x,y) ]
f(x,y) 是輸入的影像g(x,y) 是經過處理的影像T -> 影像濾波的方法
空間域的方程式表示
Chin-Kun Chang Mean and Median Filters 4
Introduction 影像濾波的定義 ( 方程式 g(x,y) = T[ f(x,y) ] )
x
yOriginal
(x,y)
Image f(x,y)
x
yOriginal
(x,y)
Image g(x,y)
g(x,y) = T[ f(x,y) ]
f(x,y) 是輸入的影像g(x,y) 是經過處理的影像T -> 影像濾波的方法
Chin-Kun Chang Mean and Median Filters 5
Outline
Introduction Mean Filter Median Filter Summary Demo
Chin-Kun Chang Mean and Median Filters 6
Mean Filter
The Mean Filter is used to The Mean Filter is used to
softensoften an image by averaging surrounding an image by averaging surrounding pixel values. pixel values.
Chin-Kun Chang Mean and Median Filters 7
Mean Filter
Grayscale 3x3 pixel window
22 77 48
150 77 158
0 77 219
Center pixel = ( 22 + 77 + 48 + 150 + 77 + 158 + 0 + 77 + 219 ) / 9 = 92
x
yOriginal
(x,y)
Image f(x,y)
x
yOriginal
(x,y)
Image g(x,y)
(x,y)
Chin-Kun Chang Mean and Median Filters 8
Mean Filter
(a) 加入點雜訊的方形影像; (b) 點雜訊方形影像的輪廓圖; (c) 經平均值濾波後的影像; (d) 平均值濾波後的輪廓圖。
Chin-Kun Chang Mean and Median Filters 9
Mean Filter
int x , y ; int a=(n-1)/2; int color(i) , color(x,y);for(int k=x-a ; k<=x+a ; k++){
for(int m=y-a ; m<=y+a ; m++){
color(x,y)+=color(k,m)}
}color(i)=[color(x, y)/n*n);
演算法
x
yOriginal
(x,y)
Image f(x,y)
Chin-Kun Chang Mean and Median Filters 10
Mean Filter
Header file includedHeader file included #include “itkMeanImageFilter.h”
UsingUsing Typedef Itk::MeanImageFilter < InputImageType, OutputImageType > FilterType; FilterType::Pointer filter = FilterType::New((); InputImageType::SizeType indexRadius;
indexRadius[0] = 1; // radius along x 1-> 2D 2-> 3*51-> 2D 2-> 3*5 indexRadius[1] = 1; // radius along y
Rx * 2 + 1 = 2 * 1 + 1 = 3 Rx 就是 x 方向的半徑 , 1 代表中心點 Ry * 2 + 1 = 2 * 1 + 1 = 3 Ry 就是 y 方向的半徑 , 1 代表中心點
ITKx
yOriginal
(x,y)
Image f(x,y)
Chin-Kun Chang Mean and Median Filters 11
Mean Filter
Source Mean
Chin-Kun Chang Mean and Median Filters 12
Mean Filter
Source Mean
Chin-Kun Chang Mean and Median Filters 13
Outline
Introduction Mean Filter Median Filter Summary Demo
Chin-Kun Chang Mean and Median Filters 14
The Median filter is used to
remove noise from an image
by replacing pixels with the middle pixel value selected from a certain window size.
Median Filter
Chin-Kun Chang Mean and Median Filters 15
Median Filter
Grayscale 3x3 pixel window
22 77 48
150 77 158
0 77 219
0, 22, 48, 77, [ 77 ], 77, 150, 158, 219
x
yOriginal
(x,y)
Image f(x,y)
x
yOriginal
(x,y)
Image g(x,y)
(x,y)
Chin-Kun Chang Mean and Median Filters 16
Median Filter
(a) 加入點雜訊的方形影像; (b) 點雜訊方形影像的輪廓圖; (c) 經中間值濾波後的影像; (d) 中間值濾波後的輪廓圖。
Chin-Kun Chang Mean and Median Filters 17
Median Filter
int x , y ;int z=0;int a=(n-1)/2;int color(i) ;int array[] = new int [nxn-1];for(int k=x-a ; k<=x+a ; k++){
for(int m=y-a ; m<=y+a ; m++){
array [z]=color(k,m)z++;
}}sort(array);color(i)=median(array []);
演算法
Chin-Kun Chang Mean and Median Filters 18
Header file includedHeader file included #include “itkMedianImageFilter.h”
UsingUsing Typedef Itk::MedianImageFilter < InputImageType, OutputImageType > FilterType; FilterType::Pointer filter = FilterType::New((); InputImageType::SizeType indexRadius;
indexRadius[0] = 1; // radius along x 1-> 2D 2-> 3*51-> 2D 2-> 3*5 indexRadius[1] = 1; // radius along y
ITK
x
yOriginal
(x,y)
Image f(x,y)Median Filter
Chin-Kun Chang Mean and Median Filters 19
Median Filter
Source 3×3 median filtering
Chin-Kun Chang Mean and Median Filters 20
Median Filter
Source 3×3 median filtering 9×9 median filtering
Chin-Kun Chang Mean and Median Filters 21
Outline
Introduction Mean Filter Median Filter Summary Demo
Chin-Kun Chang Mean and Median Filters 22
Summary Mean filter and Median filter 的比較 - 1
Chin-Kun Chang Mean and Median Filters 23
Summary Mean filter and Median filter 的比較 - 2
Mean filter Median filter
Chin-Kun Chang Mean and Median Filters 24
Summary Mean filter and Median filter 的比較 - 3
(c) 平均值濾波輸出
Chin-Kun Chang Mean and Median Filters 25
Outline
Introduction Mean Filter Median Filter Summary Demo
Chin-Kun Chang Mean and Median Filters 26
Demo
Chin-Kun Chang Mean and Median Filters 27
Demo
Chin-Kun Chang Mean and Median Filters 28
參考文獻 ItkSoftwareGuide.pdfItkSoftwareGuide.pdf http://www.cee.hw.ac.uk/hipr/html/mean.html http://www.ntut.edu.tw/~s9598008/homework1.htm http://www.cc.ntut.edu.tw/~s8410010/hw1.htm 連國珍,“數位影像處理”,儒林圖書公司 (SIM 949) 。 http://140.128.102.71/http://140.128.102.71/ 東海大學影像視訊處理實驗室 東海大學影像視訊處理實驗室
Chin-Kun Chang Mean and Median Filters 29
報告結束報告結束敬請指教敬請指教