#ifndef _SAVE_H_
#define _SAVE_H_
#include "config.h"
template<typename A> void saveSingleImg(Mat img, string imgname,char type);
template<class A> void saveSingleImg(Mat img, string imgname, char type)
{
int rows = img.rows;
int cols = img.cols;
int i, j;
string str1 = "D:\\CodeDocuments\\Visual Studio 2013\\project\\TV_L1_OF\\TV_L1_OF\\text\\";
str1 = str1 + imgname;
const char *ch = str1.c_str();
FILE *fd = fopen(ch, "w");
for (i = 0; i<rows; i++)
{
for (j = 0; j < cols; j++)
{
if (type == 'd')
{
fprintf(fd, "%d ", img.at<A>(i, j));
}
if (type == 'f')
{
fprintf(fd, "%f ", img.at<A>(i, j));
}
}
fprintf(fd, "\n");
}
fclose(fd);
}
#include "saveSingleImg.cpp"
#endif