package yi.or;

import java.awt.*;

import yi.iu.CY_HSI;
import yi.iu.processor.*;
import yi.iu.ui.DisplayFrame;
import yi.util.io.OutputResult;

public class OR_boat extends OR_simple
{
    public String objName() {return "boat";}
    public Region recognition(int source[], int[][] hsi, int[][] laws, int[][] diff, Dimension d)
    {
        VISUALIZE=false;
        
        /*
        //based on hsi
        if (VERBOSE) System.err.println("based on hsi...");
        int[][] filter_hsi= getHSIFilter();
        Region hsi_rgn= new Region(d).rangeFilter(hsi,filter_hsi);
        if (VISUALIZE) hsi_rgn.display("hsi",source);
        
        //only on hsi information
        Region rgn= hsi_rgn;
        */
        Region rgn= super.recognition(source, hsi, laws, diff, d);
        

        //get sea
        Region rgn_sea= (new OR_sea()).recognition(source, hsi, laws, diff, d);
        //using sea as a hint
        rgn.intersection(rgn_sea.getExtension());
        rgn.difference(rgn_sea);
        
        //get the statistics information about all the connected component
        if (VERBOSE) System.err.println("region filtering...");
        rgn.connectComponent();
        if (VISUALIZE) rgn.display("connected",source);
        
        //first eliminate the small regions
        double[][] rgns_stat= rgn.getStatistics();
        double[][] stat_filter= getRegionFilter();
        rgn.rangeFilterOnRegion(rgns_stat, stat_filter);
        if (VISUALIZE) rgn.display("result",source);
        //OutputResult.outputResult("rgns_stat",rgns_stat);

        
        return rgn;
    }
    
    public int[][] getHSIFilter()
    {
        int[][] filter= {
            {100, 184},
            {0,	25},
            {62, 256},
        };
        return filter;
    }
    
    public double[][] getRegionFilter()
    {
        //0.00421875	0.528125	0.7625	0.496875	0.7166666666666667	0.059375	0.0875	0.10012523486435178	0.12047702940777884	0.6466165413533834	2.078362937414169	126.32590180780446	

        double[][] filter= {
            {0.002,1.1},    //area
            null, null,     //position
            null, null, null, null, //extent
            {0, 1.25},       //asepect  {0, 1.2}?
            {0, 1},       //slant
            null,
            null,
            null,
        };
        return filter;
    }
    
/*
    public int[][] getDiffFilter()
    {
        int[][] filter= {
            {0 , 25 },
            {0 , 25 },
        };
        return filter;
    }
*/    
    
}