Top Banner
DTU Compute Introduction to Medical Image Analysis Plenty of slides adapted from Thomas Moeslunds lectures Rasmus R. Paulsen DTU Compute [email protected] http://www.compute.dtu.dk/courses/02511 http://www.compute.dtu.dk/courses/02512
76

Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Sep 16, 2018

Download

Documents

nguyendan
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

Introduction to Medical Image Analysis

Plenty of slides adapted from Thomas Moeslunds lectures

Rasmus R PaulsenDTU Compute

rapadtudk

httpwwwcomputedtudkcourses02511httpwwwcomputedtudkcourses02512

DTU Compute

2122018Introduction to Medical Image Analysis2 DTU Compute Technical University of Denmark

Lecture 4 ndash Neighbourhood Processing

800 ndash 900 Exercises900 ndash 11ish Lecture

11ish - Exercises

1200 ndash 1300 Lunch break

1300 - Exercises

DTU Compute

2122018Introduction to Medical Image Analysis3 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis4 DTU Compute Technical University of Denmark

Point processing

0 2

1 2

1 2 1

2 5 3

1 3

2 2

0 1

1 2 0

2 1 4

1 0 19

12

Input Output

bull The value of the output pixel is only dependent on the value of one input pixel

bull A global operation ndash changes all pixels

DTU Compute

2122018Introduction to Medical Image Analysis5 DTU Compute Technical University of Denmark

Point processing Grey level enhancement

ndash Process one pixel at a time independent of all other pixelsndash For example used to correct Brightness and Contrast

Too lowcontrastCorrect

Too highcontrast

Too high brightness

Too low brightness

DTU Compute

2122018Introduction to Medical Image Analysis6 DTU Compute Technical University of Denmark

Neighbourhood processing

0 2

1 2

1 2 1

2 5 3

1 3

2 2

0 1

1 2 0

2 1 4

1 0 19

12

Input Output

bull Several pixels in the input has an effect on the output

DTU Compute

2122018Introduction to Medical Image Analysis7 DTU Compute Technical University of Denmark

Use of filtering

Noise removal Enhance edges Smoothing

bull Image processing

bull Typically done before actual image analysis

DTU Compute

2122018Introduction to Medical Image Analysis8 DTU Compute Technical University of Denmark

Salt and pepper noise Pixel values that are very

different from their neighbours

Very bright or very dark spots

Scratches in X-rays

What is that

DTU Compute

2122018Introduction to Medical Image Analysis9 DTU Compute Technical University of Denmark

Salt and pepper noise Fake example

ndash Let us take a closer look at noise pixels

They are all 0 or 255

Should we just remove all the 0rsquos and 255rsquos from the image

DTU Compute

2122018Introduction to Medical Image Analysis10 DTU Compute Technical University of Denmark

What is so special about noise What is the value of the pixel

compared to the neighbours Average of the neighbours

ndash 170 Can we compare to the

averagendash Difficult ndash should we remove

all values bigger than average+1

It is difficult to detect noise

172 169 171 168 0 169 172 173 168

DTU Compute

2122018Introduction to Medical Image Analysis11 DTU Compute Technical University of Denmark

Noise ndash go away We can not tell what pixels

are noise One solution

ndash Set all pixels to the average of the neighbours (and the pixel itself)

Oh nondash Problemsndash The noise ldquopollutesrdquo the

good pixels

172 169 171 168 0 169 172 173 168

170

169 168 0 170 172173 170 172 170

149

DTU Compute

2122018Introduction to Medical Image Analysis12 DTU Compute Technical University of Denmark

What is the median ValueA) 170B) 173C) 169D) 171E) 172

13

0 0 02

A B C D E

169 168 0 170172 173 170 172 170

Chart1

13
0
0
0
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis13 DTU Compute Technical University of Denmark

The median value The values are sorted from low to high The middle number is picked

ndash The median value

169 168 0 170172 173 170 172 170

0168 169 170 170 170172 172173

Median

Noise has no influence on the median

DTU Compute

2122018Introduction to Medical Image Analysis14 DTU Compute Technical University of Denmark

Noise away ndash the median filter All pixels are set to the

median of its neighbourhood Noise pixels do not pollute

good pixels

172 169 171 168 0 169 172 173 168

170

169 168 0 170 172173 170 172 170

170

DTU Compute

2122018Introduction to Medical Image Analysis15 DTU Compute Technical University of Denmark

Noise removal ndash average filter

Scanned X-ray with salt and pepper noise

Average filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis16 DTU Compute Technical University of Denmark

Noise removal ndash median filter

Scanned X-ray with salt and pepper noise

Median filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis17 DTU Compute Technical University of Denmark

Image Filtering Creates a new filtered image Output pixel is computed based

on a neighbourhood in the input image

3 x 3 neighbourhoodndash Filter size 3 x 3ndash Kernel size 3 x 3ndash Mask size 3 x 3

Larger filters often usedndash Size

7 x 7ndash Number of elements

49

DTU Compute

2122018Introduction to Medical Image Analysis18 DTU Compute Technical University of Denmark

Median filterA) 25B) 90C) 198D) 86E) 103

0

13

1 0 0

A B C D E

Chart1

0
13
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis20 DTU Compute Technical University of Denmark

Rank filters Based on sorting the pixel

values in the neighbouring region

Minimum rank filterndash Darker image Noise problems

Maximum rank filterndash Lighter image Noise problems

Difference filterndash Enhances changes (edges)

0168 169 170 170 170172 172173

-

DTU Compute

2122018Introduction to Medical Image Analysis21 DTU Compute Technical University of Denmark

Median filter

A) 3B) 84C) 112D) 73E) 202

0

12

10 0

A B C D E

Chart1

0
12
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis23 DTU Compute Technical University of Denmark

Correlation What is it Two measurements

ndash Low correlationndash High correlation

High correlation means that there is a relation between the values

They look the same Correlation is a measure of

similarity

Low

High

Muscles

Mat

h Ski

lls

Muscles

Ben

ch P

ress

DTU Compute

2122018Introduction to Medical Image Analysis24 DTU Compute Technical University of Denmark

Why do we need similarity Image analysis is also about recognition of patterns Often an example pattern is used We need something to tell us if there is a high match

between our pattern and a part of the image

Example pattern

Image

Find matches

DTU Compute

2122018Introduction to Medical Image Analysis25 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise

Kernel

Signal (1D image)

41

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
A 0
B 12
C 1
D 0
E 0
A
B
C
D
E
A 0
B 13
C 1
D 0
E 0
A
B
C
D
E
A 13
B 0
C 0
D 0
E 2
A
B
C
D
E
Page 2: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis2 DTU Compute Technical University of Denmark

Lecture 4 ndash Neighbourhood Processing

800 ndash 900 Exercises900 ndash 11ish Lecture

11ish - Exercises

1200 ndash 1300 Lunch break

1300 - Exercises

DTU Compute

2122018Introduction to Medical Image Analysis3 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis4 DTU Compute Technical University of Denmark

Point processing

0 2

1 2

1 2 1

2 5 3

1 3

2 2

0 1

1 2 0

2 1 4

1 0 19

12

Input Output

bull The value of the output pixel is only dependent on the value of one input pixel

bull A global operation ndash changes all pixels

DTU Compute

2122018Introduction to Medical Image Analysis5 DTU Compute Technical University of Denmark

Point processing Grey level enhancement

ndash Process one pixel at a time independent of all other pixelsndash For example used to correct Brightness and Contrast

Too lowcontrastCorrect

Too highcontrast

Too high brightness

Too low brightness

DTU Compute

2122018Introduction to Medical Image Analysis6 DTU Compute Technical University of Denmark

Neighbourhood processing

0 2

1 2

1 2 1

2 5 3

1 3

2 2

0 1

1 2 0

2 1 4

1 0 19

12

Input Output

bull Several pixels in the input has an effect on the output

DTU Compute

2122018Introduction to Medical Image Analysis7 DTU Compute Technical University of Denmark

Use of filtering

Noise removal Enhance edges Smoothing

bull Image processing

bull Typically done before actual image analysis

DTU Compute

2122018Introduction to Medical Image Analysis8 DTU Compute Technical University of Denmark

Salt and pepper noise Pixel values that are very

different from their neighbours

Very bright or very dark spots

Scratches in X-rays

What is that

DTU Compute

2122018Introduction to Medical Image Analysis9 DTU Compute Technical University of Denmark

Salt and pepper noise Fake example

ndash Let us take a closer look at noise pixels

They are all 0 or 255

Should we just remove all the 0rsquos and 255rsquos from the image

DTU Compute

2122018Introduction to Medical Image Analysis10 DTU Compute Technical University of Denmark

What is so special about noise What is the value of the pixel

compared to the neighbours Average of the neighbours

ndash 170 Can we compare to the

averagendash Difficult ndash should we remove

all values bigger than average+1

It is difficult to detect noise

172 169 171 168 0 169 172 173 168

DTU Compute

2122018Introduction to Medical Image Analysis11 DTU Compute Technical University of Denmark

Noise ndash go away We can not tell what pixels

are noise One solution

ndash Set all pixels to the average of the neighbours (and the pixel itself)

Oh nondash Problemsndash The noise ldquopollutesrdquo the

good pixels

172 169 171 168 0 169 172 173 168

170

169 168 0 170 172173 170 172 170

149

DTU Compute

2122018Introduction to Medical Image Analysis12 DTU Compute Technical University of Denmark

What is the median ValueA) 170B) 173C) 169D) 171E) 172

13

0 0 02

A B C D E

169 168 0 170172 173 170 172 170

Chart1

13
0
0
0
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis13 DTU Compute Technical University of Denmark

The median value The values are sorted from low to high The middle number is picked

ndash The median value

169 168 0 170172 173 170 172 170

0168 169 170 170 170172 172173

Median

Noise has no influence on the median

DTU Compute

2122018Introduction to Medical Image Analysis14 DTU Compute Technical University of Denmark

Noise away ndash the median filter All pixels are set to the

median of its neighbourhood Noise pixels do not pollute

good pixels

172 169 171 168 0 169 172 173 168

170

169 168 0 170 172173 170 172 170

170

DTU Compute

2122018Introduction to Medical Image Analysis15 DTU Compute Technical University of Denmark

Noise removal ndash average filter

Scanned X-ray with salt and pepper noise

Average filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis16 DTU Compute Technical University of Denmark

Noise removal ndash median filter

Scanned X-ray with salt and pepper noise

Median filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis17 DTU Compute Technical University of Denmark

Image Filtering Creates a new filtered image Output pixel is computed based

on a neighbourhood in the input image

3 x 3 neighbourhoodndash Filter size 3 x 3ndash Kernel size 3 x 3ndash Mask size 3 x 3

Larger filters often usedndash Size

7 x 7ndash Number of elements

49

DTU Compute

2122018Introduction to Medical Image Analysis18 DTU Compute Technical University of Denmark

Median filterA) 25B) 90C) 198D) 86E) 103

0

13

1 0 0

A B C D E

Chart1

0
13
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis20 DTU Compute Technical University of Denmark

Rank filters Based on sorting the pixel

values in the neighbouring region

Minimum rank filterndash Darker image Noise problems

Maximum rank filterndash Lighter image Noise problems

Difference filterndash Enhances changes (edges)

0168 169 170 170 170172 172173

-

DTU Compute

2122018Introduction to Medical Image Analysis21 DTU Compute Technical University of Denmark

Median filter

A) 3B) 84C) 112D) 73E) 202

0

12

10 0

A B C D E

Chart1

0
12
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis23 DTU Compute Technical University of Denmark

Correlation What is it Two measurements

ndash Low correlationndash High correlation

High correlation means that there is a relation between the values

They look the same Correlation is a measure of

similarity

Low

High

Muscles

Mat

h Ski

lls

Muscles

Ben

ch P

ress

DTU Compute

2122018Introduction to Medical Image Analysis24 DTU Compute Technical University of Denmark

Why do we need similarity Image analysis is also about recognition of patterns Often an example pattern is used We need something to tell us if there is a high match

between our pattern and a part of the image

Example pattern

Image

Find matches

DTU Compute

2122018Introduction to Medical Image Analysis25 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise

Kernel

Signal (1D image)

41

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
A 0
B 12
C 1
D 0
E 0
A
B
C
D
E
A 0
B 13
C 1
D 0
E 0
A
B
C
D
E
A 13
B 0
C 0
D 0
E 2
A
B
C
D
E
Page 3: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis3 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis4 DTU Compute Technical University of Denmark

Point processing

0 2

1 2

1 2 1

2 5 3

1 3

2 2

0 1

1 2 0

2 1 4

1 0 19

12

Input Output

bull The value of the output pixel is only dependent on the value of one input pixel

bull A global operation ndash changes all pixels

DTU Compute

2122018Introduction to Medical Image Analysis5 DTU Compute Technical University of Denmark

Point processing Grey level enhancement

ndash Process one pixel at a time independent of all other pixelsndash For example used to correct Brightness and Contrast

Too lowcontrastCorrect

Too highcontrast

Too high brightness

Too low brightness

DTU Compute

2122018Introduction to Medical Image Analysis6 DTU Compute Technical University of Denmark

Neighbourhood processing

0 2

1 2

1 2 1

2 5 3

1 3

2 2

0 1

1 2 0

2 1 4

1 0 19

12

Input Output

bull Several pixels in the input has an effect on the output

DTU Compute

2122018Introduction to Medical Image Analysis7 DTU Compute Technical University of Denmark

Use of filtering

Noise removal Enhance edges Smoothing

bull Image processing

bull Typically done before actual image analysis

DTU Compute

2122018Introduction to Medical Image Analysis8 DTU Compute Technical University of Denmark

Salt and pepper noise Pixel values that are very

different from their neighbours

Very bright or very dark spots

Scratches in X-rays

What is that

DTU Compute

2122018Introduction to Medical Image Analysis9 DTU Compute Technical University of Denmark

Salt and pepper noise Fake example

ndash Let us take a closer look at noise pixels

They are all 0 or 255

Should we just remove all the 0rsquos and 255rsquos from the image

DTU Compute

2122018Introduction to Medical Image Analysis10 DTU Compute Technical University of Denmark

What is so special about noise What is the value of the pixel

compared to the neighbours Average of the neighbours

ndash 170 Can we compare to the

averagendash Difficult ndash should we remove

all values bigger than average+1

It is difficult to detect noise

172 169 171 168 0 169 172 173 168

DTU Compute

2122018Introduction to Medical Image Analysis11 DTU Compute Technical University of Denmark

Noise ndash go away We can not tell what pixels

are noise One solution

ndash Set all pixels to the average of the neighbours (and the pixel itself)

Oh nondash Problemsndash The noise ldquopollutesrdquo the

good pixels

172 169 171 168 0 169 172 173 168

170

169 168 0 170 172173 170 172 170

149

DTU Compute

2122018Introduction to Medical Image Analysis12 DTU Compute Technical University of Denmark

What is the median ValueA) 170B) 173C) 169D) 171E) 172

13

0 0 02

A B C D E

169 168 0 170172 173 170 172 170

Chart1

13
0
0
0
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis13 DTU Compute Technical University of Denmark

The median value The values are sorted from low to high The middle number is picked

ndash The median value

169 168 0 170172 173 170 172 170

0168 169 170 170 170172 172173

Median

Noise has no influence on the median

DTU Compute

2122018Introduction to Medical Image Analysis14 DTU Compute Technical University of Denmark

Noise away ndash the median filter All pixels are set to the

median of its neighbourhood Noise pixels do not pollute

good pixels

172 169 171 168 0 169 172 173 168

170

169 168 0 170 172173 170 172 170

170

DTU Compute

2122018Introduction to Medical Image Analysis15 DTU Compute Technical University of Denmark

Noise removal ndash average filter

Scanned X-ray with salt and pepper noise

Average filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis16 DTU Compute Technical University of Denmark

Noise removal ndash median filter

Scanned X-ray with salt and pepper noise

Median filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis17 DTU Compute Technical University of Denmark

Image Filtering Creates a new filtered image Output pixel is computed based

on a neighbourhood in the input image

3 x 3 neighbourhoodndash Filter size 3 x 3ndash Kernel size 3 x 3ndash Mask size 3 x 3

Larger filters often usedndash Size

7 x 7ndash Number of elements

49

DTU Compute

2122018Introduction to Medical Image Analysis18 DTU Compute Technical University of Denmark

Median filterA) 25B) 90C) 198D) 86E) 103

0

13

1 0 0

A B C D E

Chart1

0
13
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis20 DTU Compute Technical University of Denmark

Rank filters Based on sorting the pixel

values in the neighbouring region

Minimum rank filterndash Darker image Noise problems

Maximum rank filterndash Lighter image Noise problems

Difference filterndash Enhances changes (edges)

0168 169 170 170 170172 172173

-

DTU Compute

2122018Introduction to Medical Image Analysis21 DTU Compute Technical University of Denmark

Median filter

A) 3B) 84C) 112D) 73E) 202

0

12

10 0

A B C D E

Chart1

0
12
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis23 DTU Compute Technical University of Denmark

Correlation What is it Two measurements

ndash Low correlationndash High correlation

High correlation means that there is a relation between the values

They look the same Correlation is a measure of

similarity

Low

High

Muscles

Mat

h Ski

lls

Muscles

Ben

ch P

ress

DTU Compute

2122018Introduction to Medical Image Analysis24 DTU Compute Technical University of Denmark

Why do we need similarity Image analysis is also about recognition of patterns Often an example pattern is used We need something to tell us if there is a high match

between our pattern and a part of the image

Example pattern

Image

Find matches

DTU Compute

2122018Introduction to Medical Image Analysis25 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise

Kernel

Signal (1D image)

41

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
A 0
B 12
C 1
D 0
E 0
A
B
C
D
E
A 0
B 13
C 1
D 0
E 0
A
B
C
D
E
A 13
B 0
C 0
D 0
E 2
A
B
C
D
E
Page 4: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis4 DTU Compute Technical University of Denmark

Point processing

0 2

1 2

1 2 1

2 5 3

1 3

2 2

0 1

1 2 0

2 1 4

1 0 19

12

Input Output

bull The value of the output pixel is only dependent on the value of one input pixel

bull A global operation ndash changes all pixels

DTU Compute

2122018Introduction to Medical Image Analysis5 DTU Compute Technical University of Denmark

Point processing Grey level enhancement

ndash Process one pixel at a time independent of all other pixelsndash For example used to correct Brightness and Contrast

Too lowcontrastCorrect

Too highcontrast

Too high brightness

Too low brightness

DTU Compute

2122018Introduction to Medical Image Analysis6 DTU Compute Technical University of Denmark

Neighbourhood processing

0 2

1 2

1 2 1

2 5 3

1 3

2 2

0 1

1 2 0

2 1 4

1 0 19

12

Input Output

bull Several pixels in the input has an effect on the output

DTU Compute

2122018Introduction to Medical Image Analysis7 DTU Compute Technical University of Denmark

Use of filtering

Noise removal Enhance edges Smoothing

bull Image processing

bull Typically done before actual image analysis

DTU Compute

2122018Introduction to Medical Image Analysis8 DTU Compute Technical University of Denmark

Salt and pepper noise Pixel values that are very

different from their neighbours

Very bright or very dark spots

Scratches in X-rays

What is that

DTU Compute

2122018Introduction to Medical Image Analysis9 DTU Compute Technical University of Denmark

Salt and pepper noise Fake example

ndash Let us take a closer look at noise pixels

They are all 0 or 255

Should we just remove all the 0rsquos and 255rsquos from the image

DTU Compute

2122018Introduction to Medical Image Analysis10 DTU Compute Technical University of Denmark

What is so special about noise What is the value of the pixel

compared to the neighbours Average of the neighbours

ndash 170 Can we compare to the

averagendash Difficult ndash should we remove

all values bigger than average+1

It is difficult to detect noise

172 169 171 168 0 169 172 173 168

DTU Compute

2122018Introduction to Medical Image Analysis11 DTU Compute Technical University of Denmark

Noise ndash go away We can not tell what pixels

are noise One solution

ndash Set all pixels to the average of the neighbours (and the pixel itself)

Oh nondash Problemsndash The noise ldquopollutesrdquo the

good pixels

172 169 171 168 0 169 172 173 168

170

169 168 0 170 172173 170 172 170

149

DTU Compute

2122018Introduction to Medical Image Analysis12 DTU Compute Technical University of Denmark

What is the median ValueA) 170B) 173C) 169D) 171E) 172

13

0 0 02

A B C D E

169 168 0 170172 173 170 172 170

Chart1

13
0
0
0
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis13 DTU Compute Technical University of Denmark

The median value The values are sorted from low to high The middle number is picked

ndash The median value

169 168 0 170172 173 170 172 170

0168 169 170 170 170172 172173

Median

Noise has no influence on the median

DTU Compute

2122018Introduction to Medical Image Analysis14 DTU Compute Technical University of Denmark

Noise away ndash the median filter All pixels are set to the

median of its neighbourhood Noise pixels do not pollute

good pixels

172 169 171 168 0 169 172 173 168

170

169 168 0 170 172173 170 172 170

170

DTU Compute

2122018Introduction to Medical Image Analysis15 DTU Compute Technical University of Denmark

Noise removal ndash average filter

Scanned X-ray with salt and pepper noise

Average filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis16 DTU Compute Technical University of Denmark

Noise removal ndash median filter

Scanned X-ray with salt and pepper noise

Median filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis17 DTU Compute Technical University of Denmark

Image Filtering Creates a new filtered image Output pixel is computed based

on a neighbourhood in the input image

3 x 3 neighbourhoodndash Filter size 3 x 3ndash Kernel size 3 x 3ndash Mask size 3 x 3

Larger filters often usedndash Size

7 x 7ndash Number of elements

49

DTU Compute

2122018Introduction to Medical Image Analysis18 DTU Compute Technical University of Denmark

Median filterA) 25B) 90C) 198D) 86E) 103

0

13

1 0 0

A B C D E

Chart1

0
13
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis20 DTU Compute Technical University of Denmark

Rank filters Based on sorting the pixel

values in the neighbouring region

Minimum rank filterndash Darker image Noise problems

Maximum rank filterndash Lighter image Noise problems

Difference filterndash Enhances changes (edges)

0168 169 170 170 170172 172173

-

DTU Compute

2122018Introduction to Medical Image Analysis21 DTU Compute Technical University of Denmark

Median filter

A) 3B) 84C) 112D) 73E) 202

0

12

10 0

A B C D E

Chart1

0
12
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis23 DTU Compute Technical University of Denmark

Correlation What is it Two measurements

ndash Low correlationndash High correlation

High correlation means that there is a relation between the values

They look the same Correlation is a measure of

similarity

Low

High

Muscles

Mat

h Ski

lls

Muscles

Ben

ch P

ress

DTU Compute

2122018Introduction to Medical Image Analysis24 DTU Compute Technical University of Denmark

Why do we need similarity Image analysis is also about recognition of patterns Often an example pattern is used We need something to tell us if there is a high match

between our pattern and a part of the image

Example pattern

Image

Find matches

DTU Compute

2122018Introduction to Medical Image Analysis25 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise

Kernel

Signal (1D image)

41

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
A 0
B 12
C 1
D 0
E 0
A
B
C
D
E
A 0
B 13
C 1
D 0
E 0
A
B
C
D
E
A 13
B 0
C 0
D 0
E 2
A
B
C
D
E
Page 5: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis5 DTU Compute Technical University of Denmark

Point processing Grey level enhancement

ndash Process one pixel at a time independent of all other pixelsndash For example used to correct Brightness and Contrast

Too lowcontrastCorrect

Too highcontrast

Too high brightness

Too low brightness

DTU Compute

2122018Introduction to Medical Image Analysis6 DTU Compute Technical University of Denmark

Neighbourhood processing

0 2

1 2

1 2 1

2 5 3

1 3

2 2

0 1

1 2 0

2 1 4

1 0 19

12

Input Output

bull Several pixels in the input has an effect on the output

DTU Compute

2122018Introduction to Medical Image Analysis7 DTU Compute Technical University of Denmark

Use of filtering

Noise removal Enhance edges Smoothing

bull Image processing

bull Typically done before actual image analysis

DTU Compute

2122018Introduction to Medical Image Analysis8 DTU Compute Technical University of Denmark

Salt and pepper noise Pixel values that are very

different from their neighbours

Very bright or very dark spots

Scratches in X-rays

What is that

DTU Compute

2122018Introduction to Medical Image Analysis9 DTU Compute Technical University of Denmark

Salt and pepper noise Fake example

ndash Let us take a closer look at noise pixels

They are all 0 or 255

Should we just remove all the 0rsquos and 255rsquos from the image

DTU Compute

2122018Introduction to Medical Image Analysis10 DTU Compute Technical University of Denmark

What is so special about noise What is the value of the pixel

compared to the neighbours Average of the neighbours

ndash 170 Can we compare to the

averagendash Difficult ndash should we remove

all values bigger than average+1

It is difficult to detect noise

172 169 171 168 0 169 172 173 168

DTU Compute

2122018Introduction to Medical Image Analysis11 DTU Compute Technical University of Denmark

Noise ndash go away We can not tell what pixels

are noise One solution

ndash Set all pixels to the average of the neighbours (and the pixel itself)

Oh nondash Problemsndash The noise ldquopollutesrdquo the

good pixels

172 169 171 168 0 169 172 173 168

170

169 168 0 170 172173 170 172 170

149

DTU Compute

2122018Introduction to Medical Image Analysis12 DTU Compute Technical University of Denmark

What is the median ValueA) 170B) 173C) 169D) 171E) 172

13

0 0 02

A B C D E

169 168 0 170172 173 170 172 170

Chart1

13
0
0
0
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis13 DTU Compute Technical University of Denmark

The median value The values are sorted from low to high The middle number is picked

ndash The median value

169 168 0 170172 173 170 172 170

0168 169 170 170 170172 172173

Median

Noise has no influence on the median

DTU Compute

2122018Introduction to Medical Image Analysis14 DTU Compute Technical University of Denmark

Noise away ndash the median filter All pixels are set to the

median of its neighbourhood Noise pixels do not pollute

good pixels

172 169 171 168 0 169 172 173 168

170

169 168 0 170 172173 170 172 170

170

DTU Compute

2122018Introduction to Medical Image Analysis15 DTU Compute Technical University of Denmark

Noise removal ndash average filter

Scanned X-ray with salt and pepper noise

Average filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis16 DTU Compute Technical University of Denmark

Noise removal ndash median filter

Scanned X-ray with salt and pepper noise

Median filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis17 DTU Compute Technical University of Denmark

Image Filtering Creates a new filtered image Output pixel is computed based

on a neighbourhood in the input image

3 x 3 neighbourhoodndash Filter size 3 x 3ndash Kernel size 3 x 3ndash Mask size 3 x 3

Larger filters often usedndash Size

7 x 7ndash Number of elements

49

DTU Compute

2122018Introduction to Medical Image Analysis18 DTU Compute Technical University of Denmark

Median filterA) 25B) 90C) 198D) 86E) 103

0

13

1 0 0

A B C D E

Chart1

0
13
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis20 DTU Compute Technical University of Denmark

Rank filters Based on sorting the pixel

values in the neighbouring region

Minimum rank filterndash Darker image Noise problems

Maximum rank filterndash Lighter image Noise problems

Difference filterndash Enhances changes (edges)

0168 169 170 170 170172 172173

-

DTU Compute

2122018Introduction to Medical Image Analysis21 DTU Compute Technical University of Denmark

Median filter

A) 3B) 84C) 112D) 73E) 202

0

12

10 0

A B C D E

Chart1

0
12
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis23 DTU Compute Technical University of Denmark

Correlation What is it Two measurements

ndash Low correlationndash High correlation

High correlation means that there is a relation between the values

They look the same Correlation is a measure of

similarity

Low

High

Muscles

Mat

h Ski

lls

Muscles

Ben

ch P

ress

DTU Compute

2122018Introduction to Medical Image Analysis24 DTU Compute Technical University of Denmark

Why do we need similarity Image analysis is also about recognition of patterns Often an example pattern is used We need something to tell us if there is a high match

between our pattern and a part of the image

Example pattern

Image

Find matches

DTU Compute

2122018Introduction to Medical Image Analysis25 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise

Kernel

Signal (1D image)

41

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
A 0
B 12
C 1
D 0
E 0
A
B
C
D
E
A 0
B 13
C 1
D 0
E 0
A
B
C
D
E
A 13
B 0
C 0
D 0
E 2
A
B
C
D
E
Page 6: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis6 DTU Compute Technical University of Denmark

Neighbourhood processing

0 2

1 2

1 2 1

2 5 3

1 3

2 2

0 1

1 2 0

2 1 4

1 0 19

12

Input Output

bull Several pixels in the input has an effect on the output

DTU Compute

2122018Introduction to Medical Image Analysis7 DTU Compute Technical University of Denmark

Use of filtering

Noise removal Enhance edges Smoothing

bull Image processing

bull Typically done before actual image analysis

DTU Compute

2122018Introduction to Medical Image Analysis8 DTU Compute Technical University of Denmark

Salt and pepper noise Pixel values that are very

different from their neighbours

Very bright or very dark spots

Scratches in X-rays

What is that

DTU Compute

2122018Introduction to Medical Image Analysis9 DTU Compute Technical University of Denmark

Salt and pepper noise Fake example

ndash Let us take a closer look at noise pixels

They are all 0 or 255

Should we just remove all the 0rsquos and 255rsquos from the image

DTU Compute

2122018Introduction to Medical Image Analysis10 DTU Compute Technical University of Denmark

What is so special about noise What is the value of the pixel

compared to the neighbours Average of the neighbours

ndash 170 Can we compare to the

averagendash Difficult ndash should we remove

all values bigger than average+1

It is difficult to detect noise

172 169 171 168 0 169 172 173 168

DTU Compute

2122018Introduction to Medical Image Analysis11 DTU Compute Technical University of Denmark

Noise ndash go away We can not tell what pixels

are noise One solution

ndash Set all pixels to the average of the neighbours (and the pixel itself)

Oh nondash Problemsndash The noise ldquopollutesrdquo the

good pixels

172 169 171 168 0 169 172 173 168

170

169 168 0 170 172173 170 172 170

149

DTU Compute

2122018Introduction to Medical Image Analysis12 DTU Compute Technical University of Denmark

What is the median ValueA) 170B) 173C) 169D) 171E) 172

13

0 0 02

A B C D E

169 168 0 170172 173 170 172 170

Chart1

13
0
0
0
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis13 DTU Compute Technical University of Denmark

The median value The values are sorted from low to high The middle number is picked

ndash The median value

169 168 0 170172 173 170 172 170

0168 169 170 170 170172 172173

Median

Noise has no influence on the median

DTU Compute

2122018Introduction to Medical Image Analysis14 DTU Compute Technical University of Denmark

Noise away ndash the median filter All pixels are set to the

median of its neighbourhood Noise pixels do not pollute

good pixels

172 169 171 168 0 169 172 173 168

170

169 168 0 170 172173 170 172 170

170

DTU Compute

2122018Introduction to Medical Image Analysis15 DTU Compute Technical University of Denmark

Noise removal ndash average filter

Scanned X-ray with salt and pepper noise

Average filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis16 DTU Compute Technical University of Denmark

Noise removal ndash median filter

Scanned X-ray with salt and pepper noise

Median filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis17 DTU Compute Technical University of Denmark

Image Filtering Creates a new filtered image Output pixel is computed based

on a neighbourhood in the input image

3 x 3 neighbourhoodndash Filter size 3 x 3ndash Kernel size 3 x 3ndash Mask size 3 x 3

Larger filters often usedndash Size

7 x 7ndash Number of elements

49

DTU Compute

2122018Introduction to Medical Image Analysis18 DTU Compute Technical University of Denmark

Median filterA) 25B) 90C) 198D) 86E) 103

0

13

1 0 0

A B C D E

Chart1

0
13
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis20 DTU Compute Technical University of Denmark

Rank filters Based on sorting the pixel

values in the neighbouring region

Minimum rank filterndash Darker image Noise problems

Maximum rank filterndash Lighter image Noise problems

Difference filterndash Enhances changes (edges)

0168 169 170 170 170172 172173

-

DTU Compute

2122018Introduction to Medical Image Analysis21 DTU Compute Technical University of Denmark

Median filter

A) 3B) 84C) 112D) 73E) 202

0

12

10 0

A B C D E

Chart1

0
12
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis23 DTU Compute Technical University of Denmark

Correlation What is it Two measurements

ndash Low correlationndash High correlation

High correlation means that there is a relation between the values

They look the same Correlation is a measure of

similarity

Low

High

Muscles

Mat

h Ski

lls

Muscles

Ben

ch P

ress

DTU Compute

2122018Introduction to Medical Image Analysis24 DTU Compute Technical University of Denmark

Why do we need similarity Image analysis is also about recognition of patterns Often an example pattern is used We need something to tell us if there is a high match

between our pattern and a part of the image

Example pattern

Image

Find matches

DTU Compute

2122018Introduction to Medical Image Analysis25 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise

Kernel

Signal (1D image)

41

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
A 0
B 12
C 1
D 0
E 0
A
B
C
D
E
A 0
B 13
C 1
D 0
E 0
A
B
C
D
E
A 13
B 0
C 0
D 0
E 2
A
B
C
D
E
Page 7: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis7 DTU Compute Technical University of Denmark

Use of filtering

Noise removal Enhance edges Smoothing

bull Image processing

bull Typically done before actual image analysis

DTU Compute

2122018Introduction to Medical Image Analysis8 DTU Compute Technical University of Denmark

Salt and pepper noise Pixel values that are very

different from their neighbours

Very bright or very dark spots

Scratches in X-rays

What is that

DTU Compute

2122018Introduction to Medical Image Analysis9 DTU Compute Technical University of Denmark

Salt and pepper noise Fake example

ndash Let us take a closer look at noise pixels

They are all 0 or 255

Should we just remove all the 0rsquos and 255rsquos from the image

DTU Compute

2122018Introduction to Medical Image Analysis10 DTU Compute Technical University of Denmark

What is so special about noise What is the value of the pixel

compared to the neighbours Average of the neighbours

ndash 170 Can we compare to the

averagendash Difficult ndash should we remove

all values bigger than average+1

It is difficult to detect noise

172 169 171 168 0 169 172 173 168

DTU Compute

2122018Introduction to Medical Image Analysis11 DTU Compute Technical University of Denmark

Noise ndash go away We can not tell what pixels

are noise One solution

ndash Set all pixels to the average of the neighbours (and the pixel itself)

Oh nondash Problemsndash The noise ldquopollutesrdquo the

good pixels

172 169 171 168 0 169 172 173 168

170

169 168 0 170 172173 170 172 170

149

DTU Compute

2122018Introduction to Medical Image Analysis12 DTU Compute Technical University of Denmark

What is the median ValueA) 170B) 173C) 169D) 171E) 172

13

0 0 02

A B C D E

169 168 0 170172 173 170 172 170

Chart1

13
0
0
0
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis13 DTU Compute Technical University of Denmark

The median value The values are sorted from low to high The middle number is picked

ndash The median value

169 168 0 170172 173 170 172 170

0168 169 170 170 170172 172173

Median

Noise has no influence on the median

DTU Compute

2122018Introduction to Medical Image Analysis14 DTU Compute Technical University of Denmark

Noise away ndash the median filter All pixels are set to the

median of its neighbourhood Noise pixels do not pollute

good pixels

172 169 171 168 0 169 172 173 168

170

169 168 0 170 172173 170 172 170

170

DTU Compute

2122018Introduction to Medical Image Analysis15 DTU Compute Technical University of Denmark

Noise removal ndash average filter

Scanned X-ray with salt and pepper noise

Average filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis16 DTU Compute Technical University of Denmark

Noise removal ndash median filter

Scanned X-ray with salt and pepper noise

Median filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis17 DTU Compute Technical University of Denmark

Image Filtering Creates a new filtered image Output pixel is computed based

on a neighbourhood in the input image

3 x 3 neighbourhoodndash Filter size 3 x 3ndash Kernel size 3 x 3ndash Mask size 3 x 3

Larger filters often usedndash Size

7 x 7ndash Number of elements

49

DTU Compute

2122018Introduction to Medical Image Analysis18 DTU Compute Technical University of Denmark

Median filterA) 25B) 90C) 198D) 86E) 103

0

13

1 0 0

A B C D E

Chart1

0
13
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis20 DTU Compute Technical University of Denmark

Rank filters Based on sorting the pixel

values in the neighbouring region

Minimum rank filterndash Darker image Noise problems

Maximum rank filterndash Lighter image Noise problems

Difference filterndash Enhances changes (edges)

0168 169 170 170 170172 172173

-

DTU Compute

2122018Introduction to Medical Image Analysis21 DTU Compute Technical University of Denmark

Median filter

A) 3B) 84C) 112D) 73E) 202

0

12

10 0

A B C D E

Chart1

0
12
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis23 DTU Compute Technical University of Denmark

Correlation What is it Two measurements

ndash Low correlationndash High correlation

High correlation means that there is a relation between the values

They look the same Correlation is a measure of

similarity

Low

High

Muscles

Mat

h Ski

lls

Muscles

Ben

ch P

ress

DTU Compute

2122018Introduction to Medical Image Analysis24 DTU Compute Technical University of Denmark

Why do we need similarity Image analysis is also about recognition of patterns Often an example pattern is used We need something to tell us if there is a high match

between our pattern and a part of the image

Example pattern

Image

Find matches

DTU Compute

2122018Introduction to Medical Image Analysis25 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise

Kernel

Signal (1D image)

41

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
A 0
B 12
C 1
D 0
E 0
A
B
C
D
E
A 0
B 13
C 1
D 0
E 0
A
B
C
D
E
A 13
B 0
C 0
D 0
E 2
A
B
C
D
E
Page 8: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis8 DTU Compute Technical University of Denmark

Salt and pepper noise Pixel values that are very

different from their neighbours

Very bright or very dark spots

Scratches in X-rays

What is that

DTU Compute

2122018Introduction to Medical Image Analysis9 DTU Compute Technical University of Denmark

Salt and pepper noise Fake example

ndash Let us take a closer look at noise pixels

They are all 0 or 255

Should we just remove all the 0rsquos and 255rsquos from the image

DTU Compute

2122018Introduction to Medical Image Analysis10 DTU Compute Technical University of Denmark

What is so special about noise What is the value of the pixel

compared to the neighbours Average of the neighbours

ndash 170 Can we compare to the

averagendash Difficult ndash should we remove

all values bigger than average+1

It is difficult to detect noise

172 169 171 168 0 169 172 173 168

DTU Compute

2122018Introduction to Medical Image Analysis11 DTU Compute Technical University of Denmark

Noise ndash go away We can not tell what pixels

are noise One solution

ndash Set all pixels to the average of the neighbours (and the pixel itself)

Oh nondash Problemsndash The noise ldquopollutesrdquo the

good pixels

172 169 171 168 0 169 172 173 168

170

169 168 0 170 172173 170 172 170

149

DTU Compute

2122018Introduction to Medical Image Analysis12 DTU Compute Technical University of Denmark

What is the median ValueA) 170B) 173C) 169D) 171E) 172

13

0 0 02

A B C D E

169 168 0 170172 173 170 172 170

Chart1

13
0
0
0
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis13 DTU Compute Technical University of Denmark

The median value The values are sorted from low to high The middle number is picked

ndash The median value

169 168 0 170172 173 170 172 170

0168 169 170 170 170172 172173

Median

Noise has no influence on the median

DTU Compute

2122018Introduction to Medical Image Analysis14 DTU Compute Technical University of Denmark

Noise away ndash the median filter All pixels are set to the

median of its neighbourhood Noise pixels do not pollute

good pixels

172 169 171 168 0 169 172 173 168

170

169 168 0 170 172173 170 172 170

170

DTU Compute

2122018Introduction to Medical Image Analysis15 DTU Compute Technical University of Denmark

Noise removal ndash average filter

Scanned X-ray with salt and pepper noise

Average filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis16 DTU Compute Technical University of Denmark

Noise removal ndash median filter

Scanned X-ray with salt and pepper noise

Median filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis17 DTU Compute Technical University of Denmark

Image Filtering Creates a new filtered image Output pixel is computed based

on a neighbourhood in the input image

3 x 3 neighbourhoodndash Filter size 3 x 3ndash Kernel size 3 x 3ndash Mask size 3 x 3

Larger filters often usedndash Size

7 x 7ndash Number of elements

49

DTU Compute

2122018Introduction to Medical Image Analysis18 DTU Compute Technical University of Denmark

Median filterA) 25B) 90C) 198D) 86E) 103

0

13

1 0 0

A B C D E

Chart1

0
13
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis20 DTU Compute Technical University of Denmark

Rank filters Based on sorting the pixel

values in the neighbouring region

Minimum rank filterndash Darker image Noise problems

Maximum rank filterndash Lighter image Noise problems

Difference filterndash Enhances changes (edges)

0168 169 170 170 170172 172173

-

DTU Compute

2122018Introduction to Medical Image Analysis21 DTU Compute Technical University of Denmark

Median filter

A) 3B) 84C) 112D) 73E) 202

0

12

10 0

A B C D E

Chart1

0
12
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis23 DTU Compute Technical University of Denmark

Correlation What is it Two measurements

ndash Low correlationndash High correlation

High correlation means that there is a relation between the values

They look the same Correlation is a measure of

similarity

Low

High

Muscles

Mat

h Ski

lls

Muscles

Ben

ch P

ress

DTU Compute

2122018Introduction to Medical Image Analysis24 DTU Compute Technical University of Denmark

Why do we need similarity Image analysis is also about recognition of patterns Often an example pattern is used We need something to tell us if there is a high match

between our pattern and a part of the image

Example pattern

Image

Find matches

DTU Compute

2122018Introduction to Medical Image Analysis25 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise

Kernel

Signal (1D image)

41

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
A 0
B 12
C 1
D 0
E 0
A
B
C
D
E
A 0
B 13
C 1
D 0
E 0
A
B
C
D
E
A 13
B 0
C 0
D 0
E 2
A
B
C
D
E
Page 9: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis9 DTU Compute Technical University of Denmark

Salt and pepper noise Fake example

ndash Let us take a closer look at noise pixels

They are all 0 or 255

Should we just remove all the 0rsquos and 255rsquos from the image

DTU Compute

2122018Introduction to Medical Image Analysis10 DTU Compute Technical University of Denmark

What is so special about noise What is the value of the pixel

compared to the neighbours Average of the neighbours

ndash 170 Can we compare to the

averagendash Difficult ndash should we remove

all values bigger than average+1

It is difficult to detect noise

172 169 171 168 0 169 172 173 168

DTU Compute

2122018Introduction to Medical Image Analysis11 DTU Compute Technical University of Denmark

Noise ndash go away We can not tell what pixels

are noise One solution

ndash Set all pixels to the average of the neighbours (and the pixel itself)

Oh nondash Problemsndash The noise ldquopollutesrdquo the

good pixels

172 169 171 168 0 169 172 173 168

170

169 168 0 170 172173 170 172 170

149

DTU Compute

2122018Introduction to Medical Image Analysis12 DTU Compute Technical University of Denmark

What is the median ValueA) 170B) 173C) 169D) 171E) 172

13

0 0 02

A B C D E

169 168 0 170172 173 170 172 170

Chart1

13
0
0
0
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis13 DTU Compute Technical University of Denmark

The median value The values are sorted from low to high The middle number is picked

ndash The median value

169 168 0 170172 173 170 172 170

0168 169 170 170 170172 172173

Median

Noise has no influence on the median

DTU Compute

2122018Introduction to Medical Image Analysis14 DTU Compute Technical University of Denmark

Noise away ndash the median filter All pixels are set to the

median of its neighbourhood Noise pixels do not pollute

good pixels

172 169 171 168 0 169 172 173 168

170

169 168 0 170 172173 170 172 170

170

DTU Compute

2122018Introduction to Medical Image Analysis15 DTU Compute Technical University of Denmark

Noise removal ndash average filter

Scanned X-ray with salt and pepper noise

Average filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis16 DTU Compute Technical University of Denmark

Noise removal ndash median filter

Scanned X-ray with salt and pepper noise

Median filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis17 DTU Compute Technical University of Denmark

Image Filtering Creates a new filtered image Output pixel is computed based

on a neighbourhood in the input image

3 x 3 neighbourhoodndash Filter size 3 x 3ndash Kernel size 3 x 3ndash Mask size 3 x 3

Larger filters often usedndash Size

7 x 7ndash Number of elements

49

DTU Compute

2122018Introduction to Medical Image Analysis18 DTU Compute Technical University of Denmark

Median filterA) 25B) 90C) 198D) 86E) 103

0

13

1 0 0

A B C D E

Chart1

0
13
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis20 DTU Compute Technical University of Denmark

Rank filters Based on sorting the pixel

values in the neighbouring region

Minimum rank filterndash Darker image Noise problems

Maximum rank filterndash Lighter image Noise problems

Difference filterndash Enhances changes (edges)

0168 169 170 170 170172 172173

-

DTU Compute

2122018Introduction to Medical Image Analysis21 DTU Compute Technical University of Denmark

Median filter

A) 3B) 84C) 112D) 73E) 202

0

12

10 0

A B C D E

Chart1

0
12
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis23 DTU Compute Technical University of Denmark

Correlation What is it Two measurements

ndash Low correlationndash High correlation

High correlation means that there is a relation between the values

They look the same Correlation is a measure of

similarity

Low

High

Muscles

Mat

h Ski

lls

Muscles

Ben

ch P

ress

DTU Compute

2122018Introduction to Medical Image Analysis24 DTU Compute Technical University of Denmark

Why do we need similarity Image analysis is also about recognition of patterns Often an example pattern is used We need something to tell us if there is a high match

between our pattern and a part of the image

Example pattern

Image

Find matches

DTU Compute

2122018Introduction to Medical Image Analysis25 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise

Kernel

Signal (1D image)

41

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
A 0
B 12
C 1
D 0
E 0
A
B
C
D
E
A 0
B 13
C 1
D 0
E 0
A
B
C
D
E
A 13
B 0
C 0
D 0
E 2
A
B
C
D
E
Page 10: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis10 DTU Compute Technical University of Denmark

What is so special about noise What is the value of the pixel

compared to the neighbours Average of the neighbours

ndash 170 Can we compare to the

averagendash Difficult ndash should we remove

all values bigger than average+1

It is difficult to detect noise

172 169 171 168 0 169 172 173 168

DTU Compute

2122018Introduction to Medical Image Analysis11 DTU Compute Technical University of Denmark

Noise ndash go away We can not tell what pixels

are noise One solution

ndash Set all pixels to the average of the neighbours (and the pixel itself)

Oh nondash Problemsndash The noise ldquopollutesrdquo the

good pixels

172 169 171 168 0 169 172 173 168

170

169 168 0 170 172173 170 172 170

149

DTU Compute

2122018Introduction to Medical Image Analysis12 DTU Compute Technical University of Denmark

What is the median ValueA) 170B) 173C) 169D) 171E) 172

13

0 0 02

A B C D E

169 168 0 170172 173 170 172 170

Chart1

13
0
0
0
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis13 DTU Compute Technical University of Denmark

The median value The values are sorted from low to high The middle number is picked

ndash The median value

169 168 0 170172 173 170 172 170

0168 169 170 170 170172 172173

Median

Noise has no influence on the median

DTU Compute

2122018Introduction to Medical Image Analysis14 DTU Compute Technical University of Denmark

Noise away ndash the median filter All pixels are set to the

median of its neighbourhood Noise pixels do not pollute

good pixels

172 169 171 168 0 169 172 173 168

170

169 168 0 170 172173 170 172 170

170

DTU Compute

2122018Introduction to Medical Image Analysis15 DTU Compute Technical University of Denmark

Noise removal ndash average filter

Scanned X-ray with salt and pepper noise

Average filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis16 DTU Compute Technical University of Denmark

Noise removal ndash median filter

Scanned X-ray with salt and pepper noise

Median filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis17 DTU Compute Technical University of Denmark

Image Filtering Creates a new filtered image Output pixel is computed based

on a neighbourhood in the input image

3 x 3 neighbourhoodndash Filter size 3 x 3ndash Kernel size 3 x 3ndash Mask size 3 x 3

Larger filters often usedndash Size

7 x 7ndash Number of elements

49

DTU Compute

2122018Introduction to Medical Image Analysis18 DTU Compute Technical University of Denmark

Median filterA) 25B) 90C) 198D) 86E) 103

0

13

1 0 0

A B C D E

Chart1

0
13
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis20 DTU Compute Technical University of Denmark

Rank filters Based on sorting the pixel

values in the neighbouring region

Minimum rank filterndash Darker image Noise problems

Maximum rank filterndash Lighter image Noise problems

Difference filterndash Enhances changes (edges)

0168 169 170 170 170172 172173

-

DTU Compute

2122018Introduction to Medical Image Analysis21 DTU Compute Technical University of Denmark

Median filter

A) 3B) 84C) 112D) 73E) 202

0

12

10 0

A B C D E

Chart1

0
12
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis23 DTU Compute Technical University of Denmark

Correlation What is it Two measurements

ndash Low correlationndash High correlation

High correlation means that there is a relation between the values

They look the same Correlation is a measure of

similarity

Low

High

Muscles

Mat

h Ski

lls

Muscles

Ben

ch P

ress

DTU Compute

2122018Introduction to Medical Image Analysis24 DTU Compute Technical University of Denmark

Why do we need similarity Image analysis is also about recognition of patterns Often an example pattern is used We need something to tell us if there is a high match

between our pattern and a part of the image

Example pattern

Image

Find matches

DTU Compute

2122018Introduction to Medical Image Analysis25 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise

Kernel

Signal (1D image)

41

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
A 0
B 12
C 1
D 0
E 0
A
B
C
D
E
A 0
B 13
C 1
D 0
E 0
A
B
C
D
E
A 13
B 0
C 0
D 0
E 2
A
B
C
D
E
Page 11: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis11 DTU Compute Technical University of Denmark

Noise ndash go away We can not tell what pixels

are noise One solution

ndash Set all pixels to the average of the neighbours (and the pixel itself)

Oh nondash Problemsndash The noise ldquopollutesrdquo the

good pixels

172 169 171 168 0 169 172 173 168

170

169 168 0 170 172173 170 172 170

149

DTU Compute

2122018Introduction to Medical Image Analysis12 DTU Compute Technical University of Denmark

What is the median ValueA) 170B) 173C) 169D) 171E) 172

13

0 0 02

A B C D E

169 168 0 170172 173 170 172 170

Chart1

13
0
0
0
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis13 DTU Compute Technical University of Denmark

The median value The values are sorted from low to high The middle number is picked

ndash The median value

169 168 0 170172 173 170 172 170

0168 169 170 170 170172 172173

Median

Noise has no influence on the median

DTU Compute

2122018Introduction to Medical Image Analysis14 DTU Compute Technical University of Denmark

Noise away ndash the median filter All pixels are set to the

median of its neighbourhood Noise pixels do not pollute

good pixels

172 169 171 168 0 169 172 173 168

170

169 168 0 170 172173 170 172 170

170

DTU Compute

2122018Introduction to Medical Image Analysis15 DTU Compute Technical University of Denmark

Noise removal ndash average filter

Scanned X-ray with salt and pepper noise

Average filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis16 DTU Compute Technical University of Denmark

Noise removal ndash median filter

Scanned X-ray with salt and pepper noise

Median filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis17 DTU Compute Technical University of Denmark

Image Filtering Creates a new filtered image Output pixel is computed based

on a neighbourhood in the input image

3 x 3 neighbourhoodndash Filter size 3 x 3ndash Kernel size 3 x 3ndash Mask size 3 x 3

Larger filters often usedndash Size

7 x 7ndash Number of elements

49

DTU Compute

2122018Introduction to Medical Image Analysis18 DTU Compute Technical University of Denmark

Median filterA) 25B) 90C) 198D) 86E) 103

0

13

1 0 0

A B C D E

Chart1

0
13
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis20 DTU Compute Technical University of Denmark

Rank filters Based on sorting the pixel

values in the neighbouring region

Minimum rank filterndash Darker image Noise problems

Maximum rank filterndash Lighter image Noise problems

Difference filterndash Enhances changes (edges)

0168 169 170 170 170172 172173

-

DTU Compute

2122018Introduction to Medical Image Analysis21 DTU Compute Technical University of Denmark

Median filter

A) 3B) 84C) 112D) 73E) 202

0

12

10 0

A B C D E

Chart1

0
12
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis23 DTU Compute Technical University of Denmark

Correlation What is it Two measurements

ndash Low correlationndash High correlation

High correlation means that there is a relation between the values

They look the same Correlation is a measure of

similarity

Low

High

Muscles

Mat

h Ski

lls

Muscles

Ben

ch P

ress

DTU Compute

2122018Introduction to Medical Image Analysis24 DTU Compute Technical University of Denmark

Why do we need similarity Image analysis is also about recognition of patterns Often an example pattern is used We need something to tell us if there is a high match

between our pattern and a part of the image

Example pattern

Image

Find matches

DTU Compute

2122018Introduction to Medical Image Analysis25 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise

Kernel

Signal (1D image)

41

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
A 0
B 12
C 1
D 0
E 0
A
B
C
D
E
A 0
B 13
C 1
D 0
E 0
A
B
C
D
E
A 13
B 0
C 0
D 0
E 2
A
B
C
D
E
Page 12: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis12 DTU Compute Technical University of Denmark

What is the median ValueA) 170B) 173C) 169D) 171E) 172

13

0 0 02

A B C D E

169 168 0 170172 173 170 172 170

Chart1

13
0
0
0
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis13 DTU Compute Technical University of Denmark

The median value The values are sorted from low to high The middle number is picked

ndash The median value

169 168 0 170172 173 170 172 170

0168 169 170 170 170172 172173

Median

Noise has no influence on the median

DTU Compute

2122018Introduction to Medical Image Analysis14 DTU Compute Technical University of Denmark

Noise away ndash the median filter All pixels are set to the

median of its neighbourhood Noise pixels do not pollute

good pixels

172 169 171 168 0 169 172 173 168

170

169 168 0 170 172173 170 172 170

170

DTU Compute

2122018Introduction to Medical Image Analysis15 DTU Compute Technical University of Denmark

Noise removal ndash average filter

Scanned X-ray with salt and pepper noise

Average filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis16 DTU Compute Technical University of Denmark

Noise removal ndash median filter

Scanned X-ray with salt and pepper noise

Median filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis17 DTU Compute Technical University of Denmark

Image Filtering Creates a new filtered image Output pixel is computed based

on a neighbourhood in the input image

3 x 3 neighbourhoodndash Filter size 3 x 3ndash Kernel size 3 x 3ndash Mask size 3 x 3

Larger filters often usedndash Size

7 x 7ndash Number of elements

49

DTU Compute

2122018Introduction to Medical Image Analysis18 DTU Compute Technical University of Denmark

Median filterA) 25B) 90C) 198D) 86E) 103

0

13

1 0 0

A B C D E

Chart1

0
13
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis20 DTU Compute Technical University of Denmark

Rank filters Based on sorting the pixel

values in the neighbouring region

Minimum rank filterndash Darker image Noise problems

Maximum rank filterndash Lighter image Noise problems

Difference filterndash Enhances changes (edges)

0168 169 170 170 170172 172173

-

DTU Compute

2122018Introduction to Medical Image Analysis21 DTU Compute Technical University of Denmark

Median filter

A) 3B) 84C) 112D) 73E) 202

0

12

10 0

A B C D E

Chart1

0
12
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis23 DTU Compute Technical University of Denmark

Correlation What is it Two measurements

ndash Low correlationndash High correlation

High correlation means that there is a relation between the values

They look the same Correlation is a measure of

similarity

Low

High

Muscles

Mat

h Ski

lls

Muscles

Ben

ch P

ress

DTU Compute

2122018Introduction to Medical Image Analysis24 DTU Compute Technical University of Denmark

Why do we need similarity Image analysis is also about recognition of patterns Often an example pattern is used We need something to tell us if there is a high match

between our pattern and a part of the image

Example pattern

Image

Find matches

DTU Compute

2122018Introduction to Medical Image Analysis25 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise

Kernel

Signal (1D image)

41

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
A 0
B 12
C 1
D 0
E 0
A
B
C
D
E
A 0
B 13
C 1
D 0
E 0
A
B
C
D
E
A 13
B 0
C 0
D 0
E 2
A
B
C
D
E
Page 13: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Chart1

13
0
0
0
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis13 DTU Compute Technical University of Denmark

The median value The values are sorted from low to high The middle number is picked

ndash The median value

169 168 0 170172 173 170 172 170

0168 169 170 170 170172 172173

Median

Noise has no influence on the median

DTU Compute

2122018Introduction to Medical Image Analysis14 DTU Compute Technical University of Denmark

Noise away ndash the median filter All pixels are set to the

median of its neighbourhood Noise pixels do not pollute

good pixels

172 169 171 168 0 169 172 173 168

170

169 168 0 170 172173 170 172 170

170

DTU Compute

2122018Introduction to Medical Image Analysis15 DTU Compute Technical University of Denmark

Noise removal ndash average filter

Scanned X-ray with salt and pepper noise

Average filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis16 DTU Compute Technical University of Denmark

Noise removal ndash median filter

Scanned X-ray with salt and pepper noise

Median filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis17 DTU Compute Technical University of Denmark

Image Filtering Creates a new filtered image Output pixel is computed based

on a neighbourhood in the input image

3 x 3 neighbourhoodndash Filter size 3 x 3ndash Kernel size 3 x 3ndash Mask size 3 x 3

Larger filters often usedndash Size

7 x 7ndash Number of elements

49

DTU Compute

2122018Introduction to Medical Image Analysis18 DTU Compute Technical University of Denmark

Median filterA) 25B) 90C) 198D) 86E) 103

0

13

1 0 0

A B C D E

Chart1

0
13
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis20 DTU Compute Technical University of Denmark

Rank filters Based on sorting the pixel

values in the neighbouring region

Minimum rank filterndash Darker image Noise problems

Maximum rank filterndash Lighter image Noise problems

Difference filterndash Enhances changes (edges)

0168 169 170 170 170172 172173

-

DTU Compute

2122018Introduction to Medical Image Analysis21 DTU Compute Technical University of Denmark

Median filter

A) 3B) 84C) 112D) 73E) 202

0

12

10 0

A B C D E

Chart1

0
12
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis23 DTU Compute Technical University of Denmark

Correlation What is it Two measurements

ndash Low correlationndash High correlation

High correlation means that there is a relation between the values

They look the same Correlation is a measure of

similarity

Low

High

Muscles

Mat

h Ski

lls

Muscles

Ben

ch P

ress

DTU Compute

2122018Introduction to Medical Image Analysis24 DTU Compute Technical University of Denmark

Why do we need similarity Image analysis is also about recognition of patterns Often an example pattern is used We need something to tell us if there is a high match

between our pattern and a part of the image

Example pattern

Image

Find matches

DTU Compute

2122018Introduction to Medical Image Analysis25 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise

Kernel

Signal (1D image)

41

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
A 0
B 12
C 1
D 0
E 0
A
B
C
D
E
A 0
B 13
C 1
D 0
E 0
A
B
C
D
E
A 13
B 0
C 0
D 0
E 2
A
B
C
D
E
Page 14: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis13 DTU Compute Technical University of Denmark

The median value The values are sorted from low to high The middle number is picked

ndash The median value

169 168 0 170172 173 170 172 170

0168 169 170 170 170172 172173

Median

Noise has no influence on the median

DTU Compute

2122018Introduction to Medical Image Analysis14 DTU Compute Technical University of Denmark

Noise away ndash the median filter All pixels are set to the

median of its neighbourhood Noise pixels do not pollute

good pixels

172 169 171 168 0 169 172 173 168

170

169 168 0 170 172173 170 172 170

170

DTU Compute

2122018Introduction to Medical Image Analysis15 DTU Compute Technical University of Denmark

Noise removal ndash average filter

Scanned X-ray with salt and pepper noise

Average filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis16 DTU Compute Technical University of Denmark

Noise removal ndash median filter

Scanned X-ray with salt and pepper noise

Median filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis17 DTU Compute Technical University of Denmark

Image Filtering Creates a new filtered image Output pixel is computed based

on a neighbourhood in the input image

3 x 3 neighbourhoodndash Filter size 3 x 3ndash Kernel size 3 x 3ndash Mask size 3 x 3

Larger filters often usedndash Size

7 x 7ndash Number of elements

49

DTU Compute

2122018Introduction to Medical Image Analysis18 DTU Compute Technical University of Denmark

Median filterA) 25B) 90C) 198D) 86E) 103

0

13

1 0 0

A B C D E

Chart1

0
13
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis20 DTU Compute Technical University of Denmark

Rank filters Based on sorting the pixel

values in the neighbouring region

Minimum rank filterndash Darker image Noise problems

Maximum rank filterndash Lighter image Noise problems

Difference filterndash Enhances changes (edges)

0168 169 170 170 170172 172173

-

DTU Compute

2122018Introduction to Medical Image Analysis21 DTU Compute Technical University of Denmark

Median filter

A) 3B) 84C) 112D) 73E) 202

0

12

10 0

A B C D E

Chart1

0
12
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis23 DTU Compute Technical University of Denmark

Correlation What is it Two measurements

ndash Low correlationndash High correlation

High correlation means that there is a relation between the values

They look the same Correlation is a measure of

similarity

Low

High

Muscles

Mat

h Ski

lls

Muscles

Ben

ch P

ress

DTU Compute

2122018Introduction to Medical Image Analysis24 DTU Compute Technical University of Denmark

Why do we need similarity Image analysis is also about recognition of patterns Often an example pattern is used We need something to tell us if there is a high match

between our pattern and a part of the image

Example pattern

Image

Find matches

DTU Compute

2122018Introduction to Medical Image Analysis25 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise

Kernel

Signal (1D image)

41

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
A 0
B 12
C 1
D 0
E 0
A
B
C
D
E
A 0
B 13
C 1
D 0
E 0
A
B
C
D
E
A 13
B 0
C 0
D 0
E 2
Page 15: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis13 DTU Compute Technical University of Denmark

The median value The values are sorted from low to high The middle number is picked

ndash The median value

169 168 0 170172 173 170 172 170

0168 169 170 170 170172 172173

Median

Noise has no influence on the median

DTU Compute

2122018Introduction to Medical Image Analysis14 DTU Compute Technical University of Denmark

Noise away ndash the median filter All pixels are set to the

median of its neighbourhood Noise pixels do not pollute

good pixels

172 169 171 168 0 169 172 173 168

170

169 168 0 170 172173 170 172 170

170

DTU Compute

2122018Introduction to Medical Image Analysis15 DTU Compute Technical University of Denmark

Noise removal ndash average filter

Scanned X-ray with salt and pepper noise

Average filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis16 DTU Compute Technical University of Denmark

Noise removal ndash median filter

Scanned X-ray with salt and pepper noise

Median filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis17 DTU Compute Technical University of Denmark

Image Filtering Creates a new filtered image Output pixel is computed based

on a neighbourhood in the input image

3 x 3 neighbourhoodndash Filter size 3 x 3ndash Kernel size 3 x 3ndash Mask size 3 x 3

Larger filters often usedndash Size

7 x 7ndash Number of elements

49

DTU Compute

2122018Introduction to Medical Image Analysis18 DTU Compute Technical University of Denmark

Median filterA) 25B) 90C) 198D) 86E) 103

0

13

1 0 0

A B C D E

Chart1

0
13
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis20 DTU Compute Technical University of Denmark

Rank filters Based on sorting the pixel

values in the neighbouring region

Minimum rank filterndash Darker image Noise problems

Maximum rank filterndash Lighter image Noise problems

Difference filterndash Enhances changes (edges)

0168 169 170 170 170172 172173

-

DTU Compute

2122018Introduction to Medical Image Analysis21 DTU Compute Technical University of Denmark

Median filter

A) 3B) 84C) 112D) 73E) 202

0

12

10 0

A B C D E

Chart1

0
12
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis23 DTU Compute Technical University of Denmark

Correlation What is it Two measurements

ndash Low correlationndash High correlation

High correlation means that there is a relation between the values

They look the same Correlation is a measure of

similarity

Low

High

Muscles

Mat

h Ski

lls

Muscles

Ben

ch P

ress

DTU Compute

2122018Introduction to Medical Image Analysis24 DTU Compute Technical University of Denmark

Why do we need similarity Image analysis is also about recognition of patterns Often an example pattern is used We need something to tell us if there is a high match

between our pattern and a part of the image

Example pattern

Image

Find matches

DTU Compute

2122018Introduction to Medical Image Analysis25 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise

Kernel

Signal (1D image)

41

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
A 0
B 12
C 1
D 0
E 0
A
B
C
D
E
A 0
B 13
C 1
D 0
E 0
A
B
C
D
E
Page 16: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis14 DTU Compute Technical University of Denmark

Noise away ndash the median filter All pixels are set to the

median of its neighbourhood Noise pixels do not pollute

good pixels

172 169 171 168 0 169 172 173 168

170

169 168 0 170 172173 170 172 170

170

DTU Compute

2122018Introduction to Medical Image Analysis15 DTU Compute Technical University of Denmark

Noise removal ndash average filter

Scanned X-ray with salt and pepper noise

Average filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis16 DTU Compute Technical University of Denmark

Noise removal ndash median filter

Scanned X-ray with salt and pepper noise

Median filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis17 DTU Compute Technical University of Denmark

Image Filtering Creates a new filtered image Output pixel is computed based

on a neighbourhood in the input image

3 x 3 neighbourhoodndash Filter size 3 x 3ndash Kernel size 3 x 3ndash Mask size 3 x 3

Larger filters often usedndash Size

7 x 7ndash Number of elements

49

DTU Compute

2122018Introduction to Medical Image Analysis18 DTU Compute Technical University of Denmark

Median filterA) 25B) 90C) 198D) 86E) 103

0

13

1 0 0

A B C D E

Chart1

0
13
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis20 DTU Compute Technical University of Denmark

Rank filters Based on sorting the pixel

values in the neighbouring region

Minimum rank filterndash Darker image Noise problems

Maximum rank filterndash Lighter image Noise problems

Difference filterndash Enhances changes (edges)

0168 169 170 170 170172 172173

-

DTU Compute

2122018Introduction to Medical Image Analysis21 DTU Compute Technical University of Denmark

Median filter

A) 3B) 84C) 112D) 73E) 202

0

12

10 0

A B C D E

Chart1

0
12
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis23 DTU Compute Technical University of Denmark

Correlation What is it Two measurements

ndash Low correlationndash High correlation

High correlation means that there is a relation between the values

They look the same Correlation is a measure of

similarity

Low

High

Muscles

Mat

h Ski

lls

Muscles

Ben

ch P

ress

DTU Compute

2122018Introduction to Medical Image Analysis24 DTU Compute Technical University of Denmark

Why do we need similarity Image analysis is also about recognition of patterns Often an example pattern is used We need something to tell us if there is a high match

between our pattern and a part of the image

Example pattern

Image

Find matches

DTU Compute

2122018Introduction to Medical Image Analysis25 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise

Kernel

Signal (1D image)

41

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
A 0
B 12
C 1
D 0
E 0
A
B
C
D
E
A 0
B 13
C 1
D 0
E 0
A
B
C
D
E
Page 17: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis15 DTU Compute Technical University of Denmark

Noise removal ndash average filter

Scanned X-ray with salt and pepper noise

Average filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis16 DTU Compute Technical University of Denmark

Noise removal ndash median filter

Scanned X-ray with salt and pepper noise

Median filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis17 DTU Compute Technical University of Denmark

Image Filtering Creates a new filtered image Output pixel is computed based

on a neighbourhood in the input image

3 x 3 neighbourhoodndash Filter size 3 x 3ndash Kernel size 3 x 3ndash Mask size 3 x 3

Larger filters often usedndash Size

7 x 7ndash Number of elements

49

DTU Compute

2122018Introduction to Medical Image Analysis18 DTU Compute Technical University of Denmark

Median filterA) 25B) 90C) 198D) 86E) 103

0

13

1 0 0

A B C D E

Chart1

0
13
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis20 DTU Compute Technical University of Denmark

Rank filters Based on sorting the pixel

values in the neighbouring region

Minimum rank filterndash Darker image Noise problems

Maximum rank filterndash Lighter image Noise problems

Difference filterndash Enhances changes (edges)

0168 169 170 170 170172 172173

-

DTU Compute

2122018Introduction to Medical Image Analysis21 DTU Compute Technical University of Denmark

Median filter

A) 3B) 84C) 112D) 73E) 202

0

12

10 0

A B C D E

Chart1

0
12
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis23 DTU Compute Technical University of Denmark

Correlation What is it Two measurements

ndash Low correlationndash High correlation

High correlation means that there is a relation between the values

They look the same Correlation is a measure of

similarity

Low

High

Muscles

Mat

h Ski

lls

Muscles

Ben

ch P

ress

DTU Compute

2122018Introduction to Medical Image Analysis24 DTU Compute Technical University of Denmark

Why do we need similarity Image analysis is also about recognition of patterns Often an example pattern is used We need something to tell us if there is a high match

between our pattern and a part of the image

Example pattern

Image

Find matches

DTU Compute

2122018Introduction to Medical Image Analysis25 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise

Kernel

Signal (1D image)

41

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
A 0
B 12
C 1
D 0
E 0
A
B
C
D
E
A 0
B 13
C 1
D 0
E 0
A
B
C
D
E
Page 18: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis16 DTU Compute Technical University of Denmark

Noise removal ndash median filter

Scanned X-ray with salt and pepper noise

Median filter (3x3)

DTU Compute

2122018Introduction to Medical Image Analysis17 DTU Compute Technical University of Denmark

Image Filtering Creates a new filtered image Output pixel is computed based

on a neighbourhood in the input image

3 x 3 neighbourhoodndash Filter size 3 x 3ndash Kernel size 3 x 3ndash Mask size 3 x 3

Larger filters often usedndash Size

7 x 7ndash Number of elements

49

DTU Compute

2122018Introduction to Medical Image Analysis18 DTU Compute Technical University of Denmark

Median filterA) 25B) 90C) 198D) 86E) 103

0

13

1 0 0

A B C D E

Chart1

0
13
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis20 DTU Compute Technical University of Denmark

Rank filters Based on sorting the pixel

values in the neighbouring region

Minimum rank filterndash Darker image Noise problems

Maximum rank filterndash Lighter image Noise problems

Difference filterndash Enhances changes (edges)

0168 169 170 170 170172 172173

-

DTU Compute

2122018Introduction to Medical Image Analysis21 DTU Compute Technical University of Denmark

Median filter

A) 3B) 84C) 112D) 73E) 202

0

12

10 0

A B C D E

Chart1

0
12
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis23 DTU Compute Technical University of Denmark

Correlation What is it Two measurements

ndash Low correlationndash High correlation

High correlation means that there is a relation between the values

They look the same Correlation is a measure of

similarity

Low

High

Muscles

Mat

h Ski

lls

Muscles

Ben

ch P

ress

DTU Compute

2122018Introduction to Medical Image Analysis24 DTU Compute Technical University of Denmark

Why do we need similarity Image analysis is also about recognition of patterns Often an example pattern is used We need something to tell us if there is a high match

between our pattern and a part of the image

Example pattern

Image

Find matches

DTU Compute

2122018Introduction to Medical Image Analysis25 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise

Kernel

Signal (1D image)

41

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
A 0
B 12
C 1
D 0
E 0
A
B
C
D
E
A 0
B 13
C 1
D 0
E 0
A
B
C
D
E
Page 19: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis17 DTU Compute Technical University of Denmark

Image Filtering Creates a new filtered image Output pixel is computed based

on a neighbourhood in the input image

3 x 3 neighbourhoodndash Filter size 3 x 3ndash Kernel size 3 x 3ndash Mask size 3 x 3

Larger filters often usedndash Size

7 x 7ndash Number of elements

49

DTU Compute

2122018Introduction to Medical Image Analysis18 DTU Compute Technical University of Denmark

Median filterA) 25B) 90C) 198D) 86E) 103

0

13

1 0 0

A B C D E

Chart1

0
13
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis20 DTU Compute Technical University of Denmark

Rank filters Based on sorting the pixel

values in the neighbouring region

Minimum rank filterndash Darker image Noise problems

Maximum rank filterndash Lighter image Noise problems

Difference filterndash Enhances changes (edges)

0168 169 170 170 170172 172173

-

DTU Compute

2122018Introduction to Medical Image Analysis21 DTU Compute Technical University of Denmark

Median filter

A) 3B) 84C) 112D) 73E) 202

0

12

10 0

A B C D E

Chart1

0
12
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis23 DTU Compute Technical University of Denmark

Correlation What is it Two measurements

ndash Low correlationndash High correlation

High correlation means that there is a relation between the values

They look the same Correlation is a measure of

similarity

Low

High

Muscles

Mat

h Ski

lls

Muscles

Ben

ch P

ress

DTU Compute

2122018Introduction to Medical Image Analysis24 DTU Compute Technical University of Denmark

Why do we need similarity Image analysis is also about recognition of patterns Often an example pattern is used We need something to tell us if there is a high match

between our pattern and a part of the image

Example pattern

Image

Find matches

DTU Compute

2122018Introduction to Medical Image Analysis25 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise

Kernel

Signal (1D image)

41

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
A 0
B 12
C 1
D 0
E 0
A
B
C
D
E
A 0
B 13
C 1
D 0
E 0
A
B
C
D
E
Page 20: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis18 DTU Compute Technical University of Denmark

Median filterA) 25B) 90C) 198D) 86E) 103

0

13

1 0 0

A B C D E

Chart1

0
13
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis20 DTU Compute Technical University of Denmark

Rank filters Based on sorting the pixel

values in the neighbouring region

Minimum rank filterndash Darker image Noise problems

Maximum rank filterndash Lighter image Noise problems

Difference filterndash Enhances changes (edges)

0168 169 170 170 170172 172173

-

DTU Compute

2122018Introduction to Medical Image Analysis21 DTU Compute Technical University of Denmark

Median filter

A) 3B) 84C) 112D) 73E) 202

0

12

10 0

A B C D E

Chart1

0
12
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis23 DTU Compute Technical University of Denmark

Correlation What is it Two measurements

ndash Low correlationndash High correlation

High correlation means that there is a relation between the values

They look the same Correlation is a measure of

similarity

Low

High

Muscles

Mat

h Ski

lls

Muscles

Ben

ch P

ress

DTU Compute

2122018Introduction to Medical Image Analysis24 DTU Compute Technical University of Denmark

Why do we need similarity Image analysis is also about recognition of patterns Often an example pattern is used We need something to tell us if there is a high match

between our pattern and a part of the image

Example pattern

Image

Find matches

DTU Compute

2122018Introduction to Medical Image Analysis25 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise

Kernel

Signal (1D image)

41

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
A 0
B 12
C 1
D 0
E 0
A
B
C
D
E
A 0
B 13
C 1
D 0
E 0
A
B
C
D
E
Page 21: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Chart1

0
13
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis20 DTU Compute Technical University of Denmark

Rank filters Based on sorting the pixel

values in the neighbouring region

Minimum rank filterndash Darker image Noise problems

Maximum rank filterndash Lighter image Noise problems

Difference filterndash Enhances changes (edges)

0168 169 170 170 170172 172173

-

DTU Compute

2122018Introduction to Medical Image Analysis21 DTU Compute Technical University of Denmark

Median filter

A) 3B) 84C) 112D) 73E) 202

0

12

10 0

A B C D E

Chart1

0
12
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis23 DTU Compute Technical University of Denmark

Correlation What is it Two measurements

ndash Low correlationndash High correlation

High correlation means that there is a relation between the values

They look the same Correlation is a measure of

similarity

Low

High

Muscles

Mat

h Ski

lls

Muscles

Ben

ch P

ress

DTU Compute

2122018Introduction to Medical Image Analysis24 DTU Compute Technical University of Denmark

Why do we need similarity Image analysis is also about recognition of patterns Often an example pattern is used We need something to tell us if there is a high match

between our pattern and a part of the image

Example pattern

Image

Find matches

DTU Compute

2122018Introduction to Medical Image Analysis25 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise

Kernel

Signal (1D image)

41

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
A 0
B 12
C 1
D 0
E 0
A
B
C
D
E
A 0
B 13
C 1
D 0
E 0
A
B
C
D
E
Page 22: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis20 DTU Compute Technical University of Denmark

Rank filters Based on sorting the pixel

values in the neighbouring region

Minimum rank filterndash Darker image Noise problems

Maximum rank filterndash Lighter image Noise problems

Difference filterndash Enhances changes (edges)

0168 169 170 170 170172 172173

-

DTU Compute

2122018Introduction to Medical Image Analysis21 DTU Compute Technical University of Denmark

Median filter

A) 3B) 84C) 112D) 73E) 202

0

12

10 0

A B C D E

Chart1

0
12
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis23 DTU Compute Technical University of Denmark

Correlation What is it Two measurements

ndash Low correlationndash High correlation

High correlation means that there is a relation between the values

They look the same Correlation is a measure of

similarity

Low

High

Muscles

Mat

h Ski

lls

Muscles

Ben

ch P

ress

DTU Compute

2122018Introduction to Medical Image Analysis24 DTU Compute Technical University of Denmark

Why do we need similarity Image analysis is also about recognition of patterns Often an example pattern is used We need something to tell us if there is a high match

between our pattern and a part of the image

Example pattern

Image

Find matches

DTU Compute

2122018Introduction to Medical Image Analysis25 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise

Kernel

Signal (1D image)

41

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
A 0
B 12
C 1
D 0
E 0
A
B
C
D
E
A 0
B 13
C 1
D 0
E 0
Page 23: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis20 DTU Compute Technical University of Denmark

Rank filters Based on sorting the pixel

values in the neighbouring region

Minimum rank filterndash Darker image Noise problems

Maximum rank filterndash Lighter image Noise problems

Difference filterndash Enhances changes (edges)

0168 169 170 170 170172 172173

-

DTU Compute

2122018Introduction to Medical Image Analysis21 DTU Compute Technical University of Denmark

Median filter

A) 3B) 84C) 112D) 73E) 202

0

12

10 0

A B C D E

Chart1

0
12
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis23 DTU Compute Technical University of Denmark

Correlation What is it Two measurements

ndash Low correlationndash High correlation

High correlation means that there is a relation between the values

They look the same Correlation is a measure of

similarity

Low

High

Muscles

Mat

h Ski

lls

Muscles

Ben

ch P

ress

DTU Compute

2122018Introduction to Medical Image Analysis24 DTU Compute Technical University of Denmark

Why do we need similarity Image analysis is also about recognition of patterns Often an example pattern is used We need something to tell us if there is a high match

between our pattern and a part of the image

Example pattern

Image

Find matches

DTU Compute

2122018Introduction to Medical Image Analysis25 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise

Kernel

Signal (1D image)

41

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
A 0
B 12
C 1
D 0
E 0
A
B
C
D
E
Page 24: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis21 DTU Compute Technical University of Denmark

Median filter

A) 3B) 84C) 112D) 73E) 202

0

12

10 0

A B C D E

Chart1

0
12
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis23 DTU Compute Technical University of Denmark

Correlation What is it Two measurements

ndash Low correlationndash High correlation

High correlation means that there is a relation between the values

They look the same Correlation is a measure of

similarity

Low

High

Muscles

Mat

h Ski

lls

Muscles

Ben

ch P

ress

DTU Compute

2122018Introduction to Medical Image Analysis24 DTU Compute Technical University of Denmark

Why do we need similarity Image analysis is also about recognition of patterns Often an example pattern is used We need something to tell us if there is a high match

between our pattern and a part of the image

Example pattern

Image

Find matches

DTU Compute

2122018Introduction to Medical Image Analysis25 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise

Kernel

Signal (1D image)

41

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
A 0
B 12
C 1
D 0
E 0
A
B
C
D
E
Page 25: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Chart1

0
12
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis23 DTU Compute Technical University of Denmark

Correlation What is it Two measurements

ndash Low correlationndash High correlation

High correlation means that there is a relation between the values

They look the same Correlation is a measure of

similarity

Low

High

Muscles

Mat

h Ski

lls

Muscles

Ben

ch P

ress

DTU Compute

2122018Introduction to Medical Image Analysis24 DTU Compute Technical University of Denmark

Why do we need similarity Image analysis is also about recognition of patterns Often an example pattern is used We need something to tell us if there is a high match

between our pattern and a part of the image

Example pattern

Image

Find matches

DTU Compute

2122018Introduction to Medical Image Analysis25 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise

Kernel

Signal (1D image)

41

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
A 0
B 12
C 1
D 0
E 0
A
B
C
D
E
Page 26: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis23 DTU Compute Technical University of Denmark

Correlation What is it Two measurements

ndash Low correlationndash High correlation

High correlation means that there is a relation between the values

They look the same Correlation is a measure of

similarity

Low

High

Muscles

Mat

h Ski

lls

Muscles

Ben

ch P

ress

DTU Compute

2122018Introduction to Medical Image Analysis24 DTU Compute Technical University of Denmark

Why do we need similarity Image analysis is also about recognition of patterns Often an example pattern is used We need something to tell us if there is a high match

between our pattern and a part of the image

Example pattern

Image

Find matches

DTU Compute

2122018Introduction to Medical Image Analysis25 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise

Kernel

Signal (1D image)

41

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
A 0
B 12
C 1
D 0
E 0
Page 27: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis23 DTU Compute Technical University of Denmark

Correlation What is it Two measurements

ndash Low correlationndash High correlation

High correlation means that there is a relation between the values

They look the same Correlation is a measure of

similarity

Low

High

Muscles

Mat

h Ski

lls

Muscles

Ben

ch P

ress

DTU Compute

2122018Introduction to Medical Image Analysis24 DTU Compute Technical University of Denmark

Why do we need similarity Image analysis is also about recognition of patterns Often an example pattern is used We need something to tell us if there is a high match

between our pattern and a part of the image

Example pattern

Image

Find matches

DTU Compute

2122018Introduction to Medical Image Analysis25 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise

Kernel

Signal (1D image)

41

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
Page 28: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis24 DTU Compute Technical University of Denmark

Why do we need similarity Image analysis is also about recognition of patterns Often an example pattern is used We need something to tell us if there is a high match

between our pattern and a part of the image

Example pattern

Image

Find matches

DTU Compute

2122018Introduction to Medical Image Analysis25 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise

Kernel

Signal (1D image)

41

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
Page 29: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis25 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise

Kernel

Signal (1D image)

41

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
Page 30: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis26 DTU Compute Technical University of Denmark

Correlation (1D)

1 1 2 2 1 1 2 2 1 1

1 2 1

45

47

47

45

45

47

47

45

41

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
Page 31: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis27 DTU Compute Technical University of Denmark

Normalisation

1 1 2 2 1 1 2 2 1 1

1 2 1

45

41

1 1 + 2 1 + 1 2 = 5

Normalise41

bull The sum of the kernel elements is used

bull Keep the values in the same range as the input image

Sum is 4

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
Page 32: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis28 DTU Compute Technical University of Denmark

Normalisation Normalisation factor

ndash Sum of kernel coefficients

1 2 1h(x)

119909119909

ℎ 119909119909 = 1 + 2 + 1

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
Page 33: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis29 DTU Compute Technical University of Denmark

Correlation on images The filter is now 2D 1 1 1

1 1 1

1 1 1

0 2 4

1 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

912

91

Input OutputKernel

Kernel coefficients

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
Page 34: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis30 DTU Compute Technical University of Denmark

Correlation on images

1 1 11 1 11 1 1

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

912

911

91

Input Output

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
Page 35: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis31 DTU Compute Technical University of Denmark

Correlation on images

Input Output

The mask is moved row by row

No values at the border

0 2 4

1 2 2

1 6 3

1 2 0

2 1 4

1 0 1

1 3 1

2 2 2

0 1 3

1 2 12 5 3

2 1 3

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
Page 36: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis32 DTU Compute Technical University of Denmark

1 2 1

1 3 1

1 2 1

-1 -2 -1

0 0 0

1 2 1

Draw your filter

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
Page 37: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis33 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisationA) 4B) 7C) 16D) 23E) 25

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 11 0

14

0 0

A B C D E

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
Page 38: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Chart1

1
0
14
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
A
B
C
D
E
Page 39: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
A 1
B 0
C 14
D 0
E 0
Page 40: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis34 DTU Compute Technical University of Denmark

Correlation on images ndash no normalisation 2A) 010B) 3 3C) 6 2D) 10 15E) 11 32

13

0 0 0 0

A B C D E

-1 -2 -10 0 01 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
Page 41: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Chart1

13
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
A
B
C
D
E
Page 42: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
A 13
B 0
C 0
D 0
E 0
Page 43: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis37 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

h

f

Correlation operator

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

119892119892 119909119909119910119910 = 119891119891 119909119909119910119910 ∘ ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
Page 44: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis38 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

fh(00)

f(21)

Example g(21)

i = -1 j = -1

i = 1 j = 0

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
Page 45: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis39 DTU Compute Technical University of Denmark

Mathematics of 2D Correlation

1 2 11 3 11 2 1

0 2 4

1 2 2

1 6 3

1 2 1

2 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

h

f

119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892(119909119909119910119910 = 1 2 + 2 0 + 1 1 + 1 1 + 3 4 + 1 2 + 1 0 + 2 1 + 1 0

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
Page 46: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis40 DTU Compute Technical University of Denmark

119892119892 119909119909 119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

119892119892 22 =ℎ minus1minus1 sdot 119891119891 11 + ℎ 0minus1 sdot 119891119891 21 + ℎ 1minus1 sdot 119891119891 31 +ℎ minus10 sdot 119891119891 12 + ℎ 00 sdot 119891119891 22 + ℎ 10 sdot 119891119891 32 +ℎ minus11 sdot 119891119891 13 + ℎ 01 sdot 119891119891 23 + ℎ 11 sdot 119891119891 33

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
Page 47: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis41 DTU Compute Technical University of Denmark

2D Kernel Normalisation

1 2 11 3 11 2 1

h

Normalisation factor

1 + 2 + 1 + 1 + 3 + 1 + 1 + 2 + 1 = 13

119909119909

119910119910

ℎ(119909119909119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
Page 48: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis42 DTU Compute Technical University of Denmark

CorrelationA) 50122B) 123001C) 11233D) 2550E) 90454

0 0 0 0

13

A B C D E

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
Page 49: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Chart1

0
0
0
0
13

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
A
B
C
D
E
Page 50: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
A 0
B 0
C 0
D 0
E 13
Page 51: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis44 DTU Compute Technical University of Denmark

Smoothing filters

Also know as ndash Smoothing kernel Mean filter Low pass filter blurring

The simplest filter ndash Spatial low pass filterndash Removes high frequencies

Another mask ndash Gaussian filter

1 1 1

1 1 1

1 1 191

1 2 1

2 4 2

1 2 1161

Why Gaussian

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
Page 52: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis45 DTU Compute Technical University of Denmark

Use of smoothing

3x3 7x7 11x11 15x15

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
Page 53: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis46 DTU Compute Technical University of Denmark

Use of smoothing Large kernels smooth more Removes high frequency information Good at enhancing big structures

3x3 15x15

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
Page 54: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis47 DTU Compute Technical University of Denmark

Mean filterA) 166B) 113C) 12D) 51E) 245

0 0 0 0

A B C D E

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
Page 55: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Chart1

12
0
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
A
B
C
D
E
Page 56: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
A 12
B 0
C 0
D 0
E 0
Page 57: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis49 DTU Compute Technical University of Denmark

Border handling

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input Output

No values at the border

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
Page 58: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis50 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

0 0 0 0 000000

bull Zero padding ndash what happens

bull Zero is black ndash creates dark border around the image

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
Page 59: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis51 DTU Compute Technical University of Denmark

Correlation with zero paddingA) 5 8B) 12 16C) 13 3D) 15 21E) 17 12

1 2 11 3 11 2 1

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

0

13

0 0 0

A B C D E

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
Page 60: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Chart1

0
13
0
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
A
B
C
D
E
Page 61: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
A 0
B 13
C 0
D 0
E 0
Page 62: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis53 DTU Compute Technical University of Denmark

Border handling ndash extend the input

0 2 41 2 2

1 6 3

1 2 12 5 3

2 1 3

1 3 1

2 2 2

0 1 3

1 2 0

2 1 4

1 0 1

Input

1 2 0 1 311211

bull Reflection

bull Normally better than zero padding

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
Page 63: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis54 DTU Compute Technical University of Denmark

Template Matching Template

ndash Skabelon paring dansk Locates objects in images

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
Page 64: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis55 DTU Compute Technical University of Denmark

Template Matching The correlation between the template and the input

image is computed for each pixel

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
Page 65: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis56 DTU Compute Technical University of Denmark

Template Matching The pixel with the highest value is found in the

output imagendash Here is the highest correlation

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
Page 66: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis57 DTU Compute Technical University of Denmark

Template Matching This corresponds to the found pattern in the input

image

Input

Template

Output Correlation image

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
Page 67: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis58 DTU Compute Technical University of Denmark

Problematic Correlation Correlation matching has problem with light areas ndash

why

Input (f)

Template (h)

Output Correlation imageFake max

Real max

Very High119892119892 119909119909119910119910 = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) 119891119891(119909119909 + 119894119894119910119910 + 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
Page 68: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis59 DTU Compute Technical University of Denmark

Normalised Cross Correlation

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
Page 69: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis60 DTU Compute Technical University of Denmark

Length of template Vector length

ndash Put all pixel values into a vectorndash Compute the length of this vector

Describes the intensity of the templatendash Bright template has a large lengthndash Dark template has a small length

Template (h)

Length of template = 119895119895=minus119877119877

119877119877

119894119894=minus119877119877

119877119877

ℎ(119894119894 119895119895) ℎ(119894119894 119895119895)

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
Page 70: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis61 DTU Compute Technical University of Denmark

Length of image patch Vector length based on pixel values in image patch Describes the intensity of the image patch

Template (h)

Input (f) with patch

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
Page 71: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis62 DTU Compute Technical University of Denmark

Normalised Cross Correlation The length of the image patch and the length of

template normalise the NCC If the image is very bright the NCC will be ldquopulled

downrdquo

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
Page 72: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis63 DTU Compute Technical University of Denmark

Normalised Cross Correlation NCC will be between

ndash 0 No similarity between template and image patchndash 1 Template and image patch are identical

Input (f)

Template (h)

Output Correlation image

Real max

NCC x y =Correlation

Length of image patch sdot Length of template

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
Page 73: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis64 DTU Compute Technical University of Denmark

Normalised Cross Correlation

A) 010B) 033C) 083D) 062E) 098

Der udfoslashres template matching med og normalized crosscorrelation (NCC) beregnes Hvad bliver NNC i den markerede pixel

1

2 2

3

2

A B C D E

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
Page 74: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Chart1

1
2
2
3
2

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
A
B
C
D
E
Page 75: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
A 1
B 2
C 2
D 3
E 2
Page 76: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis66 DTU Compute Technical University of Denmark

Edges An edge is where there is a

high change in gray level values

Objects are often separated from the background by edgesGray level profile

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
Page 77: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis67 DTU Compute Technical University of Denmark

Edges The profile as a function f(d) What value is high when there

is an edgendash The slope of fndash The slope of the tangent at d

f(d)

119891119891prime(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
Page 78: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis68 DTU Compute Technical University of Denmark

Finite Difference Definition of slope

Approximation

Simpler approximationh = 1

119891119891prime 119889119889 = limℎrarr0

119891119891 119889119889 + ℎ minus 119891119891(119889119889)ℎ

119891119891prime 119889119889 asymp119891119891 119889119889 + ℎ minus 119891119891(119889119889)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
Page 79: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis69 DTU Compute Technical University of Denmark

Edges Discrete approximation of frsquo(d) Can be implemented as a filter

-1 0 1

f(d-2) f(d-1) f(d) f(d+1) f(d+2) f(d+3)

f(d)

119891119891prime 119889119889 asymp 119891119891 119889119889 + 1 minus 119891119891(119889119889)

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
Page 80: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis70 DTU Compute Technical University of Denmark

Edges in 2D Changes in gray level values

ndash Image gradientndash Gradient is the 2D derivative of a 2D function f(xy)ndash Equal to the slope of the imagendash A steep slope is equal to an edge

120571120571119891119891 119909119909119910119910 = 119866(119892119892119909119909119892119892119910119910)

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
Page 81: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis71 DTU Compute Technical University of Denmark

Edge filter kernel The Prewitt filter is a typical

edge filter Output image has high

values where there are edges

-1 0 1

-1 0 1

-1 0 1Vertical Prewitt filter

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
Page 82: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis72 DTU Compute Technical University of Denmark

Prewitt filter

Original Prewitt Prewitt

Hot colormapSmooth 15x15

Smooth 15x15

Prewitt

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
Page 83: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis73 DTU Compute Technical University of Denmark

Edge detection Edge filter

ndash Prewitt for example Thresholding

ndash Separate edges from non-edges

Output is binary imagendash Edges are white

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
Page 84: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis74 DTU Compute Technical University of Denmark

Edge filtering

A) MeanB) Horizontal SobelC) Vertical PrewittD) Horisontal PrewittE) Median

Der udfoslashres en filtrering (correlation) med et filter paring billedet Der bruges ikke coefficient normalization Den filtrerede vaeligrdi i den markerede pixel bliver -119 Hvilket et 3x3 filter blev benyttet

0

8

1 10

A B C D E

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
Page 85: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Chart1

0
8
1
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
A
B
C
D
E
Page 86: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
A 0
B 8
C 1
D 1
E 0
Page 87: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis76 DTU Compute Technical University of Denmark

02511 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

23

6

10

A B C D E

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
Page 88: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Chart1

2
3
6
1
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
A
B
C
D
E
Page 89: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
A 2
B 3
C 6
D 1
E 0
Page 90: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis77 DTU Compute Technical University of Denmark

02512 - Niveau af dagens emne forelaeligsingA) Meget letB) LetC) PassendeD) SvaeligrtE) Meget svaeligrt

0 0

1

0 0

A B C D E

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
Page 91: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Chart1

0
0
1
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
A
B
C
D
E
Page 92: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
A 0
B 0
C 1
D 0
E 0
Page 93: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis78 DTU Compute Technical University of Denmark

02511 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

0 0

2

6

0

A B C D E

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
Page 94: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Chart1

0
0
2
6
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
A
B
C
D
E
Page 95: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
A 0
B 0
C 2
D 6
E 0
Page 96: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis79 DTU Compute Technical University of Denmark

02512 - Mit eget udbytte af dagenA) Jeg har laeligrt meget lidtB) Lidt laeligringC) PassendeD) God laeligringE) Jeg har laeligrt meget

2

1

3

2

0

A B C D E

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
Page 97: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Chart1

2
1
3
2
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
A
B
C
D
E
Page 98: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
A 2
B 1
C 3
D 2
E 0
Page 99: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis80 DTU Compute Technical University of Denmark

02511 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

0 0

1

4

1

A B C D E

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
Page 100: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Chart1

0
0
1
4
1

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
A
B
C
D
E
Page 101: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
A 0
B 0
C 1
D 4
E 1
Page 102: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis81 DTU Compute Technical University of Denmark

02512 - Sidste uges oslashvelser (pixelwiseoperations)A) Meget letteB) LetteC) PassendeD) SvaeligreE) Meget svaeligre

3

0

3

0 0

A B C D E

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
Page 103: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Chart1

3
0
3
0
0

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
A
B
C
D
E
Page 104: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
A 3
B 0
C 3
D 0
E 0
Page 105: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis82 DTU Compute Technical University of Denmark

Denne uges brug af clickersA) click click click ndash jeg bliver

sindssygB) For meget clickC) PassendeD) Jeg vil gerne have lidt mereE) Jeg kan ikrsquo faring nok

0 0

5

0

6

A B C D E

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
Page 106: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Chart1

0
0
5
0
6

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
A
B
C
D
E
Page 107: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

Sheet1

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
A 0
B 0
C 5
D 0
E 6
Page 108: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis83 DTU Compute Technical University of Denmark

What can you do after today Describe the difference between point processing and neighbourhood

processing Compute a rank filtered image using the min max median and

difference rank filters Compute a mean filtered image Decide if median or average filtering should be used for noise removal Choose the appropriate image border handling based on a given input

image Implement and apply template matching Compute the normalised cross correlation and explain why it should be

used Apply given image filter kernels to images Use edge filters on images Describe finite difference approximation of image gradients Describe the concept of edge detection

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
Page 109: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis84 DTU Compute Technical University of Denmark

Oslashvelsesrapport over oslashvelse 4 - 02511 Oslashvelser taeligller cirka 30 af karakteren Skal afleveres senest den 7 marts kl 2359 Kan afleveres af 1 eller 2 personer

ndash I skal skrive jeres egen oslashvelsesrapportndash Brug mindst et af jeres egne billeder

Afleveres som PDF Lad vaeligre med at kopiere opgaveteksten ind i jeres

opgave Put Matlab kode i et Appendix og henvis fra teksten Eksempel rapport over oslashvelse findes paring

hjemmesiden under eksamen

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises
Page 110: Introduction to Medical Image Analysis - compute.dtu.dk - week4.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical Image Analysis 21/2/2018

DTU Compute

2122018Introduction to Medical Image Analysis85 DTU Compute Technical University of Denmark

Exercises

  • Introduction to Medical Image Analysis
  • Lecture 4 ndash Neighbourhood Processing
  • What can you do after today
  • Point processing
  • Point processing
  • Neighbourhood processing
  • Use of filtering
  • Salt and pepper noise
  • Salt and pepper noise
  • What is so special about noise
  • Noise ndash go away
  • What is the median Value
  • The median value
  • Noise away ndash the median filter
  • Noise removal ndash average filter
  • Noise removal ndash median filter
  • Image Filtering
  • Median filter
  • Rank filters
  • Median filter
  • Correlation
  • Why do we need similarity
  • Correlation (1D)
  • Correlation (1D)
  • Normalisation
  • Normalisation
  • Correlation on images
  • Correlation on images
  • Correlation on images
  • Draw your filter
  • Correlation on images ndash no normalisation
  • Correlation on images ndash no normalisation 2
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Mathematics of 2D Correlation
  • Slide Number 40
  • 2D Kernel Normalisation
  • Correlation
  • Smoothing filters
  • Use of smoothing
  • Use of smoothing
  • Mean filter
  • Border handling
  • Border handling ndash extend the input
  • Correlation with zero padding
  • Border handling ndash extend the input
  • Template Matching
  • Template Matching
  • Template Matching
  • Template Matching
  • Problematic Correlation
  • Normalised Cross Correlation
  • Length of template
  • Length of image patch
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Normalised Cross Correlation
  • Edges
  • Edges
  • Finite Difference
  • Edges
  • Edges in 2D
  • Edge filter kernel
  • Prewitt filter
  • Edge detection
  • Edge filtering
  • 02511 - Niveau af dagens emne forelaeligsing
  • 02512 - Niveau af dagens emne forelaeligsing
  • 02511 - Mit eget udbytte af dagen
  • 02512 - Mit eget udbytte af dagen
  • 02511 - Sidste uges oslashvelser (pixelwise operations)
  • 02512 - Sidste uges oslashvelser (pixelwise operations)
  • Denne uges brug af clickers
  • What can you do after today
  • Oslashvelsesrapport over oslashvelse 4 - 02511
  • Exercises