Vous êtes sur la page 1sur 18

Bitmap Image Filtering and Its Tools

-Multimedia Design Technologies-


4th Lecture

1
Review previous lecture’s contents (Cont…)
Color intensity levels in the image
( A Gray scale image)

Grey intensity levels x


255 5 5 255 255 255

255 65 56 76 255 255

10
Original Object A Bitmap Image 96 96 9 255 255
(8bits Grey Scale)
65
92 175 210 255 255
Black white
70
90 175 162 165 255
0 1 2 3 4 5 6 … ………..255

y
Review previous lecture’s contents (Cont…)
Point Processing
z In this case T is referred to as a grey level transformation function or
a point processing operation
z Point processing operations take the form
z s=T(r)
z where s refers to the processed image pixel value and r refers to the
original image pixel value
Original Image Enhanced Image x
x

r s = T[ r] s

y Image f (x, y) y Image f (x, y)


Review previous lecture’s contents (cont…)
z Point Processing Example: Negative images

s = intensitymax - r
Original Negative
Image s = 255 - r Image

z Point Processing Example: Thresholding

Original 1.0 r > threshold Thresholded


Image s= Image
0.0 r <= threshold
Point Processing Example:
Thresholding

z Point Processing Example: Thresholding

1.0 r > threshold


s=
0.0 r <= threshold
Review previous lecture’s contents (cont…)
Point Processing Example: Histogram Equalisation
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

k n
s k = ∑
j = 1 n
j

nj: the frequency of intensity j


n: the sum of all frequencies
Contents
z In this lecture we will look at spatial filtering techniques:
{ Neighbourhood operations
{ What is spatial filtering?
{ Smoothing operations
{ Practical work (working with photoshop):
1. Image Filters
2. Layer Basics
3. Mask and Channels
Neighbourhood Operations

z Neighbourhood operations simply operate on a


larger neighbourhood of pixels than point
operations Origin x

z Neighbourhoods are
mostly a rectangle
around a central pixel
z Any size rectangle Neighbourhood
(x, y)

and any shape filter


are possible

y Image f (x, y)
Simple Neighbourhood Operations

z Some simple neighbourhood operations include:


{Min: Set the pixel value to the minimum in the
neighbourhood
{Max: Set the pixel value to the maximum in the
neighbourhood
{Average: The average value of the neighbourhood
{Median: The median value of a set of numbers is the
midpoint value in that set (e.g. from the set [1, 7, 15,
18, 24] 15 is the median). Sometimes the median
works better than the average
Simple Neighbourhood Operations
Original Image neighbourhood operations:
Pixels
MIN(106,104,100,108,99,98,95,90,85) = 85
104 100 108
MAX(106,104,100,108,99,98,95,90,85) = 108
99 106 98
AVERAGE(106,104,100,108,99,98,95,90,85) = 98.3
95 90 85
MEDIAN(106,104,100,108,99,98,95,90,85) = 99
A pixel intensity level
that will be transformed
The pixel’s Intensity levels
of transformed image

10
The Spatial Filtering Process
Origin x
a b c r s t
d
g
e
h
f
i
* u
x
v
y
w
z
Original Image Filter
Simple 3*3 Pixels
e 3*3 Filter
Neighbourhood
eprocessed = v*e +
r*a + s*b + t*c +
u*d + w*f +
y Image f (x, y) x*g + y*h + z*i

The above calculation is repeated for every pixel in the


original image to generate the smoothed image
Smoothing Spatial Filters

z One of the simplest spatial filtering operations


we can perform is a smoothing operation
{Simply average all of the pixels in a neighbourhood
around a central value
{Especially useful
in removing noise 1/ 1/ 1/
9 9 9
from images
{Also useful for 1/ 1/ 1/ Simple
9 9 9
highlighting gross averaging
detail 1 1 1 filter
/9 /9 /9
Smoothing Spatial Filtering
Origin x
104 100 108 1/ 1/ 1/
9 9 9

99 106 98

95 90 85
* 1/

1/
9
1/

1/
9
1/

1/
9

9 9 9

1/ 100
104 1/ 108
1/ Original Image Filter
9 9 9
Simple 3*3 199
/9 1106
/9 198
/9
3*3 Smoothing Pixels
Neighbourhood 195
/9 190
/9 185
/9
Filter
e = 1/9*106 +
1/ *104 + 1/ *100 + 1/ *108 +
9 9 9
1/ *99 + 1/ *98 +
9 9
y Image f (x, y) 1/ *95 + 1/ *90 + 1/ *85
9 9 9
= 98.3333
The above calculation is repeated for every pixel in the original image to
generate the smoothed image
Image Smoothing Example

z The image at the top left


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

is an original image of
size 500*500 pixels
z The subsequent images
show the image after
filtering with an averaging
filter of increasing sizes
{3, 5, 9, 15 and 35
z Notice how detail begins
to disappear
Weighted Smoothing Filters

zMore effective smoothing filters can be


generated by allowing different pixels in
the neighbourhood different weights in the
averaging function 1/ 2/ 1/
16 16 16
{Pixels closer to the
central pixel are more 2/ 4/ 2/
16 16 16
important
{Often referred to as a 1/
16
2/
16
1/
16
weighted averaging
Weighted
averaging filter
Averaging Filter Vs. Median Filter Example
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Original Image Image After Image After


With Noise Averaging Filter Median Filter

z Filtering is often used to remove noise from images


z Sometimes a median filter works better than an
averaging filter
Exercise
1/ 1/ 1/
9 9 9
Simple
Grey intensity levels x 1/ 1/ 1/ averaging filter
9 9 9
255 5 5 255 255 255 (3x3)
1/ 1/ 1/
9 9 9
255 65 56 76 255 255
10
96 96 9 255 255
65 1/ 2/ 1/
92 175 210 255 255 16 16 16
70 Weighted
90 175 162 165 255 2/ 4/ 2/ averaging filter
16 16 16
(3x3)
y Original Image 1/ 2/ 1/
16 16 16
Pixels

1) Calculate a yellow colour pixel’s intensity levels of the median smoothed image!

2) Calculate a red colour pixel’s intensity levels of the simple averaging smoothed image!

3) Calculate a blue colour pixel’s intensity level of the weighted averaging smoothed image!
Practical work (working with photoshop):
1. Image Filters in Photoshop CS
2. Layer Basics
z Create, View, Hide and Select layers
z Renaming and copying a layer
z Selecting and removing some pixels from layers
z Rearranging layers
z Apply blending modes to layers
z Apply text
3. Mask and Channels
z Refine a selection using a quick mask
z Save a selection as a channel mask
z Load saved mask and apply effects
z Extracting an image
z Adding the extracted image as a layer
z Applying a filter effect to masked selection
z Creating and applying effect using gradient mask