8-- Spatial Domain Image Enhancement in the Spatial Domain What is spatial domain The space whee all pixels fom an image In spatial domain we can epesent an image by f( whee x and y ae coodinates along x and y axis with espect to an oigin Thee is duality between Spatial and Fequency Domains Images in the spatial domain ae pictues in the xy plane whee the wod distance is meaningful. Using the Fouie tansfom, the wod distance is lost but the wod fequency becomes alive. Image Enhancement Image Enhancement means impovement of images to be suitable fo specific applications. Example: Image Enhancement Example Note: each image enhancement technique that is suitable fo one application may not be suitable fo othe applications. Oiginal image Enhanced image using Gamma coection Wood, Digital Image Pocessing, nd Edition. Wood, Digital Image Pocessing, nd Edition. Image Enhancement in the Spatial Domain = Image enhancement using pocesses pefomed in the Spatial domain esulting in images in the Spatial domain. We can witten as g( T f ( whee f( is an oiginal image, g( is an output and T[ ] is a function defined in the aea aound ( Note: T[ ] may have one input as a pixel value at ( only o multiple inputs as pixels in neighbos of ( depending in each function. Ex. Contast enhancement uses a pixel value at ( only fo an input while smoothing filte use seveal pixels aound ( as inputs. Types of Image Enhancement in the Spatial Domain - Single pixel methods - Gay level tansfomations Example - Histogam equalization - Contast stetching - Aithmetic/logic opeations Examples - Image subtaction - Image aveaging - Multiple pixel methods Examples Spatial filteing - Smoothing filtes - Shapening filtes
Output intensity 8-- Gay Level Tansfomation Tansfoms intensity of an oiginal image into intensity of an output image using a function: s T() whee = input intensity and s = output intensity Image Negative L- White s L Oiginal digital mammogam Example: Contast enhancement Black L- Black Input intensity White Negative digital mammogam Wood, Digital Image Pocessing, nd Edition. L = the numbe of gay levels Wood, Digital Image Pocessing, nd Edition. Log Tansfomations s clog( ) Fouie spectum Application Powe-Law Tansfomations s c Log T. of Fouie spectum Wood, Digital Image Pocessing, nd Edition. Wood, Digital Image Pocessing, nd Edition. Powe-Law Tansfomations : Gamma Coection Application Powe-Law Tansfomations : Gamma Coection Application Desied image Image displayed at Monito MRI Image afte Gamma Coection Afte Gamma coection Image displayed at Monito Wood, Digital Image Pocessing, nd Edition. Wood, Digital Image Pocessing, nd Edition.
Bit Bit 8-- Powe-Law Tansfomations : Gamma Coection Application Aiel images afte Gamma Coection Contast Stetching Contast means the diffeence between the bightest and dakest intensities Befoe contast enhancement Afte Wood, Digital Image Pocessing, nd Edition. Wood, Digital Image Pocessing, nd Edition. How to know whee the contast is enhanced? Notice the slope of T() - if Slope > Contast inceases - if Slope < Contast decease - if Slope = no change Gay Level Slicing Ds D Smalle D yields wide Ds = inceasing Contast Wood, Digital Image Pocessing, nd Edition. Wood, Digital Image Pocessing, nd Edition. Bit-plane Slicing Bit Bit Histogam Histogam = Gaph of population fequencies 8 No. of Students A B+ B C+ C D+ D F Bit Bit Wood, Digital Image Pocessing, nd Edition. Gades of the couse 8 xxx
จำนวน pixel จำนวน pixel 8-- Histogam of an Image = gaph of no. of pixels vs intensities Histogam of an Image (cont.) h( ) n k Dak image has histogam on the left k low contast image has naow histogam Bight image has histogam on the ight high contast image has wide histogam Wood, Digital Image Pocessing, nd Edition. Wood, Digital Image Pocessing, nd Edition. Histogam Pocessing = intensity tansfomation based on histogam infomation to yield desied histogam - Histogam equalization To make histogam distibuted unifomly Monotonically Inceasing Function = Function that is only inceasing o constant s T() Popeties of Histogam pocessing function. Monotonically inceasing function. T( ) fo - Histogam matching To make histogam as the desie Pobability Density Function Histogam is analogous to Pobability Density Function (PDF) which epesent density of population Let s and be Random vaiables with PDF p s (s) and p ( ) espectively and elation between s and is Histogam Equalization Let s T ( ) p( w) dw We get We get s T() d ps ( s) p( ) ds d ps( s) p( ) p( ) ds ds d p ( ) p ( ) p( ) d ( ) p w dw d!
8-- Histogam Equalization Histogam Equalization Example Fomula in the pevious slide is fo a continuous PDF Fo Histogam of Digital Image, we use s T ( ) k k j k n j N k j p ( ) n j = the numbe of pixels with intensity = j N = the numbe of total pixels j Intensity # pixels Total Accumulative Sum of P / =. (+)/ =. (++)/ =. (+++)/ =. (++++)/ =. (+++++)/ =.8 (++++++)/ =. (+++++++)/ =.. Histogam Equalization Example (cont.) Histogam Equalization Intensity () No. of Pixels (n j ) Acc Sum Output value Quantized of P Output (s)..x =...* =...* =...* =...* =..8.8* =...* =...x = Total Wood, Digital Image Pocessing, nd Edition. Histogam Equalization (cont.) Histogam Equalization (cont.) Wood, Digital Image Pocessing, nd Edition. Wood, Digital Image Pocessing, nd Edition.
8-- Histogam Equalization (cont.) Histogam Equalization (cont.) Oiginal image Afte histogam equalization, the image become a low contast image Wood, Digital Image Pocessing, nd Edition. Wood, Digital Image Pocessing, nd Edition. Histogam Matching : Algoithm To tansfom image histogam to be a desied histogam Concept : fom Histogam equalization, we have s T ( ) p( w) dw We want an output image to have PDF p z (z) Apply histogam equalization to p z (z), we get z We get p s (s) = v G( z) pz( u) du We get p v (v) = Since p s (s) = p v (v) = theefoe s and v ae equivalent Theefoe, we can tansfom to z by T( ) s G - ( ) z Histogam Matching : Algoithm (cont.) s = T() v = G(z) z = G - (v) Wood, Digital Image Pocessing, nd Edition. Histogam Matching Example Example Oiginal data Input image histogam Intensity ( s ) Total # pixels Desied Histogam Intensity ( z ) Total # pixels Use define Histogam Matching Example (cont.). Apply Histogam Equalization to both tables (n j ) SP s z (n j ) SP z v...........8.8.... s k = T( k ) v k = G(z k )
8-- Histogam Matching Example (cont.). Get a map s v z We get s s v v z z Actual Output Histogam z # Pixels Histogam Matching Example (cont.) Desied histogam Tansfe function Actual histogam s k = T( k ) z k = G - (v k ) Wood, Digital Image Pocessing, nd Edition. Histogam Matching Example (cont.) Local Enhancement : Local Histogam Equalization Concept: Pefom histogam equalization in a small neighbohood Oignal image Afte Hist Eq. Afte Local Hist Eq. In x neighbohood Oiginal image Afte histogam equalization Afte histogam matching Wood, Digital Image Pocessing, nd Edition. Local Enhancement : Histogam Statistic fo Image Enhancement We can use statistic paametes such as Mean, Vaiance of Local aea fo image enhancement Image of tungsten filament taken using An electon micoscope Local Enhancement Example: Local enhancement fo this task E f ( when ms km xy g( f ( othewise G and k D G sxy k M G In the lowe ight cone, thee is a filament in the backgound which is vey dak and we want this to be bighte. Oiginal image Local Vaiance image Multiplication facto We cannot incease the bightness of the whole image since the white filament will be too bight. Wood, Digital Image Pocessing, nd Edition. Wood, Digital Image Pocessing, nd Edition.
8-- Local Enhancement Logic Opeations AND Application: Cop aeas of inteest Output image OR Wood, Digital Image Pocessing, nd Edition. Oiginal image Image mask Result Region of Inteest Wood, Digital Image Pocessing, nd Edition. Aithmetic Opeation: Subtaction Application: Eo measuement Aithmetic Opeation: Subtaction (cont.) Application: Mask mode adiogaphy in angiogaphy wok Eo image Wood, Digital Image Pocessing, nd Edition. Wood, Digital Image Pocessing, nd Edition. Aithmetic Opeation: Image Aveaging Application : Noise eduction Aithmetic Opeation: Image Aveaging (cont.) Degaded image g( f ( ( Image aveaging g( K Aveaging esults in eduction of Noise vaiance g ( K i i K (noise) g ( ( Wood, Digital Image Pocessing, nd Edition. Wood, Digital Image Pocessing, nd Edition. 8
8-- Basics of Spatial Filteing Basics of Spatial Filteing (cont.) Sometime we need to manipulate values obtained fom neighboing pixels Step. Selected only needed pixels Example: How can we compute an aveage value of pixels in a x egion cente at a pixel z? 8 Image Pixel z 8 Pixel z Basics of Spatial Filteing (cont.) Basics of Spatial Filteing (cont.) Step. Multiply evey pixel by / and then sum up the values Question: How to compute the x aveage values at evey pixels? X Mask o Window o Template y Solution: Imagine that we have a x window that can be placed eveywhee on the image Masking Window Basics of Spatial Filteing (cont.) Basics of Spatial Filteing (cont.) Step : Move the window to the fist location whee we want to compute the aveage value and then select only pixels inside the window. Oiginal image Step : Move the window to the next location and go to Step Sub image p. Step : Compute the aveage value y p( i, j) i j Step : Place the esult at the pixel in the output image Output image The x aveaging method is one example of the mask opeation o Spatial filteing. The mask opeation has the coesponding mask (sometimes called window o template). The mask contains coefficients to be multiplied with pixel values. Example : moving aveaging w(,) w(,) w(,) w(,) w(,) w(,) w(,) w(,) w(,) Mask coefficients The mask of the x moving aveage filte has all coefficients = /
8-- Basics of Spatial Filteing (cont.) Basics of Spatial Filteing (cont.) The mask opeation at each point is pefomed by:. Move the efeence point (cente) of mask to the location to be computed. Compute sum of poducts between mask coefficients and pixels in subimage unde the mask. The efeence point of the mask p(,) p(,) p(,) p(,) p(,) p(,) p(,) p(,) p(,) Subimage y Mask fame N M i j w( i, j) p( i, j) w(,) w(,) w(,) w(,) w(,) w(,) w(,) w(,) w(,) Mask coefficients The spatial filteing on the whole image is given by:. Move the mask ove the image at each location.. Compute sum of poducts between the mask coefficeints and pixels inside subimage unde the mask.. Stoe the esults at the coesponding pixels of the output image.. Move the mask to the next location and go to step until all pixel locations have been used. Examples of Spatial Filteing Masks Examples of the masks - - Sobel opeatos - P to compute x - - - P to compute y x shapening filte - - - - - 8 - - - x moving aveage filte Pupose: Blu o noise eduction Lowpass/Smoothing spatial filteing Sum of the mask coefficients is Visual effect: educed noise but blued edge as well Smoothing linea filtes Aveaging filte Weighted aveage (e.g., Gaussian) Smoothing nonlinea filtes Ode statistics filtes (e.g., median filte) Spatial filtes Pupose Highlight fine detail o enhance detail blued Highpass/Shapening spatial filte Sum of the mask coefficients is Visual effect: enhanced edges on a dak backgound High-boost filteing and unshap masking Deivative filtes st nd 8 Smoothing filtes Smoothing: Image Aveaging Pupose: Blu o noise eduction Smoothing linea filteing (lowpass spatial filte) Neighbohood (weighted) aveaging Can use diffeent size of masks Sum of the mask coefficients is Dawback: Ode-statistic nonlinea filtes / x / Response is detemined by odeing the pixels contained in the image aea coveed by the mask Median filteing The gay level of each pixel is eplaced by the median of its neighbo. Good at denoising (salt-and-peppe noise/impulse noise) Max filte Min filte -- smoothing opeato Low-pass filte, leads to softened edges
8-- Smoothing Linea Filte : Moving Aveage Application : noise eduction and image smoothing Smoothing Linea Filte (cont.) Disadvantage: lose shap details Wood, Digital Image Pocessing, nd Edition. Wood, Digital Image Pocessing, nd Edition. Ode-Statistic Filtes Oiginal image Moving window subimage Statistic paametes Mean, Median, Mode, Min, Ma Etc. Ode-Statistic Filtes- Eg: Median Filte Median filte eplaces the pixel at the cente of the filte with the median value of the pixels falling beneath the mask. Median filte does not blu the image but it ounds the cones. Conside x oiginal image Median filteing using the full neighbohood: We sot the oiginal image values on the full window:, 8,,,,,,, median value =. We eplace the cente pixel(i.e 8) by. Othe pixels ae unchanged Output image Ode-Statistic Filtes: Median Filte Shapening filtes - - - / x - 8 - - - - Pupose Highlight fine detail o enhance detail that has been blued Basic highpass spatial filte Sum of the mask coefficients is Visual effect: enhanced edges on a dak backgound Unshap masking and High-boost filteing Deivatives st deivative nd deivative Wood, Digital Image Pocessing, nd Edition.
8-- image deivative and shapening Shapening Spatial Filtes Thee ae intensity discontinuities nea object edges in an image Wood, Digital Image Pocessing, nd Edition. Laplacian Shapening : How it woks Laplacian Shapening : How it woks (cont.). Intensity pofile p(x) st deivative dp dx nd deivative d p dx... 8 8. Edge -. p(x) d p p( x) dx. -... -. Laplacian shapening esults in lage intensity discontinuity nea the edge. Laplacian Shapening : How it woks (cont.) Laplacian Masks Used fo estimating image Laplacian P P P x y Befoe shapening p(x) Afte shapening d p p( x) dx - - - - - 8 - - - - - - - o -8 - Application: Enhance edge, line, point Disadvantage: Enhance noise The cente of the mask is positive The cente of the mask is negative
8-- Laplacian Shapening Example Laplacian Shapening (cont.) Mask fo P P p P Mask fo P - - - - o - - - - - - - - P P P Wood, Digital Image Pocessing, nd Edition. -8 o - Wood, Digital Image Pocessing, nd Edition. Unshap masking and high-boost filtes Unshap Masking and High-Boost Filteing - - - - Unshap masking To geneate the mask: Subtact a blued vesion of the image fom itself Add the mask to the oiginal - - k+8 - - - - k+ - - g mask ( = f( - f( g( = f( + k*g mask ( Highboost: k> Application: input image is vey dak Equation: kp( P( kp( P( P hb ( The cente of the mask is negative The cente of the mask is positive Unshap Masking and High-Boost Filteing (cont.) Fist Ode Deivative Intensity pofile p(x). Edges st deivative dp dx nd deivative dp dx. 8 8 -... Wood, Digital Image Pocessing, nd Edition.
8-- Fist Ode Patial Deivative: Sobel opeatos - - - P to compute x - - - P to compute y Fist Ode Patial Deivative: Image Gadient Gadient magnitude P P P x y P P x P y A gadient image emphasizes edges Wood, Digital Image Pocessing, nd Edition. Fist Ode Patial Deivative: Image Gadient Image Enhancement in the Spatial Domain : Mix things up! P P P y P A B D smooth P x P + - Shapening C Wood, Digital Image Pocessing, nd Edition. E Image Enhancement in the Spatial Domain : Mix things up! C E G Powe Law T. S F Multiplication A H Wood, Digital Image Pocessing, nd Edition.