Esempio n. 1
0
        public void TrimString()
        {
            int start = 0;

            while (gystogram[start].count == 0)
            {
                start++;
            }
            int finish = gystogram.Count - 1;

            while (gystogram[finish].count == 0)
            {
                finish--;
            }
            MyBitmap newMBM = new MyBitmap(new Bitmap(str.width, finish - start));

            Console.WriteLine(str.width + "---" + str.height);
            //for (int y = start; y < finish - start - 1; y++)
            //{
            //    for (int x = 0; x < str.width; x++)
            //    {
            //        newMBM.bitmap.SetPixel(x, y - (start), str.bitmap.GetPixel(x, y));
            //    }
            //}
            //str = newMBM;
        }
Esempio n. 2
0
        public static List <GystMember> DoStringGystogram(MyBitmap bitmap)
        {
            List <GystMember> gystogram = new List <GystMember>();

            for (int x = 0; x < bitmap.height; x++)
            {
                gystogram.Add(new GystMember(x));
                for (int y = 0; y < bitmap.width; y++)
                {
                    if (bitmap.bitmap.GetPixel(y, x).ToArgb() != Color.White.ToArgb())
                    {
                        gystogram[x].Add();
                    }
                }
            }
            return(gystogram);
        }
Esempio n. 3
0
        public static List <GystMember> DoWordGystogram(MyBitmap str)
        {
            Bitmap newBm = new Bitmap(str.height, str.width);

            for (int y = 0; y < str.height; y++)
            {
                for (int x = 0; x < str.width; x++)
                {
                    newBm.SetPixel(y, newBm.Height - x - 1, str.bitmap.GetPixel(x, y));
                }
            }
            MyBitmap turnedString = new MyBitmap(newBm);

            str = turnedString;
            List <GystMember> wordGyst = DoStringGystogram(turnedString);

            //SavePhotoWithGystogram(wordGyst, newBm, "F:\\Progr\\Csh\\wordCounter\\wordCounter\\bin\\Debug\\img\\" + 12 + ".jpg");
            return(wordGyst);
        }
Esempio n. 4
0
        public int Count(Bitmap image)
        {
            MyBitmap text = new MyBitmap(image);

            text.ConvertBitmapToBlackAndWhite();
            text.gystogram = Gystogram.DoStringGystogram(text);
            Gystogram.SavePhotoWithGystogram(text.gystogram, text.bitmap, "F:\\Progr\\Csh\\wordCounter\\wordCounter\\bin\\Debug\\img\\Text_gystogram.jpg");
            text.DivideIntoStrings();
            int i = 0;

            foreach (TextString stroke in text.strings)
            {
                stroke.gystogram = Gystogram.DoWordGystogram(stroke.str);
                stroke.TrimString();
                Gystogram.SavePhotoWithGystogram(stroke.gystogram, stroke.str.bitmap, "F:\\Progr\\Csh\\wordCounter\\wordCounter\\bin\\Debug\\img\\" + i + ".jpg");
                stroke.DivideWords();
                i++;
            }
            return(0);
        }
Esempio n. 5
0
        public void DivideWords()
        {
            List <GystMember> spaces = MyBitmap.DoSpaceGystogram(gystogram);

            foreach (GystMember gm in spaces)
            {
                Console.WriteLine(gm.value + "--------" + gm.count);
            }
            Console.WriteLine("____________________________________");
            //int startInd = spaces[0].value;
            //spaces.RemoveAt(0);
            //spaces.RemoveAt(0);
            //int space = FindMaxSpace(spaces);
            //int y = startInd;
            //while (y < gystogram.Count)
            //{
            //    if (gystogram[y].count != 0)
            //    {
            //        int i = 0;
            //        while (i + y < gystogram.Count && gystogram[y + i].count != 0 || y + i - 1 + space < gystogram.Count && gystogram[y + i - 1 + space].count != 0)
            //            i++;
            //        Bitmap strBitm = new Bitmap(str.width, i);
            //        for (int coordY = 0; coordY < i; coordY++)
            //        {
            //            for (int coordX = 0; coordX < str.width; coordX++)
            //            {
            //                strBitm.SetPixel(coordX, coordY, str.bitmap.GetPixel(coordX, coordY + y - 2));
            //            }
            //        }
            //        words.Add(new Word(new MyBitmap(strBitm)));
            //        y += i + space;
            //    }
            //    else
            //    {
            //        y++;
            //    }
            //}
        }
Esempio n. 6
0
 public Word(MyBitmap word)
 {
     this.word = word;
 }
Esempio n. 7
0
 public TextString(Bitmap str)
 {
     this.str = new MyBitmap(str);
 }