[SciPy-User] Numpy/Scipy: Avoiding nested loops to operate on matrix-valued images
Thu Mar 15 03:59:28 CDT 2012
I am a beginner at python and numpy and I need to compute the matrix
logarithm for each "pixel" (i.e. x,y position) of a matrix-valued image of
dimension MxNx3x3. 3x3 is the dimensions of the matrix at each pixel.
The function I have written so far is the following:
from scipy import linalg
dimx = im.shape
dimy = im.shape
res = zeros_like(im)
for x in range(dimx):
for y in range(dimy):
res[x, y, :, :] = linalg.logm(asmatrix(im[x,y,:,:]))
Is it ok? Is there a way to avoid the two nested loops ?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-User