%% PRE-PRE-PROCESSING SCRIPT % Saving the Images in Date Formats to Easily Track Down Your Progress formatOut = 'mm-dd-yy_HH-MM'; % The time the file is run date = datestr(now,formatOut) imname = strcat('Image', date); % Name Format for each frame foldername = strcat(date,'\'); % Creating the folder % Modify This Directory to the Folder That You Want to Put the Frames In newdirectory = 'C:\Users\annaf\Documents\MATLAB\PIVlab-main\PIVlab-main\Examples\testimages\'; folderdir = strcat(newdirectory, foldername); mkdir(folderdir); % Make the new folder % Take in a Video and Convert to Images vid = VideoReader('PIVtestslomomanyparticles_Trim.mp4'); % Name of the video (put in the same folder as prepre.m) numFrames = vid.NumberOfFrames; % Number of frames n = numFrames; % Loop Through Frames and Read EVERY Image for i = 1:n frames = read(vid,i); % Read the video to a frame imwrite(rgb2gray(frames),[folderdir, imname, int2str(i), '.png']); % Write to image with name end % numvals = 20; % custommap = ones(numvals,3); % for i=1:numvals % if i< numvals*.6 % custommap(i,:)=custommap(i,:)*(i-1)/(numvals*5); % else % custommap(i,:)=custommap(i,:)*1; % end % % end % % Save them in files % newim = rgb2gray(frames); % [newnew, custommap] = rgb2ind(frames, custommap); % % if i==1 % imwrite(I,custommap,[folderdir, imname, int2str(i), '.png']); % end % loop thru all images and make them black and white % make a new folder in the examples file with a timestamp? %imwrite(newim,custommap,[folderdir, imname, int2str(i), '.png']); %movefile imname* folderdir