Message Boards Message Boards

0
|
2844 Views
|
1 Reply
|
1 Total Likes
View groups...
Share
Share this post:

What does this code do

Posted 9 years ago

files = Import["~/blog/faces94/male"][[1 ;; -1 ;; 30]];
faces = Map[Import["~/blog/faces94/male/" <> #] &, files];

I can't find any documentation that explains how to use Import in this way. I'm trying to use the notebook from this website: http://jeremykun.com/2011/07/27/eigenfaces/

The github page is here: https://github.com/j2kun/eigenfaces

files = Import["~/blog/faces94/male"][[1 ;; -1 ;; 30]];

The call Import["~/blog/faces94/male"] reads the names of all the files in the folder ~/blog/faces94/male. Then they filter it out using [[1 ;; -1 ;; 30]]; which I find strange way of doing it. I do not know why they did not use FileNames[] for this part.

SetDirectory[NotebookDirectory[]];
dim = {200, 180};
files = Import["faces94/male"][[1 ;; -1 ;; 30]]

enter image description here

faces = Map[Import["~/blog/faces94/male/" <> #] &, files];

This line imports each image from the list of the files from the above operation. Now all these images are stored in faces list

faces = Map[Import["faces94/male/" <> #] &, files];
Length[faces]
 (*76*)
POSTED BY: Nasser M. Abbasi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract