0% found this document useful (0 votes)
2 views10 pages

Image Analysis 7 Neighborhood Operations

Neighborhood operations modify pixel values based on nearby pixels, with convolution and correlation being fundamental techniques. Convolution filters images for various purposes, while correlation assesses similarity in image regions for pattern recognition. The document also discusses computational performance and methods for handling image borders during convolution.

Uploaded by

Al-Amin Bhuiyan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views10 pages

Image Analysis 7 Neighborhood Operations

Neighborhood operations modify pixel values based on nearby pixels, with convolution and correlation being fundamental techniques. Convolution filters images for various purposes, while correlation assesses similarity in image regions for pattern recognition. The document also discusses computational performance and methods for handling image borders during convolution.

Uploaded by

Al-Amin Bhuiyan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Neighborhood Operations

Lecture 6

Md. Al-Amin Bhuiyan


Dept. of Computer Engineering
King Faisal University
Al Ahsa 31982, Saudi Arabia.
Neighborhood Operations
Neighborhood operations modify pixel values based
on the values of nearby pixels. Convolution and
Correlation are fundamental neighborhood
operations.

Convolution is used to filter images for specific


reasons – to remove noise, to remove motion blur, to
enhance image features, etc.

Correlation is used to determine the similarity of


regions of an image to other regions of interest. Used
in pattern recognition and image registration.

March 07, 2023 Dr. Al-Amin Bhuiyan [email protected] 1


Convolution
 The value of a pixel is determined by computing a weighted
sum of nearby pixels.
1 1
g ( x, y )   h(i, j) f ( x  i, y  j)
j  1i  1

-1 0 +1 72 53 60
-1 0 1 76 56 65
+1 0 -1

-2 0 2 88 78 82
-1 0 1
Given a “kernel” of weights to be Compute the new value of the
centered on the pixel of interest center pixel by “overlaying” the
kernel and computing the
weighted sum

March 07, 2023 Dr. Al-Amin Bhuiyan [email protected] 1


Convolution
J X

K
-1 0 +1 Y

Location
-1 0 1 (X,Y)

+1 0 -1
72 53 60
-2 0 2 76 56 65
-1 0 1 88 78 82

g(x,y) = h(-1, -1) * f(x+1, y+1) + g(x,y) = -1 * 82 +


h(0, -1) * f(x, y+1) + 0 * 78 +
h(1, -1) * f(x-1, y+1) + 1 * 88 +
h(-1, 0) * f(x+1, y) + -2 * 65 +
h(0, 0) * f(x, y) + 0 * 56 +
h(1, 0) * f(x-1, y) + 2 * 76 +
h(-1, 1) * f(x+1, y-1) + -1 * 60 +
h(0, 1) * f(x, y-1) + 0 * 53 +
h(1, 1) * f(x-1, y-1) 1 * 72

1 1
g ( x, y )   h(i, j) f ( x  i, y  j)
j  1i  1

March 07, 2023 Dr. Al-Amin Bhuiyan [email protected] 1


Convolution
 The summation is expressed as:
1 1
g ( x, y )   h(i, j) f ( x  i, y  j)
j  1i  1

For a kernel of width M and height N the more general


formula becomes:
N / 2 M / 2 
g ( x, y)    h(i, j) f ( x  i, y  j)
j    N / 2  i   M / 2 

March 07, 2023 Dr. Al-Amin Bhuiyan [email protected] 1


Convolution
 Convolution is used so frequently in certain domains
that it has been given the following shorthand
notation:
g ( x, y )  h  f ( x, y )
 The above formula implies convolution at a single pixel. To
indicate convolution of an entire image with a kernel we
write:

g  h f

March 07, 2023 Dr. Al-Amin Bhuiyan [email protected] 1


Convolution…
 The weights may be real-valued numbers
– The resulting pixel values must either be quantized or maintained with
real-valued pixel intensities!

 The range of values of the output may be significantly changed by


the weights
– Must increase the pixel resolution or
– re-scale the computed image

 What about borders?


– Ignore pixels where the kernel “falls off” the image.
 Output pixels may be set to zero
 Input pixel may be copied to the output
 Truncate the output image
– Truncate the kernel!
 The kernel is made smaller for processing borders, edges
– Use “circular” or “reflected” indexing

March 07, 2023 Dr. Al-Amin Bhuiyan [email protected] 1


Reflected Indexing
– Considers the image is “tiled” at each border by a
mirror
– Imagine a mirror vertically placed at each border that
“reflects” the image back upon itself

Reflection of X component
Let M be the width of the image
if x < 0 then
x = -x-1
else if x >= M then
x = 2M-x-1
end

March 07, 2023 Dr. Al-Amin Bhuiyan [email protected] 1


Circular Indexing
– Considers the image is infinitely repeated at each border
– Provides a good theoretical reason for convolution

Circular indexing of X
component
Let M be the width of the
image
if x < 0 then
x = x+M
else if x >= M then
x = x-M
end

March 07, 2023 Dr. Al-Amin Bhuiyan [email protected] 1


Convolution Computation
 What is the computational performance for
computing g = hf given the formula below?
N / 2 M / 2 
g ( x, y)    h(i, j) f ( x  i, y  j)
j    N / 2  i   M / 2 

M×N multiplications and additions per pixel


Assuming that f is a P×Q pixel image the performance is then
P×Q×M×N!

March 07, 2023 Dr. Al-Amin Bhuiyan [email protected] 1

You might also like