 #include <psychlops.h>
 using namespace Psychlops;

const int S = 128;

 void psychlops_main() {
	Canvas cnvs(1024, 768, Canvas::window);

	Image source("test.png");
	Image result;

	Image img[5];
	//for(int i=0; i<1000; i++){
		FFT2 fftworkspace;
		Matrix source_mat(S,S), filtered_mat, filter;
		for(int x=1; x<=S; x++)
			for(int y=1; y<=S; y++)
				source_mat(x,y) = random(0.0,1.0);
		//source_mat=FFT2::makeNoise(64, 64);
		filter=FFT2::makeFilter(S, S, 8, 12);

		//fftworkspace.set(64,64);
		//fftworkspace.makeNoise();
		fftworkspace.set(source_mat);
		fftworkspace.fft();
		fftworkspace.filtering(filter);
		fftworkspace.ifft();
		fftworkspace.getImage(filtered_mat);

		img[0].from(source_mat);
		img[1].from(filter);
		img[2].from(filtered_mat);

	while(!Keyboard::esc.pushed())
	{
		cnvs.clear(0.5);
		for(int i=0; i<5; i++) img[i].centering().shift(-400,0).shift((S+1)*i,0).draw();
		cnvs.var(Mouse::x, 100, 80);
		cnvs.var(Mouse::y, 100, 100);
		cnvs.flip();
	}

 }

