python - Principal Component Analysis (PCA) - accessing shape -
i beginner in python , trying apply principal component analysis (pca) set of images. want put images in matrix able perform pca. still @ beginning having errors.
import numpy np import image import os #insert images matrix dirname = 'c:\users\karim\downloads\shp_marcel_train\marcel-train\a' x = [np.asarray(image.open(os.path.join(dirname, fn))) fn in os.listdir(dirname)] #get dimensions num_data,dim = x.shape
it gives attributeerror: 'list' object has no attribute 'shape'
anyone can help?
a link detailed tutorial appreciated
when
[np.asarray(image.open(os.path.join(dirname, fn))) fn in os.listdir(dirname)]
it return array, stored in local variable x
you trying extract variables list, , hence error.
the individual elements within x
have shape attributes. hence, need (modify according datastructure shape
defined )
dim0 = x[0].shape
, on
Comments
Post a Comment