%% LoadPics
% Given a set of jpg images in the current directory, load them, and vectorize each sheet. 

%% Syntax (after changing the MyPic_Dir variable below)
%  LoadPics

%% To use & edit this code, paste the following into MATLAB, hit return and save the file as SeeVector.m
% grabcode('http://euclid.nmu.edu/~joshthom/Teaching/MA211/LoadPics.html');

%% Set resize values since most pics are too large as is.
	r = 30;
	c = 40;

%% Load Pictures
% The fist line below is a string of text characters containing the location of a jpg file.  The second line pieces this location together with the name(s) of your jpgs.*CAUTION* You should have less than 25 jpgs in this directory so that you don't kill your computer. 
	MyPic_Dir = '~/Teaching/MA211/';
	Pics = dir(strcat(MyPic_Dir,'*.jpg'));
	

%% Vectorize each RGB sheet of each image
	for i = 1:length(Pics)
		A{i} = imread(strcat(MyPic_Dir,Pics(i).name));
		for s = 1:3
			B{s} = ResizeMatrix(A{i}(:,:,s),r,c);	
			if i == 1; M = zeros(r*c*3,length(Pics)); end
			if s == 1; 
				v = [uint8(reshape(B{s},r*c,1))];
			else
				v = [v; uint8(reshape(B{s},r*c,1))];
			end
		end
		M(:,i) = v;
	end
