Code covered by the BSD License  

Highlights from
Reading and Saving a sequence of images

Reading and Saving a sequence of images

by

 

This file loads an image and stores it in your work directory

Bucle_Imagenes.m
clc
myFolder='H:\Sistemas de Vision\plumas';% This is your work directory
% Read image1.jpg through imagem.jpg.  
% Files are in the "myFolder" directory.
m=input('Type the Number of Images to Process:');% Ask the amount of image to process
for k = 1:m
  jpgFilename = sprintf('image%d.jpg', k);
  fullFileName = fullfile(myFolder, jpgFilename);
  if exist(fullFileName, 'file')
    imageData = imread(fullFileName);
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    processedimage=sprintf('ip%d',k);    % Image 
    FileName = fullfile(processedimage); % Processing
    i=im2double(imageData);              % 
    ip=rgb2gray(i);                      %
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    filename = sprintf('ip%d.jpeg', k);  % Image Data
    imwrite(ip,filename);                % Storage
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  else
    warningMessage = sprintf('Warning: image file does not exist:\n%s', fullFileName);%if file doesent exist sends an error message
    uiwait(warndlg(warningMessage));
  end
  figure(k)
  imshow(ip)
 end
disp('All Done');

Contact us