/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dataBase.search.distance;

import data.bins.Bins;
import dataBase.subPicture.SubPicture;

/**
 *
 * @author Niklas
 */
public class Distance_L1 extends AbstractDistance {

	@Override
	public float getDistance(SubPicture a, SubPicture b) {

		assert a.getNrOfBins() == b.getNrOfBins();
		int length = a.getNrOfBins();

		float[] aBins = a.getBinsDirect();
		float[] bBins = b.getBinsDirect();
		float sum=0;

		for(int i=0; i<length; i++){
			sum += getDistance(aBins[i],bBins[i]);
		}
		return sum;
	}

	@Override
	public float getDistance(float a, float b) {
		return  Math.abs(b - a);
	}

}
