Exemplo n.º 1
0
    void proc_click(Object sender, EventArgs e)
    {
        int              i, j;
        Workbook         workbook = new Workbook();
        Worksheet        warea    = new Worksheet("Area");
        RegionCollection rc       = new RegionCollection();

        for (i = 0; i < imWidth; i++)
        {
            for (j = 0; j < imHeight; j++)
            {
                rc.Add(mask[i, j]);
            }
        }
        j = 3;
        warea.Cells[0, 0] = new Cell("Region");
        warea.Cells[0, 1] = new Cell("Area");
        warea.Cells[1, 0] = new Cell("Pared");
        warea.Cells[1, 1] = new Cell(rc.GetVal(1));
        warea.Cells[2, 0] = new Cell("Exterior");
        warea.Cells[2, 1] = new Cell(rc.GetVal(2));
        for (i = 3; i < rc.Count; i++)
        {
            if (rc.GetVal(i) > 0)
            {
                warea.Cells[j, 0] = new Cell("Alveolo");
                warea.Cells[j, 1] = new Cell(rc.GetVal(i));
                j++;
            }
        }
        for (i = 0; i < 100; i++)
        {
            warea.Cells[i + j + 1, 0] = new Cell("");
        }
        double[]  lm  = new Lm(imWidth, imHeight, mask).Process();
        Worksheet wlm = new Worksheet("Lm");

        wlm.Cells[0, 0] = new Cell("Lm X");
        wlm.Cells[0, 1] = new Cell(lm[0]);
        wlm.Cells[1, 0] = new Cell("Lm y");
        wlm.Cells[1, 1] = new Cell(lm[1]);
        wlm.Cells[2, 0] = new Cell("Lm medio");
        wlm.Cells[2, 1] = new Cell((lm[0] + lm[1]) / 2);
        workbook.Worksheets.Add(warea);
        workbook.Worksheets.Add(wlm);
        string f = "C:\\histo\\histo.xls";

        workbook.Save(f);
        Process.Start(f);
    }