image processing - tu dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfimage processing: filtering...

30
Image Processing Filtering Slide 1

Upload: others

Post on 31-May-2020

19 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing

Filtering

Slide 1

Page 2: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing: Filtering

Preliminary

Slide 2

Original Noise

Result

Image generation

Image restoration

Page 3: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing: Filtering

Preliminary

3

Classic application: denoising However:

Denoising is much more than a simple filtering Filtering can do many other things as well

Filtering is “a kind of image processing algorithms” (Almost) each filter is based on a model (assumptions)

Model = signal + noise

Usual pipeline:

Model → Formal task → Solution → Algorithm (program)

Page 4: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing: Filtering

Outline

4

1. Mean filter: Model → … → Solution 2. Median filter: Formal task → Solution 3. Some other filters (short) 4. Algorithms

Notations: the domain (grid), − Pixel Image is a mapping (color space) is the color of the pixel (at the position) Let be the “ideal” signal (original image, desired result …) is the nosed version The task: observe , compute

Page 5: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing: Filtering

Mean filter

5

Noise model: Gaussian probability distribution for color differences

Page 6: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing: Filtering

Mean filter

6

Further assumption: independent noise Let us try to formulate a task just now according to e.g. the Maximum-Likelihood principle (probability maximization): is a constant (drop it out), assume uniform prior the solution is trivial: for all additional assumptions about the signal are necessary !!!

Page 7: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing: Filtering

Mean filter

7

Assumption: in a small vicinity the “true” signal is nearly constant Maximum-Likelihood: take logarithm: Derive: (the average)

Page 8: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing: Filtering

Median filter

8

Corresponds to another noise model for simplicity let (gray-valued image) Another subject to optimize: Problem: not differentiable , good news: it is convex

The solution: median filter − order the values and take the middle one

Page 9: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing: Filtering

A bit comparison

9

Original Noised

Mean Median

Page 10: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing: Filtering

Another noise model (salt and pepper)

10

In a small amount of pixels the colors are corrupted uniformly

Original

Mean Median

Noised

Page 11: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing: Filtering

An application

11

The background smoothing improves spatial perception (Xue Bai, Guillermo Sapiro) btw. the reverse task is called shape from focus

Page 12: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing: Filtering

Linear filtering

12

Convolution With the mask (convolution kernel) (the mask is also an “image”) Example: mean filter if

otherwise

Page 13: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing: Filtering

Some other filters

13

Which other masks could be useful, for what ? A bit more delicate smoothing with the Gaussian kernel: Unsharp mask: Edge detectors and a lot of other things …

Original Unsharp Unsharp even more

Page 14: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing: Filtering

A “completely other” task

14

Salt and pepper noise for 90% of pixels Usual linear filtering has no chance an explicit modeling of the signal is necessary (MRF in the case above)

Page 15: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing: Filtering

Conclusion, further reading

15

• Explicit assumptions for the processed signal/noise − local filtering

• Description by auto-correlation function − Wiener filter

• Signal is a composition of different frequencies − Fourier analysis

• Description by partial differential equations − Variational methods

• Explicit modeling of statistic dependencies − Markov Random Fields

• Etc.

The properties of a particular problem (signal/noise model, a kind of the formal task to be solved etc.) are crucial.

Page 16: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing: Filtering

Linear Filtering − Algorithms

16

One-dimensional signal for simplicity, i.e. Example: mean filter: A naïve algorithm (according to the formula): Time complexity:

Page 17: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing: Filtering

Linear Filtering − Algorithms

17

A better Algorithm − Idea: If the “blue” sums are

pre-computed, only one summation per value are needed for output !!!

Page 18: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing: Filtering

Linear Filtering − Algorithms

18

It is indeed very simple to pre-compute quickly A better Algorithm: 1. Compute for all :

2. Compute :

Time complexity: − does not depend on the window size at all !!!

Page 19: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing: Filtering

Linear Filtering − “Integral Image”

19

Generalization to the 2D-case: 1. Compute for all :

2. Compute :

Time complexity: − does not depend on the window size at all !!!

Page 20: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing: Filtering

Convolutions

20

Properties: • Commutative:

• Associative

• Distributive with “+”

Page 21: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing: Filtering

Convolutions:

21

Identical convolution (unity): Inverse convolutions fulfill: Example: ( is marked bold): The trick is in fact: Consequence: is easy to compute (linear time complexity) is sparse (a constant number of non-zero elements)

− differential operator − integral operator

Page 22: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing: Filtering

A bit complicated example

22

Convolve efficiently with the mask (1D)

Page 23: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing: Filtering

A bit complicated example

23

Consider, how can be computed efficiently using .

Page 24: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing: Filtering

A bit complicated example

24

If is known, the next value could be computed in a constant time. However is nothing but a mean filter, i.e. it can be pre-computed in linear time as well ! The algorithm: 1. Compute the integral signal ; 2. Compute the mean filter ; 3. Compute the output from and .

All steps have the linear complexity → the overall time complexity is linear as well.

Page 25: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing: Filtering

A bit complicated example

25

Explain it by convolutions: – differential operator, – integral operator

Page 26: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing: Filtering

Separable filters

26

Assume that a mask (seen as a matrix) can be represented as outer product of two vectors, i.e. . Example: Gaussian smoothing A convolution is then with an “intermediate convolution” .

Page 27: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing: Filtering

Separable filters

27

If the filter mask is an outer product, the convolution kernel can be written as . In what follows: Let the convolution kernel be of the size . Direct convolution takes operations per pixel. Consecutive application takes only operations per pixel ! Gaussian, mean and many others are separable

Page 28: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing: Filtering

Some “interesting” tasks:

28

Let a convolution kernel be given. 1. Try to find its representation using differentiation and

integration in order to reduce the time complexity.

2. Try to approximate the mask by “the best possible” separable one.

3. Decompose the kernel into a sum of separable filters.

4. Try to represent the kernel as a convolution of sparse ones.

5. Consider combinations of 1. – 4. etc.

Page 29: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing: Filtering

The consecutive application of the mean filtering approximate the Gaussian smoothing (based on the Central Limit Theorem) Time complexity: with – the number of iterations (5-6 times is usually enough).

Box-Filter

29

Page 30: Image Processing - TU Dresdends24/lehre/bvme_ss_2013/ip_03_filter.pdfImage Processing: Filtering Conclusion, further reading 15 •Explicit assumptions for the processed signal/noise

Image Processing: Filtering

Conclusion

30

Use filtering with care and respect. Do not use filters without to know, what are they really doing, have in mind always the whole:

Model → Formal task → Solution → Algorithm (program) Today: 1. Mean filter: Model → … → Algorithm 2. Some other filters 3. Some examples 4. Algorithms, Convolutions, some further filtering tricks

Next lecture: 1. Morphologic operations