Top Banner
Digital Image Digital Image Processing and Processing and Analysis (I) Analysis (I) Image Processing
44

Digital Image Processing and Analysis (I) Image Processing.

Dec 20, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Digital Image Processing and Analysis (I) Image Processing.

Digital Image Processing and Digital Image Processing and Analysis (I)Analysis (I)

Image Processing

Page 2: Digital Image Processing and Analysis (I) Image Processing.

What are images ? 廣義 :

– image 就是 pictures– 一種視覺化的方式來做紀錄或呈現– 基本上人類是一種視覺化的生物 , 我門利用眼

睛來接收大部分的資訊 , 而我們的腦也非常的習慣來對這些視覺化的資料做處理

– 在科學的領域上有句常說的話• “a picture is worth a thousands words”

Page 3: Digital Image Processing and Analysis (I) Image Processing.

波長 (/m)10-12 10-10 10-8 10-6 10-4 10-2 1 102 104

Gamma rays

X-rays UV IR microwaves FM radio

400 700600500

紫 藍 綠 黃 紅

(/nm)

Page 4: Digital Image Processing and Analysis (I) Image Processing.

狹義 :– Image 是描述一個表面其參數是如何的變化

標準的視覺影像 :– 在一個 2D 的平面上光的強度變化程度

然而光線並不是唯一被使用在科學影像上的參數 , 影像尚可由– 積體電路電流的溫度所形成– 人動脈血液的流動形成– 從遠方銀河放射來的 X-ray 所形成– 當地震時地面產生的移動所形成

這些奇特的影像都會被轉換成我們所習慣的圖像 ( 如光所形成的影像 ), 因此他們得以被人類的眼睛所估算

Page 5: Digital Image Processing and Analysis (I) Image Processing.

數位影像的結構 這個影像是由 40,000 個樣本在一個具有 200 個行

和 200 個列的 2D 的陣列中組成 ,

Page 6: Digital Image Processing and Analysis (I) Image Processing.

每一個樣本我們將其稱之為像素 (pixel) 像素是由一個從 0 ~ 255 的數字所構成 這個數字是和微波的能量從行星表面反射有關 為了表現將這樣的一個數字變為視覺化的影像 , 我們必須將每一個像

數轉換成灰階 ,0 代表黑色 ,255 代表白色

Page 7: Digital Image Processing and Analysis (I) Image Processing.

影像的大小– 典型的數位影像 : 500500500500

• 例如 television, personnel computer applications, and general scientific research.

– 有時使用 會使用大於 1000100010001000 • 例如 computer graphics, high-definition

television, and 35 mm motion pictures.

– 偶而需要使用 several thousand pixels per several thousand pixels per sideside• 例如 digitized x-ray images, space photographs,

and glossy advertisements in magazines.

Page 8: Digital Image Processing and Analysis (I) Image Processing.

影像的解析度

Page 9: Digital Image Processing and Analysis (I) Image Processing.

為什麼會想限制影像的大小 :– 因為大部分影像處理所碰到的困難其實都是在

管理非常大量的資料– Ex:

• 一秒的數位化聲音約佔 8KB

• 一秒的數位化影像約佔 8MB

Page 10: Digital Image Processing and Analysis (I) Image Processing.

灰階 通常使用 256 gray levels

– 電腦記憶體儲存方便 • a single byte is convenient for data

management

– 人眼有自動平均的能力• the large number of pixels in an image

compensate to a certain degree for a limited number of quantization steps

– 人眼判別灰階的能力有限• a brightness step size of 1/256 (0.39%) is

smaller than the eye can perceive.

Page 11: Digital Image Processing and Analysis (I) Image Processing.

較精細的灰階能夠提供更多的資訊給電腦,雖然人眼看不見,但是較精細的灰階可能能夠使得電腦程式提供較好的結果,在這類情況下,常會使用較精細的灰階資訊。

Page 12: Digital Image Processing and Analysis (I) Image Processing.

彩色影像 使用 3 個數字來代表一個像素 (RGB) 藉由呈現這 3 個數值的強度來表示像素 混合這三種顏色可以產生所有可能的顏色 通常使用 1 的 Byte 來儲存一個顏色 , 因此

所有的顏色約– 256x256x256 ≈ 16.8 百萬

Page 13: Digital Image Processing and Analysis (I) Image Processing.

Image Process 簡單的說 :

– 就是利用各種方法來操作及修改影像– 攝影師和物理學家可以利用一些化學物質或光

學設備來完成一些影像處理的操作 Digital image processing (DIP):

– 利用電腦來進行影像處理– 不單指影像處理 ,還包括影像如何取得 , 儲存

和呈現

Page 14: Digital Image Processing and Analysis (I) Image Processing.

數位影像的技術實際上要來得比電腦發展早 , 在 1920早期 ,報紙的圖片就以數位化的方式利用海底纜線來橫度大西洋

DIP 一直等到電腦硬體發展到一定的技術時才漸漸熱門

Page 15: Digital Image Processing and Analysis (I) Image Processing.

All three are interrelated ! – Image Processing: Images to Images.Images to Images.

• Image → enhanced, restored, feature-extracted, or compressed image data.

– Computer Vision: Images to Descriptions.Images to Descriptions.• Image → 2- or 3-D description or interpretation.

– Computer Graphics: Descriptions to Images.Descriptions to Images.• 2- or 3-D description → Image (synthesized)

Pattern Recognition: (Classification)

– Transducer → Feature Extraction → Classification.

Image Processing, Computer Vision and Computer Graphics

Page 16: Digital Image Processing and Analysis (I) Image Processing.

Example: Volume rendering for medical Volume rendering for medical

applicationsapplications::

– Clean up the image:

• (( image processing image processing ))

– Separate the regions of interest:

• segmentation.

• (( computer vision computer vision ))

– Render:

• (( computer graphics computer graphics ))

Page 17: Digital Image Processing and Analysis (I) Image Processing.

Digital Image Processing and Analysis (I)

Image File Format

Page 18: Digital Image Processing and Analysis (I) Image Processing.

JPEG

Page 19: Digital Image Processing and Analysis (I) Image Processing.

JPEG Joint Photographic Experts Group (聯合圖像專家組織 )

1991年公佈規範 ,屬於 ISO 10918-1 的標準 主要特性 :

– 其設計目的用來壓縮全彩或黑白的自然寫實影像

– 用在照片或美術作品方面的表現繪比只有線條的圖形要來得恰當

– 主要用來處理靜態的影像 ,至於動態影像方面則有另一個技術稱之為 MPEG

Page 20: Digital Image Processing and Analysis (I) Image Processing.

– JPEG 所採用的壓縮技術稱之為失真壓縮 ,即解壓縮之後所得的影像並不會與壓縮前的影像完全一樣

– 處理檔案的大小上具更大的壓縮比 , 利於傳輸 ,相對地 , 在演算法的編碼及解碼上較費時

– 由於人類的眼睛雖然對於微小的亮度發生改變可以正確的感覺出來 , 但是對色彩些微的改變時 ,卻無法察覺

Page 21: Digital Image Processing and Analysis (I) Image Processing.

– JPEG 就是針對那些人類無法察覺到的色彩變化來進行壓縮 , 但是如果我們利用機器對影像進行分析 ,則由 JPEG 所產生出來微小的影像誤差有仍可能會產生錯誤 , 而這個錯誤是眼睛所觀察不到的

– JPEG 的另一個特點在於其具有階段性的失真壓縮能力 , 不太在乎影像的品質 , 可以把影像壓縮的非常小 , 如果影像的品質太差時 , 我們也可以調整到滿足我們需求的程度

Page 22: Digital Image Processing and Analysis (I) Image Processing.

JPEG壓縮影像的原理 JPEG 的壓縮法是利用離散餘弦轉

(Discrete Cosine Transform ; DCT) 的壓縮技術來儲存靜態影像的檔案格式

JPEG 利用 DCT把整個影像壓縮成許多8x8 像素的正方形格子所構成的「像素訊息方塊」並將之按照一定順序排列的方式儲存後進行壓縮,每一次壓縮都會捨棄若干頻率訊息,壓縮得越多,則捨棄的頻率訊息也越多

Page 23: Digital Image Processing and Analysis (I) Image Processing.

完整的影像

DCT計算

量化

可變長度碼分配

8x8 像素的區塊

52 55 61 66 70 61 64 73 63 59 66 90 109 85 69 72 62 59 68 113 144 104 66 7363 58 71 122 154 106 70 6967 61 68 104 126 88 68 7079 65 60 70 77 68 58 7585 71 64 59 55 61 65 8387 79 69 68 65 76 78 94

壓縮前 (512 bits)1010110 0100 001 0100 0101 100001 0110 100011 001 100011 001 001 100101 11100110 110110 0110 11110100 000 1010

壓縮後 (92 bits)

壓縮比約 5.6 : 1

Page 24: Digital Image Processing and Analysis (I) Image Processing.

JPEG檔之缺失及近年來之發展 網路上 JPEG 的圖檔只能一行一行地下載 ,直到全部下載完畢 ,才可以看到整個影像

JPEG檔案的體積仍然過大 ,再加上其為失真壓縮 , 當被壓縮的圖像上有大片的近似顏色時 ,即會產生「馬賽克」的現象

對於許多影像品質要求較高的應用領域 ,JPEG 並不是一個好的選擇

Page 25: Digital Image Processing and Analysis (I) Image Processing.

JPEG2000 在 2000 年 3月的東京會議 ,靜態圖像的新

一代編碼方式「 JPEG2000」的編碼演算法才告確定

其核心在於它的新演算法放棄了以原本所採用 DCT 為主的區塊編碼方式,而改用以離散小波轉換演算法為主的編碼方式

http://www.jpeg.org/JPEG2000.htm

Page 26: Digital Image Processing and Analysis (I) Image Processing.

BMP

Page 27: Digital Image Processing and Analysis (I) Image Processing.

BMP BMP (Bitmapped) 影像是 Microsoft公司自

行規劃的影像檔案格式 BMP檔案格式是和顯示裝置無關的 , 所以又稱為 DIB (Device-Independent Bitmap),這種格式的圖形檔可以是 2 色、 16色、 256 色或是全彩 (16777216 色 )

Page 28: Digital Image Processing and Analysis (I) Image Processing.

BMP檔案的特色 檔案結構只能存放一張資料 只儲存單色、 16 色、 256 色和全彩 (16,777,216

色 )四種影像資料 影像資料可以選擇壓縮或不壓縮 Windows設計了兩種壓縮方式: RLE4 和 RLE8,

其中 RLE4只能處理 16 色的影像 , 而 RLE8則只用在 256 色的影像資料

影像資料排列順序和一般影像檔有所不同 調色盤的資料結構特殊

Page 29: Digital Image Processing and Analysis (I) Image Processing.

BMP檔案的結構 分成三部分 :

BMP檔頭資料區

調色盤資料區

影像資料區

Page 30: Digital Image Processing and Analysis (I) Image Processing.

檔頭的大小固定為 54 個 Bytes 檔案最前面兩個位元組為固定常數 0x4D42 ( 字

串 BM) 調色盤的部分 ,只有全彩的 BMP檔案內沒有調

色盤資料 , 其餘的三種色彩模式 ( 單色、 16 色和256 色 ) 都必須有調色盤資料

它儲存影像的資料順序是由下而上 , 由左而右 ,亦即 BMP檔案是以螢幕的左下角作為起點 ,依據左至右 , 下而上的次序直到螢幕的右上角為止

Page 31: Digital Image Processing and Analysis (I) Image Processing.

檔案儲存格式 單色影像方面是以 1 個 Byte 儲存 8 個像

素 -調色盤會有 2 組 16 色影像是以 1 個 Byte 儲存 2 個像素 -調

色盤有 16 組 256 色影像是以 1 個 Byte 儲存 1 個像素 -調色盤有 256 組

全彩影像則是以 3 個 Byte 儲存 1 個像素

Page 32: Digital Image Processing and Analysis (I) Image Processing.

調色盤由四個 Byte (BGRA) 組成:第一個 Byte是藍色所佔的強度、第二個 Byte 是綠色所佔的強度、第三個 Byte 是紅色所佔的強度 ,第四個Byte則為保留位元

圖形是兩種顏色 ( 黑白 ),則調色盤所佔的空間為8 Bytes

16 色 ,則調色盤佔了 64 Bytes 256 色時 ,調色盤將佔去 1024 Bytes 圖形為全彩時 , 圖形資料本身每個點就佔了 3 個

Byte,正好可視為調色盤

Page 33: Digital Image Processing and Analysis (I) Image Processing.

TIFF

Page 34: Digital Image Processing and Analysis (I) Image Processing.

TIFF 全名為 Tag Image File Format 其設計的原意是專門用來處理掃描器所產

生的影像資料 而後逐一的增加檔案內的識別資訊與壓縮

法,成為一種包容萬象的影像檔案格式

Page 35: Digital Image Processing and Analysis (I) Image Processing.

TIFF檔案的特色 可利用指標功能 , 儲存多張影像畫面 檔案內的資料區塊沒有固定的排列順序 可以制定私人用的標籤訊息 可接受多種不同的影像格式 ,除了一般的 RGB外

尚可接受 CMYK (靛青 , 紫紅 , 黃 , 黑 ) 等影像模式

可儲存多份調色盤資料 調色盤資料型態和排列順序特殊 影像畫面可分割成幾個部分儲存

Page 36: Digital Image Processing and Analysis (I) Image Processing.

TIFF檔案的結構 主要由三種資料段所組成 ,檔頭、標籤資

訊區段、影像資料區段 – 每個檔案內只有一個檔頭 , 而且必定位於檔案

的最前端 – 標籤資訊區段內有多組標籤資訊 , 每一組標籤

資訊的長度固定為 12 個 Bytes

Page 37: Digital Image Processing and Analysis (I) Image Processing.

檔案儲存格式 單張影像及多張影像之儲存方式不同

– 單張影像 :

TIFF檔頭資料

標籤資訊區段

影像資料區段

Page 38: Digital Image Processing and Analysis (I) Image Processing.

– 多張影像

TIFF檔頭資料

標籤資訊區段

影像資料區段

標籤資訊區段

影像資料區段

Page 39: Digital Image Processing and Analysis (I) Image Processing.

TIFF檔頭資料的起點必為 0x4949(II) 或0x4D4D(MM)

TIFF檔案內的調色盤有著特殊的儲存方式 ,首先是將 1 個 Byte 單位的顏色值改用 2 個 Bytes 儲存 , 如此一來 ,16 色調色盤的資料原本是 48 Bytes

TIFF檔案還改變了調色盤的儲存方式 :– 一般影像檔案的調色盤是以 RGB相間

(RGBRGBRGBRGB…) 的形式儲存– 但是 TIFF則是把調色盤中所有的紅色值先儲存 , 接著

儲存綠色值 ,最後儲存藍色值 , 以 RGB 的色帶形式儲存 (RRRR….GGGG….BBBB…..)

Page 40: Digital Image Processing and Analysis (I) Image Processing.

GIF

Page 41: Digital Image Processing and Analysis (I) Image Processing.

來自於 Graphics Interchange Format 的縮寫 這個檔案格式的設計是為了方便網路使用者傳送影像資料 . 如今 ,GIF檔案也已成為網路上最常使用的影像檔

Page 42: Digital Image Processing and Analysis (I) Image Processing.

GIF檔案的特色 檔案具有多元化結構 , 能夠儲存多張的影像畫面 根據區塊的第一個位元組 (Byte) 來尋找及辨識資

料區塊 調色盤的資料有通用調色盤和局部調色盤兩種 採用改良的 Lempel Ziv Welch(LZW)壓縮法 , 其演算法是屬於無失真式的壓縮

影像資料以 1 個 Byte 儲存 1 個像素 影像資料有兩種排列方式:循序排列與交錯排列 最多只能儲存 256 色的影像畫面

Page 43: Digital Image Processing and Analysis (I) Image Processing.

GIF檔案的結構 由七項資料單元所構成

GIF 表頭資料

通用調色盤

註解補充區段

圖形控制補充區段

影像資料區段

文字補充區段

應用補充區段

Page 44: Digital Image Processing and Analysis (I) Image Processing.

每一個影像資料區段內儲存一張影像畫面 四個補充區段 也都可以在檔案中出現一次

以上 而影像資料區段與四個補充區段 中的第一

個 Byte 是用來當作辨識的符號 若使用 GIF檔案只是用來儲存影像資料

時 , 這樣的 GIF 影像檔並不需要儲存這四個補充區段 的資料