I'm trying to calculate a 3d sobel filter in python. I have a pretty good code for 2d image which is below.
btw. my original image is uint8 type.
preSobel = preSobel.astype('int32')
dx = ndimage.sobel(preSobel, 0) # horizontal derivative
dy = ndimage.sobel(preSobel, 1) # vertical derivative
mag = numpy.hypot(dx, dy) # magnitude
mag *= 255.0 / numpy.max(mag) # normalize (Q&D)
img[i,:,:]=mag
but from my understanding of the wiki page for calculating 2d, i should have multiplied the 1d sobel results rather than hypot :confused
anyway, to go to 3d, I guess I need to calculate 1d sobel on each axis and then multiply all but I'm not sure... Is there any library out there that calculates 3d sobel faster ?
解决方案
First, in reference to your wikipedia link: The multiplication