Lecture 03 Area Based Image Processing Lecture 03 Area Based Image Processing Mata kuliah: T Computer Vision Tahun: 2010
January 20, 2010T Computer Vision3 Learning Objectives After carefullylistening this lecture, students will be able to do the following : After carefully listening this lecture, students will be able to do the following : understand spatial information based image operation such as area-based processing understand spatial information based image operation such as area-based processing demonstrate how area-based image processing is performed (i.e. convolution-based image processing) demonstrate how area-based image processing is performed (i.e. convolution-based image processing)
January 20, 2010T Computer Vision4 What is a Mask ? A mask is a small matrix whose values are called weights Each mask has an origin, which is usually one of its positions The origin of symmetric masks are usually their center pixel position For non-symmetric masks, any pixel location may be chosen as the origin (depending on the intended use)
January 20, 2010T Computer Vision5 Linear filtering is filtering in which the value of an output pixel is a linear combination of the values of the pixels in the input pixel's neighborhood. Linear filtering of an image is accomplished through an operation called convolution. Convolution is a neighborhood operation in which each output pixel is the weighted sum of neighboring input pixels. The matrix of weights is called the convolution kernel, also known as the filter. Applying Masks to Images : Linear Filtering
January 20, 2010T Computer Vision6 Applying Masks to Images : Linear Filtering
January 20, 2010T Computer Vision7 Rotate the convolution kernel 180 degrees about its center element. Slide the center element of the convolution kernel so that it lies on top of the (2,4) element of A. Multiply each weight in the rotated convolution kernel by the pixel of A underneath. Sum the individual products from step 3. Hence the (2,4) output pixel is 1*2 + 8*9 + 15*4 + 7*7 + 14*5 + 16*3 + 13*6 + 20*1 + 22*8 = 575 Computing the (2,4) Output of Convolution
January 20, 2010T Computer Vision8 Computing the (2,4) Output of Convolution Image pixel values Center of Kernel Values of rotated Kernel
January 20, 2010T Computer Vision9 Slide the center element of the correlation kernel so that it lies on top of the (2,4) element of A. Multiply each weight in the rotated correlation kernel by the pixel of A underneath. Sum the individual products from step 2. Hence the (2,4) output pixel is 1*8 + 8*1 + 15*6 + 7*3 + 14*5 + 16*7+ 13*4 + 20*9 + 22*2 = 585 1*8 + 8*1 + 15*6 + 7*3 + 14*5 + 16*7+ 13*4 + 20*9 + 22*2 = 585 Computing the (2,4) Output of Correlation
January 20, 2010T Computer Vision Image pixel values Center of Kernel Values of Correlation Kernel Computing the (2,4) Output of Correlation
January 20, 2010T Computer Vision11 Dealing with Image Borders Only convolve with interior Shrinks image Zero-padding Results in spurious gradients Border replication
January 20, 2010T Computer Vision12 Filtering Example How to treat image borders : Zero Padding Rotate
January 20, 2010T Computer Vision Step 1
January 20, 2010T Computer Vision14 Step 2
January 20, 2010T Computer Vision Step 3
January 20, 2010T Computer Vision Step 4
January 20, 2010T Computer Vision Step 5
January 20, 2010T Computer Vision18 Final Result I’I’I
January 20, 2010T Computer Vision19 Smoothing (Low Pass Filtering) Useful for noise reduction and image blurring It removes the finer details of an image Averaging or Mean (Box) Filter The elements of the mask must be positive The size of the mask determines the degree of smoothing x 3 box filter kernel
January 20, 2010T Computer Vision20 Gaussian Filter (LPF) The weights are sampled from a Gaussian function which fall off to zero at the mask’s edges x 5, = 1
January 20, 2010T Computer Vision21 Gaussian Filter (cont’d) Gaussian smoothing can be implemented efficiently, thanks to the fact that the kernel is separable
January 20, 2010T Computer Vision22 To convolve an image I with a n x n Gaussian mask G with = G Build a 1-D Gaussian mask g, of width n, with g = G Convolve each column of I with g, yielding a ne image I c Convolve each row of I c with g The value of determines degree of smoothing Gaussian Filter (cont’d)
January 20, 2010T Computer Vision23 Gaussian Filter (examples) = 1 = 3 7 x 7 kernel Original imageBox filter
January 20, 2010T Computer Vision24 Median Filter (non-linear) Effective for removing “salt & pepper” noise (random occurences of black & white pixels) Replace each pixel value by the median of the gray-levels in the neighborhood of the pixels sort median
January 20, 2010T Computer Vision25 Median Filter (non-linear)
January 20, 2010T Computer Vision26 Median Filter (non-linear)
January 20, 2010T Computer Vision27 Sharpening (High Pass Filtering) It is used to emphasize the fine details of an image Points of high contrast can be detected by computing intensity differences in local image regions The weights of the mask are both positive and negative When the mask is over an area of constant or slowly varying gray level, the result of convolution will be close to zero When gray level is varying rapidly within the neighborhood, the result of convolution will be a large number Typically, such points form the border between different objects or scene parts (i.e., sharpening is a precursor step to edge detection
January 20, 2010T Computer Vision28 Sharpening (cont’d)