Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

why dose the maxComponent argument in function cv.PCACompute doesn't work???

import cv2 as cv import numpy as np

img=cv.imread(r'T/s.jpg',cv.IMREAD_GRAYSCALE) img=cv.resize(img,(512,512)) tdata=img.flatten() tdata=tdata.reshape(512*512,1) tdata=tdata-tdata.mean() tdata=tdata/np.sqrt(tdata.var()) mean=np.array([]) mean,eigenvectors=cv.PCACompute(tdata,mean,cv.PCA_DATA_AS_COL, maxComponents=9) projectedVectors=cv.PCAProject(tdata,mean,eigenvectors) result=cv.PCABackProject(tdata,mean,eigenvectors) result=result.reshape(512,512) cv.imshow('show',img) cv.waitKey() cv.imshow('show',result) cv.waitKey() cv.destroyAllWindows()

click to hide/show revision 2
No.2 Revision

updated 2016-09-03 03:42:11 -0600

berak gravatar image

why dose the maxComponent argument in function cv.PCACompute doesn't work???

import cv2 as cv
import numpy as np

np

img=cv.imread(r'T/s.jpg',cv.IMREAD_GRAYSCALE) img=cv.resize(img,(512,512)) tdata=img.flatten() tdata=tdata.reshape(512*512,1) tdata=tdata-tdata.mean() tdata=tdata/np.sqrt(tdata.var()) mean=np.array([]) mean,eigenvectors=cv.PCACompute(tdata,mean,cv.PCA_DATA_AS_COL, maxComponents=9) projectedVectors=cv.PCAProject(tdata,mean,eigenvectors) result=cv.PCABackProject(tdata,mean,eigenvectors) result=result.reshape(512,512) cv.imshow('show',img) cv.waitKey() cv.imshow('show',result) cv.waitKey() cv.destroyAllWindows()

cv.destroyAllWindows()