myDir = 'projectImages';% Gets list of all files with the corresponding file extension
f = fullfile(myDir, '*.jpg');theFiles = dir(f);vector_img = zeros(28^2, length(theFiles ));for k = 1 : length(theFiles) baseFile = theFiles(k).name; completeFile = fullfile(myDir, baseFile); fprintf(1, 'Now reading %s\n', completeFile); %prints the current image being processed.
img = imread(completeFile); %reads image
vector_img(:,k) = img_28(:); %vectorizes the image
img_gray = rgb2gray(img); %turns image to grayscale
vector_img(:,k+1) = img_28(:); %vectorizes the image img_28 = imresize(img_gray, [28 28]); %resizes image
vector_img(:,k+2) = img_28(:); %vectorizes the imageendcsvwrite('completeimgdata.csv', vector_img'); %writes the vectorized images to csv file
MATLAB: Is there any reason why this loop is not reading the images in order? I noticed that once it starts running, it reads the images in a random order. It prints the image being read on each itereation, and i dont know why it does not start at image 1.
csvimage processingloop
Best Answer