title: Loading and processing multiple images
body: <pre><code>    #include "iostream"
      #include "cv.h"
      #include "highgui.h"
      #include "cvaux.h"
      #include "cxmisc.h"
      #include "math.h"
  
      using namespace cv;
      using namespace std;
  
      int main(){
  
      int height, width, x, y, i, minX, minY, maxX, maxY;
      char imgFileName[100];
  
  
      IplImage *origImage = cvLoadImage("data set baybayin/0000.jpg", -1);
      height = origImage-&gt;height;
      width = origImage-&gt;width;
  
      IplImage *grayImage = cvCreateImage(cvSize(width, height), 8, 1);
      IplImage *binImage = cvCreateImage(cvSize(width, height), 8, 1);
  
  
      //Pre-processing phase
      //image cleaning
      cvCvtColor(origImage, grayImage, CV_BGR2GRAY);
      cvDilate(grayImage, grayImage, NULL, 1);
      cvSmooth(grayImage, grayImage, CV_GAUSSIAN, 21, 21, 0, 0);
      //image binarization
      cvThreshold(grayImage, binImage, 120, 255, CV_THRESH_BINARY);
      //cvNormalize(binImage,binImage,0,1,CV_MINMAX);
  
      //getting image info
      minX = width;
      minY = height;
      maxX = 0;
      maxY = 0;
  
      //image cropping
      CvScalar s;
  
      //finding the boundaries
      for (x=0; x&lt;width-1; x++){
          for(y=0; y&lt;height-1; y++){
              //getting pixel values
              s = cvGet2D(binImage, y, x);
              //printf("%f\n", s.val[0]);
              //identifying boundaries
              if (s.val[0] == 0){
                  //printf("HELLO");
                  minX = min(minX, x);
                  minY = min(minY, y);
                  maxX = max(maxX, x);
                  maxY = max(maxY, y);
                  //printf("%d\n", minY);
              }   
          }
      }
  
      //creating rectangle
      CvRect rect = cvRect(minX, minY, maxX-minX, maxY-minY);
      //sets the part of the image to be cropped
      cvSetImageROI(binImage, rect);
      IplImage *cropImage = cvCreateImage(cvGetSize(binImage), 8, 1);
      IplImage *newImage = cvCreateImage(cvSize(400, 400), 8, 1);
  
      //copies cropped image to new declared image
      cvCopy(binImage, cropImage, NULL);
      //cvSaveImage("bin/binImage16.jpg", binImage);
  
      cvSaveImage("data set baybayin/cropImage0.jpg", cropImage);
  
  
      cvResetImageROI(binImage);
      cvReleaseImage(&amp;origImage);
      cvReleaseImage(&amp;binImage);
      cvReleaseImage(&amp;grayImage);
      cvReleaseImage(&amp;cropImage);
      cvReleaseImage(&amp;newImage);
  
  
      }
  </code></pre>
  
  <p>Hi may I just ask about how can I load multiple images in my code above? Because this code only loads and processes one image and I can barely understand some of the instructions online. I'm sorry I'm a newbie. I would also want to ask about the code after processing; how can I save the new and processed images into another folder with the corresponding filenames? Thanks.</p>