I am working on an image processing program with OpenCV and numpy. For most pixel operations, I can avoid nested loops using np.vectorize (), but one of the functions that I need to implement is required as a parameter "distance from the center" or basically the coordinate of the point being processed.
Pseudo Exam:
myArr = [[0,1,2]
[3,4,5]]
def myFunc(val,row,col):
return [row,col]
f = np.vectorize(myFunc)
myResult = f(myArr,row,col)
I obviously can't get elemX and elemY from a vectorized array, but is there another numpy function that I could use in this situation or do I need to use for loops ?, is there a way to do this with openCV?
The function with which I must place each pixel is:,
f(i, j) = 1/(1 + d(i, j)/L)d (i, j) is the Euclidean distance of the point from the center of the image.