Форум программистов, компьютерный форум, киберфорум
Алгоритмы
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.90/21: Рейтинг темы: голосов - 21, средняя оценка - 4.90
238 / 235 / 43
Регистрация: 16.03.2011
Сообщений: 750
1

Алгоритм скелетизации

04.01.2012, 16:50. Показов 3963. Ответов 3
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
Как бы не старался получаю скелет как на cкрине
Нужно сделать как во вложении, помогите с алгоритмом
Изображения
 
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
04.01.2012, 16:50
Ответы с готовыми решениями:

Алгоритм скелетизации изображения Зонга-Суня (Zhang-Suen)
Здравствуйте! Понадобилось сделать свой векторизатор для линий. Один из этапов обработки - получить...

Построить алгоритм Маркова, который ищет НОД (Алгоритм Евклида)
Здравствуйте, ребята, выручайте. Весь инет перерыл, всю голову сломал, но не могу сделать. Суть в...

алгоритм сжатя? коке алгоритм взят?
всем доброго времени суток ест дани таком формате...

Нужен алгоритм поиска пути в этом лабиринте (будь то волновой алгоритм или алгоритм правой/левой руки )
#include "stdafx.h" #include <iostream> #include <conio.h> using namespace std; void lab...

3
238 / 235 / 43
Регистрация: 16.03.2011
Сообщений: 750
05.01.2012, 14:31  [ТС] 2
Забыл сказать, нужен однопроходный алгоритм, все попутки реализации такого алгоритма провалились.
0
238 / 235 / 43
Регистрация: 16.03.2011
Сообщений: 750
11.01.2012, 18:16  [ТС] 3
Поделитесь тогда информацией по любому алгоритму скелетизации. Алгоритм Зонга-Суня медленно работает на больших изображениях получаю отростки как на скрине, хотел бы найти что нибудь лучше.
Изображения
 
0
2 / 2 / 1
Регистрация: 06.01.2012
Сообщений: 16
16.01.2012, 21:27 4
вот нашел в одной из своих прог какой то алгоритм скилетизации не помню если чесино что за рн но глянь может пригодится.

скилетизация C#
C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
 private void skelet(ref int[,] mas, ref Bitmap bit, ToolStripProgressBar prog)
        {
            prog.Minimum = 0;
            prog.Maximum = bit.Height;
            int[,] massiv = new int[bit.Width, bit.Height];
            for (int i = 0; i < bit.Height; i++)
            {
                for (int j = 0; j < bit.Width; j++)
                {
                    massiv[j, i] = mas[j, i];
                }
            }
            for (int i = 0; i < bit.Height; i++)
            {
                for (int j = 0; j < bit.Width; j++)
                {
                    int sum = 0;
                    int colZeroOne = 0;
                    int inte1C = 0, inter1D = 0;
                    int inte2C = 0, inter2D = 0;
                    bool first = false, second = false, third = false;
 
 
                    summa(mas, bit, i, j, sum);
                    ZeroOne(mas, bit, i, j, colZeroOne);
 
                    //1
                    if ((i != 0) && (j < bit.Width - 1) && (i < bit.Height - 1))
                    {
                        inte1C = mas[j, i - 1] * mas[j + 1, i] * mas[j, i + 1];
                    }
                    if ((j < bit.Width - 1) && (i < bit.Height - 1) && (j != 0))
                    {
                        inter1D = mas[j + 1, i] * mas[j, i + 1] * mas[j - 1, i];
                    }
 
                    //2
                    if ((i != 0) && (j < bit.Width - 1) && (j != 0))
                    {
                        inte2C = mas[j, i - 1] * mas[j + 1, i] * mas[j - 1, i];
                    }
                    if ((i != 0) && (i < bit.Height - 1) && (j != 0))
                    {
                        inter2D = mas[j, i - 1] + mas[j, i + 1] * mas[j - 1, i];
                    }
 
                    //part 3
                    int iter31 = 0;
                    int iter32 = 0;
                    int iter33 = 0;
                    int iter34 = 0;
                    if ((i != 0) && (j != 0) && (i < bit.Height - 1) && (j < bit.Width - 1))
                    {
                        int point1 = 0;
                        int point5 = 0;
                        int point3 = 0;
                        int point7 = 0;
                        //1
                        if (mas[j - 1, i - 1] == 0)
                        {
                            point1 = 1;
                        }
                        else
                        {
                            point1 = 0;
                        }
                        //5
                        if (mas[j + 1, i + 1] == 0)
                        {
                            point5 = 1;
                        }
                        else
                        {
                            point5 = 0;
                        }
                        //3
                        if (mas[j + 1, i - 1] == 0)
                        {
                            point3 = 1;
                        }
                        else { point3 = 0; }
                        //7
                        if (mas[j - 1, i + 1] == 0) { point7 = 1; } else { point7 = 0; }
 
                        iter31 = point1 * mas[j + 1, i] * mas[j, i + 1];
                        iter32 = point5 * mas[j - 1, i] * mas[j, i - 1];
                        iter33 = point3 * mas[j, i + 1] * mas[j - 1, i];
                        iter34 = point7 * mas[j, i - 1] * mas[j + 1, i];
 
                    }
                    if ((2 <= sum) && (sum <= 6) && (colZeroOne == 1) && (inte1C == 0) && (inter1D == 0))
                    {
                        first = true;
                    }
                    if ((2 <= sum) && (sum <= 6) && (colZeroOne == 1) && (inte2C == 0) && (inter2D == 0))
                    {
                        second = true;
                    }
                    if ((iter31 == 1) || (iter32 == 1) || (iter33 == 1) || (iter34 == 1))
                    {
                        third = true;
                    }
                    if ((first) || (second) || (third))
                    {
                        mas[j, i] = 0;
                        bit.SetPixel(j, i, Color.White);
                    }
                }
                prog.Value++;
            }
            /*for (int i = 0; i < bit.Width; i++)
            {
                bit.SetPixel(i, 10, Color.Teal);
            }*/
            prog.Value = 0;
             //pic4.Image = bit;
            //pic4.Update();
        }
        private void summa(int[,] mass, Bitmap bitt, int i, int j, int summ)
        {
            summ = 0;
            if ((i != 0) && (j != 0))
            {
                summ = summ + mass[j - 1, i - 1];
            }
            if (i != 0)
            {
                summ = summ + mass[j, i - 1];
            }
            if ((j < bitt.Width - 1) && (i != 0))
            {
                summ = summ + mass[j + 1, i - 1];
            }
            if (j != 0)
            {
                summ = summ + mass[j - 1, i];
            }
            if ((j != 0) && (i < bitt.Height - 1))
            {
                summ = summ + mass[j - 1, i + 1];
            }
            if (i < bitt.Height - 1)
            {
                summ = summ + mass[j, i + 1];
            }
            if ((j < bitt.Width - 1) && (i < bitt.Height - 1))
            {
                summ = summ + mass[j + 1, i + 1];
            }
            if (j < bitt.Width - 1)
            {
                summ = summ + mass[j + 1, i];
            }
        }
        private void ZeroOne(int[,] mass, Bitmap bitt, int i, int j, int col)
        {
            string temp;
            string comp = "01";
            col = 0;
            //1-2
            if ((i != 0) && (j != 0))
            {
                temp = mass[j - 1, i - 1].ToString() + "" + mass[j - 1, i].ToString();
                if (temp.Equals(comp))
                {
                    col++;
                }
 
            }
            //2-3
            if ((i != 0) && (j < bitt.Width - 1) && (i != 0))
            {
                temp = mass[j, i - 1].ToString() + "" + mass[j + 1, i - 1].ToString();
                if (temp.Equals(comp))
                {
                    col++;
                }
            }
            //3-4
            if ((j < bitt.Width - 1) && (i != 0) && (i < bitt.Height - 1))
            {
                temp = mass[j + 1, i + 1].ToString() + "" + mass[j + 1, i].ToString();
                if (temp.Equals(comp))
                {
                    col++;
                }
            }
            //4-5
            if ((j < bitt.Width - 1) && (i < bitt.Height - 1))
            {
                temp = mass[j + 1, i].ToString() + "" + mass[j + 1, i + 1].ToString();
                if (temp.Equals(comp))
                {
                    col++;
                }
            }
            //5-6
            if ((j < bitt.Width - 1) && (i < bitt.Height - 1))
            {
                temp = mass[j + 1, i + 1].ToString() + "" + mass[j, i + 1].ToString();
                if (temp.Equals(comp))
                {
                    col++;
                }
            }
            //6-7
            if ((i < bitt.Height - 1) && (j != 0))
            {
                temp = mass[j, i + 1].ToString() + "" + mass[j - 1, i].ToString();
                if (temp.Equals(comp))
                {
                    col++;
                }
            }
            //7-8
            if ((j != 0) && (i < bitt.Height - 1))
            {
                temp = mass[j - 1, i + 1].ToString() + "" + mass[j - 1, i].ToString();
                if (temp.Equals(comp))
                {
                    col++;
                }
            }
            //8-1
            if ((j != 0) && (i != 0))
            {
                temp = mass[j - 1, i].ToString() + "" + mass[j - 1, i - 1].ToString();
                if (temp.Equals(comp))
                {
                    col++;
                }
            }
 
 
        }


ну и это может пригодится кому ЖУК.

Утоньшение жуком C#
C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
  private void juc(Bitmap bit, int[,] mas, Label lab, PictureBox pictureMain, PictureBox pic, ToolStripProgressBar progress)
        {
 
            //result znach
            ArrayList kordHMaxMin = new ArrayList();
            ArrayList kordWMaxMin = new ArrayList();
 
            //Temp para
            ArrayList tempKordSimvolaXWidth = new ArrayList();
            ArrayList tempKordSimvolaYHeight = new ArrayList();
 
            int tecH = 0;
            int tecW = 0;
            int PredH = 0;
            int PredW = 0;
 
            lab.Text = "";
 
            progress.Minimum = 0;
 
 
            for (int i = 0; i < bit.Width; i++)
            {
                progress.Maximum = bit.Width;
                progress.Value++;
               if (mas[i, 20] == 1)
                {
                    tecH = 14;
                    tecW = i;
 
                    PredH = 14;
                    PredW = i - 1;
                    tempKordSimvolaXWidth.Clear();
                    tempKordSimvolaYHeight.Clear();
 
                    bool done = true;
 
                    while (done)
                    {
                        tempKordSimvolaXWidth.Add(tecW);
                        tempKordSimvolaYHeight.Add(tecH);
 
                        if (mas[tecW, tecH] == 1)
                        {
                            LeftPoint(ref tecH, ref tecW, ref PredH, ref PredW);
                        }
                        else
                        {
                           RightPoint(ref tecH, ref tecW, ref PredH, ref PredW);
                        }
                        if (tecH == 14 && tecW == i)
                       {
                            int maxH = 0;
                            int minH = 0;
                            int maxW = 0;
                            int minW = 0;
 
                            MinMax(tempKordSimvolaXWidth, ref minW, ref maxW);
                            kordWMaxMin.Add(maxW);
                            kordWMaxMin.Add(minW);
                            //4 8 3h 1400
                            MinMax(tempKordSimvolaYHeight, ref minH, ref maxH);
                            kordHMaxMin.Add(maxH);
                            kordHMaxMin.Add(minH);
 
                            i = maxW;
 
                            Bitmap findpicture = new Bitmap(bit.Clone(new Rectangle(minW - 1, minH - 1, maxW - minW + 2, maxH - minH + 2), bit.PixelFormat));
                            int[,] massiv = new int[findpicture.Width, findpicture.Height];
 
                            Bitmap findpicforharacterpoint = new Bitmap(findpicture.Clone(new Rectangle(0, 0, findpicture.Width, findpicture.Height), findpicture.PixelFormat));
                            int[,] massivforskelet = new int[findpicforharacterpoint.Width, findpicforharacterpoint.Height];
                            binarize(findpicforharacterpoint, ref massivforskelet, progressBar);
 
                            skelet(ref massivforskelet, ref findpicforharacterpoint, progress);
                            binarize(findpicforharacterpoint, ref massivforskelet, progressBar);
                            binarize(findpicture, ref massiv, progressBar);
                            Noise(ref massiv, ref findpicture, pic, progressBar);
                     
                            lab.Update();
 
                            break;
                        }
                    }
 
                }
            }
 
            int maxHr = 0;
            int minHr = 0;
            int maxWr = 0;
            int minWr = 0;
 
            MinMax(kordWMaxMin, ref minWr, ref maxWr);
            MinMax(kordHMaxMin, ref minHr, ref maxHr);
            progress.Value = 0;
            Bitmap biting = new Bitmap(bit.Clone(new Rectangle(minWr, minHr, maxWr - minWr, maxHr - minHr), bit.PixelFormat));
            Bitmap skeletPic = new Bitmap(bit.Clone(new Rectangle(minWr, minHr, maxWr - minWr, maxHr - minHr), bit.PixelFormat));
            int[,] massivSkelet = new int[skeletPic.Width, skeletPic.Height];
            binarize(skeletPic, ref massivSkelet, progress);
 
            int[,] massiveLetter = new int[biting.Width, biting.Height];
            binarize(biting, ref massiveLetter, progress); 
            skelet(ref massivSkelet, ref skeletPic, progress);
            FirstLitter(biting, massivSkelet);
            pictureBox6.Image = skeletPic;
            pictureBox6.Update();
 
            pic.Image = biting;
            pic.Update();
 
 
 
 
 
        }
        private void LeftPoint(ref int tecI, ref int tecJ, ref int predI, ref int predJ)
        {
            //sleva
            if ((tecI == predI) && (tecJ > predJ))
            {
                predI = tecI;
                predJ = tecJ;
                tecI = tecI - 1;
            }
            else
            {
                //sverhy
                if ((tecI > predI) && (tecJ == predJ))
                {
                    predI = tecI;
                    predJ = tecJ;
                    tecJ = tecJ + 1;
                }
                else
                {
                    //sprava
                    if ((tecI == predI) && (tecJ < predJ))
                    {
                        predI = tecI;
                        predJ = tecJ;
                        tecI = tecI + 1;
                    }
                    else
                    {
                        //snizy
                        if ((tecI < predI) && (tecJ == predJ))
                        {
                            predI = tecI;
                            predJ = tecJ;
                            tecJ = tecJ - 1;
                        }
                    }
                }
            }
        }
      
        
        private void RightPoint(ref int tecI, ref int tecJ, ref int predI, ref int predJ)
        {
            //sleva
            if ((tecI == predI) && (tecJ < predJ))
            {
                predI = tecI;
                predJ = tecJ;
                tecI = tecI - 1;
            }
            else
            {
                //sverhy
                if ((tecI > predI) && (tecJ == predJ))
                {
                    predI = tecI;
                    predJ = tecJ;
                    tecJ = tecJ - 1;
                }
                else
                {
                    //sprava
                    if ((tecI == predI) && (tecJ > predJ))
                    {
                        predI = tecI;
                        predJ = tecJ;
                        tecI = tecI + 1;
                    }
                    else
                    {
                        //snizy
                        if ((tecI < predI) && (tecJ == predJ))
                        {
                            predI = tecI;
                            predJ = tecJ;
                            tecJ = tecJ + 1;
                        }
                    }
                }
            }
        }
        private void MinMax(ArrayList arraylist, ref int min, ref int max)
        {
            max = 0;
            min = 1000000;
            int[] mas = new int[arraylist.Count];
            arraylist.CopyTo(mas);
            for (int i = 0; i < arraylist.Count; i++)
            {
                if (mas[i] > max)
                {
                    max = mas[i];
                }
                if (mas[i] < min)
                {
                    min = mas[i];
                }
            }
        }
1
16.01.2012, 21:27
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
16.01.2012, 21:27
Помогаю со студенческими работами здесь

Волновой алгоритм поиска (Алгоритм A* / Алгоритм А стар)
Хочу разработать алгоритм для решения головоломки с подвижными дисками (перестановочная...

Линейный алгоритм, Алгоритм с ветвлениями, Циклический алгоритм Линейный алгоритм
Линейный алгоритм, Алгоритм с ветвлениями, Циклический алгоритм Линейный алгоритм 1. Объясни, что...

Алгоритм устранения непродуктивных нетерминалов, алгоритм построения недостижимых символов
Задание: найдите лишние нетерминалы в следующей грамматике с начальным нетерминалом S и в...

Построить алгоритм ДО и алгоритм ПОКА для вычислений значения функции на отрезке [a,b] с шагом h.
Построить алгоритм ДО и алгоритм ПОКА для вычислений значения функции на отрезке с шагом h....


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
4
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru