🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

Lecture2-PointOperation_x0p68v7hwrbr9xt.pdf

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Full Transcript

Point Operation Intensity Transformation Image Processing (310-3311) Image in real world Big, wide and large variety Lecture 02 : Point Operation Page 2 What is intensity transformation? Lecture 02 : Point Operation...

Point Operation Intensity Transformation Image Processing (310-3311) Image in real world Big, wide and large variety Lecture 02 : Point Operation Page 2 What is intensity transformation? Lecture 02 : Point Operation Page 3 OK, Before doing that thing. We need to answer these questions. When we need intensity transformation? What method we should choose? It depend on your problem. What Goal do you aiming for? What Feature your algorithm used? Lecture 02 : Point Operation Page 4 It depend on your problem. Goal do you aiming for? What What Feature your algorithm used? For example (ปลากะพงขาว) Lecture 02 : Point Operation Page 5 It depend on your problem. Goal do you aiming for? What What Feature your algorithm used? For example (ปลากะพงขาว) Lecture 02 : Point Operation Page 6 So,… How we do that? 255 Negative 𝑔 𝑥, 𝑦 = 𝑇 𝑓 𝑥, 𝑦 nth root Output intensity level Log f(x,y) : input image nth power 127 g(x,y) : output image Identity Inverse log 0 127 255 Input intensity level Lecture 02 : Point Operation Page 7 So,… How we do that? Mapping Table 255 Negative nth root Input Output 0 0 Output intensity level Log 1 25 nth power 127 2 33 3 56 Identity Inverse log 0 127 255 255 255 Input intensity level Lecture 02 : Point Operation Page 8 After Before Lecture 02 : Point Operation Page 9 ปรับระดับ Intensity Level ของภาพโดยการ ใช้ Log function ถ้าไม่เปลี่ยนเป็ น uint8 จะเกิดอะไรขึน้ ? ถ้า data type เป็ น float ทางานได้มยั้ ? Lecture 02 : Point Operation Page 10 Tools Intensity Transformation Power-law Transformation where 𝑐 and  are positive constants. r input intensity levels s output intensity levels Sometimes this equation is written as 𝛾 𝑠 =𝑐 𝑟+𝜀 to account for offsets (that is, a measurable output when the input is zero). Lecture 02 : Point Operation Page 12 Power-law Transformation The response of many devices used for image capture, printing, and display obey a power law. By convention, the exponent in a power-law equation is referred to as gamma (). The process used to correct these power-law response phenomena is called gamma correction. Cathode Ray Tubes (CRTs) are Nonlinear Lecture 02 : Point Operation Page 13 Power-law Transformation https://www.wikihow.com/Calibrate-Your-Monitor Lecture 02 : Point Operation Page 14 Power-law Transformation Lecture 02 : Point Operation Page 15 Power-law Transformation Lecture 02 : Point Operation Page 16 Power-law Transformation Convert [ตัวเลข] ➔ [ตัวอักษร] แนะนาให้ใช้ฟังก์ช่นั str( ) ถ้าสามารถทาได้แล้วให้ทดลองเขียน For loop ค่า Gamma เพื่อ Save ผลลัพธ์หลายๆ ภาพตามค่า Gamma Lecture 02 : Point Operation Page 17 Power-law Transformation Lecture 02 : Point Operation Page 18 Logarithmic Transformations s = c log(1 + r ) where c is a constant, and r  0. Fourier spectrum display Lecture 02 : Point Operation Page 19 Piecewise-Linear Transformation Contrast stretching Contrast can be defined as: 𝐼max − 𝐼min contrast = 𝐼max + 𝐼min Lecture 02 : Point Operation Page 20 Piecewise-Linear Transformation Contrast stretching Lecture 02 : Point Operation Page 21 Piecewise-Linear Transformation Contrast stretching Lecture 02 : Point Operation Page 22 From previous slide… When we need intensity transformation? How can we know that this image need Intensity Transformation or not? We know, this image too dark right? But, how can we tell computer? Lecture 02 : Point Operation Page 23 Let’s analysis image. Is it need to adjust intensity or not? We will begin with a basic tool. Histogram It is simple to conclude if an image is properly exposed by visual inspection of its histogram. Lecture 02 : Point Operation Page 24 Three very different images with identical histograms Lecture 02 : Point Operation Page 25 Interpreting Histograms Lecture 02 : Point Operation Page 26 Interpreting Histograms It’s 1D Signal, So… Mean Variance Skewness Kurtosis etc.,. Lecture 02 : Point Operation Page 27 Reference: https://docs.opencv.org/4.6.0/d1/db7/tutorial_py_histogram_begins.html Lecture 02 : Point Operation Page 28 แนะนำให้ทดลองปรับรู ปแบบกรำฟ ใส่ label, grid, ฯลฯ Lecture 02 : Point Operation Page 29 Dynamic Range The dynamic range of an image is, in principle, understood as the number of distinct pixel values in an image. In the ideal case, the dynamic range encompasses all K usable pixel values, in which case the value range is completely utilized. High dynamic range Low dynamic range Lecture 02 : Point Operation Page 30 Dynamic Range The dynamic range of an image is, in principle, understood as the number of distinct pixel values in an image. In the ideal case, the dynamic range encompasses all K usable pixel values, in which case the value range is completely utilized. Lecture 02 : Point Operation Page 31 Modifying Image Intensity Contrast and Brightness Limiting the Results by Clamping Automatic Contrast Adjustment Lecture 02 : Point Operation Page 32 Modifying Image Intensity Contrast and Brightness Try to plot and see Histogram by yourself :) Lecture 02 : Point Operation Page 33 Modifying Image Intensity Contrast and Brightness Modified Automatic Contrast Adjustment Lecture 02 : Point Operation Page 34 Modifying Image Intensity Histogram Equalization A frequent task is to adjust two different images in such a way that their resulting intensity distributions are similar, for example to use them in a print publication or to make them easier to compare. Lecture 02 : Point Operation Page 35 Basically, we might want to spread the intensity equally for each value. Lecture 02 : Point Operation Page 36 Modifying Image Intensity Histogram Equalization Lecture 02 : Point Operation Page 37 Concept Idea of Histogram Equalization Histogram Cumulative Histogram Lecture 02 : Point Operation Page 38 Concept Idea of Histogram Equalization สร้ำง mapping function จำก Cumulative Histogram ไปหำ “เส้นตรง” Lecture 02 : Point Operation Page 39 Concept Idea of Histogram Equalization ภำพ Low Contrast (Histogram เกำะกลุ่มกันช่วงค่ำสีหนึ่งมำกๆ) Lecture 02 : Point Operation Page 40 Concept Idea of Histogram Equalization ภำพ High Contrast (จำกกำรทำ Histogram Equalization) Lecture 02 : Point Operation Page 41 Take a break What we know now Change intensity based on Spread it out, uniformity. known equation. 255 Negat ive nth root Output intensity level Log nth power 127 Identit y Inverse log 0 127 255 Input intensity level Lecture 02 : Point Operation Page 43 What if, we don’t know equation & We don’t want to spread it Wanna make left image look like a right image Lecture 02 : Point Operation Page 44 Histogram Specification A U1 𝐻1 Input (Histogram Equalization) 𝑈1 B U2 𝐻2 Goal (Histogram Equalization) 𝑈2 Lecture 02 : Point Operation Page 45 Histogram Specification A U1 𝐻1 Input (Histogram Equalization) 𝑈1 AB U2 𝐻2−1 Goal (Inverse Histogram Equalization) 𝑈1 ≈ 𝑈2 Lecture 02 : Point Operation Page 46 Histogram Specification input output Lecture 02 : Point Operation Page 47 Let’s play with some experiment input Draw something output With this concept you can specify what you want. Lecture 02 : Point Operation Page 48 Let’s play with some experiment input Draw something output With this concept you can specify what you want. Lecture 02 : Point Operation Page 49 ใช้ฟังก์ชนั ่ equalizeHist( ) โดย กำหนดเป้ ำหมำยเหมือนกัน (ใส่รปู หรือ histogram ทีต่ อ้ งกำร) Lecture 02 : Point Operation Page 50 Local / Adaptive Histogram Equalization ต้องกำรทีจ่ ะปรับปรุงภำพโดยใช้ขอ้ มูล Histogram ของ Intensity ในบริเวณใกล้ๆ กันเท่ำนัน้ บริเวณทีม่ ดื ➔ สว่ำง ต้องกำรมองหำรำยละเอียด บริเวณทีส่ ว่ำง ➔ มืด (Detail) เล็กๆ ในภำพ Lecture 02 : Point Operation Page 51 Method #1 Divide image into Non-overlapping blocks Apply intensity transformation / histogram equalization on each block Lecture 02 : Point Operation Page 52 20 40 Idea to implement X 20 40 u v Y X 0 --> image width Y 0 --> image height u 0 --> block size v 0 --> block size Lecture 02 : Point Operation Page 53 Method #2 Block size (Outer block size) Divide image into Overlapping blocks Stride or (ก้าวย่าง) หรือ Sliding window (Inner block size) Lecture 02 : Point Operation Page 54 Block #1 Lecture 02 : Point Operation Page 55 Block #1 Block #2 Lecture 02 : Point Operation Page 56 Block #1 Block #2 Block #3 Lecture 02 : Point Operation Page 57 Block #1 Block #2 Block #3 นาแต่ละ Block มา ประมวลผลแบบเป็ นอิสระ Do something ต่อกัน เหมือนกับที่ทาใน Non-overlapping Block #1 Block #2 Block #3 Lecture 02 : Point Operation Page 58 Block #1 Block #2 Block #3 ตอนจะประกอบกลับให้เป็ นรูป เดิมให้ตดั แต่ละ Block เฉพาะ ตรงกลางตามขนาดของ Stride (Inner block size) ที่กาหนดไว้ Block #1 Block #2 Block #3 Block #1 Block #2 Block #3 Lecture 02 : Point Operation Page 59 พอนา inner block ตรงกลางมา วางเรียงต่อกันครบทัง้ ภาพ เราก็ จะได้ผลลัพธ์ของการทา Local / Adaptive block processing ข้อสังเกตุ : stride จะต้องไม่ทบั กัน Lecture 02 : Point Operation Page 60 ขอบภาพบางส่วนจะขาดหายไปเพราะไม่มีข้อมูล Lecture 02 : Point Operation Page 61 แก้ไขโดยการปรับให้ Inner block ไปเริ่มที่ มุมซ้ายบนสุดของภาพ ส่วนที่ Outer block เกินขอบภาพไป เราสามารถ แก้ไขได้หลากหลายวิธีดงั ตัวอย่างต่อไปนี้ Ignore Constant value Padded image Lecture 02 : Point Operation Page 62 ตัวอย่างการ Padded image รูปต้นฉบับ (original image) Reflected Edge value Lecture 02 : Point Operation Page 63 ตัวอย่างการ Padded image รูปต้นฉบับ (original image) Linear function Wrap Lecture 02 : Point Operation Page 64 *** ภาพนี้ เป็ นภาพตัดต่อ ใส่รปู กระต่ายเข้าไปที่ป้าย ขนาดของหน้ าต่าง (Outer block size) ลองทาดู ทาให้ผลลัพธ์ของการประมวลผลเปลี่ยนไป ภาพไหนหน้ าต่างใหญ่ ? (เพราะปริมาณข้อมูลที่นามาคิดในแต่ละ Block เปลี่ยนไป) Lecture 02 : Point Operation Page 65 Assignment #2 Implement adaptive gamma correction function 1.) Capture image from camera (Webcam / USB Camera) 2.) Find histogram of image. 3.) Apply statistical tools… 4.) If too dark, then apply gamma correction with 𝛾 < 1 5.) If too bright, then apply gamma correction with 𝛾 > 1 Lecture 02 : Point Operation Page 66

Use Quizgecko on...
Browser
Browser