Digital Image Processing (CS/ECE 545) Lecture 11: Geometric - - PowerPoint PPT Presentation

digital image processing cs ece 545 lecture 11 geometric
SMART_READER_LITE
LIVE PREVIEW

Digital Image Processing (CS/ECE 545) Lecture 11: Geometric - - PowerPoint PPT Presentation

Digital Image Processing (CS/ECE 545) Lecture 11: Geometric Operations, Comparing Images and Future Directions Prof Emmanuel Agu Computer Science Dept. Worcester Polytechnic Institute (WPI) Geometric Operations Filters, point operations change


slide-1
SLIDE 1

Digital Image Processing (CS/ECE 545) Lecture 11: Geometric Operations, Comparing Images and Future Directions Prof Emmanuel Agu

Computer Science Dept. Worcester Polytechnic Institute (WPI)

slide-2
SLIDE 2

Geometric Operations

 Filters, point operations change intensity  Pixel position (and geometry) unchanged  Geometric operations: change image geometry  Examples: translating, rotating, scaling an image

Examples of Geometric

  • perations
slide-3
SLIDE 3

Geometric Operations

 Example applications of geometric operations:

Zooming images, windows to arbitrary size

Computer graphics: deform textures and map to arbitrary surfaces

 Definition: Geometric operation transforms image I to new

image I’ by modifying coordinates of image pixels

 Intensity value originally at (x,y) moved to new position (x’,y’)

Example: Translation geometric operation moves value at (x,y) to (x + dx, y + dy)

(x,y)

(x + dx, y + dy)

slide-4
SLIDE 4

Geometric Operations

 Since image coordinates can only be discrete values, some

transformations may yield (x’,y’) that’s not discrete

 Solution: interpolate nearby values

slide-5
SLIDE 5

Simple Mappings

 Translation: (shift) by a vector (dx, dy)  Scaling: (contracting or stretching) along x or y axis by a factor

sx or sy

slide-6
SLIDE 6

Simple Mappings

 Shearing: along x and y axis by factor bx and by  Rotation: the image by an angle α

slide-7
SLIDE 7

Image Flipping & Rotation by 90 degrees

 We can achieve 90,180 degree rotation easily  Basic idea: Look up a transformed pixel address instead of

the current one

 To flip an image upside down:

At pixel location xy, look up the color at location x (1 – y)

 For horizontal flip:

At pixel location xy, look up (1 – x) y

 Rotating an image 90 degrees counterclockwise:

At pixel location xy, look up (y, 1 – x)

slide-8
SLIDE 8

Image Flipping, Rotation and Warping

 Image warping: we can use a function to select which pixel

somewhere else in the image to look up

 For example: apply function on both texel coordinates (x, y)

) * sin( * x y x x   

slide-9
SLIDE 9

Homogeneous Coordinates

 Notation useful for converting scaling, translation, rotating

into point‐matrix multiplication

 To convert ordinary coordinates into homogeneous

coordinates

slide-10
SLIDE 10

Affine (3‐Point) Mapping

 Can use homogeneous coordinates to rewrite translation,

rotation, scaling, etc as vector‐matrix multiplication

 Affine mapping: Can then derive values of matrix that achieve

desired transformation (or combination of transformations)

 Inverse of transform matrix is inverse mapping

slide-11
SLIDE 11

Affine (3‐Point) Mapping

 What’s so special about affine mapping?  Maps

straight lines ‐> straight lines,

triangles ‐> triangles

rectangles ‐> parallelograms

Parallel lines ‐> parallel lines

 Distance ratio on lines do not change

slide-12
SLIDE 12

Non‐Linear Image Warps

Original Twirl Ripple Spherical

slide-13
SLIDE 13

Twirl

Notation: Instead using texture colors at (x’,y’), use texture colors at twirled (x,y) location

Twirl?

Rotate image by angle α at center or anchor point (xc,yc)

Increasingly rotate image as radial distance r from center increases (up to rmax)

Image unchanged outside radial distance rmax

slide-14
SLIDE 14

Ripple

 Ripple causes wavelike displacement of

image along both the x and y directions

 Sample values for parameters (in pixels) are

τx= 120

τy= 250

ax= 10

ay= 15

slide-15
SLIDE 15

Spherical Transformation

Imitates viewing image through a lens placed over image

Lens parameters: center (xc, yc ), lens radius rmax and refraction index ρ

Sample values ρ = 1.8 and rmax = half image width

slide-16
SLIDE 16

Image Warping

slide-17
SLIDE 17

Digital Image Processing (CS/ECE 545) Lecture 11: Comparing Images Prof Emmanuel Agu

Computer Science Dept. Worcester Polytechnic Institute (WPI)

slide-18
SLIDE 18

How to tell if 2 Images are same?

 Pixel by pixel comparison?

 Makes sense only if pictures taken from same angle, same

lighting, etc

 Noise, quantization, etc introduces differences

 Human may say images are same even with numerical

differences

slide-19
SLIDE 19

Comparing Images

 Better approach: Template matching

Identify similar sub‐images (called template) within 2 images

 Applications?

Match left and right picture of stereo images

Find particular pattern in scene

Track moving pattern through image sequence

slide-20
SLIDE 20

Template Matching

 Basic idea

 Move given pattern (template) over search image  Measure difference between template and sub‐images at

different positions

 Record positions where highest similarity is found

Template SubImage

slide-21
SLIDE 21

Template Matching

 Difficult issues?

 What is distance (difference) measure?  What levels of difference should be considered a match?  How are results affected when brightness or contrast

changes?

Template SubImage

slide-22
SLIDE 22

Template Matching in Intensity Images

 Consider problem of finding a template (reference image) R

within a search image

 Can be restated as Finding positions in which contents of R

are most similar to the corresponding subimage of I

 If we denote R shifted by some distance (r,s) by

slide-23
SLIDE 23

Template Matching in Intensity Images

 We can restate template matching problem as:  Finding the offset (r,s) such that the similarity between the shifted

reference image Rr,s and corresponding subimage I is a maximum

 Solving this problem involves solving many sub‐problems

slide-24
SLIDE 24

Distance between Image Patterns

 Many measures proposed to compute distance between the

shifted reference image Rr,s and corresponding subimage I

slide-25
SLIDE 25

Distance between Image Patterns

 Many measures proposed to compute distance between the

shifted reference image Rr,s and corresponding subimage I

 Sum of absolute differences:  Maximum difference:  Sum of squared differences (also called N‐dimensional

Euclidean distance):

slide-26
SLIDE 26

Distance and Correlation

 Best matching position between shifted reference image Rr,s

and subimage I minimizes square of dE which can be expanded as

 B term is a constant, independent of r, s and can be ignored  A term is sum of squared values within subimage I at current

  • ffset r, s
slide-27
SLIDE 27

Distance and Correlation

 C(r,s) term is linear cross correlation between I and R defined as  Since R and I are assumed to be zero outside their boundaries  Note: Correlation is similar to linear convolution  Min value of d2

E(r,s) corresponds to max value of

slide-28
SLIDE 28

Normalized Cross Correlation

 Unfortunately, A term is not constant in most images  Thus cross correlation result varies with intensity changes in

image I

 Normalized cross correlation considers energy in I and R  CN (r,s) is a local distance measure, is in [0,1] range  CN (r,s) = 1 indicates maximum match  CN (r,s) = 0 indicates images are very dissimilar

slide-29
SLIDE 29

Correlation Coefficient

 Correlation coefficient: Use differences between I and R and

their average values where the average values are defined as

 K is number of pixels in reference image R  CL(r,s) can be rewritten as

slide-30
SLIDE 30

Correlation Coefficient Algorithm

slide-31
SLIDE 31

Correlation Coefficient Java Implementation

slide-32
SLIDE 32

Correlation Coefficient Java Implementation

slide-33
SLIDE 33

Examples and Discussion

 We now compare these distance metrics  Original image I: Repetitive flower pattern  Reference image R: one instance of repetitive pattern

extracted from I

 Now compute various distance measures for this I and R

slide-34
SLIDE 34

Examples and Discussion

 Sum of absolute differences: performs okay but affected by

global intensity changes

 Maximum difference: Responds more to lighting intensity

changes than pattern similarity

slide-35
SLIDE 35

Examples and Discussion

 Sum of squared (euclidean) distances: performs okay but

affected by global intensity changes

 Global cross correlation: Local maxima at true template

position, but is dominated by high‐intensity responses in brighter image parts

slide-36
SLIDE 36

Examples and Discussion

 Normalized cross correlation: results similar to euclidean

distance (affected by global intensity changes)

 Correlation coefficient: yields best results. Distinct peaks

produced for all 6 template instances, unaffected by lighting

slide-37
SLIDE 37

Effects of Changing Intensity

 To explore effects of globally changing intensity, raise intensiy

  • f reference image R by 50 units

 Distinct peaks disappear in Euclidean distance  Correlation coefficient unchanged, robust measure in

realistic lighting conditions

slide-38
SLIDE 38

Euclidean Distance under Global Intensity Changes

 Local peaks disappear as template intensity (and thus

distance) is increased

Distance function for

  • riginal template R

Distance function with intensity increased by 25 units Distance function with intensity increased by 50 units

slide-39
SLIDE 39

Shape of Template

 Template does not have to be rectangular  Some applications use circular, elliptical or custom‐shaped

templates

 Non‐rectangular templates stored in rectangular array, but

pixels in template marked using a mask

 More generally, a weighted function can be applied to

template elements

slide-40
SLIDE 40

Matching under Rotation and Scaling

 Simple Approach:

 Store multiple rotated and scaled versions of template  Computationally prohibitive

 Alternate approaches:

 Matching in logarithmic‐polar space (complicated!)  Affine matching use local statistical features invariant

under affine image transformations (including rotation and scaling)

slide-41
SLIDE 41

Matching Binary Images

 Direct Comparison:

Count the number of identical pixels in search image and template

Small total difference when most pixels are same

 Problem: Small shift, rotation or distortion of image create

high distance

 Need a more tolerant measure

slide-42
SLIDE 42

The Distance Transform

 For every position (u,v) in the search image I, record distance

to closest foreground pixel

 So, for binary image  Distance transform is defined as  Examples of distance measures are Euclidean distance  Or Manhattan distance

slide-43
SLIDE 43

Distance Transform Example

 Example using Manhattan distance

slide-44
SLIDE 44

Chamfer Algorithm

 Efficient method to compute distance transform  Similar to sequential region labeling  Traverses image twice

First, starting at upper left corner of image, propagates distance values downward in diagonal direction

Second traversal starts at bottom right, proceeds in opposite direction (bottom to top)

 For each traversal, the following masks is used for

propagating distance values

slide-45
SLIDE 45

Chamfer Distance

 Specifically, for masks for Manhattan distance  And masks for Euclidean distance  Floating point‐operations can be avoided using distance masks

with scaled integer values for Euclidean distance such as

slide-46
SLIDE 46

Chamfer Matching

 Uses distance transform for matching binary images  Finds points of maximum agreement between binary search

image I and binary reference image R

 Accumulates values of distance transform as match score Q  At each position, (r,s) of the template R, distance values to all

foreground pixels are accumulated where K = |FG(R)| is number of foreground pixels in template R

 Zero Q score = maximum match  Large Q score = large deviations  Best match corresponds to global minimum of Q

slide-47
SLIDE 47

Chamfer Matching

Compute distance transform D

  • f image using Chamfer algorithm

Accumulate sum of distance values For all foreground pixels in template R Results stored in 2D match map D

slide-48
SLIDE 48

Comparing Direct Pixel comparison and Chamfer Matching

 Chamfer match score Q much smoother than direct comparison

Distinct peaks in places of high similarity

slide-49
SLIDE 49

Distance Transform using Chamfer Algorithm

slide-50
SLIDE 50

Distance Transform using Chamfer Algorithm

slide-51
SLIDE 51

Digital Image Processing (CS/ECE 545) Lecture 11: Future Directions Prof Emmanuel Agu

Computer Science Dept. Worcester Polytechnic Institute (WPI)

slide-52
SLIDE 52

Recall: Electromagnetic Spectrum and IP

 Images can be made from any form of EM radiation

slide-53
SLIDE 53

Recall: Images from Different EM Radiation

 Radar imaging (radio waves)  Magnetic Resonance Imaging (MRI) (Radio waves)  Microwave imaging  Infrared imaging  Photographs  Ultraviolet imaging telescopes  X‐rays and Computed tomography  Positron emission tomography (gamma rays)  Ultrasound (not EM waves)

Non-visible Wavelengths Used for Medical imaging

slide-54
SLIDE 54

Medical Imaging Example Technologies

 XRay  Computerized tomography  Mammogram  Nuclear magnetic resonance  Positron Emission Tomography  Single Photon Emission Computerized Tomography  Ultrasound imaging

slide-55
SLIDE 55

XRay

 Imaging body internals using electromagnetic waves

  • f wavelength 0.01 to 10 nanometers
slide-56
SLIDE 56

Computerized Tomography

 Tomography: Cross‐sectional image formed from projections  Example: XRay Computerized tomography of human brain  Virtual slices allow human to see inside without cutting open

slide-57
SLIDE 57

Ultrasound

 Uses sound waves undetectable by human ear  Non‐invasive imaging, used for imaging unborn babies

slide-58
SLIDE 58

Computer Vision

 Vision builds on Image processing  Inverse problem to computer graphics

Courtesy Grauman U of Texas

slide-59
SLIDE 59

Why do we need Computer Vision?

 Explosion of visual content  Let computers help humans with “easy” tasks

slide-60
SLIDE 60

Computer Vision

 Classic CV task: Recognize objects in image  First step: Describe images using distinct features

(textures, colors, edges, etc)

 Outputs of image processing = inputs for CV

Courtesy Grauman U of Texas

slide-61
SLIDE 61

Courtesy Grauman U of Texas

Hough transform, etc

slide-62
SLIDE 62

Courtesy Grauman U of Texas

slide-63
SLIDE 63

Digital Forensics

 Detecting when images have been tampered with  Has been around for a long time  Example: 1961 Grigoriy Nelyubov, one of astronauts removed

from image of Russian astronauts on moon for misbehavior

slide-64
SLIDE 64

Computational Photography

 Traditional camera: only configurable settings  Computational camera: More parts programmable

 Programmable illumination: complex flash patterns  Programmable apertures, shutter, etc  Programmable image processing

 What’s possible?

slide-65
SLIDE 65

Tone Mapping, Color Correction on Camera

 Courtesy Fredo Durand MIT

slide-66
SLIDE 66

Depth from Image using programmable aperture

 Courtesy Bill Freeman, MIT

slide-67
SLIDE 67

ReFocus badly focussed Images

 Courtesy Fredo

Durand MIT

slide-68
SLIDE 68

Computational Photography

 What’s possible?

 Deblurring: Take out motion blur artifacts

slide-69
SLIDE 69

Computer Graphics CS/ECE 545 – Final Review Prof Emmanuel Agu

Computer Science Dept. Worcester Polytechnic Institute (WPI)

slide-70
SLIDE 70

Exam Overview

 Wednesday, April 30, 2014, in‐class  Midterm covered up to lecture 5 (Corner Detection)  Final covers lecture 6 till today’s class (lecture 11)  Can bring:  One page cheat‐sheet, hand‐written (not typed)  Calculator  Will test:  Theoretical concepts  Mathematics  Algorithms  Programming  ImageJ knowledge (program structure and some commands)

slide-71
SLIDE 71

What am I Really Testing?

 Understanding of

 concepts (NOT only programming)  programming (pseudocode/syntax)

 Test that:

 you can plug in numbers by hand to check your

programs

 you did the projects  you understand what you did in projects

slide-72
SLIDE 72

General Advise

 Read your projects and refresh memory of what you did  Read the slides: worst case – if you understand slides, you’re

more than 50% prepared

 Focus on Mathematical results, concepts, algorithms  Plug numbers: calculate by hand  Try to predict subtle changes to algorithm.. What ifs?..  Past exams: One sample final will be on website  All lectures have references. Look at refs to focus reading  Do all readings I asked you to do on your own

slide-73
SLIDE 73

Grading Policy

 I try to give as much partial credit as possible  In time constraints, laying out outline of solution

gets you healthy chunk of points

 Try to write something for each question  Many questions will be easy, exponentially harder to

score higher in exam

slide-74
SLIDE 74

Topics

 Curve Detection  Morphological Filters  Regions in Binary Images  Color Images  Introduction to Spectral Techniques  Discrete Fourier Transform  Geometrical Operations  Comparing Images  Future Directions

slide-75
SLIDE 75

References

 Wilhelm Burger and Mark J. Burge, Digital Image

Processing, Springer, 2008

 University of Utah, CS 4640: Image Processing Basics,

Spring 2012

 Rutgers University, CS 334, Introduction to Imaging

and Multimedia, Fall 2012

 Gonzales and Woods, Digital Image Processing (3rd

edition), Prentice Hall

 CS 376 Slides, Computer Vision, Fall 2011