equal
deleted
inserted
replaced
118 |
118 |
119 :: |
119 :: |
120 |
120 |
121 C[-1] = 0 |
121 C[-1] = 0 |
122 |
122 |
123 Now, how do we access one column of C? As with accessing |
123 Now, how do we access one column of C? As with accessing individual |
124 individual elements, the column is the second parameter to be |
124 elements, the column is the second parameter to be specified (after |
125 specified (after the comma). The first parameter, is now replaced |
125 the comma). The first parameter, is replaced with a ``:``. This |
126 with a ``:`` to say, that we want all the elements of that |
126 specifies that we want all the elements of that dimension, instead of |
127 dimension, instead of one particular element. We access the third |
127 just one particular element. We access the third column by |
128 column by |
|
129 |
128 |
130 :: |
129 :: |
131 |
130 |
132 C[:, 2] |
131 C[:, 2] |
133 |
132 |
261 |
260 |
262 C[1:5, 0] |
261 C[1:5, 0] |
263 |
262 |
264 gives the elements [21, 31, 41, 0] |
263 gives the elements [21, 31, 41, 0] |
265 |
264 |
266 Note that when specifying ranges, if you are starting from or |
265 Note that when specifying ranges, if you are starting from the |
267 going up-to the end, the corresponding element may be dropped. So, |
266 beginning or going up-to the end, the corresponding element may be |
268 in the previous example to obtain [11, 21, 31, 41], we could have |
267 dropped. So, in the previous example to obtain [11, 21, 31, 41], we |
269 simply said, |
268 could have simply said, :: |
270 :: |
|
271 |
269 |
272 C[:4, 0] |
270 C[:4, 0] |
273 |
271 |
274 and |
272 and |
275 :: |
273 :: |
315 |
313 |
316 {{ show slide containing Question 5 }} |
314 {{ show slide containing Question 5 }} |
317 |
315 |
318 %%5%% Obtain the square in the center of the image. |
316 %%5%% Obtain the square in the center of the image. |
319 |
317 |
320 Following is an exercise that you must do. |
318 Please, pause the video here. Do the exercises and then continue. |
321 |
319 |
322 {{ show slide containing Solution 5 }} |
320 {{ show slide containing Solution 5 }} |
323 |
321 |
324 :: |
322 :: |
325 |
323 |
375 |
373 |
376 C[::4, 1:4] |
374 C[::4, 1:4] |
377 |
375 |
378 gives the elements [[12, 13, 14], [0, 0, 0]] |
376 gives the elements [[12, 13, 14], [0, 0, 0]] |
379 |
377 |
380 Now, that we know how to stride over an image, we can drop |
378 Now, that we know how to stride over an array, we can drop |
381 alternate rows and columns out of the image in I. |
379 alternate rows and columns out of the image in I. |
382 :: |
380 :: |
383 |
381 |
384 I[::2, ::2] |
382 I[::2, ::2] |
385 |
383 |
415 .. |
413 .. |
416 Local Variables: |
414 Local Variables: |
417 mode: rst |
415 mode: rst |
418 indent-tabs-mode: nil |
416 indent-tabs-mode: nil |
419 sentence-end-double-space: nil |
417 sentence-end-double-space: nil |
420 fill-column: 75 |
418 fill-column: 70 |
421 End: |
419 End: |