ofImage ofVideoGrabber: How to reduce this code

Is there anyway to reduce this code to an array or something?

im1.allocate(camWidth,camHeight,OF_IMAGE_COLOR);
im2.allocate(camWidth,camHeight,OF_IMAGE_COLOR);
im3.allocate(camWidth,camHeight,OF_IMAGE_COLOR);
im4.allocate(camWidth,camHeight,OF_IMAGE_COLOR);
im5.allocate(camWidth,camHeight,OF_IMAGE_COLOR);
im6.allocate(camWidth,camHeight,OF_IMAGE_COLOR);
im7.allocate(camWidth,camHeight,OF_IMAGE_COLOR);
im8.allocate(camWidth,camHeight,OF_IMAGE_COLOR);
im9.allocate(camWidth,camHeight,OF_IMAGE_COLOR);
im10.allocate(camWidth,camHeight,OF_IMAGE_COLOR);
im11.allocate(camWidth,camHeight,OF_IMAGE_COLOR);

make a vector of ofImages and loop on it.
Something like that :

vector<ofImage> images; 
for (int i = 0; i < images.size(); i++)
{
    images[i].allocate(camWidth,camHeight,OF_IMAGE_COLOR);
}

thanks, but I have this, and I’m trying to make a loop to reduce it all, but I only want to use one key for the whole thing not a bunch of keys:

  if(key=='w'){

  ofPixels pixels2 = vidGrabber.getPixelsRef();

  im2.setFromPixels(pixels2);
  im2.saveImage("sample2.png");
  im2.loadImage("sample2.png");
  }

  if(key=='e'){
  ofPixels pixels3 = vidGrabber.getPixelsRef();

  im3.setFromPixels(pixels3);
  im3.saveImage("sample3.png");
  im3.loadImage("sample3.png");
  }

   if(key=='r'){
   ofPixels pixels4 = vidGrabber.getPixelsRef();

  im4.setFromPixels(pixels4);
  im4.saveImage("sample4.png");
  im4.loadImage("sample4.png");
  }

  if(key=='t'){
  ofPixels pixels5 = vidGrabber.getPixelsRef();

  im5.setFromPixels(pixels5);
  im5.saveImage("sample5.png");
  im5.loadImage("sample5.png");
  }

  if(key=='y'){
  ofPixels pixels6 = vidGrabber.getPixelsRef();

  im6.setFromPixels(pixels6);
  im6.saveImage("sample6.png");
  im6.loadImage("sample6.png");
  }


  if(key=='u'){
  ofPixels pixels7 = vidGrabber.getPixelsRef();

  im7.setFromPixels(pixels7);
  im7.saveImage("sample7.png");
  im7.loadImage("sample7.png");
  }

  if(key=='i'){
  ofPixels pixels8 = vidGrabber.getPixelsRef();

  im8.setFromPixels(pixels8);
  im8.saveImage("sample8.png");
  im8.loadImage("sample8.png");
  }

  if(key=='o'){
  ofPixels pixels9 = vidGrabber.getPixelsRef();

  im9.setFromPixels(pixels9);
  im9.saveImage("sample9.png");
  im9.loadImage("sample9.png");
  }

if(key=='p'){
ofPixels pixels10= vidGrabber.getPixelsRef();

im10.setFromPixels(pixels10);

im10.saveImage("sample10.png");
im10.loadImage("sample10.png");
}

 if(key=='a'){
  ofPixels pixels11 = vidGrabber.getPixelsRef();

  im11.setFromPixels(pixels11);
  im11.saveImage("sample11.png");
  im11.loadImage("sample11.png");
  }

  if(key=='z'){
 im12.grabScreen(0,0,1024,768);

im12.saveImage(“screenshot.png”);

  }



}

Are you trying to save a bunch of copies of the same video frame?