Convolution. Why? Image processing Remove noise from images (e.g. poor transmission (from space),...
-
Upload
carley-whittingham -
Category
Documents
-
view
215 -
download
0
Transcript of Convolution. Why? Image processing Remove noise from images (e.g. poor transmission (from space),...
![Page 1: Convolution. Why? Image processing Remove noise from images (e.g. poor transmission (from space), measurement (X-Rays))](https://reader030.fdocuments.us/reader030/viewer/2022032701/56649c765503460f94929eeb/html5/thumbnails/1.jpg)
Convolution
![Page 2: Convolution. Why? Image processing Remove noise from images (e.g. poor transmission (from space), measurement (X-Rays))](https://reader030.fdocuments.us/reader030/viewer/2022032701/56649c765503460f94929eeb/html5/thumbnails/2.jpg)
Why?
• Image processing
• Remove noise from images (e.g. poor transmission (from space), measurement (X-Rays))
![Page 3: Convolution. Why? Image processing Remove noise from images (e.g. poor transmission (from space), measurement (X-Rays))](https://reader030.fdocuments.us/reader030/viewer/2022032701/56649c765503460f94929eeb/html5/thumbnails/3.jpg)
Edge Detection
• e.g. could digitally extract brain for display
• could check if machined parts are correct
![Page 4: Convolution. Why? Image processing Remove noise from images (e.g. poor transmission (from space), measurement (X-Rays))](https://reader030.fdocuments.us/reader030/viewer/2022032701/56649c765503460f94929eeb/html5/thumbnails/4.jpg)
How does it work?
• Lets use a grey image for ease
• Each pixel has a single value between 0 (black) and 255 (white)
![Page 5: Convolution. Why? Image processing Remove noise from images (e.g. poor transmission (from space), measurement (X-Rays))](https://reader030.fdocuments.us/reader030/viewer/2022032701/56649c765503460f94929eeb/html5/thumbnails/5.jpg)
Filter Kernel
• Now select a filter kernel
• e.g. Gaussian blur (removes noise)
• For each pixel in the image
• Can the kernel be centred over the pixel?
• If so, calculate the sum of the products
![Page 6: Convolution. Why? Image processing Remove noise from images (e.g. poor transmission (from space), measurement (X-Rays))](https://reader030.fdocuments.us/reader030/viewer/2022032701/56649c765503460f94929eeb/html5/thumbnails/6.jpg)
Filter Kernel
• Now select a filter kernel
• e.g. Gaussian blur (removes noise)
• For each pixel in the image
• Can the kernel be centred over the pixel?
• If so, calculate the sum of the products1 3 1
3 9 3
1 3 1
Sum=1x100+3x110+1x120+ 3x120+9x120+3x130+ 1x130+3x140+1x150 = 3080
![Page 7: Convolution. Why? Image processing Remove noise from images (e.g. poor transmission (from space), measurement (X-Rays))](https://reader030.fdocuments.us/reader030/viewer/2022032701/56649c765503460f94929eeb/html5/thumbnails/7.jpg)
Filter Kernel
• Now select a filter kernel
• e.g. Gaussian blur (removes noise)
• For each pixel in the image
• Can the kernel be centred over the pixel?
• If so, calculate the sum of the products1 3 1
3 9 3
1 3 1
Sum=1x110+3x120+1x130+ 3x120+9x130+3x130+ 1x140+3x150+1x150 = 3260
![Page 8: Convolution. Why? Image processing Remove noise from images (e.g. poor transmission (from space), measurement (X-Rays))](https://reader030.fdocuments.us/reader030/viewer/2022032701/56649c765503460f94929eeb/html5/thumbnails/8.jpg)
Filter Kernel
• Now select a filter kernel
• e.g. Gaussian blur (removes noise)
• For each pixel in the image
• Can the kernel be centred over the pixel?
• If so, calculate the sum of the products1 3 1
3 9 3
1 3 1
Sum=1x120+3x130+1x140+ 3x130+9x130+3x140+ 1x150+3x150+1x160 = 3390
![Page 9: Convolution. Why? Image processing Remove noise from images (e.g. poor transmission (from space), measurement (X-Rays))](https://reader030.fdocuments.us/reader030/viewer/2022032701/56649c765503460f94929eeb/html5/thumbnails/9.jpg)
Filter Kernel
• Now select a filter kernel
• e.g. Gaussian blur (removes noise)
• For each pixel in the image
• Can the kernel be centred over the pixel?
• If so, calculate the sum of the products
1 3 1
3 9 3
1 3 1
Sum=1x120+3x120+1x130+ 3x130+9x140+3x150+ 1x140+3x150+1x150 = 3450
![Page 10: Convolution. Why? Image processing Remove noise from images (e.g. poor transmission (from space), measurement (X-Rays))](https://reader030.fdocuments.us/reader030/viewer/2022032701/56649c765503460f94929eeb/html5/thumbnails/10.jpg)
Filter Kernel
• Now select a filter kernel
• e.g. Gaussian blur (removes noise)
• For each pixel in the image
• Can the kernel be centred over the pixel?
• If so, calculate the sum of the products
1 3 1
3 9 3
1 3 1
* * * * *
* 3080 3260 3390 *
* 3450 3620 3740 *
* 3720 3870 4060 *
* * * * *
Result
![Page 11: Convolution. Why? Image processing Remove noise from images (e.g. poor transmission (from space), measurement (X-Rays))](https://reader030.fdocuments.us/reader030/viewer/2022032701/56649c765503460f94929eeb/html5/thumbnails/11.jpg)
*What about the edges?
• * indicates filter could not be centred
• 3x3 = 1 pixel edge all the way around
• 5x5 = 2 pixels edge all the way around
• 4x4 = ? 1 edge top and left, and 2 bottom and right OR some variant on that
• nxm = ? Coursework!* * * * *
* 3080 3260 3390 *
* 3450 3620 3740 *
* 3720 3870 4060 *
* * * * *
![Page 12: Convolution. Why? Image processing Remove noise from images (e.g. poor transmission (from space), measurement (X-Rays))](https://reader030.fdocuments.us/reader030/viewer/2022032701/56649c765503460f94929eeb/html5/thumbnails/12.jpg)
*What about the edges?
• Reduce size of image – but could be counter intuitive for users (good)
• Put a single colour border (OK)• Use old pixel values (not sensible for edge
detectors) (OK)• Use known neighbours colour (Very good)• Use some fudge (e.g. have some special
filters reduced in size so they can fit against the edges when needed) (V Good)
![Page 13: Convolution. Why? Image processing Remove noise from images (e.g. poor transmission (from space), measurement (X-Rays))](https://reader030.fdocuments.us/reader030/viewer/2022032701/56649c765503460f94929eeb/html5/thumbnails/13.jpg)
Aren’t those numbers too big?
• Yes, they are no longer in the range 0-255• We could even have negative numbers
(for a high pass filter)• So we need to map the new numbers onto
our range 0-255• First calculate the max and min values• max=4060, min=3080
* * * * *
* 3080 3260 3390 *
* 3450 3620 3740 *
* 3720 3870 4060 *
* * * * *
* * * * *
* 0 47 81 *
* 96 141 172 *
* 167 206 255 *
* * * * *
• Then for each intermediatevalue I, calculateI’=((I-min)*255)/(max-min)
![Page 14: Convolution. Why? Image processing Remove noise from images (e.g. poor transmission (from space), measurement (X-Rays))](https://reader030.fdocuments.us/reader030/viewer/2022032701/56649c765503460f94929eeb/html5/thumbnails/14.jpg)
And colour?140 150 150 128 130
120 110 100 120 120
120 130 150 140 145
147 168 165 162 160
150 170 167 167 165
120 130 130 108 110
110 105 87 80 78
90 85 82 82 81
80 82 85 86 89
92 95 100 101 102
14 15 15 12 13
12 11 10 12 12
12 13 15 14 14
20 21 22 23 26
19 18 16 20 21
1 3 1
3 9 3
1 3 1
1 3 1
3 9 3
1 3 1
1 3 1
3 9 3
1 3 1
Calculate sum of products for each colour channel independentlyNormalise as before, but replace red with new red, etc.
![Page 15: Convolution. Why? Image processing Remove noise from images (e.g. poor transmission (from space), measurement (X-Rays))](https://reader030.fdocuments.us/reader030/viewer/2022032701/56649c765503460f94929eeb/html5/thumbnails/15.jpg)
What about the filters?• Low pass 3x3 box filter (nxm box
filter has size nxm with all 1’s). The bigger the filter, the larger the blur (and time – think about that)
• High pass filter (like sharpen in Photoshop
• Sobel edge detectors – X-direction and Y-direction
![Page 16: Convolution. Why? Image processing Remove noise from images (e.g. poor transmission (from space), measurement (X-Rays))](https://reader030.fdocuments.us/reader030/viewer/2022032701/56649c765503460f94929eeb/html5/thumbnails/16.jpg)
![Page 17: Convolution. Why? Image processing Remove noise from images (e.g. poor transmission (from space), measurement (X-Rays))](https://reader030.fdocuments.us/reader030/viewer/2022032701/56649c765503460f94929eeb/html5/thumbnails/17.jpg)
Low Pass Filter - Gaussian7x7
3x3
Where do thesenumbers comefrom?
![Page 18: Convolution. Why? Image processing Remove noise from images (e.g. poor transmission (from space), measurement (X-Rays))](https://reader030.fdocuments.us/reader030/viewer/2022032701/56649c765503460f94929eeb/html5/thumbnails/18.jpg)
Gaussian
• 1 dimensional
• G(x)=e-(x2/2σ2)
• In Excel power(exp(1), -(x*x/2*σ*σ))
0
0.2
0.4
0.6
0.8
1
1.2
-5
-4.6
-4.2
-3.8
-3.4 -3
-2.6
-2.2
-1.8
-1.4 -1
-0.6
-0.2 0.2
0.6 1
1.4
1.8
2.2
2.6 3
3.4
3.8
4.2
4.6 5
Series2
2σ
![Page 19: Convolution. Why? Image processing Remove noise from images (e.g. poor transmission (from space), measurement (X-Rays))](https://reader030.fdocuments.us/reader030/viewer/2022032701/56649c765503460f94929eeb/html5/thumbnails/19.jpg)
Gaussian
• 2D
• G(x,y)=e-((x2+y2)/2σ2) -5
-4.1
-3.2
-2.3
-1.4
-0.5
0.4
1.3
2.2
3.1 4
4.9
S1
S25
S49
S73
S97
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
0.9-1
0.8-0.9
0.7-0.8
0.6-0.7
0.5-0.6
0.4-0.5
0.3-0.4
0.2-0.3
0.1-0.2
0-0.1