EEM 463 Introduction to Image Processing Week 3: Intensity Transformations Fall 2013 Instructor: Hatice Çınar Akakın, Ph.D. haticecinarakakin@anadolu.edu.tr Anadolu University
Enhancement Domains Spatial Domain: image plane itself, direct manipulation of pixels Transform domain: process on the transform domain coefficients Spatial domain process g( x, y) T[ f ( x, y)]) f ( x, y) :input image g( x, y) : output image T : an operator on f defined over a neighborhood of point ( xy, )
Enhanced Images For human vision Evaluation of image quality is a highly subjective process No standard for a for a good image definition For machine perception Evaluation of image quality is easier Best machine results represents the good image Trail and error is necessary to select an appropriate image enhancement approach. e.g. a method that is quite useful for enhancing X-Ray images may not be the best for satellite images taken in infrared band of EM specytrum.
Intensity Transformation T : intensity transformation function s = T( r ) Point processşng Higher contrast Two-level (binary) image
Tree basic gray-level transformation f ns. Linear function: Negative and intensity transformations Logarithmic function: Log snd inverse-log transformations Power-law function: n th power and n th root transformations
Image Negatives Image negatives s L 1 r Suitable for enhancing white or gray detail embedded in dark regions of an image, especially when black area is large. Same visual content
Log Transformations Log Transformations s clog(1 r) Log curve maps a narrow range of low graylevels in input image into a wider range of output levels. Expands range of dark image pixels while shrinking bright range. Inverse log expands range of bright image pixels while shrinking dark range.
Power-Law Transformation It is also called Gamma Correction s cr
Cathode ray tube (CRT) devices have an intensity-tovoltage response that is a power function, with exponents varying from approximately 1.8 to 2.5 s r 1/2.5 This darkens the picture. Gamma correction is done by preprocessing the image before inputting it to the monitor.
a) Dark MRI. Expand gray level range for contrast manipulation γ < 1 (b) γ = 0.6, c=1 (c) γ = 0.4 (best result) (d) γ = 0.3 (limit of acceptability) When γ is reduced too much, the İmage begins to reduce contrast to the point where it starts to have a washed-out look,especially in the background
Washed-out image. Shrink gray level range γ > 1
Piecewise-Linear Transformation Functions Pro: can be arbitrarily complex Con: specification requires considerably more user input
Contrast Stretching Expands the range of intensity levels in an image so that it spans the full intensity range of the recording medium or display device.
Intensity level slicing Highlights a specific range of intensities
Bit-plane slicing highlight the contribution made to total image appearance by specific bits
Original image
Histogram Processing Histogram h( r ) r k n k is the k th k n intensity value k is the number of pixels in the image with intensity r k nk Normalized histogram pr ( k ) MN n : the number of pixels in the image of k size M N with intensity r k Estimate of the probability of occurrence of intensity level
Components of histogram are concentrated on the low side of the gray scale. Components of histogram are concentrated on the high side of the gray scale. Basis for numerous spatial domain processing techniques Provides useful image statistics Useful for image enhancement, image compression and segmentation
Histogram Equalization Probability density function (pdf) is wanted to be uniformly ditributed. s T( r) 0 r L 1 a. T(r) is a strictly monotonically increasing function in the interval 0 r L-1; b. 0 T( r) L -1 for 0 r L -1.
Tr ( ) is continuous and differentiable. r s T( r) ( L 1) p 0 r ( w) dw ds dt () r d r ( L 1) p ( ) 0 r w dw dr dr dr ( L 1) p ( r) r p ( s) ds p ( r) dr s Cumulative distribution function (cdf) r p () s s pr () r dr p ( ) ( ) 1 r r pr r ds ds ( L 1) pr ( r) L 1 dr
Histogram Equalization Discrete values: k s T( r ) ( L 1) p ( r ) k k r j j 0 k n k j L 1 ( L 1) nj k=0,1,..., L-1 MN MN j 0 j 0
Example: 3-bit image (L=8), 64x64pixels 0 s0 T( r0) 7 pr( rj) 7 0.19 1.33 j 0 1 s1 T( r1) 7 pr( rj) 7 (0.19 0.25) 3.08 j 0
Tend to spread the histogram of the input image intensity levels of the equalized image span a wider range contrast enhancement
Histogram Matching (Specification) If uniform distribution is not a good approach Generate a processed image that has a specified histogram Let p ( r) and p ( z) denote the continous probability r z density functions of the variables r and z. p ( z) is the specified probability density function. Let s be the random variable with the probability s T( r) ( L 1) p ( w) dw 0 0 Define a random variable z with the probability G( z) ( L 1) p ( t) dt s z z r r z s T ( r) ( L 1) p ( w) dw G( z) ( L 1) p ( t) dt s z G s G T r z 0 1 ( ) 1 ( ) r 0 z r
Procedure Obtain p r (r) from the input image and then obtain the values of s r s ( L 1) pr ( w) dw 0 Use the specified PDF and obtain the transformation function G(z) z G( z) ( L 1) pz( t) dt s Mapping from s to z z G 1 () s 0 p z (z) is given! Obtain the output image by equalizing the input image. For each pixel with value s in the equalized image, perform the inverse mapping to obtain output pixels.
Discrete Formulation p z (z k ): specified pdf k k ( L 1) s T( r ) ( L 1) p ( r ) n k k r j j j 0 MN j 0 Tansformation function: q G( z ) ( L 1) p ( z ) s q z i k i 0 Mapping: z G 1 ( s ) q k
(1): G(z) (2): G -1 (z)
For the details of histogram processing, read Chapter 3.1-3.3
Fundamentals of Spatial Filtering Spatial filter: spatial masks, kernels, templates or windows Filtering creates a new pixel with coordinates equal to the center of the neighborhood, with value of the result of filtering operation a b g( x, y) w( s, t) f ( x s, y t) s a t b
Spatial Correlation and Convolution Correlation is a process of moving a filter mask over the image and computing the sum of products at each location Convolution has the same mechanics but with a filter rotated by 180.
Spatial Correlation and Convolution The convolution of a filter w( x, y) of size m n with an image f ( x, y), denoted as w( x, y) f ( x, y) a w( x, y) * f ( x, y) w( s, t) f ( x s, y t) b s a t b
Smoothing Spatial Filters Output is the average of pixels caontained in the neighborhood of the filter mask Averaging filters or lowpass filters Reduce sharp transitions in intensities Used for blurring and noise reduction Blurring removes small details and connects small gaps in lines or curves They can be linear or nonlinear filters
The general implementation for filtering an M N image with a weighted averaging filter of size m n is given g( x, y) a b s a t b w( s, t) f ( x s, y t) w( s, t) where m 2a 1, n 2b 1. a b s a t b Sum of the mask coefficients: constant computed only once
To generate a mxn linear filter, we need to specify mn mask coefficients, selected based on the purpose of the filter Example: Spatial filter mask based on a continuous function of two variables, e.g. Gaussian Function:
Note that: big mask is used to eliminate small objects from an image. the size of the mask establishes the relative size of the objects that will be blended with the background.
- Blur to get gross representation of objects. - Intensity of smaller objects blend with background. - Larger objects become blob-like and easy to detect Threshold value is chosen to be 25% of the highest intensity
Order-Statistic (Nonlinear) Filters It is based on ordering (ranking) the pixels contained in the filter mask Center pixel value is replaced with the value of ranking result Median filter Max filter Min filter
Sharpening Spatial Filters Objective is to highlight transitions in intensity Spatial differentiation enhances the edges and other discontinuities Foundation 1. The first-order derivative of a one-dimensional function f(x) is the difference f f ( x 1) f ( x) x 2. The second-order derivative of f(x) as the difference 2 f f ( x 1) f ( x 1) 2 f ( x) 2 x
The Laplacian Operator Isotropic filter: response independent of the direction of the discontinuities in the image (rotation invariant) Laplacian of a function f(x,y): Discrete form: f x f y 2 2 2 f 2 2 2 f f ( x 1, y) f ( x 1, y) 2 f ( x, y) 2 x 2 f f ( x, y 1) f ( x, y 1) 2 f ( x, y) 2 y 2 f f x y f x y f x y f x y ( 1, ) ( 1, ) (, 1) (, 1) - 4 f ( x, y)
Unsharp masking and Highboost Filtering Unsharp masking: Blur the original image f(x, y) f(x, y) Subtract the blurred image f(x, y) from the original image f(x, y) mask Add the mask to the original image: g mask = f x, y f(x, y) g x, y = f x, y + k g mask x, y k 0 k = 1 unsharp masking k > 1 highboost filtering
Image Sharpening based on First-Order Derivatives For function f ( x, y), the gradient of f at coordinates ( x, y) is defined as f gx x f grad( f) g y f y The magnitude of vector f, denoted as M ( x, y) Gradient Image M ( x, y) mag( f ) gx g y 2 2
M ( x, y) g g x y Robert s crossgradient operators Sobel operators
Sobel Operators M ( x, y) ( z 2 z z ) ( z 2 z z ) 7 8 9 1 2 3 ( z 2 z z ) ( z 2 z z ) 3 6 9 1 4 7
Combining Spatial Enhamement Methods
Calculating the histogram % % reading image from the file im = imread('c:\users\user\documents\documents\eem463\butterflyyorkshire_rose.jpg'); im1 = double(rgb2gray(im)); % size of the image [M N]= size(im1); for k = 0:255 p(k+1) = sum(sum(im1==k)); end bar(0:255,p);
Normalizing an image i1 = load('clown'); whos i1 i1 figure;image(x); colormap(map); mx = max(max(x)); mn = min(min(x)); imn = 255*(X-mn)/(mx-mn);