22
22
"colab" : {
23
23
"name" : " 2-Image-stats-and-image-processing.ipynb" ,
24
24
"provenance" : [],
25
- "collapsed_sections" : [],
26
- "toc_visible" : true
25
+ "collapsed_sections" : []
27
26
}
28
27
},
29
28
"cells" : [
50
49
},
51
50
{
52
51
"cell_type" : " code" ,
53
- "execution_count" : 0 ,
54
52
"metadata" : {
55
- "colab" : {},
56
53
"colab_type" : " code" ,
57
54
"deletable" : true ,
58
55
"editable" : true ,
59
- "id" : " sWiMMUll3fWL"
56
+ "id" : " sWiMMUll3fWL" ,
57
+ "colab" : {}
60
58
},
61
- "outputs" : [],
62
59
"source" : [
63
60
" # Download the test image and utils files\n " ,
64
61
" !wget --no-check-certificate \\\n " ,
79
76
" pylab.rcParams['figure.figsize'] = (10.0, 8.0) # this controls figure size in the notebook\n " ,
80
77
" \n " ,
81
78
" input_image=cv2.imread('noidea.jpg')"
82
- ]
79
+ ],
80
+ "execution_count" : 0 ,
81
+ "outputs" : []
83
82
},
84
83
{
85
84
"cell_type" : " markdown" ,
97
96
},
98
97
{
99
98
"cell_type" : " code" ,
100
- "execution_count" : 0 ,
101
99
"metadata" : {
102
- "colab" : {},
103
100
"colab_type" : " code" ,
104
101
"deletable" : true ,
105
102
"editable" : true ,
106
- "id" : " 4LHzdNvt3fWP"
103
+ "id" : " 4LHzdNvt3fWP" ,
104
+ "colab" : {}
107
105
},
108
- "outputs" : [],
109
106
"source" : [
110
107
" flipped_code_0=cv2.flip(input_image,0) # vertical flip\n " ,
111
108
" plt.imshow(flipped_code_0)"
112
- ]
109
+ ],
110
+ "execution_count" : 0 ,
111
+ "outputs" : []
113
112
},
114
113
{
115
114
"cell_type" : " code" ,
116
- "execution_count" : 0 ,
117
115
"metadata" : {
118
- "colab" : {},
119
116
"colab_type" : " code" ,
120
117
"deletable" : true ,
121
118
"editable" : true ,
122
- "id" : " 9SOq_oD-3fWR"
119
+ "id" : " 9SOq_oD-3fWR" ,
120
+ "colab" : {}
123
121
},
124
- "outputs" : [],
125
122
"source" : [
126
123
" flipped_code_1=cv2.flip(input_image,1) # horizontal flip\n " ,
127
124
" plt.imshow(flipped_code_1)"
128
- ]
125
+ ],
126
+ "execution_count" : 0 ,
127
+ "outputs" : []
129
128
},
130
129
{
131
130
"cell_type" : " code" ,
132
- "execution_count" : 0 ,
133
131
"metadata" : {
134
- "colab" : {},
135
132
"colab_type" : " code" ,
136
133
"deletable" : true ,
137
134
"editable" : true ,
138
- "id" : " 7zapvC1p3fWU"
135
+ "id" : " 7zapvC1p3fWU" ,
136
+ "colab" : {}
139
137
},
140
- "outputs" : [],
141
138
"source" : [
142
139
" transposed=cv2.transpose(input_image)\n " ,
143
140
" plt.imshow(transposed)"
144
- ]
141
+ ],
142
+ "execution_count" : 0 ,
143
+ "outputs" : []
145
144
},
146
145
{
147
146
"cell_type" : " markdown" ,
159
158
},
160
159
{
161
160
"cell_type" : " code" ,
162
- "execution_count" : 0 ,
163
161
"metadata" : {
164
- "colab" : {},
165
162
"colab_type" : " code" ,
166
163
"deletable" : true ,
167
164
"editable" : true ,
168
- "id" : " S7nLP0QL3fWY"
165
+ "id" : " S7nLP0QL3fWY" ,
166
+ "colab" : {}
169
167
},
170
- "outputs" : [],
171
168
"source" : [
172
169
" for i in range(0,3):\n " ,
173
170
" min_value, max_value, min_location, max_location=cv2.minMaxLoc(input_image[:,:,i])\n " ,
174
171
" print(\" min {} is at {}, and max {} is at {}\" .format(min_value, min_location, max_value, max_location))\n "
175
- ]
172
+ ],
173
+ "execution_count" : 0 ,
174
+ "outputs" : []
176
175
},
177
176
{
178
177
"cell_type" : " markdown" ,
192
191
},
193
192
{
194
193
"cell_type" : " code" ,
195
- "execution_count" : 0 ,
196
194
"metadata" : {
197
- "colab" : {},
198
195
"colab_type" : " code" ,
199
196
"deletable" : true ,
200
197
"editable" : true ,
201
- "id" : " Gg5M59Lt3fWa"
198
+ "id" : " Gg5M59Lt3fWa" ,
199
+ "colab" : {}
202
200
},
203
- "outputs" : [],
204
201
"source" : [
205
202
" #First create an image the same size as our input\n " ,
206
203
" blank_image = np.zeros((input_image.shape), np.uint8)\n " ,
210
207
" new_image=cv2.add(blank_image,input_image) # add the two images together\n " ,
211
208
" \n " ,
212
209
" plt.imshow(cv2.cvtColor(new_image, cv2.COLOR_BGR2RGB))"
213
- ]
210
+ ],
211
+ "execution_count" : 0 ,
212
+ "outputs" : []
214
213
},
215
214
{
216
215
"cell_type" : " markdown" ,
228
227
},
229
228
{
230
229
"cell_type" : " code" ,
231
- "execution_count" : 0 ,
232
230
"metadata" : {
233
- "colab" : {},
234
231
"colab_type" : " code" ,
235
232
"deletable" : true ,
236
233
"editable" : true ,
237
- "id" : " EyxmwP0E3fWd"
234
+ "id" : " EyxmwP0E3fWd" ,
235
+ "colab" : {}
238
236
},
239
- "outputs" : [],
240
237
"source" : [
241
238
" d=3\n " ,
242
239
" img_blur3 = cv2.GaussianBlur(input_image, (2*d+1, 2*d+1), -1)[d:-d,d:-d]\n " ,
243
240
" \n " ,
244
241
" plt.imshow(cv2.cvtColor(img_blur3, cv2.COLOR_BGR2RGB))"
245
- ]
242
+ ],
243
+ "execution_count" : 0 ,
244
+ "outputs" : []
246
245
},
247
246
{
248
247
"cell_type" : " code" ,
249
- "execution_count" : 0 ,
250
248
"metadata" : {
251
- "colab" : {},
252
249
"colab_type" : " code" ,
253
250
"deletable" : true ,
254
251
"editable" : true ,
255
- "id" : " GjGY7Dl33fWg"
252
+ "id" : " GjGY7Dl33fWg" ,
253
+ "colab" : {}
256
254
},
257
- "outputs" : [],
258
255
"source" : [
259
256
" d=5\n " ,
260
257
" img_blur5 = cv2.GaussianBlur(input_image, (2*d+1, 2*d+1), -1)[d:-d,d:-d]\n " ,
261
258
" \n " ,
262
259
" plt.imshow(cv2.cvtColor(img_blur5, cv2.COLOR_BGR2RGB))"
263
- ]
260
+ ],
261
+ "execution_count" : 0 ,
262
+ "outputs" : []
264
263
},
265
264
{
266
265
"cell_type" : " code" ,
267
- "execution_count" : 0 ,
268
266
"metadata" : {
269
- "colab" : {},
270
267
"colab_type" : " code" ,
271
268
"deletable" : true ,
272
269
"editable" : true ,
273
- "id" : " AaJ7zd1w3fWi"
270
+ "id" : " AaJ7zd1w3fWi" ,
271
+ "colab" : {}
274
272
},
275
- "outputs" : [],
276
273
"source" : [
277
274
" d=15\n " ,
278
275
" img_blur15 = cv2.GaussianBlur(input_image, (2*d+1, 2*d+1), -1)[d:-d,d:-d]\n " ,
279
276
" \n " ,
280
277
" plt.imshow(cv2.cvtColor(img_blur15, cv2.COLOR_BGR2RGB))"
281
- ]
278
+ ],
279
+ "execution_count" : 0 ,
280
+ "outputs" : []
282
281
},
283
282
{
284
283
"cell_type" : " markdown" ,
298
297
},
299
298
{
300
299
"cell_type" : " code" ,
301
- "execution_count" : 0 ,
302
300
"metadata" : {
303
- "colab" : {},
304
301
"colab_type" : " code" ,
305
302
"deletable" : true ,
306
303
"editable" : true ,
307
- "id" : " d7ceQSv13fWk"
304
+ "id" : " d7ceQSv13fWk" ,
305
+ "colab" : {}
308
306
},
309
- "outputs" : [],
310
307
"source" : [
311
308
" sobelimage=cv2.cvtColor(input_image,cv2.COLOR_BGR2GRAY)\n " ,
312
309
" \n " ,
313
310
" sobelx = cv2.Sobel(sobelimage,cv2.CV_64F,1,0,ksize=9)\n " ,
314
311
" sobely = cv2.Sobel(sobelimage,cv2.CV_64F,0,1,ksize=9)\n " ,
315
312
" plt.imshow(sobelx,cmap = 'gray') \n " ,
316
313
" # Sobel works in x and in y, change sobelx to sobely in the olt line above to see the difference\n "
317
- ]
314
+ ],
315
+ "execution_count" : 0 ,
316
+ "outputs" : []
318
317
},
319
318
{
320
319
"cell_type" : " markdown" ,
331
330
},
332
331
{
333
332
"cell_type" : " code" ,
334
- "execution_count" : 0 ,
335
333
"metadata" : {
336
- "colab" : {},
337
334
"colab_type" : " code" ,
338
335
"deletable" : true ,
339
336
"editable" : true ,
340
- "id" : " 1MJQRgXL3fWn"
337
+ "id" : " 1MJQRgXL3fWn" ,
338
+ "colab" : {}
341
339
},
342
- "outputs" : [],
343
340
"source" : [
344
341
" th1=30\n " ,
345
342
" th2=60 # Canny recommends threshold 2 is 3 times threshold 1 - you could try experimenting with this...\n " ,
355
352
" edgeresult[edge != 0] = (0, 255, 0) # this takes pixels in edgeresult where edge non-zero colours them bright green\n " ,
356
353
" \n " ,
357
354
" plt.imshow(cv2.cvtColor(edgeresult, cv2.COLOR_BGR2RGB))"
358
- ]
359
- },
360
- {
361
- "cell_type" : " code" ,
355
+ ],
362
356
"execution_count" : 0 ,
363
- "metadata" : {
364
- "colab" : {},
365
- "colab_type" : " code" ,
366
- "deletable" : true ,
367
- "editable" : true ,
368
- "id" : " fpjccg2Z3fWp"
369
- },
370
- "outputs" : [],
371
- "source" : [
372
- " "
373
- ]
357
+ "outputs" : []
374
358
},
375
359
{
376
360
"cell_type" : " markdown" ,
384
368
"source" : [
385
369
" [Previous](1-Fundamentals.ipynb) [Next](3-Features.ipynb)"
386
370
]
387
- },
388
- {
389
- "cell_type" : " code" ,
390
- "execution_count" : null ,
391
- "metadata" : {},
392
- "outputs" : [],
393
- "source" : []
394
371
}
395
372
]
396
- }
373
+ }
0 commit comments