/**
 * 
         -------- Copyright (C) [2012]  [Kristofer SCHWEIGER & Niklas FLORIAN1]---------

    This program is free software; you can redistribute it and/or modify it under the terms of the
 *  GNU General Public License as published by the Free Software Foundation; either version 2 of the License,
 *  or (at your option) any later version.
    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 *  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *  See the GNU General Public License for more details.
 * 
    You should have received a copy of the GNU General Public License along with this program; if not, 
 *  write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA

 * 
 * For any licensing issues please contact us under following adress: Mosaik.Projekt.2012@gmail.com
 */


package dataBase.search.distance;

import dataBase.subPicture.PixelByte;
import dataBase.subPicture.SubPicture;

public abstract class AbstractDistance {

	/**
	 * @param p1
	 * @param p2
	 * @return distance between SubPictures >= 0
	 */
	public float getDistance(SubPicture p1, SubPicture p2) {

		float sum=0;
		PixelByte[] pixelsA = p1.pixels;
		PixelByte[] pixelsB = p2.pixels;
		int partsX = SubPicture.partsX;
		int partsY = SubPicture.partsY;

		int size = partsY*partsX;
		for(int i=0; i<size; i++){
			sum += getDistance(pixelsA[i],pixelsB[i]);
		}

		return sum;
	}
	
	/**
	 * Distance between single Pixel objects.
	 * @param a
	 * @param b
	 * @return distance >= 0
	 */
	abstract public float getDistance(PixelByte a, PixelByte b);
}
