Last time you did an exercise (convolutions and pooling) where you manually applied a 3x3 array as a filter to an image of two people ascending an outdoor staircase. Modify the existing filter and if needed the associated weight in order to apply your new filters to the image 3 times. Plot each result, upload them to your response, and describe how each filter transformed the existing image as it convolved through the original array and reduced the object size.
filter1 = [ [-2, -2, -2], [0, 0, 0], [2, 2, 2]]
filter2 = [ [2, 2, 2], [0, 0, 0], [-2, -2, -2]]
filter3 = [ [2, 0, 2], [1, 0, -1], [-2, 0, -2]]
What are you functionally accomplishing as you apply the filter to your original array (see the following snippet for reference)?
Why is the application of a convolving filter to an image useful for computer vision?
Stretch goal:
Instead of using the misc.ascent() image from scipy, can you apply three filters and weights to your own selected image? Again describe the results.
filter4 = [ [0, 1, 0], [1, 1, 1], [0, 1, 0]]
filter5 = [ [-1, 0, 1], [-2, 0, 2], [-1, 0, 1]]
filter6 = [ [0, 1, 0], [0, -2, 0], [0, 1, 0]]
Another useful method is pooling. Apply a 2x2 filter to one of your convolved images, and plot the result.
In effect what have you accomplished by applying this filter?
Does there seem to be a logic (i.e. maximizing, averaging or minimizing values?) associated with the pooling filter provided in the example exercise (convolutions & pooling)?
for x in range(0,size_x,2):
in the for loop, which means that it is iterating over the pixels but skipping every other pixel (because the step is 2). So it creates an empty image which is half the x and half the y of the original using line new_x = int(size_x/2)
and new_y = int(size_y/2)
and then populates the image with only half the pixels from the original image. For this strategy, there doesn’t seem to be much logic. It’s basically choose randomly which pixels to keep or not.Did the resulting image increase in size or decrease? Why would this method be useful?
Stretch goal:
Again, instead of using misc.ascent(), apply the pooling filter to one of your transformed images.
Convolve the 3x3 filter over the 9x9 matrix and provide the resulting matrix.
[[0, 0, 0, 3, 0, 0, 0],
[0, 0, 0, 3, 0, 0, 0],
[1, 1, 1, 3, 1, 1, 1],
[1, 1, 1, 3, 1, 1, 1],
[1, 1, 1, 3, 1, 1, 1],
[0, 0, 0, 3, 0, 0, 0],
[0, 0, 0, 3, 0, 0, 0]]