image processing & computer vision
DESCRIPTION
Image Processing & Computer Vision. การแปลงข้อมูลภาพในสองมิติ Two Dimensional Geometric Transformation. Image Transformation. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Image Processing & Computer Vision](https://reader034.vdocuments.site/reader034/viewer/2022050800/568131f7550346895d98527b/html5/thumbnails/1.jpg)
Image Processing & Computer Visionการแปลงขอ้มูลภาพในสองมติิ
Two Dimensional Geometric Transformation
![Page 2: Image Processing & Computer Vision](https://reader034.vdocuments.site/reader034/viewer/2022050800/568131f7550346895d98527b/html5/thumbnails/2.jpg)
Image Transformation การแปลงขอ้มูลภาพ (Image Transformation) มี
ความจำาเป็นมากในการทำาการประมวลผลภาพ ยกตัวอยา่งเชน่ การทำา Template matching, Shape Matching, Image Search, Generalized Hough Transform
ซึ่งการใช ้Image Transformation นัน้ ใชเ้พื่อต้องการ ทำาการหมุนภาพ, ปรบัตำาแหน่งของภาพ, หรอืเล่ือนภาพ เพื่อใหอ้ยูใ่นตำาแหน่งท่ีเหมาะสม
![Page 3: Image Processing & Computer Vision](https://reader034.vdocuments.site/reader034/viewer/2022050800/568131f7550346895d98527b/html5/thumbnails/3.jpg)
การแปลงขอ้มูลภาพแบบพื้นฐาน การเลื่อนภาพ (Translation) ใชเ้พื่อทำาการเล่ือนภาพใหไ้ปวาง
ยงัตำาแหน่งใหม่ การหมุนภาพ (Rotation) ใชเ้พื่อทำาการหมุนภาพไปตามทิศทาง
เชน่ clockwise(ตามเขม็) หรอื counterclockwise(ทวนเขม็) โดยมกีารระบุองศาท่ีจะทำาการหมุนด้วย
การยอ่หรอืขยายภาพ (Scaling) ใชเ้พื่อทำาการยอ่ หรอื ขยายภาพโดยต้องมกีารระบุจำานวนเท่าของภาพท่ีจะทำาการยอ่หรอืขยายด้วย
การบดิภาพ (Shearing) ใชเ้พื่อทำาการบดิภาพใหม้รีูปทรงหรอืทิศทางต่างไปจากเดิม ซึ่งสามารถระบุใหบ้ดิภาพได้ทัง้ในแนวแกน x และ y
![Page 4: Image Processing & Computer Vision](https://reader034.vdocuments.site/reader034/viewer/2022050800/568131f7550346895d98527b/html5/thumbnails/4.jpg)
การเลื่อนภาพ (Translation) เป็นการเล่ือนตำาแหน่งของภาพตามระยะการขจดัตามแนว
แกน x(Tx) และตามแนวแกน y(Ty) เมื่อกำาหนดใหพ้กัิดเดิมคือ (x, y) และพกัิดใหมคื่อ (x’, y’)
ซึ่งจะทำาใหไ้ด้สมการของการเล่ือนภาพ ดังนี้
''
'yx
P
x’ = x + Tx
y’ = y + Ty
ซึง่สามารถเขยีนให้อยูใ่นรูปแบบของ Matrix ได้มลีักษณะดังนี้คือ P’ = P + T เมื่อ
yx
P
TyTx
Tและ
Tx = ระยะหา่งจากจุด x ทางแกนนอนTy = ระยะหา่งจากจุด y ทางแกนตัง้
![Page 5: Image Processing & Computer Vision](https://reader034.vdocuments.site/reader034/viewer/2022050800/568131f7550346895d98527b/html5/thumbnails/5.jpg)
การเลื่อนภาพ (Translation)
)5(' xx10' yy
การยา้ยภาพจากจุด (x, y) ไปยงัจุด (x’, y’) เชน่
y
x0
(x’,y’)
(x,y)
5 pixels
10 pixels
![Page 6: Image Processing & Computer Vision](https://reader034.vdocuments.site/reader034/viewer/2022050800/568131f7550346895d98527b/html5/thumbnails/6.jpg)
การหมุนภาพ (Rotation)
จากรูปเป็นการหมุนภาพในระนาบ xy เมื่อจุดศูนยก์ลางการหมุน (Pivot Point) อยูท่ี่จุด Origin (0,0)
![Page 7: Image Processing & Computer Vision](https://reader034.vdocuments.site/reader034/viewer/2022050800/568131f7550346895d98527b/html5/thumbnails/7.jpg)
การหมุนภาพ (Rotation)
การหมุนภาพต้องกำาหนดวา่จุดใดเป็นหมุนเสมอ และแบง่เป็น
1 .หมุนแบบทวนเขม็นาฬิกา2. หมุนแบบตามเขม็นาฬิกา3. จุดหมุนอยูท่ี่จุดกำาเนิด (origin) (0,0)4. จุดหมุนไมอ่ยูท่ี่จุดกำาเนิด (จุด x,y ใด ๆ)
![Page 8: Image Processing & Computer Vision](https://reader034.vdocuments.site/reader034/viewer/2022050800/568131f7550346895d98527b/html5/thumbnails/8.jpg)
การหมุนภาพ (Rotation) จุดพกัิด (x,y) ในระบบพกัิดฉาก คือกำาหนดตำาแหน่ง
จุดโดยบอกระยะทางในแนวนอนและแนวดิ่ง จุดพกัิด (x,y) ในระบบโพลาร ์คือการบอกตำาแหน่งจุด
โดยใชเ้วกเตอร์
![Page 9: Image Processing & Computer Vision](https://reader034.vdocuments.site/reader034/viewer/2022050800/568131f7550346895d98527b/html5/thumbnails/9.jpg)
การหมุนภาพ (Rotation)
ดังนัน้พกัิดของจุด (x’,y’) จะเกิดจากการนำาเอา +
![Page 10: Image Processing & Computer Vision](https://reader034.vdocuments.site/reader034/viewer/2022050800/568131f7550346895d98527b/html5/thumbnails/10.jpg)
การหมุนภาพ (Rotation)
x = r cos ()y = r sin ()x’ = r cos ( + )y’ = r sin ( + )
Trig Identity…x’ = r cos() cos() – r sin() sin()y’ = r sin() sin() + r cos() cos()
Substitute…x’ = x cos() - y sin()y’ = y sin() + x cos()
![Page 11: Image Processing & Computer Vision](https://reader034.vdocuments.site/reader034/viewer/2022050800/568131f7550346895d98527b/html5/thumbnails/11.jpg)
การหมุนภาพ (Rotation)
x’ = x cos() - y sin()y’ = y sin() + x cos()
ดังนัน้จากสมการ จะสามารถเขยีนเป็น Matrix ได้ดังน้ี P’ = R.P
P’ PR
yx
yx
.cossinsincos
![Page 12: Image Processing & Computer Vision](https://reader034.vdocuments.site/reader034/viewer/2022050800/568131f7550346895d98527b/html5/thumbnails/12.jpg)
การหมุนภาพ (Rotation) การหมุนภาพ ณ จุดใด ๆ ท่ีไมใ่ชจุ่ดกำาเนิดสำาหรบั
กรณีน้ีต้องใช ้3 ขัน้ตอนดังนี้1. ยา้ยจุดหมุน (xp,yp) ไปท่ี (0,0) และยา้ยจุดหมุนไปท่ีจุดใหมใ่ห้
ห่างจุดหมุนเดิม
![Page 13: Image Processing & Computer Vision](https://reader034.vdocuments.site/reader034/viewer/2022050800/568131f7550346895d98527b/html5/thumbnails/13.jpg)
การหมุนภาพ (Rotation)2. ยา้ยจุดหมุน (xp,yp) ไปยงัจุดกำาเนิด (0,0) เมื่อยา้ยแล้วทกุๆ จุด
(x,y) ท่ีใชนิ้ยามภาพ ก็จะถกูยา้ยไปยงัจุดใหม่ (x’,y’) ด้วย
3. ทำาการหมุนรอบจุดกำาเนิด(origin) 4. ทำาการยา้ยไปจุดเดิมโดยการบวก xp และ yp
5. สมการหมุนรอบจุด Pivot ใด ๆ ท่ีไมใ่ชจุ่ด origin คือ
x’ = x - xpy’ = y - yp
x’ = [(x – xp)cos - (y - yp)sin] + xpy’ = [(y – yp)sin + (x-xp)cos] + yp
![Page 14: Image Processing & Computer Vision](https://reader034.vdocuments.site/reader034/viewer/2022050800/568131f7550346895d98527b/html5/thumbnails/14.jpg)
การยอ่และขยายภาพ (Scaling) การยอ่และขยายภาพสามารถทำาได้โดยใช ้
Scaling factor ได้แก่ Sx และ Sy ซึง่ใชใ้นการยอ่และขยายภาพแกน x และ y ตามลำาดับโดย
0 < Sx,Sy < 1 แสดงวา่เป็นการยอ่ภาพSx,Sy > 1 แสดงวา่เป็นการขยายภาพSx = Sy แสดงวา่การยอ่และขยายเป็นไปตามอัตราสว่นSx Sy แสดงวา่การยอ่และขยายไมเ่ป็นไปตามอัตราสว่นy
x0fix point
y
x0fix point
รูปการยอ่ขยายภาพ ทำาให้ระยะห่างระหวา่งภาพกับจุดประจำาท่ี (fix point) เปล่ียนไป
![Page 15: Image Processing & Computer Vision](https://reader034.vdocuments.site/reader034/viewer/2022050800/568131f7550346895d98527b/html5/thumbnails/15.jpg)
การยอ่และขยายภาพ (Scaling)
X 2,Y 0.5
แสดงการยอ่และขยายภาพกรณี Sx และ Sy ไมเ่ท่ากัน
![Page 16: Image Processing & Computer Vision](https://reader034.vdocuments.site/reader034/viewer/2022050800/568131f7550346895d98527b/html5/thumbnails/16.jpg)
การยอ่และขยายภาพ (Scaling) สมการของการ Scaling จะมลีักษณะ ดังน้ี
x’ = x . Sxy’ = y . Sy
ดังนัน้การยอ่และขยายภาพโดยใช ้Matrix จะมลีักษณะดังนี้ คือ P’ = S.P
PP’
สงัเกตวา่การยอ่และขยายภาพจะทำาให้เกิดการเลื่อนตำาแหน่งของภาพ
![Page 17: Image Processing & Computer Vision](https://reader034.vdocuments.site/reader034/viewer/2022050800/568131f7550346895d98527b/html5/thumbnails/17.jpg)
การยอ่และขยายภาพ (Scaling) การยอ่และขยายภาพเมื่อจุด Fixed ไมไ่ด้อยูท่ี่จุด
Origin1. ให้ยา้ยตำาแหน่งไปท่ีจุด origin2. ทำาการยอ่หรอืขยายรอบจุด origin3. ยา้ยไปยงัจุด Fixed point เหมอืนเดิม ซึง่จะได้สมการ ดังนี้ x’ = (x - xf).Sx + xf
y’ = (y - yf).Sy + yf
![Page 18: Image Processing & Computer Vision](https://reader034.vdocuments.site/reader034/viewer/2022050800/568131f7550346895d98527b/html5/thumbnails/18.jpg)
การยอ่และขยายภาพ (Scaling)
4. จะแปลงได้เป็นดังนี้ คือ
5. ดังนัน้การยอ่และขยายภาพ จะอยูใ่นรูป Matrix ดังนี้
x’ = xSx + xf(1 - Sx)y’ = ySy + yf(1 - Sy)
![Page 19: Image Processing & Computer Vision](https://reader034.vdocuments.site/reader034/viewer/2022050800/568131f7550346895d98527b/html5/thumbnails/19.jpg)
การบดิภาพ (Shearing) คือการปรบัทิศทางของภาพให้เพีย้นไปจากเดิมมี
สองแบบ คือ1. การบดิภาพทางแกน x2. การบดิภาพทางแกน y- การบดิภาพทางแกน y ทำาให้เกิดการยา้ยจุด (x,y) ไป (x’,y’) โดยท่ี
x’ = xy’ = Shy.x + y
![Page 20: Image Processing & Computer Vision](https://reader034.vdocuments.site/reader034/viewer/2022050800/568131f7550346895d98527b/html5/thumbnails/20.jpg)
การบดิภาพ (Shearing)- การบดิภาพทางแกน x ทำาให้เกิดการยา้ยจุด (x,y) ไป (x’,y’) โดยท่ี
x’ = Shx.y + x y’ = y
![Page 21: Image Processing & Computer Vision](https://reader034.vdocuments.site/reader034/viewer/2022050800/568131f7550346895d98527b/html5/thumbnails/21.jpg)
Homogeneous Coordinate การอ้างอิงโคออดิเนตท่ีผ่านมาจะมสีองตำาแหน่งคือ x และ y
ซึง่เรยีกวา่ Cartesian coordinate ขอ้เสยีของ cartesian คือเมื่อมกีารแปลงภาพหลาย ๆ อยา่งเขา้ด้วยกันจะทำาให้ผลลัพธข์อง Matrix การแปลงภาพอยูใ่นรูปของการบวกและการคณูกันของ Matrix ดังนัน้เพื่อให้ผลลัพธข์องการแปลงภาพอยูใ่นรูปของการคณูกันของ Matrix ท้ังหมด จะทำาให้ง่ายต่อการคำานวณ จงึกำาหนดให้ม ีHomogeneous coordinate ขึน้ ซึง่มลีักษณะ ดังน้ี
![Page 22: Image Processing & Computer Vision](https://reader034.vdocuments.site/reader034/viewer/2022050800/568131f7550346895d98527b/html5/thumbnails/22.jpg)
Homogeneous Coordinate ดังนัน้ Matrix ของการแปลงแบบต่าง ๆ จะมลัีกษณะ ดังน้ี
การเลื่อนภาพ การหมุนภาพ
การยอ่ขยายภาพ การบดิภาพ
![Page 23: Image Processing & Computer Vision](https://reader034.vdocuments.site/reader034/viewer/2022050800/568131f7550346895d98527b/html5/thumbnails/23.jpg)
Combining Transformation ตัวอยา่งของการเลื่อนภาพ ถ้ามกีารแปลงภาพ 2 ครัง้
1. ยา้ยโดยใช ้(Tx1,Ty1)2. ยา้ยโดยใช ้(Tx2,Ty2)สมการของการเลื่อนภาพจะมลีักษณะ ดังนี้
![Page 24: Image Processing & Computer Vision](https://reader034.vdocuments.site/reader034/viewer/2022050800/568131f7550346895d98527b/html5/thumbnails/24.jpg)
Combining Transformation ตัวอยา่งของการหมุนภาพ ถ้ามกีารหมุนภาพสอง
ครัง้1. หมุนภาพโดยใช ้R(1)2. หมุนภาพโดยใช ้R(2)สมการของการหมุนภาพจะมลีักษณะดังนี้
![Page 25: Image Processing & Computer Vision](https://reader034.vdocuments.site/reader034/viewer/2022050800/568131f7550346895d98527b/html5/thumbnails/25.jpg)
Combining Transformation ตัวอยา่งการยอ่ขยายภาพ ถ้ามกีารยอ่ขยายภาพ 2
ครัง้1. ยอ่ภาพโดยใช ้S(Sx1,Sy1)2. ยอ่ภาพโดยใช ้S(Sx2,Sy2)สมการของการยอ่ขยายภาพจะมลีักษณะดังนี้
![Page 26: Image Processing & Computer Vision](https://reader034.vdocuments.site/reader034/viewer/2022050800/568131f7550346895d98527b/html5/thumbnails/26.jpg)
Example of Composition ตัวอยา่งแสดงการ Rotation รว่มกัน
Translationทำาการหมุนเสน้ตรงเป็นเป็นมุม 45 องศา โดยใช้จุด a เป็นจุดหมุน
aa
![Page 27: Image Processing & Computer Vision](https://reader034.vdocuments.site/reader034/viewer/2022050800/568131f7550346895d98527b/html5/thumbnails/27.jpg)
Example of Composition จากตัวอยา่งถ้าทำาการหมุนตามปกติ จะทำาให้เสน้
ตรงมกีารเลื่อนผิดไปจากตำาแหน่งเดิม ดังนัน้การหมุนจะต้องมกีาร เลื่อนเขา้มาเก่ียวขอ้ง
ด้วย
Wrong CorrectT(-3) R(45) T(3)R(45)
aa
a
![Page 28: Image Processing & Computer Vision](https://reader034.vdocuments.site/reader034/viewer/2022050800/568131f7550346895d98527b/html5/thumbnails/28.jpg)
Example of Composition การหมุนเสน้ตรงบนจุดใด ๆ ที่ไมใ่ช ่origin ทำาได้ดังน้ี
1. ทำาการเลื่อนจุด a ไปยงัจุด origin : T(-3)
2. Rotate เสน้ตรง 45 องศา : R(45)
3. เลื่อนเสน้ไปยงัตำาแหน่งเดิม : T(3)
a
a
a
a
![Page 29: Image Processing & Computer Vision](https://reader034.vdocuments.site/reader034/viewer/2022050800/568131f7550346895d98527b/html5/thumbnails/29.jpg)
Example of Composition ดังนัน้จะสามารถเขยีน Matrix ต่าง ๆ ได้ดังนี้