# Bitmap Image Filtering and Its Tools -Multimedia Design Technologies4th Lecture

1

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

Grey intensity levels
255 255 Original Object A Bitmap Image (8bits Grey Scale) white
2 3 4 5 6 … ………..255

x

5 65 96 92 90

5 56 96

255 255 255 76 9 255 255 255 255

10 65 70

175 210 255 255 175 162 165 255

Black
0 1

y

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

r

s = T[ r]

s

y

Image f (x, y)

y

Image f (x, y)

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

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

Point Processing Example: Thresholding

Original Image

s=

1.0 0.0

r > threshold r <= threshold

Thresholded Image

Point Processing Example: Thresholding

Point Processing Example: Thresholding

s=

1.0 r > threshold 0.0 r <= threshold

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

s

k

=

k

n n

j

j = 1

nj: the frequency of intensity j n: the sum of all frequencies

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

Neighbourhood Operations
Neighbourhood operations simply operate on a larger neighbourhood of pixels than point Origin operations Neighbourhoods are mostly a rectangle around a central pixel Any size rectangle Neighbourhood and any shape filter are possible
y Image f (x, y)

x

(x, y)

Simple Neighbourhood Operations
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 Pixels neighbourhood operations: MIN(106,104,100,108,99,98,95,90,85) = 85 = 108

104 100 108
MAX(106,104,100,108,99,98,95,90,85)

99 106 98 95 90 85
AVERAGE(106,104,100,108,99,98,95,90,85) = 98.3 MEDIAN(106,104,100,108,99,98,95,90,85)
A pixel intensity level that will be transformed

= 99

The pixel’s Intensity levels of transformed image

10

The Spatial Filtering Process
Origin x

a d g
Simple 3*3 Neighbourhood e 3*3 Filter

b e h

c f i

r

s v y
Filter

t w z

*

u x

Original Image Pixels

y

Image f (x, y)

eprocessed = v*e + r*a + s*b + t*c + u*d + w*f + 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
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 1/ 1/ 1/ in removing noise 9 9 9 from images 1/ 1/ 1/ Also useful for Simple 9 9 9 highlighting gross averaging detail filter 1 1 1

/9

/9

/9

Smoothing Spatial Filtering
Origin x

104 100 108 99 106 98 95
Simple 3*3 Neighbourhood
1/ 1/ 1/ 104 100 108 9 9 9 1/ 106 98 99 1/9 1/9 9 1/ 95 1/9 1/9 9 90 85

1/ 9

1/ 9 1/ 9 1/ 9

1/ 9 1/ 9 1/ 9

90

85

*

1/ 9 1/ 9

Original Image 3*3 Smoothing Pixels
Filter

Filter

y

Image f (x, y)

e = 1/9*106 + 1/ *104 + 1/ *100 + 1/ *108 + 9 9 9 1/ *99 + 1/ *98 + 9 9 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
mages taken from Gonzalez & Woods, Digital Image Processing (2002)

The image at the top left is an original image of size 500*500 pixels The subsequent images show the image after filtering with an averaging filter of increasing sizes
3, 5, 9, 15 and 35

Notice how detail begins to disappear

Weighted Smoothing Filters
More effective smoothing filters can be generated by allowing different pixels in the neighbourhood different weights in the averaging function 1/ 2/ 1/
Pixels closer to the central pixel are more important Often referred to as a weighted averaging
16 16 16 2/ 1/ 16 4/ 2/ 16 2/ 1/ 16

16

16

16

Weighted averaging filter

Averaging Filter Vs. Median Filter Example
mages taken from Gonzalez & Woods, Digital Image Processing (2002)

Original Image With Noise

Image After Averaging Filter

Image After Median Filter

Filtering is often used to remove noise from images Sometimes a median filter works better than an averaging filter

Exercise
1/ 9 1/ 9 1/ 9 1/ 9 1/ 9 1/ 9 1/ 9

Grey intensity levels
255 5 5 56 96 255 255 255 76 255 255 9 255 255 255 65 10 65 70 96

x

1/ 9 1/ 9

Simple averaging filter (3x3)

92 175 210 255 255 90 175 162 165 255

1/ 16 2/ 16 1/ 16

2/ 16 4/ 16 2/ 16

1/ 16 2/ 16 1/ 16

y

Original Image Pixels

Weighted averaging filter (3x3)

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
Create, View, Hide and Select layers Renaming and copying a layer Selecting and removing some pixels from layers Rearranging layers Apply blending modes to layers Apply text