Fast method for get the gradient of an image


#1

One of the methods is to apply the following kernel to an image.

[0, -1, 0
 -1, 0, 1
 0,  1, 0]

I wonder how I can directly operate on the tensor(4D). If so, is it fast than applying that kernel?


(Simon Wang) #2

torch.nn.functional.conv2d