1 | initial version |
please try the code below
note : it finds all the files having "bmp" extension at the working directory and loads as gray-scale then saves as "original-image-name + pgm"
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
using namespace cv;
using namespace std;
int main()
{
vector<String> filenames;
String folder = "*.bmp";
glob(folder, filenames);
for(size_t i = 0; i < filenames.size(); ++i)
{
Mat src = imread(filenames[i],0); // open image as gray
if(src.data)
{
imwrite( filenames[i]+".pgm", src );
}
}
return 0;
}