package yi.iu.processor.clc;

import yi.iu.processor.clc.*;
import yi.iu.processor.*;
import yi.iu.processor.building.*;
import yi.iu.processor.ort.*;
import yi.iu.processor.filter.GaussianSmooth;
import yi.iu.ui.*;
import yi.iu.processor.color.*;
import yi.util.io.*;
import yi.iu.processor.filter.*;
import yi.dp.Histogram;

import java.awt.*;
import java.util.Vector;
import java.io.*;

/**
 * Color Consistent Line Cluster.  Given an image, first find the dominant color,
 * find the color pair (in terms of dominant colors) of each line, and return
 * the lines and their color pair.  To tolerance the errors, it is possible to
 * find multiple color pairs for a line.  As the result, the returned lines may
 * have duplicates, and the number of the lines is possibly more than that of
 * detected.
 * @author Yi Li
 * @version 1.0
 * @deprecated class CSCLC is replaced by CLC_Color (Aug 25, 2002 when cleaning
 *             up the code)
 */
public class CSCLC extends yi.iu.processor.clc.ConsistentLineCluster
{
    public static double SMOOTH_SIGMA=4;
    public static int ANGEL_BINS=180;   //the number of bins for angel quantilization
    //arguments to do the canny edge detection
    public static double sigma=1;
    public static double tlow=0.5;
    public static double thigh=50;
    public static int min_length=4;
    //arguments to do the line extraction
    public static int MaxJumpPixels=1;

    public double COLORSMOOTH=0.8;
    public int LINEWIDTH=1; //the line width when calculate the color of the line
    int Tcpn=20;     //when the color pixel number > Tcpn, is a possible color
    double Tcpm=0.3;    //threshold for color portion: when calculate the color of a line,
                        //if one color takes more than Tcp of the whole line, then the color
                        //of the line is decided    (stands for color portion multi)
    int Tsp=4;       //threshold for shift pixels: shift the line until it arrives Tsp

    double Ths= 0.18;   //threshold for the size of considered color

    int testCluster1=-1;
    int outputlines=-1;
    int _color1= -1;
    int _color2= -1;

    public boolean illustration=true;

    public int getArguNum() { return 2;}

    public void setArgument(int i, String st)
    {
        if (st.length()==0) return;
        if (i==0) _color1= Integer.valueOf(st).intValue();
        if (i==1) _color2= Integer.valueOf(st).intValue();
        if (i==2) testCluster1= Integer.valueOf(st).intValue();
        if (i==3) outputlines= Integer.valueOf(st).intValue();
    }

    public String getArgument(int i)
    {
        if (i==0) return (new Integer(_color1)).toString();
        if (i==1) return (new Integer(_color2)).toString();
        if (i==2) return (new Integer(testCluster1)).toString();
        if (i==3) return (new Integer(outputlines)).toString();
        return null;
    }

    public String getArguName(int i)
    {
        if (i==0)  return "color 1";
        if (i==1)  return "color 2";
        if (i==2)  return "TestCluster";
        if (i==3)  return "output lines";
        return null;
    }

    /**
     * Given an image, find the color pairs of those detected lines.
     * @param source image pixels stored in 1-D int array
     * @param d image dimension
     * @param ref output results
     *            [0]: the dominant colors in RGB format
     *            [1]: the lines (one line could be multiple instance because of colors)
     *            [2]: the color- pairs of the lines (ref[1]-ref[2] is 1-1 map)
     * @return nothing
     */
    public LineCluster[] getProcessed_ex(int source[], Dimension d, Object ref[])
    {
        int i,j;

        //GaussianSmooth gauss= new GaussianSmooth(COLORSMOOTH);
        //int[] smooth= gauss.getRGBProcessed(source, d);
        // find the dominant colors
        int[] color_map= new int[source.length];    // every pixel corresponds
                // dominat color (only save the index of dominant color)
        DominantColor dc= new DominantColor();
        double[][] cc= dc.getProcessed_ex(source, d, color_map);  // the dominant colors
        // change dominant colors from Lab space to RGB space
        int[] dominant_colors= new int[cc.length];
        for (i=0; i<cc.length; i++)
          dominant_colors[i] = CIELab.lab2rgb(cc[i]);

        ref[0]= dominant_colors;
        int cNum=dominant_colors.length;
        System.out.println("dominant colors #="+cNum);

        //make the spectrum of the clustered colors
        int[] spectrum = yi.iu.processor.color.ColorUtil.createSpectrum(dominant_colors, 30, 60);
        int[][] rgb= new int[cNum][3];
        for (i=0;i<cNum;i++) {
            rgb[i][0]=(dominant_colors[i]>>16)&0xff;
            rgb[i][1]=(dominant_colors[i]>>8)&0xff;
            rgb[i][2]=(dominant_colors[i])&0xff;
        }
        OutputResult.outputResult("clusted_color", rgb);

        //find all the lines in an image
        Vector[] segs= (new Fex(sigma,tlow,thigh,min_length,MaxJumpPixels)).fex(source, d);
        Vector lines= segs[0];
        //recalculate the ThetaVar
        for (int k=0;k<lines.size();k++) {
            ORTLine kl=(ORTLine)lines.elementAt(k);
            kl.recal();
        }
        //ref[1]= lines;
        int numLines= lines.size();

        //for debug
        //double kx1=-58.0,ky1=-49.0,kx2=-58.0,ky2=-45.0;

        Vector newLines= new Vector();
        Vector lineColors= new Vector();        //store the color of the lines
        boolean[][] cmap= new boolean[cNum][cNum];  //prevent same color-pairs as (1,2) and (2,1)
        for (i=0;i<numLines;i++) {
            for (int m=0;m<cNum;m++) for (int n=0;n<cNum;n++) cmap[m][n]=false;
            ORTLine l= (ORTLine)lines.elementAt(i);
            int[][] colors= getLineColors_mul(color_map, d, l, cNum, Tcpm, Tsp);
            int num1=(colors[0]==null)?0:colors[0].length;
            int num2=(colors[1]==null)?0:colors[1].length;
            for (int m=0;m<num1;m++) {
                for (int n=0;n<num2;n++) {
                    //if (colors[0][m]==colors[1][n]) continue;
                    int c1= colors[0][m];
                    int c2= colors[1][n];
                    if (cmap[c2][c1]) continue;
                    cmap[c1][c2]=true;
                    newLines.addElement(l);
                    int[] cs= {c1,c2};
                    lineColors.addElement(cs);
                }
            }

        }
        int numNewLines= newLines.size();
        int[][] lineColor= new int[numNewLines][];
        for (i=0;i<lineColor.length;i++) {
            lineColor[i]=(int[])lineColors.elementAt(i);
        }
        System.err.println("get line colors using multiple choices: "+numLines+"->"+numNewLines);

        ref[1]= newLines;
        ref[2]= lineColor;


/*
        for (int k=0;k<newLines.size();k++) {
            ORTLine kl=(ORTLine)newLines.elementAt(k);
            if ((kl.Start.Col==kx1&&kl.Start.Row==ky1)||
                (kl.Start.Col==kx2&&kl.Start.Row==ky2)) {
                System.err.println("found at "+k+":"+kl.Start.Col+","+kl.Start.Row+","
                    +kl.Start.Col+","+kl.Start.Row+":"+lineColor[k][0]+","+lineColor[k][1]);
                }
        }
*/
        //OutputResult.outputResult("line_color", lineColor);

        //output the monitored newLines
        if (_color1>=0) {
            int[] _c={_color1,_color2};
            System.out.println("monitor:"+singleColorIndex(_c,cNum));
            LineCluster out= new LineCluster();
            for (i=0;i<numNewLines;i++) {
                if (_color1>=0&&(lineColor[i][0]!=_color1||lineColor[i][1]!=_color2)
                    &&(lineColor[i][0]!=_color2||lineColor[i][1]!=_color1))
                    continue;
                ORTLine l= (ORTLine)newLines.elementAt(i);
                out.insert(l);
            }
            out.output();
        }

        if (illustration) {
            //draw the dominant colors
            int[] dcimg= yi.util.ImageUtil.makeNewImageFromLabel(color_map);
            drawLineClusters(dcimg, d, lines, 0xffffffff);

            int[] lineimg= yi.util.ImageUtil.makeBackground(source);
            drawLineClusters(lineimg, d, lines, 0xffffffff);
            for (i=0;i<numNewLines;i++) {
                if (_color1>=0&&(lineColor[i][0]!=_color1||lineColor[i][1]!=_color2)
                    &&(lineColor[i][0]!=_color2||lineColor[i][1]!=_color1))
                    continue;
                ORTLine l= (ORTLine)newLines.elementAt(i);
                DrawUtil.ort2image(lineimg, d, l, 0xffff0000, 1);
            }
            (new SegFrame("dominant colors", dcimg, d.width, d.height, color_map)).show();
            (new DisplayFrame("dominant colors", lineimg, d)).show();
        }

        return null;
    }


    public int[] getProcessedPseudoColor(int source[], Dimension d)
    {
        int i,j;

        Object[] ref= new Object[3];
        getProcessed_ex(source, d, ref);
        int[] dominant_colors= (int[])ref[0];
        int cNum=dominant_colors.length;
        Vector lines= (Vector)ref[1];
        int[][] lineColor= (int[][])ref[2];


        //represent the color of the lines by a single integer
        int[] lineIndexColor= new int[lines.size()];
        for (i=0;i<lineIndexColor.length;i++) {
            lineIndexColor[i]=singleColorIndex(lineColor[i], cNum);
        }

        //draw the lines according to the color
        int[] label= new int[source.length];
        for (i=0;i<label.length;i++) label[i]=-1;
        for (i=0;i<lines.size();i++) {
            ORTLine line= (ORTLine)lines.elementAt(i);
            if (testCluster>=0&&testCluster!=lineIndexColor[i]) continue;
            DrawUtil.ort2image(label, d, line, lineIndexColor[i], 1);
        }
        int[] cluster_img= yi.util.ImageUtil.makeNewImageFromLabel_back(label);
        (new SegFrame("color consistent line cluster", cluster_img, d.width, d.height, label)).show();

        if (outputlines!=-1) outputColoredLines(lines,lineIndexColor);
        return null;
    }


    /**
     * Given the color pair index, return the color pair.
     *
     * @param color Color pair index
     * @param cNum The total number of the colors.
     * @return The color pair
     */
    public int[] colorPairs(int color, int cNum)
    {
        int[] c= new int[2];
        int c1= color/(cNum+1);
        int c2= color-c1*(cNum+1);
        if (c1<c2) {
            c[0]=c1-1;c[1]=c2-1;
        }
        else {
            c[0]=c2-1;c[1]=c1-1;
        }
        return c;
    }


    /**
     * Return a integer as the index to represent a the color pairs.  For example,
     * the lines have two colors, c1 and c2, on their sides, but we could represent this
     * attribute by one number, c1*(size of color count)+c2.
     *
     * @param colors The color pair.
     * @param cNum The color count.
     * @return The signal value to represent the color pair.
     */
    public int singleColorIndex(int[] colors, int cNum)
    {
        if (colors[0]>=cNum||colors[1]>=cNum) {
            System.err.println("wrong color index!");
        }
        if (colors[0]<colors[1])
            return ((colors[0]+1)*(cNum+1)+colors[1]+1);
        return ((colors[1]+1)*(cNum+1)+colors[0]+1);
    }


    //calculate the colors on the both side of the line
    //return null if can't decide (don't count on the non-decided pixel)
    int[][] getLineColors_mul(int[] img, Dimension d, ORTLine l, int cNum, double tcpm, int tsp)
    {
        int i,j;
        ORTLine shift= null;
        int[][] result= new int[2][];

        //color on the +90 side
        int[] color_his= new int[cNum];
        int length= -1;
        for (i=1;i<=tsp;i++)    {
            shift=l.makeNewLineByAngleShift(i, Math.PI/2);
            int[] p_length= new int[1];
            //the length of returned colors is cNum+1,
            //the colors[cNum] is the number of un-decided piexls.
            int[] colors= colorsOnVirtualLine(img, d, shift, cNum, LINEWIDTH, p_length);

            if (length<=0) length= p_length[0];
            for (j=0;j<color_his.length;j++)
                if (color_his[j]<colors[j]) color_his[j]=colors[j];
        }

        //color on the -90 side
        int[] color_his2= new int[cNum];
        for (i=1;i<=tsp;i++)    {
            shift=l.makeNewLineByAngleShift(i, -Math.PI/2);
            int[] p_length= new int[1];
            int[] colors= colorsOnVirtualLine(img, d, shift, cNum, LINEWIDTH, p_length);
            if (length<=0) length= p_length[0];
            for (j=0;j<color_his2.length;j++)
                if (color_his2[j]<colors[j]) color_his2[j]=colors[j];
        }

        //examine how many satisfy the requirement
        int threshold= (int)Math.ceil(length*tcpm);
        if (threshold<=2) {
            System.err.println("threshold<=2: "+ length);
            threshold=2;
        }
        //int threshold= (int)Math.min(Math.ceil(length*tcpm),Tcpn);
        int sat=0;
        for (i=0;i<color_his.length;i++) if (color_his[i]>=threshold) sat++;
        if (sat>0) {
            int[] colors= new int[sat];
            for (i=0;i<color_his.length;i++) if (color_his[i]>=threshold) colors[--sat]=i;
            result[0]= colors;
        }
        else result[0]=null;

        //examine how many satisfy the requirement
        sat=0;
        for (i=0;i<color_his2.length;i++) if (color_his2[i]>=threshold) sat++;
        if (sat>0) {
            int[] colors= new int[sat];
            for (i=0;i<color_his2.length;i++) if (color_his2[i]>=threshold) colors[--sat]=i;
            result[1]= colors;
        }
        else result[1]=null;

        return result;
    }


    int[] colorsOnVirtualLine(int[] img, Dimension d, ORTLine line, int cNum, int LineThickness, int[] p_length)
    {
        int[] cHist= new int[cNum+1];   //color histogram

      int temp, deltax, deltay, xincrement, yincrement, e, a, b, i;
        int k,l;

        int num=0;
        int red=0,green=0,blue=0;
        int xsize=d.width,ysize=d.height;
        double XCenter = ((double) (xsize))/2.0;
        double YCenter = ((double) (ysize))/2.0;
        int x1= (int)(Math.round(line.Start.Col+XCenter)), y1= (int)Math.round(line.Start.Row+YCenter);
        int x2= (int)(Math.round(line.End.Col+XCenter)), y2= (int)(Math.round(line.End.Row+YCenter));
        if (Math.abs(x2-x1) > Math.abs(y2-y1)) {
            if (x1 > x2) {
                temp = x1; x1 = x2; x2 = temp;
                temp = y1; y1 = y2; y2 = temp;
            }
            deltax = x2 - x1;
            deltay = Math.abs (y2 - y1);
            e = (2 * deltay) - deltax;
            a = (2 * deltay) - (2 * deltax);
            b = (2 * deltay);
            if (y2 > y1) {
              yincrement = 1;
            } else {
              yincrement = -1;
            }
            for (i= 0;i<=deltax;i++) {

                if ((x1>0) && (x1<=xsize) && (y1>0) && (y1<=ysize)) {
                    for(k =(x1-LineThickness); k<=(x1+LineThickness); k++){
                        for(l =(y1-LineThickness); l<=(y1+LineThickness); l++){
                            if (l>=0&&l<ysize&&k>=0&&k<xsize) {
                                int c= img[l*xsize+k];
                                cHist[c]++;
                                num++;
                            }
                        }
                    }
                }
                if (e > 0) {
                    y1 = y1 + yincrement;
                    e = e + a;
                } else {
                    e = e + b;
                }
                x1 = x1 + 1;
            }
        }
        else {
            if (y1 > y2) {
                temp = x1; x1 = x2; x2 = temp;
                temp = y1; y1 = y2; y2 = temp;
            }
            deltay = y2 - y1;
            deltax = Math.abs(x2 - x1);
            e = (2 * deltax) - deltay;
            a = (2 * deltax) - (2 * deltay);
            b = (2 * deltax);
            if (x2 > x1) {
              xincrement = 1;
            } else {
              xincrement = -1;
            }
            for (i= 0;i<=deltay;i++) {
                if ((x1>0) && (x1<=xsize) && (y1>0) && (y1<=ysize)) {
                        for(k =(x1-LineThickness); k<=(x1+LineThickness); k++){
                        for(l =(y1-LineThickness); l<=(y1+LineThickness); l++){
                            if (l>=0&&l<ysize&&k>=0&&k<xsize) {
                                int c= img[l*xsize+k];
                                cHist[c]++;
                                num++;
                            }
                        }
                        }
                }
                if (e > 0) {
                    x1 = x1 + xincrement;
                    e = e + a;
                } else {
                    e = e + b;
                }
                    y1 = y1 + 1;
            }
        }

        p_length[0] = num;
/*
        if (num==0) {
                System.err.println("found length =0: "+line.Start.Col+","+line.Start.Row+","
                    +line.Start.Col+","+line.Start.Row);
        }
*/
        return cHist;
        /*
        int max=0;
        int max_i=cNum;
        int threshold= (int)(num*tcp);
        for (i=0;i<=cNum;i++)
            if (cHist[i]>max) {
                max=cHist[i];
                max_i=i;
            }
        if (max<threshold) max_i=-1;

        int[] rst={max_i,max,num};
        return rst;
        */
    }

    public int[] getProcessed(int source[], Dimension d)
    {
        // This method is derived from class yi.iu.processor.ImageProcessor
        // to do: code goes here
        return null;
    }

    void outputColoredLines(Vector lines, int[] colors)
    {
        int i,j;
        if (lines.size()!=colors.length) {
            System.err.println("|lines| != |colors|");
        }
        try {
            ObjectOutputStream out= new ObjectOutputStream (
                new FileOutputStream ("coloredlines.out"));
            out.writeObject(lines);
            out.writeObject(colors);
            out.close();
        }
        catch (Exception e) {
            System.err.println(e.toString());
        }
    }

    void outputColoredLines(LineCluster[] lcs)
    {
        int i,j;
        try {
            ObjectOutputStream out= new ObjectOutputStream (
                new FileOutputStream ("csocls.out"));
            out.writeObject(lcs);
            out.close();
        }
        catch (Exception e) {
            System.err.println(e.toString());
        }
    }

    public static void main(String[] args) {
LineCluster lc= new LineCluster(0,147,16);
lc.insert(new ORTLine(-10.0,-195.0,0.0,-198.0));
lc.insert(new ORTLine(-19.0,-238.0,-15.0,-238.0));
lc.insert(new ORTLine(-3.0,-228.0,-10.0,-228.0));
lc.insert(new ORTLine(99.0,-226.0,80.0,-221.0));
lc.insert(new ORTLine(31.0,-207.0,13.0,-202.0));
lc.insert(new ORTLine(95.0,-215.0,80.0,-211.0));
lc.insert(new ORTLine(81.0,-178.0,104.0,-183.0));
lc.insert(new ORTLine(68.0,-218.0,46.0,-211.0));
lc.insert(new ORTLine(104.0,-215.0,82.0,-209.0));
lc.insert(new ORTLine(60.0,-199.0,46.0,-195.0));
lc.insert(new ORTLine(45.0,-201.0,66.0,-207.0));
lc.insert(new ORTLine(68.0,-206.0,47.0,-199.0));
lc.insert(new ORTLine(66.0,-175.0,47.0,-170.0));
lc.insert(new ORTLine(32.0,-198.0,15.0,-193.0));
lc.insert(new ORTLine(32.0,-167.0,14.0,-162.0));
lc.insert(new ORTLine(2.0,-190.0,-15.0,-185.0));
lc.insert(new ORTLine(99.0,-172.0,80.0,-168.0));
lc.insert(new ORTLine(82.0,-134.0,105.0,-139.0));
lc.insert(new ORTLine(104.0,-171.0,100.0,-169.0));
lc.insert(new ORTLine(94.0,-168.0,89.0,-167.0));
lc.insert(new ORTLine(316.0,-163.0,304.0,-157.0));
lc.insert(new ORTLine(3.0,-160.0,-17.0,-154.0));
lc.insert(new ORTLine(59.0,-160.0,69.0,-162.0));
lc.insert(new ORTLine(68.0,-165.0,51.0,-161.0));
lc.insert(new ORTLine(47.0,-128.0,70.0,-132.0));
lc.insert(new ORTLine(55.0,-159.0,48.0,-157.0));
lc.insert(new ORTLine(34.0,-157.0,14.0,-152.0));
lc.insert(new ORTLine(15.0,-121.0,35.0,-125.0));
lc.insert(new ORTLine(2.0,-150.0,-18.0,-145.0));
lc.insert(new ORTLine(-4.0,-117.0,-10.0,-116.0));
lc.insert(new ORTLine(68.0,-122.0,47.0,-117.0));
lc.insert(new ORTLine(48.0,-84.0,70.0,-88.0));
lc.insert(new ORTLine(102.0,-125.0,106.0,-126.0));
lc.insert(new ORTLine(108.0,-128.0,83.0,-124.0));
lc.insert(new ORTLine(97.0,-124.0,90.0,-123.0));
lc.insert(new ORTLine(103.0,-120.0,108.0,-120.0));
lc.insert(new ORTLine(107.0,-93.0,85.0,-90.0));
lc.insert(new ORTLine(-6.0,-107.0,-18.0,-105.0));
lc.insert(new ORTLine(26.0,-111.0,33.0,-112.0));
lc.insert(new ORTLine(32.0,-115.0,15.0,-111.0));
lc.insert(new ORTLine(15.0,-79.0,37.0,-83.0));
lc.insert(new ORTLine(3.0,-105.0,-3.0,-102.0));
lc.insert(new ORTLine(-13.0,-37.0,-18.0,-38.0));
lc.insert(new ORTLine(115.0,-46.0,128.0,-45.0));
lc.insert(new ORTLine(107.0,-43.0,80.0,-41.0));
lc.insert(new ORTLine(107.0,-41.0,98.0,-40.0));
lc.insert(new ORTLine(95.0,-39.0,81.0,-39.0));
lc.insert(new ORTLine(111.0,-38.0,122.0,-41.0));
lc.insert(new ORTLine(50.0,-37.0,44.0,-37.0));
lc.insert(new ORTLine(153.0,10.0,177.0,13.0));
lc.insert(new ORTLine(84.0,3.0,73.0,4.0));
lc.insert(new ORTLine(183.0,14.0,252.0,23.0));
lc.insert(new ORTLine(255.0,23.0,315.0,20.0));
lc.insert(new ORTLine(-150.0,15.0,-146.0,13.0));
lc.insert(new ORTLine(223.0,16.0,217.0,15.0));
lc.insert(new ORTLine(274.0,9.0,280.0,10.0));
lc.insert(new ORTLine(-169.0,9.0,-158.0,10.0));
lc.insert(new ORTLine(-170.0,12.0,-174.0,12.0));
lc.insert(new ORTLine(250.0,13.0,256.0,13.0));
lc.insert(new ORTLine(316.0,16.0,251.0,20.0));
lc.insert(new ORTLine(248.0,21.0,239.0,20.0));
lc.insert(new ORTLine(308.0,24.0,316.0,24.0));
lc.insert(new ORTLine(221.0,25.0,216.0,26.0));
lc.insert(new ORTLine(299.0,25.0,303.0,25.0));
lc.insert(new ORTLine(306.0,27.0,310.0,27.0));
lc.insert(new ORTLine(253.0,27.0,260.0,27.0));
lc.insert(new ORTLine(134.0,35.0,180.0,35.0));
lc.insert(new ORTLine(316.0,32.0,300.0,33.0));
lc.insert(new ORTLine(216.0,30.0,269.0,32.0));
lc.insert(new ORTLine(236.0,41.0,255.0,39.0));
lc.insert(new ORTLine(316.0,36.0,302.0,36.0));
lc.insert(new ORTLine(112.0,44.0,108.0,45.0));
lc.insert(new ORTLine(248.0,42.0,267.0,42.0));
lc.insert(new ORTLine(200.0,49.0,193.0,50.0));
lc.insert(new ORTLine(220.0,55.0,235.0,53.0));
lc.insert(new ORTLine(227.0,55.0,232.0,55.0));
lc.insert(new ORTLine(268.0,60.0,243.0,61.0));
lc.insert(new ORTLine(193.0,65.0,202.0,63.0));
lc.insert(new ORTLine(297.0,64.0,312.0,64.0));
lc.insert(new ORTLine(308.0,67.0,316.0,67.0));
lc.insert(new ORTLine(-156.0,68.0,-152.0,68.0));
lc.insert(new ORTLine(275.0,67.0,265.0,68.0));
lc.insert(new ORTLine(266.0,76.0,284.0,75.0));
lc.insert(new ORTLine(286.0,73.0,275.0,73.0));
lc.insert(new ORTLine(-69.0,71.0,-65.0,72.0));
lc.insert(new ORTLine(236.0,71.0,255.0,67.0));
lc.insert(new ORTLine(-46.0,84.0,-33.0,85.0));
lc.insert(new ORTLine(316.0,95.0,307.0,96.0));
lc.insert(new ORTLine(-22.0,106.0,-28.0,107.0));
lc.insert(new ORTLine(249.0,111.0,253.0,112.0));
        CSCLC csclc= new CSCLC();
        Dimension d= new Dimension(640,480);
        LineCluster[] lcs= {lc};
        csclc.drawLineClusters("lc", d, lcs, -1);

    }

}