Lecture 39  Image Manipulation
Lecture Date: Monday, April 25
Another day of image algorithms! These are a bit trickier than the last few days…
The algorithms for today are:
 Edge Detection
 Image Subtraction
Edge Detection
The edge detection algorithm will show us where the edges of objects are in an image and highlight them. The basic idea is that we can look at every pixel and then see if the pixels next to it are substantially different in intensity. To do this, we will apply a set of convolution matrices called Sobel operators to each pixel. The set consists of two matrices: one that looks for differences on the x axis and one on the y axis.
The steps of the algorithm are:
 Convert the original image to grayscale
 Create an empty image of the same size as the original
Then, for each pixel:
 Convolve the pixel with the
x_mask
, resulting in anint
calledgX
 Convolve the pixel with the
y_mask
, resulting in anint
calledgY
 Compute the square root of the sum of squares of
gX
andgY
calledg
 Based on the value of
g
, assign the corresponding pixel in the new image to black or white
One example would be if g
> 175, make the pixel black and otherwise white.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 

Image Subtraction
Image subtraction shows us the difference between two images, highlighting what has changed. We’ll have to figure out a way to determine the distance between two colors. We can use this to loop over the images.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 
