Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Perform a Principle component analysis(PCA)

I am trying to perform PCA on a binary mask of an image. Mask is of shape(480, 280) and . that looks like this

Mask=
[[0 0 0 ... 0 0 0]
 [0 0 1 ... 0 0 0]
 [0 0 1 ... 1 0 0]
 ...
 [0 0 0 ... 1 0 0]
 [0 0 0 ... 0 0 0]
 [0 0 0 ... 0 0 0]]

Value of "0" imply background and "1" imply object that i am interested in. I extract all the (x, y) of the object by

object = np.transpose(np.nonzero(Mask))
[[ 22 204]
 [ 22 205]
 [ 22 206]
 ...
 [349 115]
 [349 116]
 [349 117]]

I am not sure , how can i input this data into

mean, eigvec = cv2.PCACompute(data, None)