package yi.iu.processor.graphseg;

//the different between distacne measure diffxy_2 and diffxy is that:
//this one uses the sqrt(dx^2+dy^2) as the distance
//and the later one uses max(dx,dy) as the distance
public class DM_DIFFXY2 extends DM_DIFFXY
{
    public int distance(int h1[], int h2[]) {
        //if the difference between the weights of hue are large enough, return a big number;
        int size1=h1[SIZE], size2=h2[SIZE];
        int small_size= size1; if (size2<small_size) small_size=size2;
        
        int diff_x= distance(h1,h2,0,BINS,SIZE);
        int diff_y= distance(h1,h2,BINS,BINS2,SIZE);

        //int diff=diff_x; if (diff_y>diff) diff=diff_y;
        int diff=(int)Math.sqrt(diff_x*diff_x+diff_y*diff_y);

        //adjust the distance according to the size of region
        //if (small_size<SMALL_SIZE_THRSH) diff*=(double)small_size*small_size/(SMALL_SIZE_THRSH*SMALL_SIZE_THRSH);
        if (small_size<SMALL_SIZE_THRSH) diff=diff*small_size/(SMALL_SIZE_THRSH);

        //return diff_h+diff_c+diff_i;
        return (int)diff;
    }
}