Professional Documents
Culture Documents
Introduction
Image pre-processing
• Histogram
• Binarization
• Filters
Templates
Background
Why machine vision?
Image processing
1970s: viewed as the visual perception component of an ambitious agenda to mimic human's
intelligence to endow the robots with intelligent behaviour
1980s: a lot of attention was focused on more sophisticated mathematical techniques for
performing quantitative image and scene analysis.
1990: Increased interaction with computer graphics, especially in the cross-disciplinary area of
image-based modeling and rendering.
2000: One trend, which now dominates a lot of the visual recognition research, is the application
of sophisticated machine learning techniques to computer vision problems
Completeness check
https://www.mvtec.com/company/reference/detail/industrial-inspection-line-scan-based-vision-system-tackles-
color-print-inspection-daheng-image-v/
Image system
Sensors
Single image sensor
Line sensor
Array sensor
Cameras
• CCD
• Charge-coupled devices
• Has been used for 30 years
• 2009 års Nobel winner in physics, Willard Boyle and George Smith,
• CMOS
• Complementary metal-oxide semiconductor
• Used since 90’s
• Less power when CCD cameras
Principle CCD
Principle structure of a
interline transfer CCD
CC 2.5 Michael Schmid, wiki
Principle CMOS
P[m,n]
Pixel resolution
2 ways to define pixel resolution
• With the set of two positive integer
numbers, the number of pixel columns
(width) and the number of pixel rows
(height), for example as 2048 × 1536.
• With the total number of pixels in the
image, typically given as the number of
megapixels, calculated by multiplying
pixel columns by pixel rows and dividing
by one million.
• Example: An image that is 2048 pixels in
width and 1536 pixels in height has a total
of 2048×1536 = 3,145,728 pixels or 3.1
megapixels. Image resolution can be
either 2048 × 1536 or a 3.1-megapixel.
Light
Spectroscopy of
welding
• Bit depth
• The bit depth of a image quantifies how many unique colors are available in a
image color pallet. For a gray scale image it determines how many shades of
gray.
• Image Channels
• The available color channels for a image, normally 3 red, green and blue.
• Fourth channels handles transparacy
RGB colour system
• Images
• Normal bit depth for bmp, jpg and other images is 24. This gives 8-bits per
channel and is often referred to as “true colour”
Other color models
• HSI
• Hue, Saturation, Intensity
• Describing colors practical human interpretation
Grey scale transformation
• Average
Colour image
• Weighted average
Weighted grey scale (Red)
g = .7*r + .15*g + 0.15*b
Can be customized
Red
Colour to
Green
grey scale
Blue
= 122
120
Grey
Red
Colour to
Green
grey scale
Blue
Grey
Example grey scale
transformation
131 243 80 58
254 193 73 199
242 218 51 157
128 140 102 74
239 112 117 227
189
217
63
245
87
228
169
137
Use both weighted
244 69 150 62 and average grey
113 225 22 159
159 252 34 153 scale transformation
Pre-processing
Type of operation
input output
• Point operation:
• the output value at a specific
coordinate is dependent only on the
input value at that same coordinate.
• Local operation:
• the output value at a specific input output
coordinate is dependent on the input
values in the neighbourhoods of that
same coordinate.
Type of operation
13 10 18 10 9 9
10 10 100 100 10 8
1 10 100 102 1 10
12 100 98 103 12 11
14 103 99 100 14 40
12 104 105 101 12 60
10 10 10 10 65 70
Global Threshold,
example
0-25 18 20
18
26-50 1 16
51-75 3 14
12
76-100 6 10
101-125 6 8
6
125-150 0 4
151-175 0 2
0
176-200 0
- 25 -50 -75 100 125 150 175 200 225 255
201-225 0 0 26 51 6- 1- 5- 1- 6- 1- 6-
7 10 12 15 17 20 22
226-255 0
Global Threshold,
example
T=50
0 0 0 0 0 0
0 0 1 1 0 0
0 0 1 1 0 0
0 1 1 1 0 0
0 1 1 1 0 0
0 1 1 1 0 1
0 0 0 0 1 1
T=80
0 0 0 0 0 0
0 0 1 1 0 0
0 0 1 1 0 0
0 1 1 1 0 0
0 1 1 1 0 0
0 1 1 1 0 0
0 0 0 0 0 0
Example
microstructure
imgo = imread('TM3000_1332(x7,0k).tif');
imgc = imcrop(imgo, [1 1 1275 947]);
histogram(imgc)
imgb = imbinarize(imgc);
figure
imshowpair(imgc,imgb,'montage')
%%
thresh = multithresh(imgc,1);
seg_I = imquantize(imgc,thresh);
RGB = label2rgb(seg_I);
figure;
imshow(RGB)
axis off
title('RGB Segmented Image')
(1-sum(sum(imgb))/948/1276)/…
(sum(sum(imgb))/948/1276)
Matlab code
Example
microstructure
10 4
2.5
1.5
0.5
0
0 50 100 150 200 250
Converted grey scale image
Histogram of the image to black and white image
Example
microstructure
RGB Segmented Image
https://en.wikipedia.org/wiki/Lenna
Filter
• Linear filter
• Weighted sums
• Gaussian smoothing filter
• Non linear filter
• Everything else such as Median filter
Types of neibourhood
4 neighbours 8 neighbours
Moving window
Input image
Filter kernel
Output image
Moving window
Border effects
9
Smoothing filter
Input image
Input image Output image
Output image
19 9 12 19 1 7 19
5 24 20 93 1 128 20 25 35 21 33 24
16 105 17 18 12 19 10 26 36 23
23 6 16 22 8 15 20
24 22 5 3 17 12 20
6 18 214 213 218 19 11
7 6 222 223 210 9 4
16 2 214 211 212 24 21
15 14 221 209 215 5 1
18 19 212 221 221 2 6
5 16 221 213 203 16 1
12 19 20 19 17 116 23
18 19 9 8 14 11 0
20 21 21 15 2 12 3
Smoothing filter
Colour 2 grey
Original image 3x3 filter
Gaussian
3x3 filter
Gaussian
5x5 filter
Gaussian filter
Original image
Filtered image
Median filter
• Main problem with mean filters is that they tend to blur sharp
discontinuities in the image
• Median filter are effective in removing salt and pepper noise
• Sort the pixels into ascending order by grey level
• Select the value of the middle pixel as the new value for pixel [i,j]
• Time consuming due to the sorting of all pixels
Median filter
130
New pixel value
Median filter
Mean filter
Original image
Gaussian filter
Median filter
Example
19 9 12 19 1 7 19
5 24 20 93 1 128 20
16 105 17 18 12 19 10
23 6 16 22 8 15 20
24 22 5 3 17 12 8
6 18 214 213 218 19 11
7 6 222 223 210 9 4
16 2 214 211 212 24 21
15 14 221 209 215 5 1
18 19 212 221 221 2 6
5 16 221 213 203 16 1
12 19 20 19 17 116 23
18 19 9 8 14 11 0
20 21 21 15 2 12 3
Image arithmetic
• Linear scaling
Example subtraction
Correct
• Point operation
• Using the full range of the grey scale
• Can remove effects from the camera system