コード例 #1
0
 public void SaveNeuronet(string filepath)
 {
     FileWork.SaveNeuroNet(this, filepath);
 }
コード例 #2
0
 public static NeuroNet LoadNeuronet(string filepath)
 {
     return(FileWork.LoadNeuroNet(filepath));
 }
コード例 #3
0
ファイル: NeuroWork.cs プロジェクト: RedForest347/NeuroNet
        public bool NextPreTrainingPass(char letter, bool need_save = true)
        {
            if (current_line_TrainingPass >= LineList.Count)
            {
                Debug.Log("изображение полностью обработано");
                return(false);
            }
            if (LineList[current_line_TrainingPass].LetterList.Count == 0)
            {
                Debug.Log("в этой строке нет букв");
                current_column_TrainingPass = 0;
                current_line_TrainingPass++;
                return(false);
            }
            int min_y = LineList[current_line_TrainingPass].up_y;
            int min_x = LineList[current_line_TrainingPass].LetterList[current_column_TrainingPass].left_x;

            ClearPreShow();
            ClearStartSignals();


            int[,] start_signals_pre = new int[offset, offset * 5];
            for (int y = 0; y < start_signals_pre.GetLength(1); y++)
            {
                for (int x = 0; x < start_signals_pre.GetLength(0); x++)
                {
                    start_signals_pre[x, y] = 255;
                }
            }

            for (int y = LineList[current_line_TrainingPass].up_y; y < LineList[current_line_TrainingPass].down_y; y++)
            {
                for (int x = LineList[current_line_TrainingPass].LetterList[current_column_TrainingPass].left_x; x < LineList[current_line_TrainingPass].LetterList[current_column_TrainingPass].right_x; x++)
                {
                    if (x - min_x < offset && y - min_y < offset)
                    {
                        Color color = NormalizeImage.GetPixel(x, y);

                        start_signals_pre[(x - min_x), (y - min_y)] = color.R;
                        NormalizeImage.SetPixel(x, y, Color.White);
                        start_signals[(x - min_x) + (y - min_y) * offset] = color.R;
                    }
                    else
                    {
                        if (x - min_x < start_signals_pre.GetLength(0) && y - min_y < start_signals_pre.GetLength(1))
                        {
                            Color color = NormalizeImage.GetPixel(x, y);
                            start_signals_pre[(x - min_x), (y - min_y)] = color.R;
                        }
                    }
                }
            }


            bool free_line  = true;
            int  start_line = 0;

            for (int y = 0; y < start_signals_pre.GetLength(1); y++)
            {
                for (int x = 0; x < start_signals_pre.GetLength(0); x++)
                {
                    if (start_signals_pre[x, y] == 0)
                    {
                        free_line = false;
                    }
                }
                if (free_line)
                {
                    start_line++;
                }
                else
                {
                    break;
                }
            }

            int current_start_signal = 0;

            for (int y = start_line; y < start_signals_pre.GetLength(1); y++)
            {
                for (int x = 0; x < start_signals_pre.GetLength(0); x++)
                {
                    if (x < offset && y - start_line < offset)
                    {
                        Color color = Color.FromArgb(255, start_signals_pre[x, y], start_signals_pre[x, y], start_signals_pre[x, y]);
                        start_signals[current_start_signal] = start_signals_pre[x, y];
                        current_start_signal++;
                        PreShow.SetPixel(x, y - start_line, color);
                    }
                }
            }

            Debug.form1.Picture.Image     = NormalizeImage;
            Debug.form1.pictureBox1.Image = PreShow;

            current_column_TrainingPass++;
            if (LineList[current_line_TrainingPass].LetterList.Count <= current_column_TrainingPass)
            {
                current_column_TrainingPass = 0;
                current_line_TrainingPass++;
            }

            if (need_save)
            {
                FileWork.SaveChar(letter, @"C:\Users\Admin\Desktop\ForText\" + (current_pass - 1) + ".txt");
                FileWork.SaveImage(PreShow, @"C:\Users\Admin\Desktop\ForText\" + (current_pass) + ".jpg");
                current_pass++;
            }
            return(true);
        }