1 / 74

Neighborhood Processing

Neighborhood Processing. Introduction Filters (LPF, HPF, Gaussian Filter, …) Region of interest processing. Basic Image Processing Operations. Neighborhood processing process the pixel with its neighbors Point operations process according to the pixel’s value alone. Point Operations.

bmcneil
Télécharger la présentation

Neighborhood Processing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Neighborhood Processing Introduction Filters (LPF, HPF, Gaussian Filter, …) Region of interest processing

  2. Basic Image Processing Operations • Neighborhood processing • process the pixel with its neighbors • Point operations • process according to the pixel’s value alone.

  3. Point Operations

  4. Point Processing Nonlinear Raise Contrast Original Darken Lower Contrast Nonlinear Lower Contrast Invert Lighten Raise Contrast

  5. Point Processing x + 128 x - 128 255 - x x / 2 x * 2 x ((x / 255.0) ^ 0.33) * 255.0 ((x / 255.0) ^2) * 255.0 Nonlinear Raise Contrast Original Darken Lower Contrast Nonlinear Lower Contrast Invert Lighten Raise Contrast

  6. Neighborhood Operations

  7. Neighborhood operations Image Edge detection Blur • Deteksitepi( Edge detection ) adalahoperasi yang dijalankanuntukmendeteksigaristepi(edges) yang membatasiduawilayahcitrahomogen yang memilikitingkatkecerahanyang berbeda • Tujuannyaadalahuntukmengubahcitra 2Dmenjadibentukkurva • .

  8. Neighborhood Processing 3x3 Mask Output derives from multiplying all elements in the mask by corresponding elements in the neighborhood and adding together all these products.

  9. Filter • A rule or procedure for processing an image • Combination of mask and function • Goal: separating/attenuating a desired component of an observed image • Type: • Linear (function), Nonlinear (function) • Low-pass filter (LPF), High-pass filter (HPF), Band-pass filter (BPF)

  10. Steps of Linear Spatial Filtering • Position the mask over the current pixel. • Form all products of filter elements with the corresponding elements of the neighborhood. • Add all products. • Other names for mask: filter, filter mask, kernel, template or window, etc.

  11. 1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/9 Linear Spatial Filter: Example (1) 2 15 10 20 10 Average Filter 10 10 15 10 0 0 10 10 15 5 20 Find the output intensity of the blue pixel.

  12. Linear Spatial Filter: Example (2) 15 10 20 1/9 1/9 1/9 10 15 1/9 1/9 1/9 0 1/9 1/9 1/9 10 10 20 Multiply the number in the filter’s element with the corresponding pixel’s intensity.

  13. 15/9 + 10/9 + 20/9 + 0/9 + 10/9 + 15/9 + 20/9 + 10/9 + 10/9 = 12.22 Linear Spatial Filter: Example (3) 15/9 10/9 20/9 0/9 10/9 15/9 20/9 10/9 10/9 Output intensity of blue pixel = 12.22 Add all products for output. Spatial filtering is spatial convolution.

  14. Correlation and Convolution of Digital Image

  15. Correlation • Sum of the product of mask and intensity on each point.

  16. 1 2 3 2 3 4 3 4 5 Example: Correlation (1) 10 20 10 15 5 5 10 15 10 0 Kernel 20 10 20 15 5 20 10 5 0 0 10 10 20 15 0 10

  17. 101 +152 +103 +102 +203 +154 +53 +04 +05 = 225 Example: Correlation (2) 10 15 10 1 2 3 20 15 2 3 4 10 3 4 5 0 0 5 Multiply and sum all products.

  18. 1 2 3 2 3 4 3 4 5 Exercise: Correlation 0 0 0 0 0 0 0 0 0 0 Kernel 0 0 1 0 0 0 0 0 0 0 0 0 0 0 10 Find the correlation of the green kernel to the above image.

  19. Convolution • Sum of the response on each point

  20. 5 1 2 4 3 3 4 2 3 3 4 2 3 3 4 2 5 1 Example: Convolution (1) 10 20 10 15 5 5 10 15 10 0 Reverse Kernel!! 20 10 20 15 5 20 10 5 0 0 10 10 20 15 0 10 Kernel

  21. 105 +154 +103 +104 +203 +152 +53 +02 +01 = 285 Example: Convolution (2) 10 15 10 5 4 3 20 15 4 3 2 10 3 2 1 0 0 5 Multiply and sum all products.

  22. 1 2 3 2 3 4 3 4 5 Exercise: Convolution 0 0 0 0 0 0 0 0 0 0 Kernel 0 0 1 0 0 0 0 0 0 0 0 0 0 0 10 Find the convolution of the green kernel to the above image.

  23. Filtering the Image

  24. 1 -2 1 -2 4 -2 1 -2 1 Example: HPF 10 20 10 15 5 5 10 15 10 0 20 10 20 15 5 Kernel 10 5 0 0 10 10 20 15 0 10 Input image

  25. Example: HPF (2) 10 20 10 15 5 5 0 20 -10 0 20 -40 25 15 5 10 5 -35 0 10 10 20 15 0 10 Filtered Image

  26. 1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/9 Edges of The Image • A linear filter is represented as a matrix, e.g., the 3 x 3 averaging filter. • Edges of the Image • There are a number of different approaches to dealing with this problem. • Ignore the edges: The mask is applied to all pixels except the edges and results in an output image that is smaller than the original. If the mask is very large, a significant amount of information may be lost. • Pad with zeros: We assume that all necessary values outside the image are zero. It will return an output image of the same size as the original, but may have the effect of introducing unwanted artifacts, e.g., edges, around the image.

  27. Edges of The Image Batas atautepicitra (edges of the image) • hal yang harusdiselesaikandalamoperasi filtering • misalnya, bagaimanajikasebagian “mask” berada di luarcitra.

  28. Edges of The Image (1) Tidakmempedulikanbatasatautepicitra • “mask” hanyadiaplikasikanpadapiksel-pikselcitradimanaseluruh “mask” beradadalamcitra. • Pendekataninimenghasilkancitra output yang ukurannyalebihkecildaripadacitra input. • Jikaukuran “mask” sangatbesar, akanmenyebabkansejumlahbesarinformasimenjadihilang.

  29. Edges of The Image (2) Tambahkanpiksel-pikseldengannilai 0 (Pad with zeroes) • Dalampendekatanini, diasumsikanbahwasemuapiksel yang beradadi luarcitramempunyainilaigrey-level nol. • Pendekataninimenghasilkancitra output yang ukurannyasamadengancitrainput, namunkadangmempunyaipengaruhpadabatas-batastepicitra.

  30. Filtering in MATLAB • Command: filter2 • Syntax: filter2(filter, image, shape); filter2(filter, image); • shape: • ‘same’: pad edge with zeros. Size unchanged. (default) • ‘valid’: apply mask only to inside pixel. Size smaller. • ‘full’: pad edge with zeros and applying the filter at all places on and around the image where the mask intersects the image matrix. Size larger.

  31. Filter Construction in MATLAB • Command: fspecial • Syntax: fspecial(type, parameter); fspecial(type); • type:type of the filter • ‘average’: average filter • ‘gaussian’ : Gaussian filter • ‘laplacian’ : Laplacian filter … • parameter: parameter of the filter (size, sigma, …). Default varies among filter. Try!!!

  32. Filter Construction in MATLAB

  33. HALF

  34. Filter on Frequency Domain • Low-pass filter (LPF): filter that allows only the low-frequency components and reduces or eliminates the high-frequency components. • E.g. Gaussian, average • High-pass filter (HPF): filter that allows only the high-frequency components and reduces or eliminates the low-frequency components. • E.g. Laplacian, Prewitt, Sobel • Spatial data (intensity) transformed by Fourier transform. • Simplified version: • high-frequency indicates the abrupt changes in intensity  edges. • low-frequency indicates the intensity smoothness  uniform region.

  35. Computing Consideration • Filter may lead to the value outside [0,255] • Solution 1: Make negative values positive (use absolute value) good when there are few negative values and the negative values are close to zero • Solution 2: Clip values. Values larger than 255 become 255 and values less than 0 become 0.  not good if there are many values outside the range. • Solution 3: Scaling transformation. Rescale the range to [0,255] by pixel transform. Suppose gLand gH are the lowest and the highest values. (dgn transformasi linier)

  36. Rescaling Intensity Rescaled value (y) 1. Map gL to 0. 255 2. Map gH to 255. 3. Interpolate for the remaining intensity. 0 Filtered value (x) gL gH

  37. Rescaling: MATLAB • Manual: >> gH = max(filtered_image(:)); >> gL = min(filtered_image(:)); >> scaled = (image – gmin)/(gmax – gmin); Note: No need to rescale to 255 because intensity range for double image is [0,1].

  38. Rescaling: MATLAB (2) • Command: mat2gray • Syntax: mat2gray(double_image); What this command do? • scale the value in double_image to displayable value. Output is double type. • minimum value is mapped to 0. • maximum value is mapped to 1.

  39. Low Pass Filter Averaging Smoothing

  40. Gaussian Low Pass Filter • Useful for reducing noise and eliminating small details. • The elements of the mask must be positive. • Sum of mask elements is 1 (after normalization).

  41. Low Pass Filter : Averaging

  42. Filter Average • Filter average penting dalam permasalahan-permasalahan di mana aspek citra yang menjadi perhatian adalah bukan detail citra • objek pengamatan :berapa jumlah objek yang ada pada citraluas daerah gelap dan daerah terang pada citra. • Ex : template matching

  43. Low Pass Filter : Averaging • Mask size determines the degree of smoothing (loss of detail). original 3x3 5x5 7x7 15x15 25x25

  44. Low Pass Filter : Averaging • Mask size determines the degree of smoothing (loss of detail).filter average ukuran 15 x 15

  45. 1D Gaussian filter: 2D Gaussian filter: Low Pass Filter : Gaussian http://www-mmdb.iai.uni-bonn.de/lehre/BIT/ss03_DSP_Vorlesung/matlab_demos/ http://upload.wikimedia.org/wikipedia/su/thumb/3/38/Gaussian-pdf.png/300px-Gaussian-pdf.png

  46. Low Pass Filter : Gaussian • σ (sigma) controls the amount of smoothing • As σ increases, more samples must be obtained to represent • the Gaussian function accurately. σ = 3 σ = 1.4

  47. Low Pass Filter : Gaussian Filter Gaussian • Implementasinya : membangun filter Gaussian, mengalikannyadenganmatrikshasiltransformasi Fourier, danmenginversikanhasilnya. • Filter Gaussianmerupakanjenis filter yang “paling smooth” dan filter ideal merupakan filter yang “paling tidak smooth”. Sedangkan filter Butterworth beradadiantarakeduanya.

  48. Benefits of Gaussian Filter • They are mathematically very well behaved. The Fourier transform of a Gaussian filter is another Gaussian. • There are rotationally symmetric, so are very good starting points for some edge-detection algorithms. • They are separable in x and y axes. This can lead to very fast implementations. • The convolution of two Gaussians is another Gaussian.

  49. Low Pass Filter : Gaussian • Effect of Gaussian filter = blurring • larger leads to more blur. •  average filter

  50. Averaging vs Gaussian Smoothing Averaging Gaussian

More Related