Image Filtering

You can find this article and source code at my GitHub

Three views of filtering

  • Image filters in spatial domain
  • Filter is a mathematical operation of a grid of numbers
  • Smoothing, sharpening, measuring texture
  • Image filters in the frequency domain
  • Filtering is a way to modify the frequencies of images
  • Denoising, sampling, image compression
  • Templates and Image Pyramids
  • Filtering is a way to match a template to the image
  • Detection, coarse-to-fine registration

Example

Box filter

  • Replaces each pixel with an average of its neighborhood
  • Smoothing

Given a 3-by-3 box filter in the graph below

We will be able to find the filtered image, and the result looks like below (right one).

We also have some other popular and useful filters.

Sobel filter

Vertical Sobel filter
Horizontal Sobel filter

Now you may think that a Sobel filter can be used to find the edge in an image. And you are right. I have tried to merge two result images from the vertical and horizontal


Properties of linear filters

Linearity:

filter(f1 + f2) = filter(f1) + filter(f2)

Shift invariance: same behavior regardless of
pixel location

filter(shift(f)) = shift(filter(f))

Any linear, shift-invariant operator can be
represented as a convolution


Important filter: Gaussian

Weight contributions of neighboring pixels by nearness

Smoothing with Gaussian filter


Smoothing with Gaussian filter

Smoothing with box filter


Smoothing with box filter

A Gaussian filter can do this better since it keeps "more information" than a box filter by weighting contributions from neighbors.


Practical matters

How big should the filter be?

  • Values at edges should be near zero
  • Rule of thumb for Gaussian: set filter half-width to
    about 3σ

What about near the edge?

  • the filter window falls off the edge of the image
  • need to extrapolate
  • methods:
  • clip filter (black)
  • wrap around
  • copy edge
  • reflect across edge

What is the size of the output?


Median filter

  • A Median Filter operates over a window by
    selecting the median intensity in the window.
  • What advantage does a median filter have over
    a mean filter? (Check the picture below!)
  • Is a median filter a kind of convolution?
Comparison: salt and pepper noise

Have you seen the superior advantage of applying a mean filter?


Reference:

Computer Vision: Algorithms and Applications by Richard Szeliski.
CSCI 1430: Introduction to Computer Vision

Thanks for reading. If you find any mistake / typo in this blog, please don't hesitate to let me know, you can reach me by email: jyang7[at]ualberta.ca

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
  • 序言:七十年代末砸彬,一起剝皮案震驚了整個濱河市让歼,隨后出現的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖优训,帶你破解...
    沈念sama閱讀 221,576評論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件呢燥,死亡現場離奇詭異,居然都是意外死亡原茅,警方通過查閱死者的電腦和手機吭历,發(fā)現死者居然都...
    沈念sama閱讀 94,515評論 3 399
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來擂橘,“玉大人晌区,你說我怎么就攤上這事。” “怎么了朗若?”我有些...
    開封第一講書人閱讀 168,017評論 0 360
  • 文/不壞的土叔 我叫張陵恼五,是天一觀的道長。 經常有香客問我哭懈,道長灾馒,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 59,626評論 1 296
  • 正文 為了忘掉前任遣总,我火速辦了婚禮睬罗,結果婚禮上,老公的妹妹穿的比我還像新娘旭斥。我一直安慰自己容达,他們只是感情好,可當我...
    茶點故事閱讀 68,625評論 6 397
  • 文/花漫 我一把揭開白布垂券。 她就那樣靜靜地躺著花盐,像睡著了一般。 火紅的嫁衣襯著肌膚如雪菇爪。 梳的紋絲不亂的頭發(fā)上算芯,一...
    開封第一講書人閱讀 52,255評論 1 308
  • 那天,我揣著相機與錄音凳宙,去河邊找鬼也祠。 笑死,一個胖子當著我的面吹牛近速,可吹牛的內容都是我干的诈嘿。 我是一名探鬼主播,決...
    沈念sama閱讀 40,825評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼削葱,長吁一口氣:“原來是場噩夢啊……” “哼奖亚!你這毒婦竟也來了?” 一聲冷哼從身側響起析砸,我...
    開封第一講書人閱讀 39,729評論 0 276
  • 序言:老撾萬榮一對情侶失蹤昔字,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后首繁,有當地人在樹林里發(fā)現了一具尸體作郭,經...
    沈念sama閱讀 46,271評論 1 320
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 38,363評論 3 340
  • 正文 我和宋清朗相戀三年弦疮,在試婚紗的時候發(fā)現自己被綠了夹攒。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,498評論 1 352
  • 序言:一個原本活蹦亂跳的男人離奇死亡胁塞,死狀恐怖咏尝,靈堂內的尸體忽然破棺而出压语,到底是詐尸還是另有隱情,我是刑警寧澤编检,帶...
    沈念sama閱讀 36,183評論 5 350
  • 正文 年R本政府宣布胎食,位于F島的核電站,受9級特大地震影響允懂,放射性物質發(fā)生泄漏厕怜。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,867評論 3 333
  • 文/蒙蒙 一蕾总、第九天 我趴在偏房一處隱蔽的房頂上張望酣倾。 院中可真熱鬧,春花似錦谤专、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,338評論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至拦焚,卻和暖如春蜡坊,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背赎败。 一陣腳步聲響...
    開封第一講書人閱讀 33,458評論 1 272
  • 我被黑心中介騙來泰國打工秕衙, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人僵刮。 一個月前我還...
    沈念sama閱讀 48,906評論 3 376
  • 正文 我出身青樓据忘,卻偏偏與公主長得像,于是被迫代替她去往敵國和親搞糕。 傳聞我的和親對象是個殘疾皇子勇吊,可洞房花燭夜當晚...
    茶點故事閱讀 45,507評論 2 359

推薦閱讀更多精彩內容