digital image processing - hci.iwr.uni-heidelberg.de · 1.image enhancement grey level...

21
Digital Image Processing Praktikum Introduction to Computer Vision

Upload: dinhhanh

Post on 13-Apr-2019

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Digital Image Processing - hci.iwr.uni-heidelberg.de · 1.Image enhancement Grey level transformations •Apply a transformation or function T(r) on every pixel r of the image separately

Digital Image ProcessingPraktikum Introduction to Computer Vision

Page 2: Digital Image Processing - hci.iwr.uni-heidelberg.de · 1.Image enhancement Grey level transformations •Apply a transformation or function T(r) on every pixel r of the image separately

1.Image enhancementGrey level transformations

• Apply a transformation or function T(r) on every pixel r of the image separately and update it with result value s.

© 2008 R. C. Gonzalez & R. E. Woods

Page 3: Digital Image Processing - hci.iwr.uni-heidelberg.de · 1.Image enhancement Grey level transformations •Apply a transformation or function T(r) on every pixel r of the image separately

1.Image enhancementGrey level transformations

• Common function: • Log function

• s = c.log(1+r)

• c : normalizing constant to keep the value [0-255]

• Has no parameter.

• Alternative form with parameters α :• s = c.log(1+(eα -1)r)

© 2008 R. C. Gonzalez & R. E. Woods

Page 4: Digital Image Processing - hci.iwr.uni-heidelberg.de · 1.Image enhancement Grey level transformations •Apply a transformation or function T(r) on every pixel r of the image separately

1.Image enhancementGrey level transformations

• Common function: • Power-law function

• s = c. rϒ

• c : normalizing constant to keep the value [0-255]

• One parameter ϒ (gamma)

© 2008 R. C. Gonzalez & R. E. Woods

Page 5: Digital Image Processing - hci.iwr.uni-heidelberg.de · 1.Image enhancement Grey level transformations •Apply a transformation or function T(r) on every pixel r of the image separately

• Contrast stretching.

• Intensity Slicing.

1.Image enhancementGrey level transformations

© 2008 R. C. Gonzalez & R. E. Woods

Page 6: Digital Image Processing - hci.iwr.uni-heidelberg.de · 1.Image enhancement Grey level transformations •Apply a transformation or function T(r) on every pixel r of the image separately

Exercise 1

• Create an OpenCV program that takes an image (spine.jpg for example) and applies a gray transformation • Log transformation (with parameter α).

• Power-law transformation (with parameter ϒ )

• Another transformation of your choice.

Page 7: Digital Image Processing - hci.iwr.uni-heidelberg.de · 1.Image enhancement Grey level transformations •Apply a transformation or function T(r) on every pixel r of the image separately

• A Histogram is a distribution of gray-level in an image.• It can be seen as Probability Distribution Function PDF of

a pixel value in the image.

1.Image enhancementHistogram Equalization

Page 8: Digital Image Processing - hci.iwr.uni-heidelberg.de · 1.Image enhancement Grey level transformations •Apply a transformation or function T(r) on every pixel r of the image separately

• Probability Density Function PDF

1.Image enhancementHistogram Equalization

© 2007 R. Alan Peters

Page 9: Digital Image Processing - hci.iwr.uni-heidelberg.de · 1.Image enhancement Grey level transformations •Apply a transformation or function T(r) on every pixel r of the image separately

• Cumulative Distribution Function CDF

1.Image enhancementHistogram Equalization

© 2007 R. Alan Peters

Page 10: Digital Image Processing - hci.iwr.uni-heidelberg.de · 1.Image enhancement Grey level transformations •Apply a transformation or function T(r) on every pixel r of the image separately

• Histogram equalization T(r) :

• Continues :

• Discrete :

1.Image enhancementHistogram Equalization

Page 11: Digital Image Processing - hci.iwr.uni-heidelberg.de · 1.Image enhancement Grey level transformations •Apply a transformation or function T(r) on every pixel r of the image separately

1.Image enhancementHistogram Equalization

© 2007 R. Alan Peters

Page 12: Digital Image Processing - hci.iwr.uni-heidelberg.de · 1.Image enhancement Grey level transformations •Apply a transformation or function T(r) on every pixel r of the image separately

1.Image enhancementHistogram Equalization

© 2007 R. Alan Peters

Page 13: Digital Image Processing - hci.iwr.uni-heidelberg.de · 1.Image enhancement Grey level transformations •Apply a transformation or function T(r) on every pixel r of the image separately

1.Image enhancementHistogram Equalization

© 2007 R. Alan Peters

Page 14: Digital Image Processing - hci.iwr.uni-heidelberg.de · 1.Image enhancement Grey level transformations •Apply a transformation or function T(r) on every pixel r of the image separately

Exercise 02-a

• Open the image spine.jpg and plot its histogram and CDF.

• Apply histogram equalization using OpenCV and show the result.

• Implement Histogram matching and then use it to match the histogram of this image to another image of your choice with a nice histogram.

Page 15: Digital Image Processing - hci.iwr.uni-heidelberg.de · 1.Image enhancement Grey level transformations •Apply a transformation or function T(r) on every pixel r of the image separately

Exercise 02-b

• Open the image rocks.jpg and plot the histogram and CDF of each color channel.

• Apply histogram equalization using OpenCV on each color channel separately and then combine them and show the result image.

• A smarter way to do color image histogram equalization : take the average of the 3 histograms of color channel. Then use histogram matching to match each color channel to the average histogram you computed. Combine the channels and show the result. Compare it to the previous result.

Page 16: Digital Image Processing - hci.iwr.uni-heidelberg.de · 1.Image enhancement Grey level transformations •Apply a transformation or function T(r) on every pixel r of the image separately

Image Filtering

• Convolution with filter kernels

Page 17: Digital Image Processing - hci.iwr.uni-heidelberg.de · 1.Image enhancement Grey level transformations •Apply a transformation or function T(r) on every pixel r of the image separately

Image Filtering

• Convolution with filter kernels

Page 18: Digital Image Processing - hci.iwr.uni-heidelberg.de · 1.Image enhancement Grey level transformations •Apply a transformation or function T(r) on every pixel r of the image separately

Unsharp Mask

Page 19: Digital Image Processing - hci.iwr.uni-heidelberg.de · 1.Image enhancement Grey level transformations •Apply a transformation or function T(r) on every pixel r of the image separately

Exercise 3

• unsharp masking Kernel• Give a 3 × 3 mask for performing unsharp masking in a

single pass through an image. Demostrate it works with an example.

• Threshold median filter :• A threshold operation is applied to the median filter

such that the filter is only activated if the data within the filter window contain a grayscale level above some threshold value.

Page 20: Digital Image Processing - hci.iwr.uni-heidelberg.de · 1.Image enhancement Grey level transformations •Apply a transformation or function T(r) on every pixel r of the image separately

Correlation

• Cross correlation between two images :

Page 21: Digital Image Processing - hci.iwr.uni-heidelberg.de · 1.Image enhancement Grey level transformations •Apply a transformation or function T(r) on every pixel r of the image separately

Exercise 04: find my dog

• Write an openCV function that computes the correlation between a template image and every patch of same size in the target image.

• Use this to find the location of the patch (dog.jpg) in the image (findMyDog.jpg).

• Don’t use the built in openCV functions for template matching (even though you can look at the tutorials to see how they are used).