Lecture-4
Lecture-4
Dr Abel Zhou
[email protected]
Contents prepared by Prof Rob Davidson
[email protected]
Grey Scale Digital Images
O(x,y) = p . I(x,y)
where:
I(x,y) is the image
p is the point operation
O(x,y) is the output image
Point Operations
http://www.widescreenmuseum.com/oldcolor/additive-subtractive.htm
Digital Image Display (Grey Scale)
Concept of grey scale digital images to a colour
display monitor
digital image – I(x,y) inside monitor
(not visible) 3 x LEDs (R,G, B)
Pixel Value
R – intensity of 128
128
G – intensity of 128
B – intensity of 128
display on monitor – O(x,y)
R OUTPUT
G shade of grey
B (value of 128)
Basics of Colour Digital Images
My notation is
Ic (x, y) where Ic is the colour image
Each colour array is often referred to as a “band”
The visible displayed colour is a mix (additive) of
the 3 colour values
– eg blue (0, 0, 255)
Possible no. of colours = 256 x 256 x 256
= 16,777,216
Colour Image Display
Concept of colour digital images to display
Pixel Value digital image inside monitor
I (x,y) 3 x colour arrays (not visible) 3 x colour LEDs (R,G, B)
R = 109
G = 249 R – intensity = 109
B = 65
G – intensity = 249
B – intensity = 65
display on monitor
R OUTPUT
G hue of additive
B colour
red, green & blue colour bands
5 x 1.5 8
6 x 1.5 9 200
7 x 1.5 11
Displayed Image
8 x 1.5 12 150
9 x 1.5 14
10 x 1.5 15
100
11 x 1.5 17
12 x 1.5 18
50
0
0 50 100 150 200 250
250 x 1.5 255 Stored Im age
251 x 1.5 255
252 x 1.5 255
253 x 1.5 255
254 x 1.5 255 Operations:- x 1.5 calculation x 1 calculation
255 x 1.5 255 (or original image LUT)
Grey scale display
Grey scale images have one band (channel) of
pixel values – uses 1 LUT
The output value from the LUT goes to the 3
LUTs for each RGB colour LED in the monitor
As the intensities of the RGB colour LEDs are
equal, a grey (white → black) colour will be
perceived on the monitor
Displayed greys can be manipulated by altering
the operation of the LUT
Grey scale image display – colour monitor
R G B
Look-up Table Look-up Table Look-up Table
0 10 0 10 0 10
Stored Image Is(x, y) 1 11 1 11 1 11
2 12 2 12 2 12
Pixel Value
3 13 3 13 3 13
4 4 14 4 14 4 14
Displayed grey
displayed value LEDs - monitor
intensity
14 R
14
14 G
14
B
Displayed Image Id(x, y)
Colour display
Colour images have 3 bands (channels) of pixel values and uses 3
LUT’s – 1 for each band
3 pixel values form each band, same x,y coordinates, are the input
values for each RGB LUT.
The output value from the LUT’s goes to the corresponding colour
(RGB) LEDs in the monitor
The values of the intensities of the RGB colour LEDs will often not be
equal, hence a colour (rather than grey) will be perceived on the
monitor
Displayed colours can be manipulated by altering the LUT’s of each
band.
This can be done equally or differently on each colour LUT.
Typically, display of colour images is by a x1 LUT equally on all LUTs
RGB one-on-one (or x 1) LUTs
250 250
250
50 50 50
0 0 0
0 50 100 150 200 250 0 50 100 150 200 250 0 50 100 150 200 250
Colour display
with a change of brightness (+10)
Look-up Table Look-up Table Look-up Table
Stored Image Is(x, y) 0 10 0 10 0 10 to display
1 11 1 11 1 11
2 12 2 12 2 12
R = 109 3 13 3 13 3 13
G = 249 4 14 4 14 4 14
B = 65
200
Red 200
Green 200
Blue
150 150 150
50 50 50
0 0 0
0 50 100 150 200 250 0 50 100 150 200 250 0 50 100 150 200 250
Other colour image formats
To reduce file size, some other colour file formats
have been developed
Colour palettes can be used to replace the 3
separate bands in a “normal” colour image
– these are used in GIF images
The palette is a separate list of colour values, RGB
values (intensities), that are used in that image.
The I (x,y) value “looks up” the value of a colour in
the palette
Image Palette
4 4 4 4 8 4 251
200
Displayed Image
Graphical display of the 150
50
Plot of LUT - Red
Plot of LUT - Green 0
0 50 100 150 200 250
200 200
Straight
Log
Output values
Output values
150
ie. x by 1 150
100 100
50 50
0 0
0 50 100 150 200 250 0 50 100 150 200 250
Input Values Input Values
250 250
200 200
Exponential
Output values
Output values
150 150
/ Level
50 50
0 0
0 50 100 150 200 250 0 50 100 150 200 250
Input Values Input Values
Use of LUT to alter Brightness
Use of LUT to alter Contrast
WW / WL of original image
250
Window Width
=125
200
Output values
150
100
Window Level
(or Centre)
50 = 95
0
0 50 100 150 200 250
Input Values
WW / WL – changed to increase image contrast
250
Window Width
=62
200
Output values
150
100
50 Window Level
= 95
0
0 50 100 150 200 250
Input Values
WW / WL – changed to increase image brightness
250
Window Width
= 125
200
Output values
150
100
50 Window Level
(now 120 )
0
0 50 100 150 200 250
Input Values
Graphical Display of S-Shaped LUTs
typical shapes used in the viewing of CR and DR x-ray images
with changes of brightness and contrast
original image brightness level – Red original image contrast level – Red
image with increased brightness – Blue image with increased contrast – Blue
250
250
200
200
150
150
100
100
50 50
0 0
0 50 100 150 200 250 0 50 100 150 200 250
LUT
Results
Take note of
the image and
displayed
histograms.
Review this
section after
undertaking
the histogram
section
Histograms
Provides
– an indication of distribution of pixels values
– if displayed with a linear LUT, image contrast &
brightness
Can be used to aid in adjustment of image
contrast levels and brightness
Does not provide any information about what
can be perceived within the image, ie. does not
provided any spatial information
900
800
Image Histogram
700
No.
of 600
pixels 500
400
300
200
100
Pixel values
Histogram Stretching
– a display process, through where the histogram is stretched
through the point operation of multiplication or division
– changes the displayed / image contrast
– equivalent to Window Width in MI
Histogram Sliding
– a display process, through where the histogram is altered
through the point operation of addition or subtraction
– changes the displayed / image brightness
– equivalent to Window Level in MI
Histogram Stretching
Histogram Sliding
Histogram Sliding
Image Histogram Operations
Histogram Equalisation
– an automated process that enables a high or low contrast
image to become well balanced contrast image.
– achieved through a ‘non-linear’ process where by some
pixels values are changed at a different rate to others
(operations like x, ÷, +, - are linear operations as the
relative increase is the same across all pixel values)
– not commonly used in medical imaging though is used in
optometry
1
0.9
Non-linear 0.8
LUT
equalisation)
0.5
0.4
0
0 50 100 150 200 250 300
900
1000
800
900
700
800
600
700
500 600
500
400
400
300
300
200
200
100
100
0 0
1000
800
900
700
800
600
700
500 600
500
400
400
300
300
200
200
100
100
0 0
900
800
700 1000
600
500
400
500
300
200
100
0 0
Priya R, Aruna P. Review of automated diagnosis of diabetic retinopathy using the support vector machine.
International Journal of Applied Engineering Research, 1(4), 2011
Other Histogram Information
300
250
200
150
100
50
0
0 50 100 150 200 250
Distance along profile
300 300
250 250
200 200
150 150
100 100
50 50
0 0
0 50 100 150 200 250 0 50 100 150 200 250
Distance along profile Distance along profile
Spatial Domain Processing
Local Operations
Local Operations are primarily used to change spatial
detail or the perceived spatial resolution of the image
A local operation operates on a group pixels ie. they
take into account neighbouring pixel values
At the same time, local operations can alter the image
brightness and / or contrast
Local Operations
Instead of operating on a single pixel like point operators, local
operators operate on a group or neighbourhood of pixels in the
image.
– the size of the neighbourhood can vary
The result of the local operation is a single pixel in the new
image.
The new value must be an integer and fit within the bit depth
(clipping may occur)
An operation on a pixel and its neighbour will mean spatial detail
will change
Local Operation Process
Local Operation Process
– filter or kernel size is selected, usually square. Typical sizes, but
not limited to, are 3x3 or 5x5
– filter operates on the same size area, neighbourhood, in top left
of image
– output value, a single value, is stored in a new pixel location that
would be the centre of the original neighbourhood.
– filter is moved 1 pixel to right, operation occurs and moved until
row completed and moved 1 row down, etc
Local Operation Process
The Local Operation process is denoted by:
O(x,y) = k(a,b) ⊗ I(x,y) where k(a,b) is the kernel
this whole process is known as Convolution
A B C
a general term of k(a,b) (for a 3 x 3 kernel) = D E F
G H I
The first step of this local operation is a 3x3 kernel is placed in top left of
the image
O(x2,y2) = [I(x1,y1) * A] + [I(x1,y2) * B] + [I(x1,y3) * C]
+ [I(x2,y1) * D] + [I(x2,y2) * E] + [I(x2,y3) * F]
+ [I(x3,y1) * G] + [I(x3,y2) * H)] + [I(x3,y3) * I]
Note: * is multiplication
Local Operation Process
I(x,y) Operation 3x3
0 1 2 3 4 5 6 A B C
0 153 216 29 205 70 216 182 D E F
1 121 204 149 218 174 159 232 G H I
2 178 103 201 131 170 216 253
3 242 158 112 47 120 237 176
4
5
45
26
87
175
49
17
97
73
191
27
242
146
98
61 O(x,y)
6 104 229 63 147 247 125 51
0 1 2 3 4 5 6
7 126 20 157 181 166 66 226
0
8 199 153 10 51 202 186 150 1 156
2
3
4
5
6
7
8
Local Operation Process
in this case the operation is as
per the previous slides,
multiply image values by the
kernel value and sum them all
together to get O(x,y).
However there are other types
of kernel operations – more on
this later
Bushberg, JT, Seibert, JA, Leidholdt, EM & Boone, JM 2002, The essential physics of
medical imaging, 2nd edn, Lippincott, Williams and Wilkins, Philadelphia, p.312
An output value of the process is placed in O(x,y) in the
middle of where kernel would be located in O(x,y)
This process is then repeated by moving the kernel 1
column and producing a new output value.
Once this row is completed, the kernel is moved back to
the beginning of the row and 1 row down.
Again, this is repeated until the entire image has been
covered
Local Operation Process
I(x,y) Operation 3x3
0 1 2 3 4 5 6
0 153 216 29 205 70 216 182
1 121 204 149 218 174 159 232
2 178 103 201 131 170 216 253
3 242 158 112 47 120 237 176
4
5
45
26
87
175
49
17
97
73
191
27
242
146
98
61 O(x,y)
6 104 229 63 147 247 125 51
0 1 2 3 4 5 6
7 126 20 157 181 166 66 226
0
8 199 153 10 51 202 186 150 1 156 124
2
3
4
5
6
7
8
Local Operation Process
I(x,y) Operation 3x3
0 1 2 3 4 5 6
0 153 216 29 205 70 216 182
1 121 204 149 218 174 159 232
2 178 103 201 131 170 216 253
3 242 158 112 47 120 237 176
4
5
45
26
87
175
49
17
97
73
191
27
242
146
98
61 O(x,y)
6 104 229 63 147 247 125 51
0 1 2 3 4 5 6
7 126 20 157 181 166 66 226
0
8 199 153 10 51 202 186 150 1 156 124 132
2 178
3
4
5
6
7
8
Local Operation Process
A decision has to be made about the outer row(s) & column(s) of the
new image, O(x,y)
– In process shown previously, no new values of O(x,y) in outer
row / column, then “pad” these with zeros
– Alternative, have filter start outside of original image, I(x,y) and
fill in outer row / column with values
• no values outside of the image exist, so some filter values
would be multiplied by zero. O(x,y) values in outer row /
column will be inaccurate.
Alternate Local Operation Process
I(x,y) Operation 3x3
Original
0.05
0.5
0.04
0.4 0.03
0.3 0.02
0.2 0.01
S7
0.1 0 S4
1 2 3 4 5 6 S1
7
0 8 9
0 2 4 6 8
Surface plot of 9x9 Gaussian Filter
Filter / Kernel Total Value
Spatial domain local operators change local contrast in
the image to change spatial details
Low pass mean filters always have a sum total of their
values of 1
Reason – a sum total will not change overall image
brightness
– A point operation of x by 1 – there is no change to the image
brightness or contrast
– If the sum total of the filter is NOT = 1, then overall image
brightness will change
Original Smoothed & filter sum total = 1 Smoothed & filter sum total = 0.5
Median Filter
The median filter is a low pass filter with its prime
function as “noise” removal, though not all types of
noise
Noise is a random event and typically results in a high
or low pixel values in the image.
– on an image it will appear as black or white dots (sometimes
called a “salt & pepper” appearance)
– this type of noise will be small in size compared to other
objects in the image
– low mAs x-rays will have a similar appearance
– NOTE. There are other types of noise that don’t have this
appearance, eg scatter radiation in x-ray
Noise in images
Median Filter
12 12 13 14 13 14 15
12 (can be other sizes)
12 13 14 254 14 15 13
13
13
to
13 12 13 14 13 14 15
13 ranked order
and
14
12 13 14 13 14 15 13 14
13 14 13 14 15 13 12 14
select the
254
15 13 12 13 14 13 14 median value
13
Noise (254) is
O(x,y)
removed
Comparison - 3x3 Low Pass Mean Filter
I(x,y) 3x3 Filter
12 12 13 14 13 14 15
.111 .111 .111 Low Pass
12 13 14 254 14 15 13
.111 .111 .111 Filter
.111 .111 .111
13 12 13 14 13 14 15
12 13 14 13 14 15 13
13 14 13 14 15 13 12
15 13 12 13 14 13 14
40
Noise (254) is
O(x,y)
averaged
with the other values,
not removed
Original 3x3 low
pass
Wiener filter
Noisy image and effects of various filters
median
Original
Wiener Filter