Lets suppose that I have a point of interest in my matrix that is NxN. The point is located in the position ij. So, given the index ij, is there a simple way to get the line elements passing trough ij and to the origin (that is located in the middle of the matrix) ?
I am using torch and I though that using torch.diag would be a first start but acttualy this function does not pass in the middle of the matrix.
def directionalK(kx,ky, indices):
'''Function that provides the K values at a given direction dictated by the indices'''
kx_grid,ky_grid = torch.meshgrid(kx,kx, indexing='ij')
k_grid = torch.sqrt(kx_grid**2 + ky_grid**2)
k_grid[...,:len(k_grid)//2] *=-1
y,x = indices
diag = x - len(k_grid)//2