opencv 批量修改图片尺寸


#include
#include
using namespace cv;
using namespace std;
int main()
{
	int a = 1;
	char path[90];
	for (a = 1; a < 401; a++)
	{
		
		if (a < 10)
		{
			sprintf_s(path, "E:\\faceRec\\facePictures\\face_dec\\positivePic\\00%d.pgm", a);
		}
		else if (a < 100)
		{
			sprintf_s(path, "E:\\faceRec\\facePictures\\face_dec\\positivePic\\0%d.pgm", a);
		}
		else
		{
			sprintf_s(path, "E:\\faceRec\\facePictures\\face_dec\\positivePic\\%d.pgm", a);
		}



			Mat inputImg = imread(path, -1);

			Mat resizea;
			resizea.create(20, 20, CV_8UC1);
			resize(inputImg, resizea, resizea.size(), 0, 0, INTER_CUBIC);
			if (1)
			{
				stringstream ss;
				ss << a << ".pgm";
				imwrite(ss.str(), resizea);

			}
		}
	system("pause");
}
	

 

你可能感兴趣的:(opencv 批量修改图片尺寸)