數位影像處理(成大)
1.Introduction
1.1 數位影像處理 Digital image processing
類比影像 → 量化(quantization)是數位化amplitude、採樣(sampling)是數位化座標 → 數位影像
也就是將影像離散化(discrete)的過程,讓電腦能夠處理。
取樣率(切割影像的精度),其數位影像的大小與空間的解析度(resolution)直接相關,
數位影像分為 Color image 跟 gray image
每一格叫 Pixal,其值成為 gray-level 或 RGB三張影像通道 稱作 影像平面(image plane)
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
空間的座標系
影像簡單的概念就是 空間位置+數值 的 Array
原點在左上角 y→ x↓
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
影像處理 Image processing
對大小、數值的 Transformation
包含變形、噪點等變化
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
影像分析 Image analysis
對影像的描述與識別等
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
電腦視覺 Computer Vision
包括多張影像動作、參照、移動等分析
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
1.3 數位影像處理的領域
影像由波而來
構成紅外線、X光、可見光等等的影像
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
1.3.1 Gamma-Ray Imaging
高能輻射,會直接穿透肌肉與水,硬組織穿透力差,光線被吸收後再透過底片以負片成像。
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
1.3.2 X ray
與 1.3.1 同理,但能量較低(穿透力較弱)
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
1.3.3 Ultraviolet Band 紫外線
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
1.3.4 可見光 Visible 與 紅外線 Infrared
Visible |
Infrared |
如光學顯微鏡 |
如夜間拍攝 |
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
|
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
|
1.3.6 核磁共振(無線電) Radio band
Magnetic Resonance Imaging(MRI)
如髖關節影像
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Ultrasound 超音波
超音波由接收回波來成像
比如腹部(油、脂肪)
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
2.Digital Image Fundamentals 不重要
人的視覺
- 人的眼睛用視桿細胞、視錐細胞,分別感知光線明暗與動作、色彩細節。並透過水晶體調整焦距與範圍
- 人眼看到的並不是事實,有Optical illusions視錯覺
- Weber ratio 韋伯-費希納定理 心理量與物理量之間的定律,感覺量的大小與刺激強度的對數成正比
照相
成像是由光的能量構成,透過曝光將光線記錄到底片跟膠帶上。
分為:
- Single sensor
- Sensor stripes(Line sensor)
- Sensor arrays (Array sensor) 如X光
Image interpolation 圖像插值法
利用已知數據推論未知圖像的方法,如放大、縮小等:
- nearest neighbor interpolation 最近鄰域法:放入原始圖中最接近的點
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- Bilinear interpolation 線性內插法:參考周圍最接近的四點,按距離的權重決定填入多少
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- Bicubic interpolation
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Basic relationships between pixels: pixel之間的基本關係
Neighbors of a pixel
- : 4-neighbors of p(x,y) 十字
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- : diagonal neighbors of p(x,y) 對角線
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- = : 8-neighbors of p(x,y) 周圍
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Adjacency and Connectivity
- 4-Adjacency in the set p的上下左右皆為 Adjacency
- 8-Adjacency in the set p的上下左右斜線皆為 Adjacency
- m-Adjacency(mixed adjacency)
- q is in or
- q is in and the set has no pixels
注意相鄰的線
Connected components

Regions: 指一個連通的區域
Adjacent: 兩個區域形成連接
Disjoint: 不相鄰,如DSU。
Boundaries
- Boundary: border or contour. In the region
當使用8-鄰接性時,圓圈中的點才會被視為1值像素區域的邊界

- Outer border: in the background

Edge: 則是邊緣不存在的資料
內部 Boundary 與 外部的中間
Distance measure
- Euclidean distance

- distance city-block

- distance

- distance m-path: 找包含兩者的最短路徑

Array versus Matrix Operation
- array product of these two image

- matrix product

Linear versus Nonlinear Operation

Addition (averaging) of noisy images for noise reduction 去除雜訊
- 圖像由原圖與雜訊構成:

- 如何將圖像去除雜訊
- 方法:同一個視角拍很多次,加起來k次取平均,降低noise的影響。


- 推導過程:

假設其 為常態分佈時,平均值為0,標準差為標準差noise或1。推出期望值為0。
根據大數理論,當k越大時,效果越接近。

Image subtraction for enhancing differences 增強差異

- 概念:
只拍照物體但不要背景 = 拍一張背景 - 有物體的照片
有物體照片b - 背景a = c 物體的照片並抓出黑的背景
有物體照片b - c 黑背景= 物體照片
- 應用:

原始圖像
最低bit被設置為0
a-b,並縮放到[0,255]

先拍一張原圖(背景)
再拍一張顯影劑的圖(有物體的圖)
然後a-b 就會剩下左下心導管的影像
再強化影像到右下圖
Using image multiplication and division for shading(陰影) correction 陰影校正
- 工業檢測:乘以背景的倒數 = 原來影像

- 醫療影像:乘以背景的倒數,更清楚。

- 牙齒:拍全口 x 牙齒區塊是1其他0的mask = 就剩下單一牙齒

Full range of an arithmetic operation 改變範圍至[0,K]
改變 gray level 的 range 至

減掉最小,使

除最大值,乘以k倍
gray level 的 range 拉大到的range
Set operations involving image intensities 圖像強度
正負片影像


Single-pixel operations 單點運算(強度值)
點
原始 gray level
Transformation
相同位置的轉換 → 單點運算(跟其他點無關)
只會改變影像中gray level上的值

Neighborhood operation 鄰域操作(強度值)

的鄰域操作
該影像是透過n×m(41x41)的local框框中的gray level加起來做平均填回去
會讓影像模糊化(平滑) smoothness
- 幾何上空間的轉換,要做到 image registration 影像對位(對齊)

- 概念:不同大小的兩圖,上面的單一點如何對應到另一張圖的點,去做到T的spatial transformations 轉換。

affine transform 就是 linear transform
可以做到 scale, rotate, translate, or sheer 變形
都可經由這些矩陣達成

Image registration
- 影像對齊就是要找到 transform 的矩陣
- 兩圖分為 moving image 跟 reference image
moving image 找到對應的參考點tie points (control points):如四個角落的點,點的數量跟變數相關,才能找到對應方程式的解,貼到reference image上,得到結果

但在做 interpolation 時還是會造成影像失真
Vector and Matrix Operations

- Euclidean distance (vector norm1)

- linear transformations


- 標準的影像模型
拍出來的影像
要得到 做反矩陣運算
- 問題:無法得知 跟
但假設 是常態分布 再假設 是旋轉等 找到反矩陣就能得到真實的。

- 傅立葉轉換後,再做反傅立葉轉換可以變回原圖
用這個方法可以對影像做處理,如下圖的恢復
- 有規則性的 圖在傅立葉的圖上也會顯示規律性雜訊,用mask得到圖,就能去除掉雜訊,又稱為濾波器。
3.1 Background
- Spatial domain:空間(特定點)
- Frequency domain:頻率域(Fourier)
Spatial domain
常用

- Image negatives
- Log transformation
- Power-Law transformation
- Piecewise-linear transformations
Image negatives
黑轉白 白轉黑
為正負片(反轉)的差異
range [o,L-1]






more details
noise 更明顯



gamma correction
- 調整 gamma 值 or 有不同效果


- gamma<1暗強化

- gamma>1亮強化

Contrast stretching
對比度強化
r1→r2小 < s1→s2大


Gray-level slicing

(b)二元值影像, ()經驗設置

Bit-plane slicing
bit-slicing image

越上層越重要,越下層越不重要
可用來影像壓縮

3.3 Histogram Processing
- 明亮度的統計圖
range: [0, L-1]
- normalized histogram

Histogram Equalization(必考)
直方圖等化:改為均勻分佈,減少環境帶來的差異。


找出a到b的uniform probability density function

證明以下公式:
為 strictly monotonically increasing 嚴格單調遞增
inverse transformation: 不是函數(多r對映單一個s)
其中


- 連續型: 推導

變成 uniform distribution
- 離散型:


Example


小數做四捨五入(有誤差)
但0,2,4皆是空的
Histogram Matching (Specification)
(a)原始影像的 Histogram
(b)希望轉換後特定的 Histogram
() b轉換成uniform,生成對照表


3沒有,所以填入嚴格遞增3<x<5,x填入最小的4
Local Histogram processing
對其中一塊的 neighborhood 鄰近區域做 Histogram equalization
然後 shift 到下一格持續做區域內的 processing
稱為 Local Histogram processing

Using histogram statistics for image enhancement
- n th moment n階動量:

- m is the mean value:

- :

- the sample mean and sample variance:

- example

- 以(x,y)為中心的區域算mean

- 以(x,y)為中心的區域算variance

- Local enhancement
- example

3.4 Fundamentals of Spatial Filtering
- neighborhood operation

Filtering
- Correlation → 內積

- convolution → 將mask旋轉

Smoothing mask
lowpass filtering:模糊化,低頻的背景被留下。


加起來為1
- Gaussian Filter
距離越遠,權重越小
- kernel

3.5 Smoothing Spatial Filters

Order-Statistics Filters
ordering (ranking)
比如 median filter

3.6 Sharpening Spatial Filters
highpass filtering:邊緣、雜訊
一階微分與二階微分
一階微分: 後面減掉前一項,絕對值最大可能為edge
二階微分: 前後項相加減兩倍項,產生一亮一暗的邊中間為反曲點(zero crossing)是edge

The Laplacian(二階)




|上下左右四點相加-四倍原點|
Unsharp masking and high-boost filtering
- 原圖 - 低頻(模糊) = 高頻(銳利化)

- 原圖 + 高頻 = 強化邊界

- 結果


The gradient(一階)


sobel operation

使用步驟:
- 先使用或的mask
- 或 > 閥值 就是 edge 的位置
邊界會隨著閥值而有差別
4.Image Enhancement in the Frequency Domain
Preliminary Concept
一個函數可以用sin, cos函數在不同週期情況下相加而成。
-
Euler’s formula
-
Fourier series

-
Fourier transform in continuous domain

對作傅立葉轉換
-
Fourier transform may be written for convenience as

與上者相同
-
Inverse Fourier transform

可逆的
-
Using Euler’s formula

-
舉例

代入的範圍

-
Fourier spectrum(energy)
以下為r長度的統計圖,另外還有的Fourier phase angle


Convolution



兩個函數作Convolution的結果作Fourier = 各別作Fourier的乘積。
Sampling

第一、二張圖作乘積變為採樣後的第四張圖

- 第一張為Fourier的圖
- 第二三四張為不同的採樣頻率:
- 第二張太大
- 中間剛好,週期相同

- 第三張太小


將離散的值作積分:

也就能直接推導成

- Discrete Fourier transform (DFT)

- Inverse discrete Fourier transform (IDFT)

- DFT計算範例:




- IDFT計算範例
- 2-D discrete Fourier transform (DFT)

- Inverse discrete Fourier transform (IDFT)

- 觀念

- 計算範例

- 圖片示例

原圖→Fourier→原圖先經由以下公式轉換後再Fourier

會將亮點移到中間,方便處理


Fourier Spectrum and Phase Angle

zero padding
5x5 3x3 -> 9x9 padding zero
nxn mxm
n+m+1
The 2-D convolution Theorem




Frequency Domain Filtering Foundamentals

為什麼轉到 Frequency Domain ,因為在空間域做convolution需要花很多時間。
左:低頻,均值被拉高,模糊化
中右:高頻,背景消失,邊緣強化
Summary of Steps for Filtering in the Frequency Domain
- MxN -> PxQ, P = 2M and Q = 2N.
- padded
- f by
- DFT
- 位置相乘 array multiplication
- IDFT

- MxN 挖出來

Extension to Functions of Two Variables
5. Image Restoration
A model of the image degradation/restoration process

意外加入了雜訊,如何去做還原。
Noise Models
Gaussian (normal) noise model


Rayleigh noise model
超音波雜訊

PDF:

Mean and Variance:


Other
- Erlang (gamma) noise model

- Exponential noise model

- Uniform noise model

- Impulse (salt-and-pepper) noise model



Restoration in the presence of noise only-spatial filtering

無法完全去除雜訊的影響,只能盡可能減少
Mean Filters 考試
皆是估計出來的,而非原圖
- Arithmetic mean filter

算出mask的算術平均值:mxn的mask,mask內相加除以mxn。
畫面:越大越模糊,越小存在更多雜訊
計算:越大越久,越小越快
- Geometric mean filter

算出mask的幾何平均值:mask內相乘開mxn的根號
- Harmonic mean filter

算出mask的調和平均值
- Contraharmonic mean filter

- 還原效果


Order-Statistics Filters
- Median filter
- 取出排序
- 填入中位數
- Max and min filters


- Midpoint filter

取最大跟最小除二
- Alpha-trimmed mean filters

砍掉頭尾d個算中間的平均
- 還原效果



Adaptive Filters
Faster-RCNN: Anchor Base
- RPN(Region Proposal Network)
Anchor 瞄框
GT 真實框
去產生提議框(Proposal box) -> 正提議框(I.O.U≧0.7), 負提議框(I.O.U≦0.3)
- 提取提議框在特徵圖內的區域(部分)的特徵圖,再以提議框與真實框來提取bounding box(結果)
R.O.I Pooling, R.O.I Aligment 提議框大小一致
- NMS(non-maximun supression)來去除多餘框
非最大值壓抑
TWO-stage methon