//the big boy, iterates through the pixels and drives algorithms
        public void run(ProgressBar progressBar1)
        {
            if (pixels == null)
            {
                MessageBox.Show("No Pixels Loaded", "no pixels", 0);
                return;
            }

            selection s = new selection(pixels, imageWidth, totalPixels);

            for (int i = 0; i < totalPixels; i++)
            {
                progressBar1.Value = i;

                if (s.get(i))
                {
                    buffer    = s.Buffer;
                    perimeter = s.Perimeter;
                    objectData dat = new objectData(getAverageValue(), buffer.Count, buffer.Count / s.getedges());
                    conf       c   = confidence.getconfidence(dat);
                    dat.objconf = c;
                    objdat.Add(dat);

                    if (!c.isStructure)
                    {
                        colorbuffer(constants.COLOR_CLEAR);
                    }
                }
                s.clearbuffer();
                buffer.Clear();
            }
        }
Exemple #2
0
        //the big boy, iterates through the pixels and drives algorithms
        private void run()
        {
            System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
            int  per_25 = totalPixels / 4;
            int  per_50 = totalPixels / 2;
            int  per_75 = per_25 + per_50;
            bool b_25 = false, b_50 = false, b_75 = false;
            bool writeData = false;

            if (ofilename != "none")
            {
                ofilename = "data/" + ofilename;
                System.IO.File.WriteAllText(ofilename, "val, size, edge, dust, obj, res, type, c avg, c edge, c size\n");
                writeData = true;
            }
            selection s = new selection(pixels, imageWidth, totalPixels);

            watch.Start();
            for (int i = 0; i < totalPixels; i++)
            {
                if (s.get(i))
                {
                    buffer    = s.getBuffer();
                    perimeter = s.getPerimeter();
                    data[1]   = buffer.Count;
                    data[2]   = data[1] / s.getEdges();
                    data[0]   = getAverageValue(Convert.ToInt32(data[1]));
                    conf c = confidence.getconfidence(data);

                    if (!c.isObj)
                    {
                        colorbuffer(150, Convert.ToInt32(data[1]));
                    }

                    if (writeData)
                    {
                        printcsv(ref c);
                    }
                }
                s.clearBuffer();
                buffer.Clear();
                if (i > per_25 && !b_25)
                {
                    Console.WriteLine("25%...\n");
                    b_25 = true;
                }

                if (i > per_50 && !b_50)
                {
                    Console.WriteLine("50%...\n");
                    b_50 = true;
                }

                if (i > per_75 && !b_75)
                {
                    Console.WriteLine("75%...\n");
                    b_75 = true;
                }
            }
            watch.Stop();
            Console.WriteLine("Time elapsed: {0}", watch.Elapsed);
        }