Computing for Engineers in Python Lecture 10 Signal





![Image Representation • Encoded as a n-by-m matrix M • Each element M[x, y] Image Representation • Encoded as a n-by-m matrix M • Each element M[x, y]](https://slidetodoc.com/presentation_image_h/ccef5bc1fb7c5f0a4c61e8e185a1c17d/image-6.jpg)



























- Slides: 33

Computing for Engineers in Python Lecture 10: Signal (Image) Processing Autumn 2011 -12 1 Some slides incorporated from Benny Chor’s course

Lecture 9: Highlights • Sorting, searching and time complexity • Preprocessing (sorting) the data enables fast (O(log 2 n)) access to what we are interested in (searching) • Binary search algorithm + time complexity analysis • Comparing recursive vs. iterative implementations efficiency • Bubble sort + time complexity analysis • Is there a faster sorting algorithm? • Yes! (Quick Sort in tirgul) • Comparing Bubble sort to sorted efficiency • Generic sorting 2

More Sorting Algorithms • Insertion, Selection O(n 2) in tirgul • Quick sort O(nlog 2 n) on average in tirgul • Average versus worst case analysis • " ( "בהזדמנות maybe next week) • Merge sort O(nlog 2 n) worst case • Can we do better than O(nlog 2 n) in general? • Bucket sort 3

Signal Processing • In the physical world, any quantity measurable through time or over space can be taken as a signal • Signals are or electrical representations of timevarying or spatial-varying physical quantities • Signal processing: applying mathematical techniques for the extraction, transformation and interpretation of signals, in either discrete (digital) or continuous (analog) time • Example signals: radio, telephone, radar, sound, images, video, sensor data 4

Digital Images • Digital image is a numeric representation of a two-dimensional image • Examples: photos, microscopic, medical, astronomical 5
![Image Representation Encoded as a nbym matrix M Each element Mx y Image Representation • Encoded as a n-by-m matrix M • Each element M[x, y]](https://slidetodoc.com/presentation_image_h/ccef5bc1fb7c5f0a4c61e8e185a1c17d/image-6.jpg)
Image Representation • Encoded as a n-by-m matrix M • Each element M[x, y] in an image is called picture element (pixel), representing the light intensity / color at that location • RGB, gray-level images • Video – an image for each time t http: //www. youtube. com/watch? v=bgt. HKR 0 a. Qp. Q&feature=related 6

Resolution Pixel resolution vs. spatial resolution Pixel resolution == pixel count depends on properties of the system creating the image, not just the pixel resolution Same number of pixels, different spatial resolution: 7 http: //www. youtube. com/watch? v=i 2 AQjj. Zp 6 Jk

Image Quantization Number of bits per pixel 24 bit RGB 16 colors Note that both images have the same pixel & spatial resolution

Gray Level Images • The remaining of class will deal with gray-level images (although can be applicable for color images) • 8 bits per pixel (256 gray levels), 0 – black, 255 – white • Other representations: • Binary – 1 bit per pixel • Some applications use more colors (medical imaging) 9

An Example 10

Image Processing • Signal processing for which the input is an image • Typical operations: • • Color corrections / calibration Image segmentation Image registration / alignment Denoising • Typical applications: • • Machine vision Medical image processing Face detection Augmented reality 11

In Python • • How to handle an image? The Python Imaging Library http: //www. pythonware. com/products/pil/ Example tutorial: The Image Module: http: //www. geeks 3 d. com/20100930/tutorial-first-steps-with-pil-python-imaging-library http: //www. pythonware. com/library/pil/handbook/image. htm • Capacities: • Read / write images • Display image • Basic image processing 12

Loading and Viewing an Image http: //www. pythonware. com/library/pil/handbook/image. htm http: //en. wikipedia. org/wiki/Lenna 13

Access Pixels 14

Create and Save an Image 15

Output 16

Rotating an Image 17

Edges • Sharp change in intensity between close pixels • Denoted edges • Usually captures much of the meaningful information in the image • Edge detection algortihms: Sobel Lena Laplacian 18

Edge Detection Example 19

Blur and Noise Gaussian blur (sigma = 2) Gaussian noise Lena Credit: Wikipedia Salt and pepper noise 20

Denoising Algorithms • Examples: • Local means: replace observed pixel with neighborhood’s (usually 3 x 3 mask) average • Local medians: with neighborhood’s median x 21

Denoising Algorithms • Local means: • Pros: reduces noise on smooth areas, fast • Cons: blur edges, sensitivity to extreme values (e. g. , as in salt and pepper noise) • Local medians: • Pros: preserve edges, not sensitive to extreme values • Cons: eliminate fine details (contours) in the image, slow x 22

Example In Tirgul 23

Image Manipulation Full Example http: //www. riisen. dk/dop/pil. html 24

Image Segmentation 25

Image Segmentation Algorithms • • Thersholding Clustering Region growing Compression-based methods Histogram-based methods Model-based methods Etc. 26

Thresholding • Simplest segmentation method • Apply a threshold to turn a gray-scale image into a binary image • The key is to select the appropriate threshold value • Popular method – Otsu’s method (maximal variance) 27

Example - Thresholding 28

Example - Thresholding 29

Results TH = 20 TH = 80 TH = 140 TH = 180 30

HW – The Whole Loop • Input: noisy image • Output: segmented contours on top of input image • How? • • Denoising Edge detection Thresholding (histogram based – Otsu’s algorithm) Visualization 31

Real World Application Face Detection Credit: Intel Technology Journal, Volume 09, Issue 01 32

33