I tried to calculate eigen values and eigen vectors of an image by getting the array of the image
img = sitk.ReadImage("data/image.mhd")
img_arr = sitk.GetArrayFromImage(img)
w, v = numpy.linalg.eig(img_arr)
But I got an error “LinAlgError: Last 2 dimensions of the array must be square”.
How can I canculate the eigen values and eigen vectors ?
Square matrices have eigenvectors and eigenvalues. Interpreting an image as a matrix usually does not have much sense. What are you trying to accomplish?
The error is saying that the image you are passing should have equal sizes along X and Y dimensions (technically,
j indexing axes).
I tried to get the eigen vector and eigen value of the input image