Chapter 3.1 - Spatial Domain Image Processing
Chapter 3.1 - Spatial Domain Image Processing
(enhanced) image
2) Neighborhood Operations
Linear filtering / convolution operations
Non-linear operations
5 * 5
63 * 63 pixels
Applications:
Enhance an image (denoise, resize, etc)
Gaussian noise:
variations in intensity drawn from a Gaussian normal
distribution
>> im=imread('peppers.png');
>> grayim= rgb2gray(im);
>> subplot(1,2,1), subimage(im);
>> out=imnoise(grayim, 'salt & pepper');
>> subplot(1,2,1), imshow(grayim);
>> title('Orginal', 'color', 'r' );
>> subplot(1,2,2), imshow(out);
>> title('Salt and Pepper noise’,
'color', 'r');
>> im=imread('peppers.png');
>> grayim= rgb2gray(im);
>> subplot(1,2,1), subimage(im);
>> out=imnoise(grayim, ‘Gaussian');
>> subplot(1,2,1), imshow(grayim);
>> title('Orginal', 'color', 'r' );
>> subplot(1,2,2), imshow(out);
>> title(‘Gaussian noise’, 'color', 'r');
Linear filter:
𝟏
is the uniform weight for each pixel.
𝟐𝒌+𝟏 𝟐
The above equation can be generalized to allow non
uniform weights depending on neighboring pixel’s
relative position as:
0 0 0 0 0 0 0 0 0 0
0
0
0
0
0
0
90
0
90
0
90
0
90
0
90
0
0
0
0
1 1 1 0 10 20 30 30
0
0
0
0
0
90
90
90
90
90
90
90
90
90
90
0
0
0
0
1 1 1 ?
0 0 0 90 0 90 90 90 0 0
1 1 1
0 0 0 90 90 90 90 90 0 0
“box filter”
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
a) Original image
b) Corrupted with salt and pepper noise
c) Filtered with 3x3 box filter
d) Filtered with 5x5 box filter
Convolution:
Flip the filter in both dimensions (bottom to top, right to left)
Then apply cross-correlation
Notation for
convolution
operator
F
H
full same
g g g g
f f
g g
g g
Computer Vision 3-Image Processing
3-36
Boundary issues
need to extrapolate
1
432
methods:
1- clip filter (black)
2- wrap around
3- copy edge
methods (MATLAB):
clip filter (black): imfilter(f, g, 0)
Replace each pixel value with the median of the gray values in
the region of the pixel:
Take a 3 x 3 (or 5 x 5 etc.) region centered around pixel (i,j)
Sort the intensity values of the pixels in the region into ascending order
Non-linear filter
Salt and
Median
pepper
filtered
noise
Computer Vision
Matlab: output 3-Image
im =Processing
medfilt2(im, [h w]);
3-41
Median filter