jueves, 25 de abril de 2013

Laboratorio 7

En este laboratorio se hablara sobre el preprocesamiento de la detección de agujeros.
Se mostraran los histogramas que se generaron.

def binarizado(im, umbral):
w, h = im.size
pix = im.load()
out = Image.new('RGB', (w, h))
out_pix = out.load()
for i in range(w):
for j in range(h):
r, g, b = pix[i, j]
if r > umbral:
out_pix[i, j] = (255, 255, 255)
else:
out_pix[i, j] = (0, 0, 0)
out.save('imgbin.png', 'PNG')
return out
def histogram(im, orientation = VERTICAL):
tmp = im.copy()
pix = np.array(tmp.convert('L'))
if orientation == VERTICAL:
return [sum(x) for x in zip(*pix)]
else:
return [sum(x) for x in pix]
if __name__ == "__main__":
im = Image.open(argv[1]).convert('RGB')
im = binarize(im, 90)
vertical = histogram(im, VERTICAL)
horizontal = histogram(im, HORIZONTAL)
horizontal = list(smooth(np.array(horizontal)))
vertical = list(smooth(np.array(vertical)))
Estos son los datos generados de forma Horizontal:

0 21675
1 21675
2 21675
3 21675
4 21675
5 21675
6 21675
7 21675
8 21675
9 21675
10 21675
11 21666
12 21520
13 21342
14 21106
15 20648
16 20415
17 20222
18 20113
19 20014
20 19906
21 19826
22 19718
23 19666
24 19641
25 19670
26 19721
27 19826
28 19934
29 20043
30 20157
31 20325
32 20595
33 21045
34 21622
35 21674
36 21675
37 21675
38 21675
39 21675
40 21672
41 21613
42 21573
43 21521
44 21395
45 21257
46 21028
47 20517
48 20172
49 19919
50 19769
51 19654
52 19499
53 19371
54 19231
55 19246
56 19344
57 19506
58 19810
59 20164
60 20809
61 21059
62 21103
63 21143
64 21196
65 21297
66 21439
67 21658
68 21675
69 21675
70 21675
71 21671
72 21554
73 21409
74 21171
75 20698
76 20414
77 20196
78 20038
79 19908
80 19796
81 19703
82 19616
83 19548
84 19476
85 19432
86 19361
87 19313
88 19264
89 19177
90 19120
91 19150
92 19171
93 19320
94 19366
95 19414
96 19476
97 19528
98 19600
99 19690
100 19801
101 19927
102 20077
103 20250
104 20439
105 20800
106 21500
107 21667
108 21675
109 21675
110 21675
111 21675
112 21675
113 21675
114 21675
115 21675
116 21675
117 21675
118 21675
119 21675
120 21675
121 21675
122 21675
123 21675
124 21675
125 21675
126 21675
127 21675
view raw horizontal.txt hosted with ❤ by GitHub

En 
Vertical:

0 32640
1 32640
2 32640
3 32640
4 32640
5 32640
6 32640
7 32640
8 32631
9 32509
10 32460
11 32340
12 31871
13 31462
14 31204
15 30901
16 30618
17 30243
18 29838
19 29450
20 29183
21 29325
22 29902
23 30094
24 29998
25 29905
26 29778
27 29681
28 29648
29 29589
30 29509
31 29422
32 29414
33 29393
34 29375
35 29284
36 29256
37 29236
38 29289
39 29369
40 29542
41 29541
42 29416
43 29394
44 29436
45 29492
46 29622
47 29795
48 30062
49 30418
50 30500
51 30591
52 30754
53 30960
54 31285
55 31606
56 31600
57 31732
58 31858
59 31910
60 31948
61 32019
62 32081
63 32181
64 32310
65 32564
66 32637
67 32640
68 32640
69 32640
70 32640
71 32640
72 32640
73 32640
74 32640
75 32640
76 32640
77 32640
78 32640
79 32640
80 32640
81 32640
82 32640
83 32640
84 32640
view raw vertical.txt hosted with ❤ by GitHub

Imagen binarizada:




Imagen Final:


1 comentario:

Elisa dijo...

Pues, había que dibujar las líneas... 3 pts por el avance.

Publicar un comentario