#include <opencv/cv.h>
extern "C"
{
#include <opencv/highgui.h>
}
#include <cmath>
#include <iostream>
#include "../libseemicro/seemicro.h"

using namespace std;
using namespace seemicro;

IplImage *img;

int main(int argc, char** argv)
{
	if(argc != 4 && argc != 5)
	{
		cerr << "Call me as: " << argv[0] << " <inputimage> dx dy [<outputimage>]\n";
		return 1;
	}
	ImageFile i(argv[1]);
	int dx = atoi(argv[2]);
	int dy = atoi(argv[3]);
	IplImage* out = cvCreateImage(cvSize(i.img->width, i.img->height), IPL_DEPTH_8U, 3);
	
	circular_shift(i.img, out, dx, dy);
	
	if(argc==4)
	{
	  cvNamedWindow("CircularShift", 1);
	  cvShowImage("CircularShift", out);
          cvWaitKey();
	}
	else cvSaveImage(argv[4], out);
	
	cvReleaseImage(&img);
	cvDestroyWindow("CircularShift");
	return 0;
}

