Neighborhood Processing

Slides:



Advertisements
Similar presentations
Filters, Edge Detection and Sharpening Francesca Pizzorni Ferrarese 28/04/2010.
Advertisements

Image Enhancement in the Frequency Domain (2)
November 12, 2013Computer Vision Lecture 12: Texture 1Signature Another popular method of representing shape is called the signature. In order to compute.
Image Processing. Image processing Once we have an image in a digital form we can process it in the computer. We apply a “filter” and recalculate the.
Spatial Filtering (Chapter 3)
Image Processing Lecture 4
CS & CS Multimedia Processing Lecture 2. Intensity Transformation and Spatial Filtering Spring 2009.
Spatial Filtering.
Chapter 3 Image Enhancement in the Spatial Domain.
Lecture 6 Sharpening Filters
© by Yu Hen Hu 1 ECE533 Digital Image Processing Image Enhancement in Frequency Domain.
Multimedia communications EG 371Dr Matt Roach Multimedia Communications EG 371 and EE 348 Dr Matt Roach Lecture 6 Image processing (filters)
6/9/2015Digital Image Processing1. 2 Example Histogram.
Filtering in the Spatial Domain Filtering the spatial domain is achieved by convolution Qualitatively: Slide the filter to each position, x, then sum up.
Image Filtering CS485/685 Computer Vision Prof. George Bebis.
Digital Image Processing
Image Enhancement.
Image Analysis Preprocessing Arithmetic and Logic Operations Spatial Filters Image Quantization.
Lecture 2. Intensity Transformation and Spatial Filtering
ECE 472/572 - Digital Image Processing Lecture 4 - Image Enhancement - Spatial Filter 09/06/11.
Chapter 3 (cont).  In this section several basic concepts are introduced underlying the use of spatial filters for image processing.  Mainly spatial.
Chapter 2. Image Analysis. Image Analysis Domains Frequency Domain Spatial Domain.
Presentation Image Filters
Spatial Filtering: Basics
Digital Image Processing Image Enhancement Part IV.
Digital Image Processing
Chapter 5 Neighborhood Processing
Digital Image Processing Lecture12: Basics of Spatial Filtering.
Digital Image Processing Lecture 5: Neighborhood Processing: Spatial Filtering Prof. Charlene Tsai.
Lecture 03 Area Based Image Processing Lecture 03 Area Based Image Processing Mata kuliah: T Computer Vision Tahun: 2010.
Chapter 5: Neighborhood Processing
Digital Image Processing (Digitaalinen kuvankäsittely) Exercise 2
Course Website: Digital Image Processing Image Enhancement (Spatial Filtering 1)
Spatial Filtering.
Spatial Filtering (Applying filters directly on Image) By Engr. Muhammad Saqib.
Digital Image Processing, 3rd ed. © 1992–2008 R. C. Gonzalez & R. E. Woods Gonzalez & Woods Chapter 3 Intensity Transformations.
Digital Image Processing Lecture 16: Segmentation: Detection of Discontinuities Prof. Charlene Tsai.
Chapter 5: Neighborhood Processing 5.1 Introduction
Digital Image Processing Lecture 5: Neighborhood Processing: Spatial Filtering March 9, 2004 Prof. Charlene Tsai.
CS 691B Computational Photography
Image enhancement Last update Heejune Ahn, SeoulTech.
Digital Image Processing Lecture 16: Segmentation: Detection of Discontinuities May 2, 2005 Prof. Charlene Tsai.
Linear filtering. Motivation: Image denoising How can we reduce noise in a photograph?
Sharpening Spatial Filters ( high pass)  Previously we have looked at smoothing filters which remove fine detail  Sharpening spatial filters seek to.
1 © 2010 Cengage Learning Engineering. All Rights Reserved. 1 Introduction to Digital Image Processing with MATLAB ® Asia Edition McAndrew ‧ Wang ‧ Tseng.
CSE 185 Introduction to Computer Vision Image Filtering: Spatial Domain.
M ATLAB L ECTURE 3 Histogram Processing. H ISTOGRAM E QUALIZATION The imhist function create a histogram that show the distribution of intensities in.
Filters– Chapter 6. Filter Difference between a Filter and a Point Operation is that a Filter utilizes a neighborhood of pixels from the input image to.
Image Enhancement Band Ratio Linear Contrast Enhancement
Digital Image Processing Lecture 8: Image Enhancement in Frequency Domain II Naveed Ejaz.
Image Processing Lab Section 28/3/2016 Prepared by Mahmoud Abdelsatar Demonstrator at IT Dep. Faculty of computers and information Assuit University.
Spatial Filtering (Chapter 3) CS474/674 - Prof. Bebis.
Image Enhancement in the Spatial Domain.
Spatial Image Enhancement
Fundamentals of Spatial Filtering:
ECE 692 – Advanced Topics in Computer Vision
Image Enhancement in the
Histogram Histogram is a graph that shows frequency of anything. Histograms usually have bars that represent frequency of occuring of data. Histogram has.
Digital Image Processing
Lecture 3 (2.5.07) Image Enhancement in Spatial Domain
Digital Image Processing
Digital Image Processing
Motion illusion, rotating snakes
Spatial operations and transformations
Digital Image Processing Week IV
Interesting article in the March, 2006 issue of Wired magazine
Image Enhancement – Simple Intensity Processing
Fundamentals of Spatial Filtering
Image Enhancement in Spatial Domain: Neighbourhood Processing
Spatial operations and transformations
Presentation transcript:

Neighborhood Processing Digital Image Processing

Introduction Mask moving (or convolution) A rectangle (usually with sides of odd length) or other shape over the given image

Mask & Overlapping Pixel Values a 3X5 mask corresponding pixel values

Spatial Filtering Position mask over current pixel Form all products of filter elements with the corresponding elements of the neighborhood Add all the product Repeat for every pixel in image

Spatial Convolution Similar to spatial filtering, except .. The filter must be rotated by 180° before multiplying and adding Or, equivalently, The rationale of “convolution” will become apparent in view of Fourier Transform

Mean Filter Example Given a 3×3 mask, take the average of all nine values within the mask The result of filtering x with 3×3 averaging filter

Mask Notation It is convenient to describe a linear filter simply in terms of the coefficients of all the gray values of pixels within the mask The averaging filter The other filter example Ch5-p.91-92

Mask on the Edge What happens at the edge of the image, where the mask partly falls outside the image? There are a number of different approaches to dealing with this problem Ignore the edges (like the example shown previously) Pad with zeros Mirroring

Filtering in MATLAB imfilter(image,filter,options..) filter2(filter, image, shape) The result is a matrix of data type “double” shape is optional; it describes the method for dealing with the edges ‘same’ – pad with zeros ‘valid’ – ignore the edges ‘full’ – pad with zeros and applying the filter at all places on and around the image where the mask intersects the image matrix imfilter(image,filter,options..) More advanced image filtering function

Filtering Examples in MATLAB (1/2) >> x = uint8(10*magic(5)) 170 240 10 80 150 230 50 70 140 160 40 60 130 200 220 100 120 190 210 30 110 180 250 20 90 >> a = ones(3,3)/9 0.1111 0.1111 0.1111 >> filter2(a,x,'same') 76.6667 85.5556 65.5556 67.7778 58.8889 87.7778 111.1111 108.8889 128.8889 105.5556 66.6667 110.0000 130.0000 150.0000 106.6667 67.7778 131.1111 151.1111 148.8889 85.5556 56.6667 105.5556 107.7778 87.7778 38.8889 >> filter2(a,x,'valid') 111.1111 108.8889 128.8889 110.0000 130.0000 150.0000 131.1111 151.1111 148.8889

Filtering Examples in MATLAB (2/2) >> filter2(a,x,'full') 18.8889 45.5556 46.6667 36.6667 26.6667 25.5556 16.6667 44.4444 76.6667 85.5556 65.5556 67.7778 58.8889 34.4444 48.8889 87.7778 111.1111 108.8889 128.8889 105.5556 58.8889 41.1111 66.6667 110.0000 130.0000 150.0000 106.6667 45.5556 27.7778 67.7778 131.1111 151.1111 148.8889 85.5556 37.7778 23.3333 56.6667 105.5556 107.7778 87.7778 38.8889 13.3333 12.2222 32.2222 60.0000 50.0000 40.0000 12.2222 10.0000 filter2 provides no mirroring option Mirroring can be realized by >> D = floor(size(a)/2) >> wr=D(1);wc=D(2); % get half of the mask size >> m_x=[x(wr:-1:1,:);x;x(end:-1:end-(wr-1),:)] % additional mirrored-rows >> m_x=[m_x(:,wc:-1:1),m_x,m_x(:,end:-1:end-(wc-1))]; % additional mirrored columns >> filter2(a,m_x,'valid') 185.5556 132.2222 102.2222 94.4444 135.5556 136.6667 111.1111 108.8889 128.8889 164.4444 107.7778 110.0000 130.0000 150.0000 152.2222 95.5556 131.1111 151.1111 148.8889 123.3333 124.4444 165.5556 157.7778 127.7778 74.4444

Pre-cooked Filtering in MATLAB: fspecial() I = imread('cameraman.tif'); subplot(2,2,1);imshow(I);title('Original Image'); H = fspecial('motion',20,45); MotionBlur = imfilter(I,H,'replicate'); subplot(2,2,2);imshow(MotionBlur);title('Motion Blurred Image'); H = fspecial('disk',10); blurred = imfilter(I,H,'replicate'); subplot(2,2,3);imshow(blurred);title('Blurred Image'); H = fspecial('unsharp'); sharpened = imfilter(I,H,'replicate'); subplot(2,2,4);imshow(sharpened);title('Sharpened Image');

Low- and High-Pass Filters (1/2) Frequencies of an image are a measure of the amount by which gray values change with distance High-pass filter (left) Low-pass filter (right) >> f = fspecial('laplacian') >> cf = imfilter(c,f); >> f1 = fspecial('log') % Laplacian of Gaussian >> cf1 = imfilter(c,f1); 0.1667 0.6667 0.1667 0.6667 -3.3333 0.6667 0.0448 0.0468 0.0564 0.0468 0.0448 0.0468 0.3167 0.7146 0.3167 0.0468 0.0564 0.7146 -4.9048 0.7146 0.0564 Ch5-p.98

Low- and High-Pass Filters (2/2) Values outside [0,255] range Make negative value positive Clip values 0-255 scaling transformation >> f2 = [1 -2 1;-2 4 -2; 1 -2 1]; >> cf2 = filter2(f2,c); >> figure, imshow(mat2gray(cf2)); >> % scaling transformation >> maxcf2 = max(cf2(:)); >> mincf2 = min(cf2(:)); >> cf2g = (cf2-mincf2)/(maxcf2-mincf2); >> figure, imshow(cf2/60);

Gaussian Filters (1/2) Ch5-p.103 >> a=50;s=3; >> g=fspecial('gaussian',[a a],s); >> surf(1:a,1:a,g) >> s = 9; >> g2 = fspecial('gaussian',[a a],s); >> figure, surf(1:a,1:a,g2) Ch5-p.103

Gaussian Filters (2/2) g3 g4 g1 g2 >> c = imread('cameraman.tif'); >> g1 = fspecial('gaussian',[5 5]); >> g2 = fspecial('gaussian',[5 5],2); >> g3 = fspecial('gaussian',[11 11],1); >> g4 = fspecial('gaussian',[11 11],5); >> imshow(filter2(g1,c)/256); >> figure, imshow(filter2(g2,c)/256); >> figure, imshow(filter2(g3,c)/256); >> figure, imshow(filter2(g4,c)/256); g3 g4 g1 g2

Scheme for Sharpening Masking >> c = imread(‘cameraman.tif’); >> f = fspecial('average'); >> xf = filter2(f,c); >> xu = double(c)-xf/1.5; >> imshow(xu/70); Ch5-p.106

Unsharp Masking The unsharp option of fspecial produces such filters >> p = imread('pelicans.tif'); >> u = fspecial('unsharp',0.5); >> pu = filter2(u,p); >> imshow(p), figure, imshow(pu/255); α = 0.5 Ch5-p.108

High-Boost Filtering Allied to unsharp masking filters are the high-boost filters where A is an amplification factor If A = 1, then the high-boost filter becomes an ordinary high-pass filter >> id = [0 0 0;0 1 0; 0 0 0]; >> f = fspecial('average'); >> hb1 = 3*id-2*f; >> hb2 = 1.25*id-0.25*f; >> x1 = filter2(hb1,p); >> x2 = filter2(hb2,p); >> figure, imshow(x1/255); >> figure, imshow(x2/255);

Nonlinear Filters Maximum filter Minimum filter >> cmax = nlfilter(c,[3 3],'max(x(:))'); >> cmin = nlfilter(c,[3 3],'min(x(:))'); >> figure, imshow(cmax); >> figure, imshow(cmin); Ch5-p.112

Region of Interest Processing >> ig = imread('iguana.tif'); >> roi = roipoly(ig,[406 600 600 406],[58 58 231 231]); >> figure, imshow(ig); >> figure, imshow(roi); >> roi_2 = roipoly(ig); % interactively select ROI Ch5-p.115

Region of Interest Filtering >> a = fspecial('average',[15 15]); >> iga = roifilt2(a,ig,roi); >> imshow(iga); >> u = fspecial('unsharp'); >> igu = roifilt2(u,ig,roi); >> figure, imshow(igu); >> L = fspecial('log'); >> igl = roifilt2(L,ig,roi); >> figure, imshow(igl); iga: average filtering igu: unsharp masking igl: Laplacian of Gaussian Ch5-p.116