Sorry if this has already been asked, I'm not sure exactly how to describe my question in a sentence anyway. I'm doing some work for my bioinformatics course, and I've begun to see variables declared when functions are called, instead of just passing the argument (see line 5 below).
def sobelFilter(pixmap):
matrix = array([[-1, 0, 1],
[-2, 0, 2],
[-1, 0, 1]])
grey = pixmap.mean(axis=2) #<---here
edgeX = convolveMatrix2D(grey, matrix)
edgeY = convolveMatrix2D(grey, matrix.T)
pixmap2 = sqrt(edgeX * edgeX + edgeY * edgeY)
normalisePixmap(pixmap2)
return pixmap2
What is the purpose of grey = pixmap.mean(axis=2) when axis is never used again? Why not just say grey = pixmap.mean(2)?
If it's necessary for my question, this is just code we were given to use, not written by myself. Pixmap refers to this code:
def imageToPixmapRGB(img):
img2 = img.convert("RGB")
w,h = img2.size
data = img2.getdata()
pixmap = array(data, float)
pixmap = pixmap.reshape((h,w,3))
return pixmap