SlideShare una empresa de Scribd logo
1 de 38
1
Yossi CohenIntro to computer Vision
2
3
How to filter
2d Correlation
h=filter2(g,f); or h=imfilter(f,g);
2d Convolution
h=conv2(g,f);
],[],[],[
,
lnkmflkgnmh
lk
−−= ∑
f=image
g=filter
],[],[],[
,
lnkmflkgnmh
lk
++= ∑
4
Correlation filtering
Say the averaging window size is 2k+1 x 2k+1:
Loop over all pixels in neighborhood around
image pixel F[i,j]
Attribute uniform
weight to each pixel
Now generalize to allow different weights depending on
neighboring pixel’s relative position:
Non-uniform weights
5
Correlation filtering
Filtering an image: replace each pixel with a linear
combination of its neighbors.
The filter “kernel” or “mask” H[u,v] is the prescription for the
weights in the linear combination.
This is called cross-correlation, denoted
6
Properties of smoothing filters
Smoothing
 Values positive
 Sum to 1  constant regions same as input
 Amount of smoothing proportional to mask size
 Remove “high-frequency” components; “low-pass” filter
7
Filtering an impulse signal
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 1 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
a b c
d e f
g h i
What is the result of filtering the impulse signal
(image) F with the arbitrary kernel H?
?
8
Filtering an impulse signal
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 1 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
a b c
d e f
g h i
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 i h g 0 0
0 0 f e d 0 0
0 0 c b a 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
What is the result of filtering the impulse signal
(image) F with the arbitrary kernel H?
9
Averaging filter
 What values belong in the kernel H for the moving
average example?
0 10 20 30 30
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 0 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
111
111
111
“box filter”
?
10
Smoothing by averaging
depicts box filter:
white = high value, black = low value
original filtered
11
Gaussian filter
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 0 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
1 2 1
2 4 2
1 2 1
This kernel is an
approximation of a 2d
Gaussian function:
12
Smoothing with a Gaussian
13
Smoothing with a Box
14
 Weight contributions of neighboring pixels by nearness
0.003 0.013 0.022 0.013 0.003
0.013 0.059 0.097 0.059 0.013
0.022 0.097 0.159 0.097 0.022
0.013 0.059 0.097 0.059 0.013
0.003 0.013 0.022 0.013 0.003
5 x 5, σ = 1
Slide credit: Christopher Rasmussen
Gaussian
15
Gaussian filters
What parameters matter here?
Size of kernel or mask
Note, Gaussian function has infinite support, but discrete
filters use finite kernels
σ = 5 with
10 x 10
kernel
σ = 5 with
30 x 30
kernel
16
Gaussian filters
What parameters matter here?
Variance of Gaussian: determines extent of
smoothing
σ = 2 with
30 x 30
kernel
σ = 5 with
30 x 30
kernel
17
Matlab
>> hsize = 10;
>> sigma = 5;
>> h = fspecial(‘gaussian’ hsize, sigma);
>> mesh(h);
>> imagesc(h);
>> outim = imfilter(im, h); % correlation
>> imshow(outim);
outim
18
Smoothing with a Gaussian
for sigma=1:3:10
h = fspecial('gaussian‘, fsize, sigma);
out = imfilter(im, h);
imshow(out);
pause;
end
…
Parameter σ is the “scale” / “width” / “spread” of the Gaussian
kernel, and controls the amount of smoothing.
19
Gaussian filters
• Remove “high-frequency” components from the
image (low-pass filter)
Images become more smooth
• Convolution with self is another Gaussian
–So can smooth with small-width kernel, repeat, and
get same result as larger-width kernel would have
–Convolving two times with Gaussian kernel of width σ
is same as convolving once with kernel of width σ√2
• Separable kernel
–Factors into product of two 1D Gaussians
Source: K. Grauman
20
Separability of the Gaussian filter
Source: D. Lowe
21
Separability example
*
*
=
=
2D convolution
(center location only)
Source: K. Grauman
The filter factors
into a product of 1D
filters:
Perform convolution
along rows:
Followed by convolution
along the remaining column:
22
Convolution
 Convolution:
 Flip the filter in both dimensions (bottom to top, right to left)
 Then apply cross-correlation
Notation for
convolution
operator
F
H
23
Convolution vs. correlation
Convolution
Cross-correlation
24
Key properties of linear filters
Linearity:
filter(f1 + f2) = filter(f1) + filter(f2)
Shift invariance: same behavior
regardless of pixel location
filter(shift(f)) = shift(filter(f))
Any linear, shift-invariant operator can be
represented as a convolution
Source: S. Lazebnik
25
More properties
• Commutative: a * b = b * a
 Conceptually no difference between filter and signal
 But particular filtering implementations might break this equality
• Associative: a * (b * c) = (a * b) * c
 Often apply several filters one after another: (((a * b1) * b2) * b3)
 This is equivalent to applying one filter: a * (b1 * b2 * b3)
• Distributes over addition: a * (b + c) = (a * b) + (a * c)
• Scalars factor out: ka * b = a * kb = k (a * b)
• Identity: unit impulse e = [0, 0, 1, 0, 0],
a * e = a Source: S. Lazebnik
26
Matlab
Lab 1 – Smooth/Blur Filters
27
Lets try to blur filter
%%basic image filters
imrgb = imread('peppers.png');
imshow(imrgb);
a = [1 1 1; 1 1 1; 1 1 1]
Corroutimg = filter2(a, imgray);
Convoutimg = conv2(imgray,a);
figure;
imshow(Corroutimg)
figure
imshow(Convoutimg)
28
Fix it
Can we conv2 an RGB image??
Use rgb2gray
Whats wrong now?
Try preserving the image power
Convert image to double
29
Results
%%basic image filters
imrgb = imread('peppers.png');
imgray =
im2double(rgb2gray(imrgb));
imshow(imgray);
a = 1/16*ones(4)
Corroutimg = filter2(a, imgray);
Convoutimg = conv2(a, imgray);
figure;
imshow(Corroutimg)
figure
imshow(Convoutimg)
30
Sharp
%%basic sharp filter
imrgb = imread('peppers.png');
imgray =
im2double(rgb2gray(imrgb));
imshow(imgray);
a = [ 0 0 0; 0 2 0; 0 0 0] -
1/9*ones(3)
Corroutimg = filter2(a,
imgray);
figure;
imshow(Corroutimg)
31
Practical matters
What happens near the edge?
the filter window falls off the edge of the image
need to extrapolate
methods:
clip filter (black)
wrap around
copy edge
reflect across edge
Source: S. Marschner
32
Matlab edge aware filtering
methods (MATLAB):
clip filter (black): imfilter(f, g, 0)
wrap around: imfilter(f, g, ‘circular’)
copy edge: imfilter(f, g, ‘replicate’)
reflect across edge: imfilter(f, g, ‘symmetric’)
33
Practical matters
What is the size of the output?
• MATLAB: filter2(g, f, shape)
shape = ‘full’: output size is sum of sizes of f and g
shape = ‘same’: output size is same as f
shape = ‘valid’: output size is difference of sizes of f and g
f
gg
gg
f
gg
gg
f
gg
gg
full same valid
34
Median filters
A Median Filter operates over a window by
selecting the median intensity in the window.
What advantage does a median filter have
over a mean filter?
Is a median filter a kind of convolution?
35
Matlab
Lab 2 – Median Filter
36
Comparison: salt and pepper noise
37
Median Filter Example
%%Median
imrgb = imread('peppers.png');
imgray =
im2double(rgb2gray(imrgb));
imnoise = imnoise(imgray,'salt &
pepper',0.1);
imshow(imnoise)
figure
imshow(medfilt2(imnoise))
38
Basic Filters summary
Linear filtering is sum of dot
product at each position
Can smooth, sharpen, translate
(among many other uses)
Be aware of details for filter size,
extrapolation, cropping
111
111
111

Más contenido relacionado

La actualidad más candente

Chapter10 image segmentation
Chapter10 image segmentationChapter10 image segmentation
Chapter10 image segmentationasodariyabhavesh
 
Image filtering in Digital image processing
Image filtering in Digital image processingImage filtering in Digital image processing
Image filtering in Digital image processingAbinaya B
 
Image Restoration (Digital Image Processing)
Image Restoration (Digital Image Processing)Image Restoration (Digital Image Processing)
Image Restoration (Digital Image Processing)Kalyan Acharjya
 
Chapter 9 morphological image processing
Chapter 9   morphological image processingChapter 9   morphological image processing
Chapter 9 morphological image processingAhmed Daoud
 
5. gray level transformation
5. gray level transformation5. gray level transformation
5. gray level transformationMdFazleRabbi18
 
Enhancement in frequency domain
Enhancement in frequency domainEnhancement in frequency domain
Enhancement in frequency domainAshish Kumar
 
Digital Image Processing - Image Compression
Digital Image Processing - Image CompressionDigital Image Processing - Image Compression
Digital Image Processing - Image CompressionMathankumar S
 
Image Smoothing using Frequency Domain Filters
Image Smoothing using Frequency Domain FiltersImage Smoothing using Frequency Domain Filters
Image Smoothing using Frequency Domain FiltersSuhaila Afzana
 
Hough Transform By Md.Nazmul Islam
Hough Transform By Md.Nazmul IslamHough Transform By Md.Nazmul Islam
Hough Transform By Md.Nazmul IslamNazmul Islam
 
Fidelity criteria in image compression
Fidelity criteria in image compressionFidelity criteria in image compression
Fidelity criteria in image compressionKadamPawan
 
Image degradation and noise by Md.Naseem Ashraf
Image degradation and noise by Md.Naseem AshrafImage degradation and noise by Md.Naseem Ashraf
Image degradation and noise by Md.Naseem AshrafMD Naseem Ashraf
 
Chapter 3 image enhancement (spatial domain)
Chapter 3 image enhancement (spatial domain)Chapter 3 image enhancement (spatial domain)
Chapter 3 image enhancement (spatial domain)asodariyabhavesh
 
Edge linking in image processing
Edge linking in image processingEdge linking in image processing
Edge linking in image processingVARUN KUMAR
 
SPATIAL FILTERING IN IMAGE PROCESSING
SPATIAL FILTERING IN IMAGE PROCESSINGSPATIAL FILTERING IN IMAGE PROCESSING
SPATIAL FILTERING IN IMAGE PROCESSINGmuthu181188
 
08 frequency domain filtering DIP
08 frequency domain filtering DIP08 frequency domain filtering DIP
08 frequency domain filtering DIPbabak danyal
 
Simultaneous Smoothing and Sharpening of Color Images
Simultaneous Smoothing and Sharpening of Color ImagesSimultaneous Smoothing and Sharpening of Color Images
Simultaneous Smoothing and Sharpening of Color ImagesCristina Pérez Benito
 
Image Enhancement in Spatial Domain
Image Enhancement in Spatial DomainImage Enhancement in Spatial Domain
Image Enhancement in Spatial DomainDEEPASHRI HK
 
Chapter 1 and 2 gonzalez and woods
Chapter 1 and 2 gonzalez and woodsChapter 1 and 2 gonzalez and woods
Chapter 1 and 2 gonzalez and woodsasodariyabhavesh
 

La actualidad más candente (20)

Chapter10 image segmentation
Chapter10 image segmentationChapter10 image segmentation
Chapter10 image segmentation
 
Image filtering in Digital image processing
Image filtering in Digital image processingImage filtering in Digital image processing
Image filtering in Digital image processing
 
Image Restoration (Digital Image Processing)
Image Restoration (Digital Image Processing)Image Restoration (Digital Image Processing)
Image Restoration (Digital Image Processing)
 
Chapter 9 morphological image processing
Chapter 9   morphological image processingChapter 9   morphological image processing
Chapter 9 morphological image processing
 
5. gray level transformation
5. gray level transformation5. gray level transformation
5. gray level transformation
 
Enhancement in frequency domain
Enhancement in frequency domainEnhancement in frequency domain
Enhancement in frequency domain
 
Digital Image Processing - Image Compression
Digital Image Processing - Image CompressionDigital Image Processing - Image Compression
Digital Image Processing - Image Compression
 
Image Smoothing using Frequency Domain Filters
Image Smoothing using Frequency Domain FiltersImage Smoothing using Frequency Domain Filters
Image Smoothing using Frequency Domain Filters
 
Hough Transform By Md.Nazmul Islam
Hough Transform By Md.Nazmul IslamHough Transform By Md.Nazmul Islam
Hough Transform By Md.Nazmul Islam
 
Edge detection
Edge detectionEdge detection
Edge detection
 
Fidelity criteria in image compression
Fidelity criteria in image compressionFidelity criteria in image compression
Fidelity criteria in image compression
 
Canny Edge Detection
Canny Edge DetectionCanny Edge Detection
Canny Edge Detection
 
Image degradation and noise by Md.Naseem Ashraf
Image degradation and noise by Md.Naseem AshrafImage degradation and noise by Md.Naseem Ashraf
Image degradation and noise by Md.Naseem Ashraf
 
Chapter 3 image enhancement (spatial domain)
Chapter 3 image enhancement (spatial domain)Chapter 3 image enhancement (spatial domain)
Chapter 3 image enhancement (spatial domain)
 
Edge linking in image processing
Edge linking in image processingEdge linking in image processing
Edge linking in image processing
 
SPATIAL FILTERING IN IMAGE PROCESSING
SPATIAL FILTERING IN IMAGE PROCESSINGSPATIAL FILTERING IN IMAGE PROCESSING
SPATIAL FILTERING IN IMAGE PROCESSING
 
08 frequency domain filtering DIP
08 frequency domain filtering DIP08 frequency domain filtering DIP
08 frequency domain filtering DIP
 
Simultaneous Smoothing and Sharpening of Color Images
Simultaneous Smoothing and Sharpening of Color ImagesSimultaneous Smoothing and Sharpening of Color Images
Simultaneous Smoothing and Sharpening of Color Images
 
Image Enhancement in Spatial Domain
Image Enhancement in Spatial DomainImage Enhancement in Spatial Domain
Image Enhancement in Spatial Domain
 
Chapter 1 and 2 gonzalez and woods
Chapter 1 and 2 gonzalez and woodsChapter 1 and 2 gonzalez and woods
Chapter 1 and 2 gonzalez and woods
 

Similar a Computer Vision - Image Filters

Gaussian filtering 1up
Gaussian filtering 1upGaussian filtering 1up
Gaussian filtering 1upPham Hanh
 
Spatial Filtering in intro image processingr
Spatial Filtering in intro image processingrSpatial Filtering in intro image processingr
Spatial Filtering in intro image processingrkumarankit06875
 
06 spatial filtering DIP
06 spatial filtering DIP06 spatial filtering DIP
06 spatial filtering DIPbabak danyal
 
Filtering an image is to apply a convolution
Filtering an image is to apply a convolutionFiltering an image is to apply a convolution
Filtering an image is to apply a convolutionAbhishek Mukherjee
 
03 cie552 image_filtering_spatial
03 cie552 image_filtering_spatial03 cie552 image_filtering_spatial
03 cie552 image_filtering_spatialElsayed Hemayed
 
Notes on image processing
Notes on image processingNotes on image processing
Notes on image processingMohammed Kamel
 
05_Spatial_Filtering.ppt
05_Spatial_Filtering.ppt05_Spatial_Filtering.ppt
05_Spatial_Filtering.pptpawankamal3
 
ESTIMATING NOISE PARAMETER & FILTERING (Digital Image Processing)
ESTIMATING NOISE PARAMETER & FILTERING (Digital Image Processing)ESTIMATING NOISE PARAMETER & FILTERING (Digital Image Processing)
ESTIMATING NOISE PARAMETER & FILTERING (Digital Image Processing)Shajun Nisha
 
International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)ijceronline
 
IIR filter design, Digital signal processing
IIR filter design, Digital signal processingIIR filter design, Digital signal processing
IIR filter design, Digital signal processingAbhishek Thakkar
 
Lect 03 - first portion
Lect 03 - first portionLect 03 - first portion
Lect 03 - first portionMoe Moe Myint
 
image_enhancement_spatial
 image_enhancement_spatial image_enhancement_spatial
image_enhancement_spatialhoneyjecrc
 
Wavelet transform in two dimensions
Wavelet transform in two dimensionsWavelet transform in two dimensions
Wavelet transform in two dimensionsAyushi Gagneja
 
03_definition_bf.ppt
03_definition_bf.ppt03_definition_bf.ppt
03_definition_bf.pptTrieuDoMinh
 
03_definition_bf [Автосохраненный].ppt
03_definition_bf [Автосохраненный].ppt03_definition_bf [Автосохраненный].ppt
03_definition_bf [Автосохраненный].pptTrieuDoMinh
 
Spatial filtering
Spatial filteringSpatial filtering
Spatial filteringDeepikaT13
 

Similar a Computer Vision - Image Filters (20)

Gaussian filtering 1up
Gaussian filtering 1upGaussian filtering 1up
Gaussian filtering 1up
 
Spatial Filtering in intro image processingr
Spatial Filtering in intro image processingrSpatial Filtering in intro image processingr
Spatial Filtering in intro image processingr
 
06 spatial filtering DIP
06 spatial filtering DIP06 spatial filtering DIP
06 spatial filtering DIP
 
Filtering an image is to apply a convolution
Filtering an image is to apply a convolutionFiltering an image is to apply a convolution
Filtering an image is to apply a convolution
 
2. filtering basics
2. filtering basics2. filtering basics
2. filtering basics
 
03 cie552 image_filtering_spatial
03 cie552 image_filtering_spatial03 cie552 image_filtering_spatial
03 cie552 image_filtering_spatial
 
Image processing 2
Image processing 2Image processing 2
Image processing 2
 
Notes on image processing
Notes on image processingNotes on image processing
Notes on image processing
 
05_Spatial_Filtering.ppt
05_Spatial_Filtering.ppt05_Spatial_Filtering.ppt
05_Spatial_Filtering.ppt
 
ESTIMATING NOISE PARAMETER & FILTERING (Digital Image Processing)
ESTIMATING NOISE PARAMETER & FILTERING (Digital Image Processing)ESTIMATING NOISE PARAMETER & FILTERING (Digital Image Processing)
ESTIMATING NOISE PARAMETER & FILTERING (Digital Image Processing)
 
International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)
 
IIR filter design, Digital signal processing
IIR filter design, Digital signal processingIIR filter design, Digital signal processing
IIR filter design, Digital signal processing
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Lect 03 - first portion
Lect 03 - first portionLect 03 - first portion
Lect 03 - first portion
 
image_enhancement_spatial
 image_enhancement_spatial image_enhancement_spatial
image_enhancement_spatial
 
Wavelet transform in two dimensions
Wavelet transform in two dimensionsWavelet transform in two dimensions
Wavelet transform in two dimensions
 
Image enhancement
Image enhancementImage enhancement
Image enhancement
 
03_definition_bf.ppt
03_definition_bf.ppt03_definition_bf.ppt
03_definition_bf.ppt
 
03_definition_bf [Автосохраненный].ppt
03_definition_bf [Автосохраненный].ppt03_definition_bf [Автосохраненный].ppt
03_definition_bf [Автосохраненный].ppt
 
Spatial filtering
Spatial filteringSpatial filtering
Spatial filtering
 

Más de Yoss Cohen

Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsYoss Cohen
 
open platform for swarm training
open platform for swarm training open platform for swarm training
open platform for swarm training Yoss Cohen
 
Deep Learning - system view
Deep Learning - system viewDeep Learning - system view
Deep Learning - system viewYoss Cohen
 
Dspip deep learning syllabus
Dspip deep learning syllabusDspip deep learning syllabus
Dspip deep learning syllabusYoss Cohen
 
IoT consideration selection
IoT consideration selectionIoT consideration selection
IoT consideration selectionYoss Cohen
 
Nvidia jetson nano bringup
Nvidia jetson nano bringupNvidia jetson nano bringup
Nvidia jetson nano bringupYoss Cohen
 
Autonomous car teleportation architecture
Autonomous car teleportation architectureAutonomous car teleportation architecture
Autonomous car teleportation architectureYoss Cohen
 
Motion estimation overview
Motion estimation overviewMotion estimation overview
Motion estimation overviewYoss Cohen
 
Intro to machine learning with scikit learn
Intro to machine learning with scikit learnIntro to machine learning with scikit learn
Intro to machine learning with scikit learnYoss Cohen
 
DASH and HTTP2.0
DASH and HTTP2.0DASH and HTTP2.0
DASH and HTTP2.0Yoss Cohen
 
HEVC Definitions and high-level syntax
HEVC Definitions and high-level syntaxHEVC Definitions and high-level syntax
HEVC Definitions and high-level syntaxYoss Cohen
 
Introduction to HEVC
Introduction to HEVCIntroduction to HEVC
Introduction to HEVCYoss Cohen
 
FFMPEG on android
FFMPEG on androidFFMPEG on android
FFMPEG on androidYoss Cohen
 
Hands-on Video Course - "RAW Video"
Hands-on Video Course - "RAW Video" Hands-on Video Course - "RAW Video"
Hands-on Video Course - "RAW Video" Yoss Cohen
 
Video quality testing
Video quality testingVideo quality testing
Video quality testingYoss Cohen
 
HEVC / H265 Hands-On course
HEVC / H265 Hands-On courseHEVC / H265 Hands-On course
HEVC / H265 Hands-On courseYoss Cohen
 
Web video standards
Web video standardsWeb video standards
Web video standardsYoss Cohen
 
Product wise computer vision development
Product wise computer vision developmentProduct wise computer vision development
Product wise computer vision developmentYoss Cohen
 
3D Video Programming for Android
3D Video Programming for Android3D Video Programming for Android
3D Video Programming for AndroidYoss Cohen
 

Más de Yoss Cohen (20)

Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platforms
 
open platform for swarm training
open platform for swarm training open platform for swarm training
open platform for swarm training
 
Deep Learning - system view
Deep Learning - system viewDeep Learning - system view
Deep Learning - system view
 
Dspip deep learning syllabus
Dspip deep learning syllabusDspip deep learning syllabus
Dspip deep learning syllabus
 
IoT consideration selection
IoT consideration selectionIoT consideration selection
IoT consideration selection
 
IoT evolution
IoT evolutionIoT evolution
IoT evolution
 
Nvidia jetson nano bringup
Nvidia jetson nano bringupNvidia jetson nano bringup
Nvidia jetson nano bringup
 
Autonomous car teleportation architecture
Autonomous car teleportation architectureAutonomous car teleportation architecture
Autonomous car teleportation architecture
 
Motion estimation overview
Motion estimation overviewMotion estimation overview
Motion estimation overview
 
Intro to machine learning with scikit learn
Intro to machine learning with scikit learnIntro to machine learning with scikit learn
Intro to machine learning with scikit learn
 
DASH and HTTP2.0
DASH and HTTP2.0DASH and HTTP2.0
DASH and HTTP2.0
 
HEVC Definitions and high-level syntax
HEVC Definitions and high-level syntaxHEVC Definitions and high-level syntax
HEVC Definitions and high-level syntax
 
Introduction to HEVC
Introduction to HEVCIntroduction to HEVC
Introduction to HEVC
 
FFMPEG on android
FFMPEG on androidFFMPEG on android
FFMPEG on android
 
Hands-on Video Course - "RAW Video"
Hands-on Video Course - "RAW Video" Hands-on Video Course - "RAW Video"
Hands-on Video Course - "RAW Video"
 
Video quality testing
Video quality testingVideo quality testing
Video quality testing
 
HEVC / H265 Hands-On course
HEVC / H265 Hands-On courseHEVC / H265 Hands-On course
HEVC / H265 Hands-On course
 
Web video standards
Web video standardsWeb video standards
Web video standards
 
Product wise computer vision development
Product wise computer vision developmentProduct wise computer vision development
Product wise computer vision development
 
3D Video Programming for Android
3D Video Programming for Android3D Video Programming for Android
3D Video Programming for Android
 

Último

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 

Último (20)

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 

Computer Vision - Image Filters

  • 1. 1 Yossi CohenIntro to computer Vision
  • 2. 2
  • 3. 3 How to filter 2d Correlation h=filter2(g,f); or h=imfilter(f,g); 2d Convolution h=conv2(g,f); ],[],[],[ , lnkmflkgnmh lk −−= ∑ f=image g=filter ],[],[],[ , lnkmflkgnmh lk ++= ∑
  • 4. 4 Correlation filtering Say the averaging window size is 2k+1 x 2k+1: Loop over all pixels in neighborhood around image pixel F[i,j] Attribute uniform weight to each pixel Now generalize to allow different weights depending on neighboring pixel’s relative position: Non-uniform weights
  • 5. 5 Correlation filtering Filtering an image: replace each pixel with a linear combination of its neighbors. The filter “kernel” or “mask” H[u,v] is the prescription for the weights in the linear combination. This is called cross-correlation, denoted
  • 6. 6 Properties of smoothing filters Smoothing  Values positive  Sum to 1  constant regions same as input  Amount of smoothing proportional to mask size  Remove “high-frequency” components; “low-pass” filter
  • 7. 7 Filtering an impulse signal 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a b c d e f g h i What is the result of filtering the impulse signal (image) F with the arbitrary kernel H? ?
  • 8. 8 Filtering an impulse signal 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a b c d e f g h i 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 i h g 0 0 0 0 f e d 0 0 0 0 c b a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 What is the result of filtering the impulse signal (image) F with the arbitrary kernel H?
  • 9. 9 Averaging filter  What values belong in the kernel H for the moving average example? 0 10 20 30 30 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 90 90 90 90 90 0 0 0 0 0 90 90 90 90 90 0 0 0 0 0 90 90 90 90 90 0 0 0 0 0 90 0 90 90 90 0 0 0 0 0 90 90 90 90 90 0 0 0 0 0 0 0 0 0 0 0 0 0 0 90 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 111 111 111 “box filter” ?
  • 10. 10 Smoothing by averaging depicts box filter: white = high value, black = low value original filtered
  • 11. 11 Gaussian filter 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 90 90 90 90 90 0 0 0 0 0 90 90 90 90 90 0 0 0 0 0 90 90 90 90 90 0 0 0 0 0 90 0 90 90 90 0 0 0 0 0 90 90 90 90 90 0 0 0 0 0 0 0 0 0 0 0 0 0 0 90 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 1 2 4 2 1 2 1 This kernel is an approximation of a 2d Gaussian function:
  • 14. 14  Weight contributions of neighboring pixels by nearness 0.003 0.013 0.022 0.013 0.003 0.013 0.059 0.097 0.059 0.013 0.022 0.097 0.159 0.097 0.022 0.013 0.059 0.097 0.059 0.013 0.003 0.013 0.022 0.013 0.003 5 x 5, σ = 1 Slide credit: Christopher Rasmussen Gaussian
  • 15. 15 Gaussian filters What parameters matter here? Size of kernel or mask Note, Gaussian function has infinite support, but discrete filters use finite kernels σ = 5 with 10 x 10 kernel σ = 5 with 30 x 30 kernel
  • 16. 16 Gaussian filters What parameters matter here? Variance of Gaussian: determines extent of smoothing σ = 2 with 30 x 30 kernel σ = 5 with 30 x 30 kernel
  • 17. 17 Matlab >> hsize = 10; >> sigma = 5; >> h = fspecial(‘gaussian’ hsize, sigma); >> mesh(h); >> imagesc(h); >> outim = imfilter(im, h); % correlation >> imshow(outim); outim
  • 18. 18 Smoothing with a Gaussian for sigma=1:3:10 h = fspecial('gaussian‘, fsize, sigma); out = imfilter(im, h); imshow(out); pause; end … Parameter σ is the “scale” / “width” / “spread” of the Gaussian kernel, and controls the amount of smoothing.
  • 19. 19 Gaussian filters • Remove “high-frequency” components from the image (low-pass filter) Images become more smooth • Convolution with self is another Gaussian –So can smooth with small-width kernel, repeat, and get same result as larger-width kernel would have –Convolving two times with Gaussian kernel of width σ is same as convolving once with kernel of width σ√2 • Separable kernel –Factors into product of two 1D Gaussians Source: K. Grauman
  • 20. 20 Separability of the Gaussian filter Source: D. Lowe
  • 21. 21 Separability example * * = = 2D convolution (center location only) Source: K. Grauman The filter factors into a product of 1D filters: Perform convolution along rows: Followed by convolution along the remaining column:
  • 22. 22 Convolution  Convolution:  Flip the filter in both dimensions (bottom to top, right to left)  Then apply cross-correlation Notation for convolution operator F H
  • 24. 24 Key properties of linear filters Linearity: filter(f1 + f2) = filter(f1) + filter(f2) Shift invariance: same behavior regardless of pixel location filter(shift(f)) = shift(filter(f)) Any linear, shift-invariant operator can be represented as a convolution Source: S. Lazebnik
  • 25. 25 More properties • Commutative: a * b = b * a  Conceptually no difference between filter and signal  But particular filtering implementations might break this equality • Associative: a * (b * c) = (a * b) * c  Often apply several filters one after another: (((a * b1) * b2) * b3)  This is equivalent to applying one filter: a * (b1 * b2 * b3) • Distributes over addition: a * (b + c) = (a * b) + (a * c) • Scalars factor out: ka * b = a * kb = k (a * b) • Identity: unit impulse e = [0, 0, 1, 0, 0], a * e = a Source: S. Lazebnik
  • 26. 26 Matlab Lab 1 – Smooth/Blur Filters
  • 27. 27 Lets try to blur filter %%basic image filters imrgb = imread('peppers.png'); imshow(imrgb); a = [1 1 1; 1 1 1; 1 1 1] Corroutimg = filter2(a, imgray); Convoutimg = conv2(imgray,a); figure; imshow(Corroutimg) figure imshow(Convoutimg)
  • 28. 28 Fix it Can we conv2 an RGB image?? Use rgb2gray Whats wrong now? Try preserving the image power Convert image to double
  • 29. 29 Results %%basic image filters imrgb = imread('peppers.png'); imgray = im2double(rgb2gray(imrgb)); imshow(imgray); a = 1/16*ones(4) Corroutimg = filter2(a, imgray); Convoutimg = conv2(a, imgray); figure; imshow(Corroutimg) figure imshow(Convoutimg)
  • 30. 30 Sharp %%basic sharp filter imrgb = imread('peppers.png'); imgray = im2double(rgb2gray(imrgb)); imshow(imgray); a = [ 0 0 0; 0 2 0; 0 0 0] - 1/9*ones(3) Corroutimg = filter2(a, imgray); figure; imshow(Corroutimg)
  • 31. 31 Practical matters What happens near the edge? the filter window falls off the edge of the image need to extrapolate methods: clip filter (black) wrap around copy edge reflect across edge Source: S. Marschner
  • 32. 32 Matlab edge aware filtering methods (MATLAB): clip filter (black): imfilter(f, g, 0) wrap around: imfilter(f, g, ‘circular’) copy edge: imfilter(f, g, ‘replicate’) reflect across edge: imfilter(f, g, ‘symmetric’)
  • 33. 33 Practical matters What is the size of the output? • MATLAB: filter2(g, f, shape) shape = ‘full’: output size is sum of sizes of f and g shape = ‘same’: output size is same as f shape = ‘valid’: output size is difference of sizes of f and g f gg gg f gg gg f gg gg full same valid
  • 34. 34 Median filters A Median Filter operates over a window by selecting the median intensity in the window. What advantage does a median filter have over a mean filter? Is a median filter a kind of convolution?
  • 35. 35 Matlab Lab 2 – Median Filter
  • 36. 36 Comparison: salt and pepper noise
  • 37. 37 Median Filter Example %%Median imrgb = imread('peppers.png'); imgray = im2double(rgb2gray(imrgb)); imnoise = imnoise(imgray,'salt & pepper',0.1); imshow(imnoise) figure imshow(medfilt2(imnoise))
  • 38. 38 Basic Filters summary Linear filtering is sum of dot product at each position Can smooth, sharpen, translate (among many other uses) Be aware of details for filter size, extrapolation, cropping 111 111 111

Notas del editor

  1. e^0 = 1, e^-1 = .37, e^-2 = .14, etc.
  2. In matlab, conv2 does convolution, filter2 does correlation. Imfilter does either if specified, correlation by default (‘conv’, ‘corr’ option)
  3. Linear vs. quadratic in mask size
  4. f is image
  5. Better at salt’n’pepper noise Not convolution: try a region with 1’s and a 2, and then 1’s and a 3