Image Processing Todays Class Image Representations: Matrices - - PowerPoint PPT Presentation
Image Processing Todays Class Image Representations: Matrices - - PowerPoint PPT Presentation
CS6501: Deep Learning for Visual Recognition Image Processing Todays Class Image Representations: Matrices Image Representations: RGB, HSV, etc Image Processing: Brightness Image Filtering: Mean Filter, Median Filter Image Filtering:
Today’s Class
Image Representations: Matrices Image Representations: RGB, HSV, etc Image Processing: Brightness Image Filtering: Mean Filter, Median Filter Image Filtering: Convolutions Blurring, Sharpening, Computing Gradients Walkthrough Image Processing Primer
- Instructor: Vicente Ordóñez
- Email: vicente@virginia.edu
- Website: http://vicenteordonez.com/deeplearning/
- Class Location: Olsson Hall 005
- Class Times: Monday-Wednesday 3:30pm and 4:45pm
- Piazza:
https://piazza.com/virginia/spring2020/cs6501003/home
- Office Hours: Tuesdays 3 to 5pm (Rice 310)
3
About the Course
CS6501-003: Deep Learning for Visual Recognition
Paola Cascante-Bonilla (pc9za@virginia.edu) Hours: Fridays 2 to 4pm (Rice 442)
4
Teaching Assistants
Ziyan Yang (tw8cb@virginia.edu) Office Hours: Thursdays 3 to 5pm (Rice 442)
Grading
5
- Assignments: 400pts (4 assignments)
(100pts + 100pts + 100pts + 100pts)
- Course Project: 400pts
Groups of up to 3 students (more only if justified)
- Paper Reading Summaries: 100pts
- Class Paper Presentation: 100pts (groups of mostly 2 students)
Also…
- Assignment 1 released on course website
- You should have completed the pytorch/jupyter/Google
Colaboratory tutorial and the Numpy / Image Processing tutorial.
Additionally you will need for your Course Project:
Free credits for students! $50. g2.2xlarge: 4GB ($0.65 / hour) p2.xlarge: 12GB ($0.90 / hour)
Or maybe, even better:
GTX 1080 Ti (11GB): $700 GTX 1080 (8GB): $500 GTX 1060 (6GB): $150-$250
I am also working to get you set up on
GTX 1080 Ti (11GB): $700 GTX 1080 (8GB): $500 GTX 1060 (6GB): $150-$250
What we see What a computer sees
Source: S. Narasimhan
Reminder of what is an image for a computer.
Images as Functions
z = #(%, ')
Images as Functions
z = #(%, ')
- The domain of x and y is [0, img-width) and [0 and img-height)
- x, and y are discretized into integer values.
Light
- What determines the color of a pixel?
Figure from Szeliski
The Retina
Cross-section of eye Ganglion cell layer Bipolar cell layer Receptor layer Pigmented epithelium Ganglion axons Cross section of retina
[What the Frog's Eye Tells the Frog's Brain]
Cones cone-shaped less sensitive
- perate in high light
color vision Rods rod-shaped highly sensitive
- perate at night
gray-scale vision
Electromagnetic Spectrum
http://www.yorku.ca/eye/photopik.htm
Human Luminance Sensitivity Function
Basic Image Processing
! "!
" > 1
Basic Image Processing
! "!
0 < " < 1
Color Images as Tensors
!ℎ#$$%& ' ℎ%()ℎ* ' +(,*ℎ
Color Images as Tensors
!ℎ#$$%& ' ℎ%()ℎ* ' +(,*ℎ Channels are usually RGB: Red, Green, and Blue Other color spaces: HSV, HSL, LUV, XYZ, Lab, CMYK, etc
Color spaces: RGB
0,1,0 0,0,1 1,0,0
Image from: http://en.wikipedia.org/wiki/File:RGB_color_solid_cube.png
Some drawbacks
- Strongly correlated channels
- Non-perceptual
Default color space R
(G=0,B=0)
G
(R=0,B=0)
B
(R=0,G=0)
Slide by James Hays
Color spaces: HSV
Intuitive color space
H
(S=1,V=1)
S
(H=1,V=1)
V
(H=1,S=0)
Slide by James Hays
Color spaces: L*a*b*
“Perceptually uniform”* color space
L
(a=0,b=0)
a
(L=65,b=0)
b
(L=65,a=0)
Slide by James Hays
Most information in intensity
Only color shown – constant intensity
Slide by James Hays
Most information in intensity
Only intensity shown – constant color
Slide by James Hays
Most information in intensity
Original image
Slide by James Hays
Image filtering
Image filtering
Image Credit: http://what-when-how.com/introduction-to-video-and-image-processing/neighborhood-processing-introduction-to-video-and-image-processing-part-1/
Image filtering
Image Credit: http://what-when-how.com/introduction-to-video-and-image-processing/neighborhood-processing-introduction-to-video-and-image-processing-part-1/
Image filtering: e.g. Mean Filter
Image filtering: e.g. Mean Filter
Image filtering: e.g. Median Filter
Image Credit: http://what-when-how.com/introduction-to-video-and-image-processing/neighborhood-processing-introduction-to-video-and-image-processing-part-1/
Image filtering: Convolution operator
Image Credit: http://what-when-how.com/introduction-to-video-and-image-processing/neighborhood-processing-introduction-to-video-and-image-processing-part-1/
!(#, %) ' #, % = )
*
)
+
! ,, - .(# − ,, % − -)
http://www.cs.virginia.edu/~vicente/recognition/animation.gif (filter, kernel)
Image filtering: Convolution operator e.g. mean filter
Image Credit: http://what-when-how.com/introduction-to-video-and-image-processing/neighborhood-processing-introduction-to-video-and-image-processing-part-1/
!(#, %)
!(#, %) =
1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/9
Image filtering: Convolution operator e.g. mean filter
Image Credit: http://what-when-how.com/introduction-to-video-and-image-processing/neighborhood-processing-introduction-to-video-and-image-processing-part-1/
!(#, %)
!(#, %) =
1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/9
1 1 1 1 1 1 1 1 1
Slide credit: David Lowe (UBC)
] , [ g × ×
Example: box filter
90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
Credit: S. Seitz
] , [ ] , [ ] , [
,
l n k m f l k g n m h
l k
+ + =å
[.,.] h [.,.] f
Image filtering
1 1 1 1 1 1 1 1 1
] , [ g × ×
90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 10 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
[.,.] h [.,.] f
Image filtering
1 1 1 1 1 1 1 1 1
] , [ g × ×
Credit: S. Seitz
] , [ ] , [ ] , [
,
l n k m f l k g n m h
l k
+ + =å
90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 10 20 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
[.,.] h [.,.] f
Image filtering
1 1 1 1 1 1 1 1 1
] , [ g × ×
Credit: S. Seitz
] , [ ] , [ ] , [
,
l n k m f l k g n m h
l k
+ + =å
90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 10 20 30 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
[.,.] h [.,.] f
Image filtering
1 1 1 1 1 1 1 1 1
] , [ g × ×
Credit: S. Seitz
] , [ ] , [ ] , [
,
l n k m f l k g n m h
l k
+ + =å
10 20 30 30 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
[.,.] h [.,.] f
Image filtering
1 1 1 1 1 1 1 1 1
] , [ g × ×
Credit: S. Seitz
] , [ ] , [ ] , [
,
l n k m f l k g n m h
l k
+ + =å
10 20 30 30 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
[.,.] h [.,.] f
Image filtering
1 1 1 1 1 1 1 1 1
] , [ g × ×
Credit: S. Seitz
?
] , [ ] , [ ] , [
,
l n k m f l k g n m h
l k
+ + =å
10 20 30 30 50 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
[.,.] h [.,.] f
Image filtering
1 1 1 1 1 1 1 1 1
] , [ g × ×
Credit: S. Seitz
?
] , [ ] , [ ] , [
,
l n k m f l k g n m h
l k
+ + =å
90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 10 20 30 30 30 20 10 20 40 60 60 60 40 20 30 60 90 90 90 60 30 30 50 80 80 90 60 30 30 50 80 80 90 60 30 20 30 50 50 60 40 20 10 20 30 30 30 30 20 10 10 10 10
[.,.] h [.,.] f
Image filtering
1 1 1 1 1 1 1 1 1
] , [ g × ×
Credit: S. Seitz
] , [ ] , [ ] , [
,
l n k m f l k g n m h
l k
+ + =å
What does it do?
- Replaces each pixel with
an average of its neighborhood
- Achieve smoothing effect
(remove sharp features)
1 1 1 1 1 1 1 1 1
Slide credit: David Lowe (UBC)
] , [ g × ×
Box Filter
Image filtering: e.g. Mean Filter
Image filtering: Convolution operator Important filter: gaussian filter (gaussian blur)
Image Credit: http://what-when-how.com/introduction-to-video-and-image-processing/neighborhood-processing-introduction-to-video-and-image-processing-part-1/
!(#, %)
!(#, %) =
1/16 1/8 1/16 1/8 1/4 1/8 1/16 1/8 1/16
- 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, s = 1
Slide credit: Christopher Rasmussen
Important filter: Gaussian
Image filtering: Convolution operator e.g. gaussian filter (gaussian blur)
Image Credit: http://what-when-how.com/introduction-to-video-and-image-processing/neighborhood-processing-introduction-to-video-and-image-processing-part-1/
Practical matters
- What about 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
Practice with linear filters
1 Original
?
Source: D. Lowe
Practice with linear filters
1 Original Filtered (no change)
Source: D. Lowe
Practice with linear filters
1 Original
?
Source: D. Lowe
Practice with linear filters
1 Original Shifted left By 1 pixel
Source: D. Lowe
Practice with linear filters
Original 1 1 1 1 1 1 1 1 1 2
- ?
(Note that filter sums to 1)
Source: D. Lowe
Practice with linear filters
Original 1 1 1 1 1 1 1 1 1 2
- Sharpening filter
- Accentuates differences
with local average
Source: D. Lowe
Sharpening
Source: D. Lowe
Key properties of linear filters
Linearity:
imfilter(I, f1 + f2) = imfilter(I,f1) + imfilter(I,f2)
Shift invariance: same behavior regardless of pixel location
imfilter(I,shift(f)) = shift(imfilter(I,f))
Any linear, shift-invariant operator can be represented as a convolution
Source: S. Lazebnik
– Enhance images
- Denoise, resize, increase contrast, etc.
– Extract information from images
- Texture, edges, distinctive points, etc.
– Detect patterns
- Template matching
– Deep Convolutional Networks
Image filtering: Convolution operator
Image filtering: Convolution operator Important Filter: Sobel operator
Image Credit: http://what-when-how.com/introduction-to-video-and-image-processing/neighborhood-processing-introduction-to-video-and-image-processing-part-1/
!(#, %)
!(#, %) =
1
- 1
2
- 2
1
- 1
Other filters
- 1
1
- 2
2
- 1
1 Vertical Edge (absolute value)
Sobel
Slide by James Hays
Other filters
- 1
- 2
- 1
1 2 1 Horizontal Edge (absolute value)
Sobel
Slide by James Hays
Sobel operators are equivalent to 2D partial derivatives of the image
- Vertical sobel operator – Partial derivative in X (width)
- Horizontal sobel operator – Partial derivative in Y (height)
- Can compute magnitude and phase at each location.
- Useful for detecting edges
https://en.wikipedia.org/wiki/Sobel_operator
Sobel filters are (approximate) partial derivatives
- f the image
!"($, &) !$ = lim
,→.
" $ + ℎ, & − "($, &) ℎ "($, &) be your input image, then the partial derivative is: Let !"($, &) !$ = lim
,→.
" $ + ℎ, & − "($ − ℎ, &) 2ℎ Also:
But digital images are not continuous, they are discrete
Δ"#[%, '] = #[% + 1, '] − #[%, '] #[%, '] be your input image, then the partial derivative is: Let Δ"#[%, '] = #[% + 1, '] − #[% − 1, '] Also:
But digital images are not continuous, they are discrete
Δ"#[%, '] = #[% + 1, '] − #[%, '] #[%, '] be your input image, then the partial derivative is: Let Δ"#[%, '] = #[% + 1, '] − #[% − 1, '] Also:
- 1
1
- 1
1
k(x, y) = k(x, y) =
Sobel Operators Smooth in Y and then Differentiate in X
1
- 1
k(x, y) =
1 2 1
* =
1
- 1
2
- 2
1
- 1
Similarly to differentiate in Y
Image Features
What are Image Features?
Image 0.22 0.30 0.13 0.24 0.31 0.15 0.35 0.48 Color histogram? Maximum color on sub-areas of the image? Any statistics on the input image? The output of some image processing on the input image?
Why are they useful?
Image
0.22 0.30 0.13 0.24 0.31 0.15 0.35 0.48
Machine Learning Model Predictions As inputs to a machine learning model
Why are they useful?
0.22 0.30 0.13 0.24 0.31 0.15 0.35 0.48
To compare images (i.e. retrieve similar images)
0.24 0.34 0.23 0.27 0.63 0.15 0.25 0.48
Distance function (e.g. Euclidean distance)
Image Features: Color
Photo by: marielito
slide by Tamara L. Berg
Image Features: Color
Color often not a powerful feature
However, these are all images of people but the colors in each image are very different.
Suggested Reading
- [What the Frog's Eye Tells the Frog's Brain]
[Csurka's Bag of Keypoints. ECCV 2004]
Questions?
77