I am trying to perform PCA in python 3 on a set of tiff images that are located in a single folder. I have already referenced this answer and this one but am still unsure on what the error is. All of the tiff images are the same size.
from sklearn.decomposition import PCA
import glob
import numpy as np
from scipy import misc
images = [misc.imread(path) for path in glob.glob("path/*.tif")]
images = np.asarray(images)
print(images.size)
pca = PCA(150)
pca.fit(images)
I first upload them all into a np.array and try to perform PCA, but I keep getting the error below.
File "Users/.../anaconda3/lib/python3.7/site-packages/numpy/core/numeric.py", line 538, in asarray return array(a, dtype, copy=False, order=order)
ValueError: setting an array element with a sequence.
Why do I keep getting this error and how should I perform PCA on these tiff images?