%jhjubm *nbhf 1spdfttjoh · microsoft powerpoint - 2017term2-image ch03-part3 author: panomkhawn...

Post on 03-Oct-2020

0 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

305434

Digital Image Processing

Chapter3

Intensity Transformation

and Spatial Filtering

Part 3

ผศ.ดร.พนมขวัญ ริยะมงคล

Spatial Filter

Filter คือ image ยอย (subimage) ที่มีคาของแตละ pixel เปนคา coefficient

อาจเรียกไดเปนชื่ออ่ืน เชน

Mask

Template

Window

Kernel

• สวนใหญจะมีขนาดเปนเลขค่ี เชน 3x3, 5x5, …

กลไกของ spatial filtering

(Figure from Rafael C. Gonzalez and Richard E.

Wood, Digital Image Processing, 3rd Edition.

Linear spatial filtering

คือ ผลรวมของผลคูณของคาของ filter กับคาของ

pixel ในตําแหนงท่ีสอดคลองกัน

• ให g(x, y) คือผลลัพธที่ตาํแหนง (x, y) และ linear spatial

filter มีขนาด 3x3 จากรูปท่ี 3.28

ขอสังเกต w(0, 0) อยูตรงกับ (x, y)

g(x, y) = w(-1, -1) *f( x-1, y-1) + w(-1, 0)*f(x-1 , y) + …

+ w( 0, 0)*f(x, y) + … + w(1, 1)*f(x+1, y+1)

• เขียนรูปแบบท่ัวไป ของวิธีการ linear spatial filtering ของ

image f ขนาด MxN โดยใช linear spatial filter ขนาด mxn

ไดเปน

a

at

b

bt

tysxftswyxg ),(),(),(

ซ่ึง a = (m-1)/2 and b = (n-1)/2

เพ่ือใหได image g อยางสมบรูณจะตองหาคาใหครอบคลุม

x = 0,… M-1 และ y = 0, … , N-1

• ในกรณีที่ filter อยูเกินขอบของ image เชนที่ (0, 0) ก็

อาจจะมีหลายวิธีในการหาผลลัพธ เชน

กําหนดใหสวนที่เกินจาก image ใหมีคาเทากับ 0 ซ่ึง

เรียกวา “zero padding”

ตัดสวนท่ีไมเก่ียวของทิ้งไป

Nonlinear spatial filtering

• มีการใช filter เชนเดียวกับ linear spatial filtering

แตผลลพัธท่ีไดเกิดจากเงื่อนไขการพิจารณาที่กาํหนด

Generating Spatial Filter Masks

• ในการสราง m×n linear spatial filter จะตองกําหนดคา

coefficient ซ่ึงขึ้นอยูกับวาตองการให filter ทํางานอยางไร

โดยยังคงใชหลักการหาคําตอบดวยผลรวมของผลคูณ

• ในการสราง nonlinear spatial filter จะตองกําหนดขนาด

ของขอบเขตและกระบวนการท่ีจะกระทํากับ pixels ใน

image

Smoothing Spatial Filters

• ใชสําหรับ

การทําใหภาพเบลอ (blurring) (อาจจะใชในกระบวนการ

preprocessing เชนลดรายละเอียด เล็ก ๆ นอย ๆ หรือ

เช่ือมตอชองวางเล็ก ๆ ในเสนตรงหรือเสนโคง)

ลดสัญญาณรบกวน (noise)

Smoothing Linear Filters

คาที่ไดคือ คาเฉลี่ยของ pixels ที่อยูในขอบเขตของ mask ซ่ึงจะเรียกวา

“averaging filter”

วิธีการ : จะคํานวณหาคาของ pixel ที่อยูใน image ดวยคาเฉลี่ยของ

intensity levels ในขอบเขตที่กําหนด

ผลลัพธ : จะลดสวนที่มีการเปลีย่นแปลงกะทนัหัน (sharp transition )

เชน สัญญาณรบกวนซ่ึงจะม ีsharp transition มาก อยางไรก็ตาม

ลดความคมชัดของขอบ (Edge) ลง

• ถาตองการหาคาเฉลี่ยของ pixel ท่ีอยูในขอบเขตของ filter

ขนาด 3x3 ควรกําหนดคาของ coefficient ใน mask อยางไร

เพ่ือใหไดผลลัพธตามสมการ

9

19

1

iizR

3x3 smoothing linear filter

ขอสังเกต : ผลรวมของคาสัมประสิทธิ์ของ mask = 1

(Figure from Rafael C. Gonzalez and Richard E.

Wood, Digital Image Processing, 3rd Edition.

• ถาตองการเพ่ิมความสําคัญของ pixel ที่ตองการ ก็อาจจะใช

weighted average filter โดยมีสมการดังตอไปนี้

a

at

b

bt

a

at

b

bt

tsw

tysxftswyxg

),(

),(),(),(

ตวัอยาง

Image Mask จากรูป 3.32a

ให e อยูที่ตําแหนง (x, y) จะไดคาท่ีตําแหนง (x, y)

หลังการใช mask

R(x, y) = (1/9)*a + (1/9)*b + (1/9)*c +

(1/9)*d +(1/9)*e + (1/9)*f +

(1/9)*g + (1/9)*h + (1/9)*i

ตวัอยาง การใช smoothing linear filter

Image

500x500 pixels

(Figure from Rafael C. Gonzalez and Richard E.

Wood, Digital Image Processing, 3rd Edition.

a)Original image

b)-f) ผลลัพธของการใช

averaging filter ขนาด n =

3, 5, 9, 15 และ 35 ตามลําดบั

(Figure from Rafael C. Gonzalez and Richard E.

Wood, Digital Image Processing, 3rd Edition.

http://slideplayer.com/slide/8521074/

ตวัอยาง การใช smoothing linear filter

(Figure from Rafael C. Gonzalez and Richard E.

Wood, Digital Image Processing, 3rd Edition.

Order-Statistics filters

• nonlinear spatial filter โดยมีผลลัพธข้ึนอยูกับการจัดลําดับ

ของ pixel ที่อยูในพ้ืนท่ีของ pixel ตรงกลาง

• มีประสิทธิภาพดี เม่ือใชกับ “salt and pepper noise” (จุด

ขาวดําใน image)

ตัวอยาง การใช median filter

Image ตัวอยาง

ใหตําแหนง (x, y) อยูตรงเลข 8 จะไดคาที่ตาํแหนง (x, y)

หลังการใช median filter ขนาด 3x3 โดย

เรียงลําดับคาของ pixel ที่อยูใน image จะได

1 2 3 4 5 6 7 8 9 ซ่ึงคากลางคือ 5

ผลลัพธคือ คาที่ตาํแหนง (x, y) เทากับ 5

ตัวอยาง

(Figure from Rafael C. Gonzalez and Richard E.

Wood, Digital Image Processing, 3rd Edition.

Sharpening Spatial Filters

• จะทําใหภาพคมชัดข้ึน

• จะพิจารณา sharpening filter ที่เปนแบบ

–First-order derivative

–Second-order derivative

First-order derivative

• สมการสําหรับฟงกชันหน่ึงมิติ f(x)

Second-order derivative

• สมการสําหรับฟงกชันหน่ึงมิติ f(x)

พื้นที่ที่จะพิจารณา

• Flat segment (สวนราบ)

• Step (ขั้นบันได)

• Ramp (ลาดเอียง)

(Figure from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 3rd Edition.

การใช second-order derivatives

• สําหรับฟงกชันสองมิติ เขียนสมการ second-order

derivatives หรือ Laplacian ไดเปน

Discrete form of Laplacian

เขยีนใน x-direction และ y-direction

จะได

เขียนเปน Laplacian mask

Laplacian mask แบบตาง ๆ

(Figure from Rafael C. Gonzalez and Richard E.

Wood, Digital Image Processing, 3rd Edition.

การทําใหภาพมคีวามคมชดัขึ้น

• ใช ลบ เม่ือคาสัมประสิทธิ์ที่ตําแหนงศูนยกลางของ

Laplacian mask เปน ลบ

• ใช บวก เมื่อคาสัมประสิทธิ์ที่ตําแหนงศนูยกลางของ

Laplacian mask เปน บวก

Example of applying Laplacian with images

https://mipav.cit.nih.gov/pubwiki/index.php/Filters_(Spatial)_Laplacian

http://aishack.in/tutorials/sobel-laplacian-edge-detectors/

(Figure from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 3rd Edition.

Unsharp Masking

and Highboost Filtering

Unsharp Masking คือกระบวนการสราง mask จากการนํา

unsharped (smoothed) version ของ image มาลบกับ original

image

ในการใชงานประกอบดวยข้ันตอนดังตอไปนี้

ทําให original image เบลอ

ลบ blurred image กับ original image (เรียกวา mask)

บวก mask กับ original image

กําหนดให คอื blurred image

กระบวนการ unsharp masking แสดงไดดวยสมการ

บวก mask ที่ถูกเพ่ิมคาน้ําหนกั (k โดยที่ k มีคามากกวาหรือ

เทากับ 0) แลวกับ original image

จะได

unsharp masking จะกําหนดใหคา k = 1

),(),(),( yxfyxfyxgmask

),( yxf

),(*),(),( yxgkyxfyxg mask

เม่ือคา k มากกวา 1 จะเรียกวา “highboost filtering”

(Figure from Rafael C. Gonzalez and Richard E.

Wood, Digital Image Processing, 3rd Edition.

(Figure from Rafael C. Gonzalez and Richard E.

Wood, Digital Image Processing, 3rd Edition.

(e) ใช k=4.5

ซ่ึงเปนคาสูงสุดท่ี

เปนไปไดท่ีทําให

ทุกคายังคงเปนบวก

Unprocessed, slight unsharpmasking,

then strong

unsharpmasking.

https://en.wikipedia.org/wiki/Acutance

Source image (top), sharpened

image (middle),

highly sharpened

image (bottom)

https://en.wikipedia.org/wiki/Unsharp_masking

การใช first-order derivatives

(The Gradient)• สําหรับฟงกชันสองมิติ เขียนสมการ gradient อยูในรูปแบบของ

vector ไดเปน

เขียนสมการ first-order derivatives หรือ ขนาดของ gradient ไดเปน

y

fx

f

g

gfgradf

y

x)(

22)(),( yx ggfmagyxM

• เพ่ือใหงายตอการคํานวณ จะใช absolute แทน

สมมติให image มีพ้ืนที่ขนาด 3x3 ม ีgray level เปนคา Z1-9

||||,( yx ggyxM

(Figure from Rafael C. Gonzalez and Richard E.

Wood, Digital Image Processing, 3rd Edition.

• ให Z5 เปน center แทนดวย f(x,y)

• เรียกวา “Robert cross-gradient operators”

)()( 6859 zzgandzzg yx

||||),( 6859 zzzzyxM

• อาจจะกําหนดเปน

เรียกวา “Sobel operators”

)2()2(

)2()2(

741963

321987

zzzzzzg

and

zzzzzzg

y

x

|)2()2(|

|)2()2(|),(

741963

321987

zzzzzz

zzzzzzyxM

“Robert cross-gradient

operators”

“Sobel operators”

(Figure from Rafael C. Gonzalez and Richard E.

Wood, Digital Image Processing, 3rd Edition.

ตัวอยาง การใช sobel operators

(Figure from Rafael C. Gonzalez and Richard E.

Wood, Digital Image Processing, 3rd Edition.

Example

http://www.code2learn.com/2011/02/edge-detection-of-image-

using-matlab.html

https://www.researchgate.net/publication/236125496_Image_processing_and_recognition_for_biological_images/figures?lo=1

top related