Exemplo n.º 1
0
        public static int[][,] readBitmapSet(String path)
        {
            string[] files = System.IO.Directory.GetFiles(path, "*.bmp");

            List <int[, ]> list = new List <int[, ]>();

            list.Clear();

            foreach (string file in files)
            {
                int[,] bmp = Reader.fromFile(file);
                list.Add(bmp);
            }

            return(list.ToArray());
        }
Exemplo n.º 2
0
        static void Main2(string[] args)
        {
            String projectPath    = "C:/Users/Mateusz/Documents/Visual Studio 2012/Projects/ConsoleApplication1/ConsoleApplication1/bin/Debug/assets/p01/";
            String dirPath        = "";
            String filenamePrefix = "out_";
            String filenameExt    = "bmp";
            String path;
            int    t0 = 1;
            int    tk = 3;

            List <List <Point> > _points = new List <List <Point> >();
            List <Edge>          _edges  = new List <Edge>();

            int slices_count = tk - t0 + 1;

            for (int t = t0; t <= tk; ++t)
            {
                path         = projectPath + dirPath + filenamePrefix + t + "." + filenameExt;
                int[,] image = Reader.fromFile(path);
                Point[] points = ImageProcessing.getVertex(image);

                int image_w = image.GetLength(0);
                int image_h = image.GetLength(1);

                SortedDictionary <String, Point> dict = new SortedDictionary <string, Point>();
                foreach (Point p in points)
                {
                    double angle = Math.Atan2(p.y - image_h / 2, p.x - image_w / 2);
                    dict.Add(angle.ToString(), p);
                }

                /**
                 * Save each slice vertexes at list, contains of connected points (understand as edges)
                 */
                String       prevKey     = "";
                String       firstKey    = null;
                List <Point> slicePoints = new List <Point>();
                foreach (KeyValuePair <String, Point> entry in dict)
                {
                    if (firstKey == null)
                    {
                        firstKey = entry.Key;
                    }
                    if (!prevKey.Equals(""))
                    {
                        Point beforePoint;
                        dict.TryGetValue(prevKey, out beforePoint);

                        _edges.Add(new Edge(beforePoint, entry.Value));
                    }
                    slicePoints.Add(entry.Value);
                    prevKey = entry.Key;
                }
                _edges.Add(new Edge(dict[prevKey], dict[firstKey]));
                _points.Add(slicePoints);
                slicePoints.Clear();
            }

            /**
             *
             * Now _edges stores all edges for loaded object, retrives by alone points. What about two white blobs? Region growing based algorithm.
             *
             */


            /**
             *
             * normalization
             *
             */
            //coordinates goes to around 0,0

            /**
             *
             * interpolation on z axis
             *
             */
        }