oxford_logo Dunn_School

DTC Introduction to Programming

Extension Problem for Multidimensional Array Structures

  1. Write a function in Python that will take this image as input and apply the convolution edge detection filter that I mentioned in the lecture. You will have to:
    1. Write a subroutine that calculates the convolution between a matrix and a convolution kernel. You will find numpy matrices very helpful.
    2. Calculate matrices Gx and Gy using your convolution operator.
    3. Finally, calculate G from Gx and Gy. Note that the square and square root calculations in this step are element-wise. The functions you want are numpy.power(matrix,2) and numpy.sqrt(matrix).
    Put the processed image back together in .pgm format. Do the results seem sensible?
  2. Convolution (and therefore, edge detection) can be generalised to higher dimensions. For example, you may wish to perform edge detection in three dimensions to detect the contours of bone in an MRI image. Write down the convolution kernel matrices for three dimensional edge detection. Optional: implement three dimensional edge detection in the language of your choice, on the image of your choice.