コード例 #1
0
        static bool WangZhangThinningAlg(int x, int y, bool[][] s)
        {
            // if (x > 0 && x < s.Length - 2 && y < s[0].Length - 1 && y > 1 && s[x][y])//bounds and 1st condition p1 = 1
            //   {
            bool p2 = s[x][y - 1];
            bool p3 = s[x + 1][y - 1];
            bool p4 = s[x + 1][y];
            bool p5 = s[x + 1][y + 1];
            bool p6 = s[x][y + 1];
            bool p7 = s[x - 1][y + 1];
            bool p8 = s[x - 1][y];
            bool p9 = s[x - 1][y - 1];

            int bp1 = ThinningHelper.NumberOfNonZeroNeighbors(x, y, s);

            if (bp1 >= 2 && bp1 <= 6)    //2nd condition
            {
                if ((ThinningHelper.NumberOfZeroToOneTransitionFromP9(x, y, s) == 1) | (p2 == false & p3 == false & p4 == false & p7 == false & p6 == true & p8 == true) | (p4 == false & p5 == false & p6 == false & p9 == false & p8 == true & p2 == true))
                {
                    if ((p2 == false & (p8 == false | p4 == false | p6 == false)) | (p4 == false & (p6 == false | p2 == false | p8 == false)))
                    {
                        return(true);
                    }
                }
            }

            // }
            return(false);
        }
        static bool ZhangWangThinningAlg(int x, int y, bool[][] s)
        {
            if (x > 0 && x < s.Length - 2 && y < s[0].Length - 1 && y > 1 && s[x][y])//bounds and 1st condition p1 = 1
            {
                bool p2 = s[x][y - 1];
                bool p3 = s[x + 1][y - 1];
                bool p4 = s[x + 1][y];
                bool p5 = s[x + 1][y + 1];
                bool p6 = s[x][y + 1];
                bool p7 = s[x - 1][y + 1];
                bool p8 = s[x - 1][y];
                bool p9 = s[x - 1][y - 1];

                int bp1 = ThinningHelper.NumberOfNonZeroNeighbors(x, y, s);

                if (bp1 >= 2 && bp1 <= 6)//2nd condition
                {
                    if (ThinningHelper.NumberOfZeroToOneTransitionFromP9(x, y, s) == 1)
                    {
                        if (!((p2 && p4) && p8) || s[x][y - 2])
                        {
                            if (!((p2 && p4) && p6) || s[x + 2][y])
                            {
                                return(true);
                            }
                        }
                    }
                }
            }
            return(false);
        }
コード例 #3
0
        static bool HilditchThinningAlg(int x, int y, bool[][] s)
        {
            bool p2 = s[x][y - 1];
            bool p3 = s[x + 1][y - 1];
            bool p4 = s[x + 1][y];
            bool p5 = s[x + 1][y + 1];
            bool p6 = s[x][y + 1];
            bool p7 = s[x - 1][y + 1];
            bool p8 = s[x - 1][y];
            bool p9 = s[x - 1][y - 1];

            int bp1 = ThinningHelper.NumberOfNonZeroNeighbors(x, y, s);

            if (bp1 >= 2 && bp1 <= 6) //2nd condition
            {
                if (ThinningHelper.NumberOfZeroToOneTransitionFromP9(x, y, s) == 1)
                {
                    if (!((p2 && p4) && p8) | (ThinningHelper.NumberOfZeroToOneTransitionFromP9(x, y - 1, s) != 1))
                    {
                        if (!((p2 && p4) && p6) | (ThinningHelper.NumberOfZeroToOneTransitionFromP9(x + 1, y, s) != 1))
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
コード例 #4
0
        public static bool[][] KwonWoongKangThinningAlg(bool[][] s)
        {
            Benchmark.Start();
            bool[][] temp  = ThinningHelper.ArrayClone(s); // make a deep copy to start..
            int      count = 0;

            do  // the first pass
            {
                count  = stepKwonWoongKangThinningThinning(1, temp, s);
                temp   = ThinningHelper.ArrayClone(s);    // ..and on each..
                count += stepKwonWoongKangThinningThinning(2, temp, s);
                temp   = ThinningHelper.ArrayClone(s);    // ..call!
            }while (count > 0);

            // pokracovanie druha podmienka

            do  // the second pass
            {
                count = passKwonWoongKangThinningThinning(temp, s);
                temp  = ThinningHelper.ArrayClone(s);     // ..and on each..
            }while (count > 0);
            Benchmark.End();

            return(s);
        }
コード例 #5
0
        public static Bitmap StentifordThinningAlg(Bitmap src, Bitmap dst)
        {
            // Raster src  = srcarr[0];
            width  = src.Width;
            height = src.Height;

            bool[][] t = ThinningHelper.Image2Bool(src);

            return(thinning(src, t, dst));
        }
コード例 #6
0
        static bool skuskaAlgThinningAlg(int x, int y, bool[][] s, int stepNo)
        {
            bool p2 = s[x][y - 1];
            bool p3 = s[x + 1][y - 1];
            bool p4 = s[x + 1][y];
            bool p5 = s[x + 1][y + 1];
            bool p6 = s[x][y + 1];
            bool p7 = s[x - 1][y + 1];
            bool p8 = s[x - 1][y];
            bool p9 = s[x - 1][y - 1];

            int bp1 = ThinningHelper.NumberOfNonZeroNeighbors(x, y, s);

            if (/*!endPoint(x, y, s)*/ bp1 != 1) //2nd condition
            {
                if (removePixel(x, y, s))
                {
                    if (stepNo == 1)
                    {
                        if (!p2 && p6)
                        {
                            return(true);
                        }
                    }

                    if (stepNo == 2)
                    {
                        if (!p8 && p4)
                        {
                            return(true);
                        }
                    }

                    if (stepNo == 3)
                    {
                        if (!p6 && p2)
                        {
                            return(true);
                        }
                    }

                    if (stepNo == 4)
                    {
                        if (!p4 && p8)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
コード例 #7
0
        public static bool[][] LuWangThinningAlg(bool[][] s) //http://shodhganga.inflibnet.ac.in/bitstream/10603/3466/10/10_chapter%202.pdf
        {                                                    // str. 3
            Benchmark.Start();
            bool[][] temp  = ThinningHelper.ArrayClone(s);   // make a deep copy to start..
            int      count = 0;

            do  // the missing iteration
            {
                count  = stepLuWangThinning(1, temp, s);
                temp   = ThinningHelper.ArrayClone(s);    // ..and on each..
                count += stepLuWangThinning(2, temp, s);
                temp   = ThinningHelper.ArrayClone(s);    // ..call!
            }while (count > 0);
            Benchmark.End();
            return(s);
        }
コード例 #8
0
        public static bool[][] EfficientThinningAlg(bool[][] s)      // http://www.academia.edu/2075831/An_Efficient_Parallel_Thinning_Algorithm_using_One_and_Two_Sub-Iterations
        {
            Benchmark.Start();
            bool[][] temp  = ThinningHelper.ArrayClone(s); // make a deep copy to start..
            int      count = 0;

            do  // the missing iteration
            {
                count  = stepEfficientThinning(1, temp, s);
                temp   = ThinningHelper.ArrayClone(s);    // ..and on each..
                count += stepEfficientThinning(2, temp, s);
                temp   = ThinningHelper.ArrayClone(s);    // ..call!
            }while (count > 0);
            Benchmark.End();
            return(s);
        }
コード例 #9
0
    {                                   //  Zhang, Y. Y.;  Wang P. S. P. A fast and flexible thinning algorithm. IEEE Transactions on Computers Year: 1989, Volume: 38, Issue: 5 Pages: 741 - 745, DOI: 10.1109/12.24276
        public static bool[][] WangZhangThinningAlg(bool[][] s)
        {
            Benchmark.Start();
            bool[][] temp  = ThinningHelper.ArrayClone(s); // make a deep copy to start..
            int      count = 0;

            do  // the missing iteration
            {
                count  = stepWangZhangThinning(temp, s);
                temp   = ThinningHelper.ArrayClone(s);    // ..and on each..
                count += stepWangZhangThinning(temp, s);
                temp   = ThinningHelper.ArrayClone(s);    // ..call!
            }while (count > 0);
            Benchmark.End();
            return(s);
        }
        public static bool[][] ModifiedThinningalgorithmZhangWangThinningAlg(bool[][] s) //https://gist.github.com/anonymous/fe757151d37a7f229386#file-thinning-algs
        {                                                                                // http://www.uel.br/pessoal/josealexandre/stuff/thinning/ftp/zhang-wang.pdf
            Benchmark.Start();
            bool[][] temp  = ThinningHelper.ArrayClone(s);                               // make a deep copy to start..
            int      count = 0;

            do  // the missing iteration
            {
                count  = stepZhangWangThinning(temp, s);
                temp   = ThinningHelper.ArrayClone(s);    // ..and on each..
                count += stepZhangWangThinning(temp, s);
                temp   = ThinningHelper.ArrayClone(s);    // ..call!
            }while (count > 0);
            Benchmark.End();
            return(s);
        }
コード例 #11
0
        public static bool[][] ZhangSuenThinningAlg(bool[][] s)      //   http://stackoverflow.com/questions/20245003/zhang-suen-thinning-algorithm-c-sharp
        {
            Benchmark.Start();
            bool[][] temp  = ThinningHelper.ArrayClone(s); // make a deep copy to start..
            int      count = 0;

            do  // the missing iteration
            {
                count  = stepZhangSuenThinning(1, temp, s);
                temp   = ThinningHelper.ArrayClone(s);    // ..and on each..
                count += stepZhangSuenThinning(2, temp, s);
                temp   = ThinningHelper.ArrayClone(s);    // ..call!
            }while (count > 0);
            Benchmark.End();
            return(s);
        }
コード例 #12
0
        public static bool[][] HybridAlg(bool[][] s)            //https://www.scribd.com/document/116907201/A-Novel-Embedded-Hybrid-Thinning-Algorithm-For
        {
            Benchmark.Start();
            bool[][] temp = ThinningHelper.ArrayClone(s);  // make a deep copy to start..

            int count = 0;

            do  // the missing iteration
            {
                count  = HybridAlgThinning(1, temp, s);
                temp   = ThinningHelper.ArrayClone(s);    // ..and on each..
                count += HybridAlgThinning(2, temp, s);
                temp   = ThinningHelper.ArrayClone(s);    // ..call!
            }while (count > 0);
            Benchmark.End();
            return(s);
        }
コード例 #13
0
        /**
         * {@inheritDoc}
         */


        public bool[][] Hilditch2ThinningAlg(bool[][] s)
        {
            bool[][] temp = ThinningHelper.ArrayClone(s);  // make a deep copy to start..


            int count = 0;

            do  // the missing iteration
            {
                count  = Hilditch2Thinning(temp, s);
                temp   = ThinningHelper.ArrayClone(s);    // ..and on each..
                count += Hilditch2Thinning(temp, s);
                temp   = ThinningHelper.ArrayClone(s);    // ..call!
            }while (count > 0);

            return(s);
        }
コード例 #14
0
        static bool KwonWoongKangThinningThinningAlg(int x, int y, bool[][] s, bool even)
        {
            bool p2 = s[x][y - 1];
            bool p3 = s[x + 1][y - 1];
            bool p4 = s[x + 1][y];
            bool p5 = s[x + 1][y + 1];
            bool p6 = s[x][y + 1];
            bool p7 = s[x - 1][y + 1];
            bool p8 = s[x - 1][y];
            bool p9 = s[x - 1][y - 1];

            int bp1 = ThinningHelper.NumberOfNonZeroNeighbors(x, y, s);

            if (ThinningHelper.NumberOfZeroToOneTransitionFromP9(x, y, s) == 1)
            {
                if (even)
                {
                    if (bp1 >= 3 && bp1 <= 6)
                    {
                        if (!((p2 && p4) && p8))
                        {
                            if (!((p2 && p6) && p8))
                            {
                                return(true);
                            }
                        }
                    }
                }
                else
                {
                    if (bp1 >= 2 && bp1 <= 6)
                    {
                        if (!((p2 && p4) && p6))
                        {
                            if (!((p4 && p6) && p8))
                            {
                                return(true);
                            }
                        }
                    }
                }
            }

            return(false);
        }
コード例 #15
0
        public bool[][] MorphologicalThinningAlg(bool[][] s)
        {
            bool[][] temp = ThinningHelper.ArrayClone(s);  // make a deep copy to start..


            int count = 0;

            do  // the missing iteration
            {
                count  = stepMorphologicalThinning(temp, s);
                temp   = ThinningHelper.ArrayClone(s);    // ..and on each..
                count += stepMorphologicalThinning(temp, s);
                temp   = ThinningHelper.ArrayClone(s);    // ..call!

                iteration++;
            }while (count > 0);

            return(s);
        }
コード例 #16
0
        static bool HybridAlgThinningAlg(int x, int y, bool[][] s, int stepNo)
        {
            bool p2 = s[x][y - 1];
            bool p3 = s[x + 1][y - 1];
            bool p4 = s[x + 1][y];
            bool p5 = s[x + 1][y + 1];
            bool p6 = s[x][y + 1];
            bool p7 = s[x - 1][y + 1];
            bool p8 = s[x - 1][y];
            bool p9 = s[x - 1][y - 1];

            int bp1 = ThinningHelper.NumberOfNonZeroNeighbors(x, y, s);

            if (bp1 >= 2 && bp1 <= 6)   //2nd condition
            {
                if (removePixel(x, y, s))
                {
                    if (stepNo == 1)
                    {
                        if ((p8 && !p4) | (!p2 && p6) | (!p8 && p4))
                        {
                            if ((!p2 && p6) | (p2 && !p6) | (!p8 && p4))
                            {
                                return(true);
                            }
                        }
                    }

                    if (stepNo == 2)
                    {
                        if ((p8 && !p4) | (!p2 && p6) | (!p6 && p2))
                        {
                            if ((p8 && !p4) | (p2 && !p6) | (!p8 && p4))
                            {
                                return(true);
                            }
                        }
                    }
                }
            }
            return(false);
        }
コード例 #17
0
        public static bool[][] ArabicParallelThinningAlg(bool[][] s)                // http://www.ancient-asia-journal.com/articles/10.5334/aa.06114/
        {
            Benchmark.Start();
            bool[][] temp  = ThinningHelper.ArrayClone(s); // make a deep copy to start..
            int      count = 0;

            do  // the missing iteration
            {
                count  = stepArabicParallelThinning(1, temp, s);
                temp   = ThinningHelper.ArrayClone(s);    // ..and on each..
                count += stepArabicParallelThinning(2, temp, s);
                temp   = ThinningHelper.ArrayClone(s);    // ..call!
                count += stepArabicParallelThinning(3, temp, s);
                temp   = ThinningHelper.ArrayClone(s);    // ..call!
                count += stepArabicParallelThinning(4, temp, s);
                temp   = ThinningHelper.ArrayClone(s);    // ..call!
            }while (count > 0);
            Benchmark.End();
            return(s);
        }
コード例 #18
0
        public static bool[][] ProposedKwonWoongKangThinningAlg(bool[][] s)
        {
            Benchmark.Start();                             // time counting
            bool[][] temp  = ThinningHelper.ArrayClone(s); // make a deep copy to start..
            int      count = 0;

            do  // the first pass
            {
                count  = stepProposedKwonWoongKangThinningThinning(1, temp, s);
                temp   = ThinningHelper.ArrayClone(s);    // ..and on each..
                count += stepProposedKwonWoongKangThinningThinning(2, temp, s);
                temp   = ThinningHelper.ArrayClone(s);    // ..call!
            }while (count > 0);

            do  // the second pass
            {
                count = pass2ProposedKwonWoongKangThinningThinning(temp, s);
                temp  = ThinningHelper.ArrayClone(s);     // ..and on each..
            }while (count > 0);

            do  // the third pass
            {
                count = pass3ProposedKwonWoongKangThinningThinning(1, temp, s);
                temp  = ThinningHelper.ArrayClone(s);     // ..and on each..
                count = pass3ProposedKwonWoongKangThinningThinning(2, temp, s);
                temp  = ThinningHelper.ArrayClone(s);     // ..and on each..
                count = pass3ProposedKwonWoongKangThinningThinning(3, temp, s);
                temp  = ThinningHelper.ArrayClone(s);     // ..and on each..
                count = pass3ProposedKwonWoongKangThinningThinning(4, temp, s);
                temp  = ThinningHelper.ArrayClone(s);     // ..and on each..
            }while (count > 0);

            Benchmark.End();

            return(s);
        }
コード例 #19
0
        static bool ArabicParallelThinningAlg(int x, int y, bool[][] s, int stepNo)
        {
            bool p2 = s[x][y - 1];
            bool p3 = s[x + 1][y - 1];
            bool p4 = s[x + 1][y];
            bool p5 = s[x + 1][y + 1];
            bool p6 = s[x][y + 1];
            bool p7 = s[x - 1][y + 1];
            bool p8 = s[x - 1][y];
            bool p9 = s[x - 1][y - 1];

            int bp1 = ThinningHelper.NumberOfNonZeroNeighbors(x, y, s);

            if (bp1 >= 2 && bp1 <= 6) //2nd condition
            {
                if (ThinningHelper.NumberOfZeroToOneTransitionFromP9(x, y, s) == 1)
                {
                    if (stepNo == 1)
                    {
                        if (!((p2 && p4) && p6))
                        {
                            if (!((p4 && p6) && p8))
                            {
                                return(true);
                            }
                        }
                    }

                    if (stepNo == 2)
                    {
                        if (!((p2 && p6) && p8))
                        {
                            if (!((p4 && p6) && p8))
                            {
                                return(true);
                            }
                        }
                    }

                    if (stepNo == 3)
                    {
                        if (!((p2 && p4) && p8))
                        {
                            if (!((p2 && p6) && p8))
                            {
                                return(true);
                            }
                        }
                    }

                    if (stepNo == 4)
                    {
                        if (!((p2 && p4) && p6))
                        {
                            if (!((p2 && p4) && p8))
                            {
                                return(true);
                            }
                        }
                    }
                }
            }
            return(false);
        }
コード例 #20
0
        static bool NovelImageThinningAlg(int x, int y, bool[][] s, int stepNo)
        {
            bool p2 = s[x][y - 1];
            bool p3 = s[x + 1][y - 1];
            bool p4 = s[x + 1][y];
            bool p5 = s[x + 1][y + 1];
            bool p6 = s[x][y + 1];
            bool p7 = s[x - 1][y + 1];
            bool p8 = s[x - 1][y];
            bool p9 = s[x - 1][y - 1];

            int bp1 = ThinningHelper.NumberOfNonZeroNeighbors(x, y, s);

            if (bp1 >= 2 && bp1 <= 6) //2nd condition
            {
                if (ThinningHelper.NumberOfZeroToOneTransitionFromP9(x, y, s) == 1)
                {
                    if (stepNo == 1)
                    {
                        if (!((p3 && p5) && p7))
                        {
                            if (!((p5 && p7) && p9))
                            {
                                return(true);
                            }
                        }
                    }

                    if (stepNo == 2)
                    {
                        if (!((p3 && p7) && p9))
                        {
                            if (!((p5 && p7) && p9))
                            {
                                return(true);
                            }
                        }
                    }

                    if (stepNo == 3)
                    {
                        if (!((p3 && p5) && p9))
                        {
                            if (!((p3 && p7) && p9))
                            {
                                return(true);
                            }
                        }
                    }

                    if (stepNo == 4)
                    {
                        if (!((p3 && p5) && p7))
                        {
                            if (!((p3 && p5) && p9))
                            {
                                return(true);
                            }
                        }
                    }

                    if (stepNo == 5)
                    {
                        if ((p2 && p9 && p7) & !p4)
                        {
                            if ((p4 && p5 && p7) & !p2)
                            {
                                if ((p6 && p7 && p9) & !p4)
                                {
                                    if ((p5 && p7 && p8) & !p2)
                                    {
                                        return(true);
                                    }
                                }
                            }
                        }
                    }

                    /*
                     * if (stepNo == 1)
                     *  if (!((p2 && p4) && p6))
                     *  {
                     *      if (!((p4 && p6) && p8))
                     *      {
                     *          return true;
                     *      }
                     *  }
                     *
                     * if (stepNo == 2)
                     *  if (!((p2 && p6) && p8))
                     *  {
                     *      if (!((p4 && p6) && p8))
                     *      {
                     *          return true;
                     *      }
                     *  }
                     *
                     * if (stepNo == 3)
                     *  if (!((p2 && p4) && p8))
                     *  {
                     *      if (!((p2 && p6) && p8))
                     *      {
                     *          return true;
                     *      }
                     *  }
                     *
                     * if (stepNo == 4)
                     *  if (!((p2 && p4) && p6))
                     *  {
                     *      if (!((p2 && p4) && p8))
                     *      {
                     *          return true;
                     *      }
                     *  }
                     *
                     * if (stepNo == 5)
                     *  if ((p9 && p8 && p6) & !p3)
                     *  {
                     *      if ((p3 && p4 && p6) & !p9)
                     *      {
                     *          if ((p5 && p6 && p8) & !p3)
                     *          {
                     *              if ((p4 && p6 && p7) & !p9)
                     *              {
                     *                  return true;
                     *              }
                     *          }
                     *
                     *      }
                     *  }*/
                }
            }
            return(false);
        }