質問編集履歴
1
修正したコードを載せました
test
CHANGED
File without changes
|
test
CHANGED
@@ -173,3 +173,163 @@
|
|
173
173
|
|
174
174
|
|
175
175
|
2回目のtest1-2まで表示されるのですが、test1-3が表示されずに動作を停止してしまいます。
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
### 修正したソースコード
|
180
|
+
|
181
|
+
```
|
182
|
+
|
183
|
+
#include<stdio.h>
|
184
|
+
|
185
|
+
#include <stdlib.h>
|
186
|
+
|
187
|
+
#include"pgmlib.h"
|
188
|
+
|
189
|
+
void hough(int n);
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
int main(void)
|
194
|
+
|
195
|
+
{
|
196
|
+
|
197
|
+
load_image(0, "");
|
198
|
+
|
199
|
+
hough(0);
|
200
|
+
|
201
|
+
return 0;
|
202
|
+
|
203
|
+
}
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
void hough(int n)
|
208
|
+
|
209
|
+
{
|
210
|
+
|
211
|
+
int j, k, l, m, o, p, x, y, sum, i, indexAm, h, Am, aa, bb, h2, aam, indexA, indexB;
|
212
|
+
|
213
|
+
int maxh = 0;
|
214
|
+
|
215
|
+
int minB = 18900;
|
216
|
+
|
217
|
+
int maxB = 0;
|
218
|
+
|
219
|
+
int maxh2 = 0;
|
220
|
+
|
221
|
+
int minbb = 6552;
|
222
|
+
|
223
|
+
int maxbb = 0;
|
224
|
+
|
225
|
+
double A, a, b;
|
226
|
+
|
227
|
+
int arr[40][2583] = {0};
|
228
|
+
|
229
|
+
//int arr2[6552][400] = {0};
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
/*
|
234
|
+
|
235
|
+
arr = (int*)malloc(sizeof(int) * 3780200);
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
for (j = 0; j < l; j++) {
|
240
|
+
|
241
|
+
for (k = 0; k < m; k++) {
|
242
|
+
|
243
|
+
arr[j * m + k] = 0;
|
244
|
+
|
245
|
+
}
|
246
|
+
|
247
|
+
}
|
248
|
+
|
249
|
+
*/
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
for (y = 0; y < height[n]; y++) {
|
254
|
+
|
255
|
+
for (x = 0; x < width[n]; x++) {
|
256
|
+
|
257
|
+
if (image[n][x][y] <= 120) {
|
258
|
+
|
259
|
+
for (A = -1.0; A <= 1.0; A += 0.05) {
|
260
|
+
|
261
|
+
indexA = A * 20 + 20;
|
262
|
+
|
263
|
+
indexB = -y * indexA + x + 2520;
|
264
|
+
|
265
|
+
arr[indexA][indexB]++;
|
266
|
+
|
267
|
+
}
|
268
|
+
|
269
|
+
}
|
270
|
+
|
271
|
+
}
|
272
|
+
|
273
|
+
}
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
for (indexA = 0; indexA <= 40; indexA++) {
|
278
|
+
|
279
|
+
sum = 0;
|
280
|
+
|
281
|
+
i = 0;
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
for (indexB = 0; indexB <= 2583; indexB++) {
|
286
|
+
|
287
|
+
if (arr[indexA][indexB] >= 1) {
|
288
|
+
|
289
|
+
sum += arr[indexA][indexB] * arr[indexA][indexB];
|
290
|
+
|
291
|
+
i++;
|
292
|
+
|
293
|
+
}
|
294
|
+
|
295
|
+
}
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
h = sum / i;
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
if (h > maxh) {
|
304
|
+
|
305
|
+
maxh = h;
|
306
|
+
|
307
|
+
indexAm = indexA;
|
308
|
+
|
309
|
+
}
|
310
|
+
|
311
|
+
}
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
for (indexB = 0; indexB <= 2583; indexB++) {
|
316
|
+
|
317
|
+
if (arr[indexAm][indexB] >= 1) {
|
318
|
+
|
319
|
+
if (indexB <= minB) {
|
320
|
+
|
321
|
+
minB = indexB;
|
322
|
+
|
323
|
+
}
|
324
|
+
|
325
|
+
if (indexB >= maxB) {
|
326
|
+
|
327
|
+
maxB = indexB;
|
328
|
+
|
329
|
+
}
|
330
|
+
|
331
|
+
}
|
332
|
+
|
333
|
+
}
|
334
|
+
|
335
|
+
```
|