private Point imageMatching(Mat source, Mat template)
	{
		//TODO source greater than template -> resize?
		if(source.cols() < template.cols())
		{}
		
		if(source.rows() < template.rows())
		{}
		
		Mat sourcePolar                = new Mat(source.rows(), source.cols(), source.type());
		Mat templatePolar              = new Mat(template.rows(), template.cols(), template.type());
		Mat matchResult                = new Mat();
		Mat threshold                  = new Mat();
		MinMaxLocResult minMaxLocation = new MinMaxLocResult();
		Point location                 = new Point();
		
		
		// transform data to polar coordinates
		Imgproc.logPolar(source, sourcePolar,  new Point(source.cols() * 0.5, source.rows() * 0.5), 
				OpenCVImageDecoder.MAGNITUDE, Imgproc.INTER_LINEAR + Imgproc.CV_WARP_FILL_OUTLIERS);

        Imgproc.logPolar(template, templatePolar, new Point(template.cols() * 0.5, template.rows() * 0.5), 
        		OpenCVImageDecoder.MAGNITUDE, Imgproc.INTER_LINEAR + Imgproc.CV_WARP_FILL_OUTLIERS);
		
		// matching, normalize and create binary image
		Imgproc.matchTemplate(sourcePolar, templatePolar, matchResult, Imgproc.TM_CCOEFF);
		Core.normalize(matchResult, matchResult, 0, 1, Core.NORM_MINMAX, -1, new Mat());
		Imgproc.threshold(matchResult, threshold, 0.5, 255, 0);

		// find best match
		minMaxLocation = Core.minMaxLoc(matchResult);
		
		// method = Imgproc.TM_SQDIFF || Imgproc.TM_SQDIFF_NORMED
		// location = minMaxLocation.minLoc;
		// else
		location = minMaxLocation.maxLoc;

		// cut out relevant position, calculate width/height
		int    matchedPoints        = 0;
		double matchedPointsPercent = 0;
		int    locationWidth        = ((int)location.x + template.cols() > threshold.cols() ? 
				threshold.cols() - (int)location.x : template.cols());
		int    locationheight       = ((int)location.y + template.rows() > threshold.rows() ? 
				threshold.rows() - (int)location.y : template.rows());
		Mat    locationImage        = new Mat(locationheight, locationWidth, threshold.type());
		Rect   locationRect         = new Rect((int)location.x, (int)location.y, locationWidth, locationheight);
		
		locationImage = threshold.submat(locationRect);
		
		// rate match
		for (int i = 0; i < locationImage.cols(); i++) 
		{
			for (int j = 0; j < locationImage.rows(); j++) 
			{
				if((int)locationImage.get(j, i)[0] == 255)
				{
					matchedPoints++;
				}
			}
		}
		
		matchedPointsPercent = (100.0 / ((double)locationImage.cols() * (double)locationImage.rows())) * 
				(double)matchedPoints;
		
		// Complete image dump?
		/*
		Imgcodecs.imwrite("dump/source.jpg",        source);
		Imgcodecs.imwrite("dump/template.jpg",      template);
		Imgcodecs.imwrite("dump/sourcePolar.jpg",   sourcePolar);
		Imgcodecs.imwrite("dump/templatePolar.jpg", templatePolar);
		Imgcodecs.imwrite("dump/threshold.jpg",     threshold);
		Imgcodecs.imwrite("dump/locationImage.jpg", locationImage);
		System.out.println(matchedPointsPercent);
		*/
		
		if(matchedPointsPercent < OpenCVImageDecoder.MINIMAL_MATCH_PERCENTAGE)
		{
			return null;
		}
		
		return location;
	}