//piece of code used for database generation

#include <iostream>
#include "opencv2/opencv.hpp"
#include <stdio.h>
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <stdlib.h>

using namespace cv;
using namespace std;

int main( int argc, char** argv )
{
	string listin[] = {"01_manual1.tif","02_manual1.tif","03_manual1.tif","04_manual1.tif","05_manual1.tif","06_manual1.tif","07_manual1.tif","08_manual1.tif","09_manual1.tif","10_manual1.tif",
					   "11_manual1.tif","12_manual1.tif","13_manual1.tif","14_manual1.tif","15_manual1.tif","16_manual1.tif","17_manual1.tif","18_manual1.tif","19_manual1.tif","20_manual1.tif",
					   "21_manual1.tif","22_manual1.tif","23_manual1.tif","24_manual1.tif","25_manual1.tif","26_manual1.tif","27_manual1.tif","28_manual1.tif","29_manual1.tif","30_manual1.tif",
					   "31_manual1.tif","32_manual1.tif","33_manual1.tif","34_manual1.tif","35_manual1.tif","36_manual1.tif","37_manual1.tif","38_manual1.tif","39_manual1.tif","40_manual1.tif"};

	string listin2[] = {"01_manual.tif","02_manual.tif","03_manual.tif","04_manual.tif","05_manual.tif","06_manual.tif","07_manual.tif","08_manual.tif","09_manual.tif","10_manual.tif",
					    "11_manual.tif","12_manual.tif","13_manual.tif","14_manual.tif","15_manual.tif","16_manual.tif","17_manual.tif","18_manual.tif","19_manual.tif","20_manual.tif",
					    "21_manual.tif","22_manual.tif","23_manual.tif","24_manual.tif","25_manual.tif","26_manual.tif","27_manual.tif","28_manual.tif","29_manual.tif","30_manual.tif",
					    "31_manual.tif","32_manual.tif","33_manual.tif","34_manual.tif","35_manual.tif","36_manual.tif","37_manual.tif","38_manual.tif","39_manual.tif","40_manual.tif"};

	string listout[] = {"01_manual_cut.tif","02_manual_cut.tif","03_manual_cut.tif","04_manual_cut.tif","05_manual_cut.tif","06_manual_cut.tif","07_manual_cut.tif","08_manual_cut.tif","09_manual_cut.tif","10_manual_cut.tif",
						"11_manual_cut.tif","12_manual_cut.tif","13_manual_cut.tif","14_manual_cut.tif","15_manual_cut.tif","16_manual_cut.tif","17_manual_cut.tif","18_manual_cut.tif","19_manual_cut.tif","20_manual_cut.tif",
						"21_manual_cut.tif","22_manual_cut.tif","23_manual_cut.tif","24_manual_cut.tif","25_manual_cut.tif","26_manual_cut.tif","27_manual_cut.tif","28_manual_cut.tif","29_manual_cut.tif","30_manual_cut.tif",
						"31_manual_cut.tif","32_manual_cut.tif","33_manual_cut.tif","34_manual_cut.tif","35_manual_cut.tif","36_manual_cut.tif","37_manual_cut.tif","38_manual_cut.tif","39_manual_cut.tif","40_manual_cut.tif"};

	string listout2[] = {"01_manual_cut2.tif","02_manual_cut2.tif","03_manual_cut2.tif","04_manual_cut2.tif","05_manual_cut2.tif","06_manual_cut2.tif","07_manual_cut2.tif","08_manual_cut2.tif","09_manual_cut2.tif","10_manual_cut2.tif",
						 "11_manual_cut2.tif","12_manual_cut2.tif","13_manual_cut2.tif","14_manual_cut2.tif","15_manual_cut2.tif","16_manual_cut2.tif","17_manual_cut2.tif","18_manual_cut2.tif","19_manual_cut2.tif","20_manual_cut2.tif",
						 "21_manual_cut2.tif","22_manual_cut2.tif","23_manual_cut2.tif","24_manual_cut2.tif","25_manual_cut2.tif","26_manual_cut2.tif","27_manual_cut2.tif","28_manual_cut2.tif","29_manual_cut2.tif","30_manual_cut2.tif",
						 "31_manual_cut2.tif","32_manual_cut2.tif","33_manual_cut2.tif","34_manual_cut2.tif","35_manual_cut2.tif","36_manual_cut2.tif","37_manual_cut2.tif","38_manual_cut2.tif","39_manual_cut2.tif","40_manual_cut2.tif"};

	string listout3[] = {"01_test.tif","02_test.tif","03_test.tif","04_test.tif","05_test.tif","06_test.tif","07_test.tif","08_test.tif","09_test.tif","10_test.tif",
						 "11_test.tif","12_test.tif","13_test.tif","14_test.tif","15_test.tif","16_test.tif","17_test.tif","18_test.tif","19_test.tif","20_test.tif",
						 "21_training.tif","22_training.tif","23_training.tif","24_training.tif","25_training.tif","26_training.tif","27_training.tif","28_training.tif","29_training.tif","30_training.tif",
						 "31_training.tif","32_training.tif","33_training.tif","34_training.tif","35_training.tif","36_training.tif","37_training.tif","38_training.tif","39_training.tif","40_training.tif"};

	string listout4[] = {"01_tes.tif","02_tes.tif","03_tes.tif","04_tes.tif","05_tes.tif","06_tes.tif","07_tes.tif","08_tes.tif","09_tes.tif","10_tes.tif",
					     "11_tes.tif","12_tes.tif","13_tes.tif","14_tes.tif","15_tes.tif","16_tes.tif","17_tes.tif","18_tes.tif","19_tes.tif","20_tes.tif",
						 "21_tes.tif","22_tes.tif","23_tes.tif","24_tes.tif","25_tes.tif","26_tes.tif","27_tes.tif","28_tes.tif","29_tes.tif","30_tes.tif",
						 "31_tes.tif","32_tes.tif","33_tes.tif","34_tes.tif","35_tes.tif","36_tes.tif","37_tes.tif","38_tes.tif","39_tes.tif","40_tes.tif"};


	for(int i=0; i<sizeof(listin)/4; i++)
	{
		String in = listout3[i];
		String out = listout4[i];

		Mat ingresso = imread(in);
		//ingresso.convertTo(ingresso, CV_32F);

		Mat uscita = ingresso(cv::Rect(90,113,370,370));
		imwrite(out,uscita);
	}
}
