title: Python matrix convolution without using numpy.convolve or scipy equivalent functions
body: <p>I need to write a matrix convolution without using any built in functions to help. I am taking an image and turning it to greyscale, and then I'm supposed to pass a filter matrix over it. One of the filter matrices I have to use is:</p>
  
  <pre><code>[[-1,0,1],
  [-1,0,1],
  [-1,0,1]]
  </code></pre>
  
  <p>I understand how convolutions work, I just don't understand how to apply the convolution with code. Here is the code I am using to get my greyscale array:</p>
  
  <pre><code>import numpy
  from scipy import misc
  mylist = []
  for i in myfile:
      mylist.append(i)
  
  for i in mylist:
      q = i
      print(q)
      image = misc.imread(q[0:-1])
      threshold()
  image = misc.imread('image1.png')
  
  
  def averageArr(pixel): #make the pixel color values more realistic
      return 0.299*pixel[:,:,0] + 0.587*pixel[:,:,1] + 0.114*pixel[:,:,2]
  
  def threshold():
      picture = averageArr(image)
      for i in range(0,picture.shape[0]): #begin thresholding 
          for j in range(0,picture.shape[1]):
              myList.append(i,j)
      misc.imsave('image1.png') #save the image file
  </code></pre>
  
  <p>I take the values from the function, and add them to a list, and then I am supposed to iterate over the list, but I'm not sure how to go about doing that. I can use scipy and numpy to read and arrange the matrix, but the actual convolution function has to be written.</p>