Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How save multiple image in a "BOOST_FOREACH" loop

I have written the snippet code below to save multiple images with different names but it doesn't work. Thanks in advance for your help.

#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <sstream>

 ........
 int nBlur[] = {5, 7, 13};
 BOOST_FOREACH( int i, nBlur)
{
    std::string str = boost::lexical_cast<std::string>(i); // convert i to string
    string imgF = "imgBlur" + i;
    const char *imgFile = imgF.c_str();

    GaussianBlur(imgGray, imgGrayBlur, Size(i,i), 0, 0 );
    //imshow("Blurring image", imgGrayBlur);
    Mat blurred(imgGrayBlur);
    imwrite(imgFile+".png", imgGrayBlur);
}