Dear R users, i would like to apply a PCA on image data for data reduction. The image data is available as three matrices for the RGB values. At the moment i use x <- data.frame(R,G,B)#convert image data to data frame pca<-princomp(x,retx = TRUE) This is working so far.>From this results then i want to create a new matrixfrom the first (second..) principal component. Here i stuck. So my question is how can i create this matrix from the results of the PCA. (Maybe there is also a faster method available for PCA?) Any answers or advices are appreciated With kind regards M.Austenfeld -- View this message in context: http://www.nabble.com/PCA-on-image-data-tp18255217p18255217.html Sent from the R help mailing list archive at Nabble.com.
Dear Marcel, See ?princomp. HTH, Jorge On Thu, Jul 3, 2008 at 5:15 AM, Bio7 <marcel.austenfeld@uni-bielefeld.de> wrote:> > Dear R users, > > i would like to apply a PCA on image data for data reduction. > The image data is available as three matrices for the > RGB values. At the moment i use > > x <- data.frame(R,G,B)#convert image data to data frame > pca<-princomp(x,retx = TRUE) > > This is working so far. > >From this results then i want to create a new matrix > from the first (second..) principal component. Here i stuck. > So my question is how can i create this matrix from the results of the PCA. > (Maybe there is also a faster method available for PCA?) > > Any answers or advices are appreciated > > With kind regards > > M.Austenfeld > > -- > View this message in context: > http://www.nabble.com/PCA-on-image-data-tp18255217p18255217.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Hi, You have the values of the principal component in "scores" (for each "location" where you have a RGB reading) and the eigenvectors in "loadings", see ?princomp So your first pca component would be: comp1 <- pca$scores[,1] Now you can transform this in the matrix you need to display your image. Hope this helps, Monica PS. I think prcomp() has the retx argument, not princomp() .... my answer pertains to princomp.... ------------------------------------------------------------ Message: 14 Date: Thu, 3 Jul 2008 02:15:43 -0700 (PDT) From: Bio7 Subject: [R] PCA on image data To: r-help at r-project.org Message-ID: Content-Type: text/plain; charset=us-ascii Dear R users, i would like to apply a PCA on image data for data reduction. The image data is available as three matrices for the RGB values. At the moment i use x <- data.frame(R,G,B)#convert image data to data frame pca<-princomp(x,retx = TRUE) This is working so far.>From this results then i want to create a new matrixfrom the first (second..) principal component. Here i stuck. So my question is how can i create this matrix from the results of the PCA. (Maybe there is also a faster method available for PCA?) Any answers or advices are appreciated With kind regards M.Austenfeld _________________________________________________________________ Windows Live Hotmail is giving away Zunes. Enter for your chance to win. M_Mobile_Zune_V3