PSD2B Digital Image Processing Unit I -V
Syllabus- Unit 1 Introduction Steps in Image Processing Image Acquisition Representation Sampling & Quantization Relationship between pixels Color Models Basics of Color Image Processing PSD2B- Digital Image Processing 2
What is a Digital Image? A digital image is a representation of a two-dimensional image as a finite set of digital values, called picture elements or pixels Pixel values typically represent gray levels, colours, heights, opacities etc Remember digitization implies that a digital image is an approximation of a real scene 1 pixel PSD2B- Digital Image Processing 3
What is Digital Image Processing? Digital image processing focuses on two major tasks Improvement of pictorial information for human interpretation Processing of image data for storage, transmission and representation for autonomous machine perception PSD2B- Digital Image Processing 4
Digital Image Digital image = a multidimensional array of numbers (such as intensity image) or vectors (such as color image) Each component in the image called pixel associates with the pixel value (a single number in the case of intensity images or a vector in the case of color images). 10 10 16 28 65 70 56 43 9 6 26 37 32 99 54 70 96 56 67 78 15 25 13 22 21 60 54 90 47 96 42 67 32 15 87 39 54 85 65 85 65 43 39 92 32 65 87 99 PSD2B- Digital Image Processing 5
Fundamentals of DIP Origin y Image After snow storm f(x,y) An image: a multidimensional function of spatial coordinates. Spatial coordinate: (x,y) for 2D case such as photograph, (x,y,z) for 3D case such as CT scan images (x,y,t) for movies The function f may represent intensity (for monochrome images) or color (for color images) or other associated values PSD2B- Digital Image Processing 6
Digital Image Acquisition Process PSD2B- Digital Image Processing 7
Conventional Coordinate for TM Image Representation PSD2B- Digital Image Processing 8
Sampling and Quantization Generating a Digital Image Sampling Image sampling: discretize an image in the spatial domain Spatial resolution / image resolution: pixel size or number of pixels PSD2B- Digital Image Processing 9
Image Quantization Image quantization: discretize continuous pixel values into discrete numbers Color resolution/ color depth/ levels: - No. of colors or gray levels or - No. of bits representing each pixel value - No. of colors or gray levels N c is given by N 2 c b where b = no. of bits PSD2B- Digital Image Processing 10
Relationship between Pixels (0,0) x (x-1,y-1) (x,y-1) (x+1,y-1) y (x-1,y) (x,y) (x+1,y) (x-1,y+1) (x,y+1) (x+1,y+1) Conventional indexing method PSD2B- Digital Image Processing 11
Neighbors of a Pixel TM Neighborhood relation is used to tell adjacent pixels. It is useful for analyzing regions. (x,y-1) 4-neighbors of p: (x-1,y) p (x,y+1) (x+1,y) N 4 (p) = (x1,y) (x+1,y) (x,y1) (x,y+1) 4-neighborhood relation considers only vertical and horizontal neighbors. Note: q N 4 (p) implies p N 4 (q) PSD2B- Digital Image Processing 12
8 Neighbors of a pixel TM (x-1,y-1) (x,y-1) (x+1,y-1) 8-neighbors of p: (x-1,y) (x-1,y+1) p (x,y+1) (x+1,y) (x+1,y+1) N 8 (p) = (x1,y1) (x,y1) (x+1,y1) (x1,y) (x+1,y) (x1,y+1) (x,y+1) (x+1,y+1) 8-neighborhood relation considers all neighbor pixels. PSD2B- Digital Image Processing 13
Connectivity Connectivity is adapted from neighborhood relation. Two pixels are connected if they are in the same class (i.e. the same color or the same range of intensity) and they are neighbors of one another. For p and q from the same class 4-connectivity: p and q are 4-connected if q N 4 (p) 8-connectivity: p and q are 8-connected if q N 8 (p) mixed-connectivity (m-connectivity): p and q are m-connected if q N 4 (p) or q N D (p) and N 4 (p) N 4 (q) = PSD2B- Digital Image Processing 14
Color Models Color model, color space, color system Specify colors in a standard way A coordinate system that each color is represented by a single point RGB model CYM model CYMK model HSI model PSD2B- Digital Image Processing 15
RGB Color Model TM Pixel depth: the number of bits used to represent each pixel in RGB space Full-color image: 24-bit RGB color image (R, G, B) = (8 bits, 8 bits, 8 bits) PSD2B- Digital Image Processing 16
Color Fundamentals 3 basic qualities are used to describe the quality of a chromatic light source: Radiance: the total amount of energy that flows from the light source (measured in watts) Luminance: the amount of energy an observer perceives from the light source (measured in lumens) Note we can have high radiance, but low luminance Brightness: a subjective (practically unmeasurable) notion that embodies the intensity of light PSD2B- Digital Image Processing 17
Syllabus : Unit 2 Image Enhancement in spatial domain Some Basic Gray level transformations Histogram Processing Basics of spatial filtering and smoothing PSD2B- Digital Image Processing 18
Image Enhancement Image Enhancement: is the process that improves the quality of the image for a specific application Some Examples of enhancement process are: Contrast enhancement, Edge enhancement, noise filtering, sharpening, magnifying etc. PSD2B- Digital Image Processing 19
Image Enhancement in the Spatial Domain Spatial Domain Methods (Image Plane) Techniques are based on direct manipulation of pixels in an image Spatial domain refers to the aggregate of pixels composing an image. Spatial domain methods are procedures that operate directly on these pixels. Spatial domain processes will be denoted by the expression: g(x,y) = T [f(x,y)] Where f(x,y) in the input image, g(x,y) is the processed image and T is as operator on f, defined over some neighborhood of (x,y) In addition, T can operate on a set of input images. PSD2B- Digital Image Processing 20
Image Enhancement (Spatial Domain) The simplest form of T, is when the neighborhood of size 1X1 (that is a single pixel). In this case, g depends only on the value of f at (x,y), and T becomes a graylevel (also called intensity or mapping) transformation function of the form: s = T (r) Where, for simplicity in notation, r and s are variables denoting, respectively, the gray level of f(x,y) and g(x,y) at any point (x,y) PSD2B- Digital Image Processing 21
Examples of Enhancement Techniques- Contrast Streching Contrast Stretching A simple image enhancement technique that improves the contrast in an image by stretching the range of intensity values it contains to span a desired range of values. PSD2B- Digital Image Processing 22
Examples of Enhancement Techniques- Thresholding Thresholding Is a limited case of contrast stretching, it produces a two-level (binary) image. PSD2B- Digital Image Processing 23
Basic Gray Level Transformations PSD2B- Digital Image Processing 24
Histogram Processing Histogram based Enhancement Histogram of an image represents the relative frequency of occurrence of various gray levels in the image 3000 2500 2000 1500 1000 500 0 0 50 100 150 200 PSD2B- Digital Image Processing 25
Why Histogram? 4 x 10 4 3.5 3 2.5 2 1.5 1 Histogram information reveals that image is under-exposed 0.5 0 0 50 100 150 200 250 7000 6000 5000 4000 3000 2000 1000 Over-exposed image 0 0 50 100 150 200 250 PSD2B- Digital Image Processing 26
Histogram Equalization TM before after 3000 3000 2500 2500 2000 2000 1500 1500 1000 1000 500 500 0 0 50 100 150 200 before equalization 0 0 50 100 150 200 250 300 after equalization PSD2B- Digital Image Processing 27
Spatial Filtering The Spatial Filtering Process a b c d e f g h i Original Image Pixels j k l m n o p q r Filter (w) e processed = n*e + j*a + k*b + l*c + m*d + o*f + p*g + q*h + r*i The above is repeated for every pixel in the original image to generate the filtered image PSD2B- Digital Image Processing 28
Spatial Filtering :Equation Form a a s b b t t y s x f t s w y x g ), ( ), ( ), ( Filtering can be given in equation form as shown above Notations are based on the image shown to the left PSD2B- Digital Image Processing 29
Smoothing Image smoothing is used for two primary purposes: To give an image a softer or special effect To eliminate noise Smoothing Spatial Filters 1 / 9 1 / 9 1 / 9 1 / 9 1 / 9 1 / 9 1 / 9 1 / 9 1 / 9 Simple averaging filter 1 / 16 2 / 16 1 / 16 2 / 16 4 / 16 2 / 16 Weighted averaging filter 1 / 16 2 / 16 1 / 16 PSD2B- Digital Image Processing 30
Effect of using Filters Original Image With Noise Image After Averaging Filter Image After Median Filter Filtering is often used to remove noise from images Sometimes a median filter works better than an averaging filter PSD2B- Digital Image Processing 31
Smoothing filters: Gaussian PSD2B- Digital Image Processing 32
Smoothing Median Filtering TM Very effective for removing salt and pepper noise (i.e., random occurrences of black and white pixels). averaging median filtering PSD2B- Digital Image Processing 33
Syllabus: Unit 3 Image Enhancement in Frequency Domain Introduction to Fourier Transform 1-D, 2-D DFT & Inverse transform Smoothing and Sharpening Filters PSD2B- Digital Image Processing 34
Image Enhancement in the Frequency Domain The frequency domain refers to the plane of the two dimensional discrete Fourier transform of an image. The purpose of the Fourier transform is to represent a signal as a linear combination of sinusoidal signals of various frequencies. PSD2B- Digital Image Processing 35
Fourier Transform Any function that periodically repeats itself can be expressed as the sum of sines and/or cosines of different frequencies, each multiplied by a different coefficient (Fourier series). Even functions that are not periodic (but whose area under the curve is finite) can be expressed as the integral of sines and/or cosines multiplied by a weighting function (Fourier transform). PSD2B- Digital Image Processing 36
1D Fourier Transform TM The one-dimensional Fourier transform and its inverse Fourier transform (discrete case) DTC F( u) 1 M M 1 x0 f ( x) e j2ux / M Inverse Fourier transform: M ( ) f x 1 u0 F( u) e j2ux / M for u 0,1,2,..., M 1 for x 0,1,2,..., M 1 PSD2B- Digital Image Processing 37
2D Fourier Transform TM The two-dimensional Fourier transform and its inverse Fourier transform (discrete case) DTC M 1 1 1 2 ( / (, ) N j ux F u v f ( x, y) e MN x0 for u 0,1,2,..., M y0 Inverse Fourier transform: f ( x, y) for M 1 N 1 u0 v0 1, v 0,1,2,..., N F( u, v) e x 0,1,2,..., M 1, y u, v : the transform or frequency variables x, y : the spatial or image variables j2 ( ux / M vy/ N ) 0,1,2,..., N M vy/ N ) 1 1 PSD2B- Digital Image Processing 38
2D DFT and its inverse The 2D DFT F(u,v) can be obtained by 1. taking the 1D DFT of every row of image f(x,y), F(u,y), 2. taking the 1D DFT of every column of F(u,y) (a)f(x,y) (b)f(u,y) (c)f(u,v) PSD2B- Digital Image Processing 39
Basics of filtering in the frequency domain PSD2B- Digital Image Processing 40
Some Basic Filters & their Functions Lowpass filter Highpass filter PSD2B- Digital Image Processing 41
Smoothing Frequency Domain Filters The basic model for filtering in the frequency domain where F(u,v): the Fourier transform of the image to be smoothed H(u,v): a filter transfer function Smoothing is fundamentally a lowpass operation in the frequency domain. There are several standard forms of lowpass filters (LPF). Ideal lowpass filter Butterworth lowpass filter Gaussian lowpass filter PSD2B- Digital Image Processing 42
Ideal Low Pass TM Filters The simplest lowpass filter is a filter that cuts off all highfrequency components of the Fourier transform that are at a distance greater than a specified distance D 0 from the origin of the transform. The transfer function of an ideal lowpass filter 1 if D( u, v) D0 H( u, v) 0 if D( u, v) D0 where D(u,v) : the distance from point (u,v) to the center of ther frequency rectangle 1 2 2 ( u M / 2) ( v / 2) 2 D( u, v) N PSD2B- Digital Image Processing 43
Ideal Low Pass Filters PSD2B- Digital Image Processing 44
Sharpening Frequency Domain Filter ), ( ), ( v u H v u H lp hp Ideal highpass filter Butterworth highpass filter Gaussian highpass filter ), ( if 1 ), ( if 0 ), ( 0 0 D v D u D v D u v u H n v D u D v u H 2 0 ), ( / 1 1 ), ( 2 0 2 )/2, ( 1 ), ( D v u D e v u H PSD2B- Digital Image Processing 45
Syllabus Unit 4 Image restoration Model of degradation and restoration process noise models restoration in the presence of noise periodic noise reduction Image segmentation Thresholding Region based segmentation. PSD2B- Digital Image Processing 46
Image Restoration Goal of image restoration Improve an image in some predefined sense Difference with image enhancement? Features Image restoration v.s image enhancement Objective process v.s. subjective process A prior knowledge v.s heuristic process A prior knowledge of the degradation phenomenon is considered Modeling the degradation and apply the inverse process to recover the original image PSD2B- Digital Image Processing 47
Model of Degradation & Restoration Process g(x,y)=f(x,y)*h(x,y)+h(x,y) G(u,v)=F(u,v)H(u,v)+N(u,v) PSD2B- Digital Image Processing 48
Noise Models Source of noise Image acquisition (digitization) Image transmission Spatial properties of noise Statistical behavior of the gray-level values of pixels Noise parameters, correlation with the image Frequency properties of noise Fourier spectrum Ex. white noise (a constant Fourier spectrum) PSD2B- Digital Image Processing 49
Noise probability density functions Noises are taken as random variables Random variables Probability density function (PDF) Gaussian Noise Math. tractability in spatial and frequency domain Electronic circuit noise and sensor noise 1 p( z) e 2 ( z ) 2 / 2 2 mean Note: p( z) dz 1 variance PSD2B- Digital Image Processing 50
Other Noise Models Impulse (salt-and-pepper) noise Quick transients, such as faulty switching during imaging Periodic Noise -Arise from electrical or electromechanical interference during image acquisition PSD2B- Digital Image Processing 51
Restoration in the Presence of Noise Mean Filters Arithmetic Mean fˆ( x, y) 1 mn ( s, t) g( s, t) S xy Geometric Mean fˆ( x, y) ( s, t) S xy g( s, t) 1/ mn PSD2B- Digital Image Processing 52
Mean Filters Harmonic mean filter fˆ( x, y) mn 1 ( s, t) g( s, t) S xy Contra-harmonic mean filter fˆ( x, y) ( s, t) S xy ( s, t) S g( s, t) g( s, t) xy Q1 Q Q=-1, harmonic Q=0, airth. mean Q=+,? PSD2B- Digital Image Processing 53
Pepper Noise Salt Noise Contraharmonic Q=1.5 Contraharmonic Q=-1.5 PSD2B- Digital Image Processing 54
Uniform noise 0 2 800 5x5 Arith. Mean filter 5x5 Median filter Left + Bipolar Noise P a = 0.1 P b = 0.1 5x5 Geometric mean 5x5 Alpha-trim. Filter d=5 PSD2B- Digital Image Processing 55
Periodic Noise Reduction Pure sine wave Appear as a pair of impulse (conjugate) in the frequency domain ) sin( ), ( 0 0 y v x u A y x f ) 2, 2 ( ) 2, 2 ( 2 ), ( 0 0 0 0 v v u u v v u u A j v u F
Periodic Noise Reduction TM Bandreject filters, Bandpass filters, Notch filters, Optimum notch filters Bandreject filters * Reject an isotropic frequency ideal Butterworth Gaussian PSD2B- Digital Image Processing 57
noisy spectrum filtered bandreject PSD2B- Digital Image Processing 58
Image Segmentation TM Image segmentation is the operation of partitioning an image into a collection of connected sets of pixels. 1. into regions, which usually cover the image 2. into linear structures, such as - line segments - curve segments 3. into 2D shapes, such as - circles - ellipses - ribbons (long, symmetric regions) PSD2B- Digital Image Processing 59
Thresholding In A: light objects in dark background To extract the objects: Select a T that separates the objects from the background i.e. any (x,y) for which f(x,y)>t is an object point PSD2B- Digital Image Processing 60
Region Based Segmentation TM 1. Region Growing Region growing techniques start with one pixel of a potential region and try to grow it by adding adjacent pixels till the pixels being compared are too disimilar. 2. Clustering There are K clusters C1,, CK with means m1,, mk. The least-squares error is defined as Out of all possible partitions into K clusters, choose the one that minimizes D. 3. Split and Merge PSD2B- Digital Image Processing 61
Syllabus- Unit 5 Image compression Fundamentals Models Information theory Error free compression Lossy compression Predictive and transform coding JPEG standard. PSD2B- Digital Image Processing 62
Image Compression TM The goal of image compression is to reduce the amount of data required to represent a digital image. Data compression aims to reduce the amount of data while preserving as much information as possible. PSD2B- Digital Image Processing 63
Types of Image Compression Lossless Information preserving Low compression ratios Lossy Not information preserving High compression ratios Trade-off: information loss vs compression ratio PSD2B- Digital Image Processing 64
compression Compression ratio: PSD2B- Digital Image Processing 65
Compression Ratio Example: PSD2B- Digital Image Processing 66
Types of Redundancy (1) Coding Redundancy (2) Interpixel Redundancy (3) Psychovisual Redundancy Data compression attempts to reduce one or more of these redundancy types. PSD2B- Digital Image Processing 67
Coding Definitions Code: a list of symbols (letters, numbers, bits etc.) Code word: a sequence of symbols used to represent some information (e.g., gray levels). Code word length: number of symbols in a code word. PSD2B- Digital Image Processing 68
Coding Redundancy Case 1: l(r k ) = constant length Example: PSD2B- Digital Image Processing 69
Interpixel redundancy Interpixel redundancy implies that pixel values are correlated (i.e., a pixel value can be reasonably predicted by its neighbors). f ( x) o g( x) f ( x) g( x a) da auto-correlation: f(x)=g(x) PSD2B- Digital Image Processing 70
Psycho visual redundancy TM The human eye is more sensitive to the lower frequencies than to the higher frequencies in the visual spectrum. Idea: discard data that is perceptually insignificant! PSD2B- Digital Image Processing 71
Image Compression Model TM PSD2B- Digital Image Processing 72
Lossy Compression Transform the image into some other domain to reduce interpixel redundancy. ~ (N/n) 2 subimages PSD2B- Digital Image Processing 73
JPEG Compression Accepted as an international image compression standard in 1992. Entropy encoder PSD2B- Digital Image Processing 74
JPEG - Steps 1. Divide image into 8x8 subimages. For each subimage do: 2. Shift the gray-levels in the range [-128, 127] 3. Apply DCT 64 coefficients 1 DC coefficient: F(0,0) 63 AC coefficients: F(u,v) PSD2B- Digital Image Processing 75