summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--accessing_parts_of_arrays/script.rst570
-rw-r--r--accessing_parts_of_arrays/slides.org129
-rw-r--r--accessing_parts_of_arrays/slides.org.orig123
-rw-r--r--accessing_parts_of_arrays/slides.tex212
-rw-r--r--accessing_parts_of_arrays/slides.tex.orig199
5 files changed, 627 insertions, 606 deletions
diff --git a/accessing_parts_of_arrays/script.rst b/accessing_parts_of_arrays/script.rst
index b6567a4..c4a74fe 100644
--- a/accessing_parts_of_arrays/script.rst
+++ b/accessing_parts_of_arrays/script.rst
@@ -16,7 +16,7 @@
.. 1. getting started with arrays
-.. #[anand: internal reviewer not mentioned]
+
.. Author : Puneeth
Internal Reviewer :
External Reviewer :
@@ -26,149 +26,258 @@
Script
------
-{{{ Screen shows welcome slide }}}
+.. L1
-Welcome to the tutorial on accessing pieces of arrays
+{{{ Show the first slide containing title, name of the production
+team along with the logo of MHRD }}}
-{{{ Show the outline for this tutorial }}}
+.. R1
-In this tutorial we shall learn to access individual elements of
-arrays, get rows and columns and other chunks of arrays using
-slicing and striding.
+Hello friends and Welcome to the tutorial on
+'Accessing pieces of arrays'.
-{{{ switch back to the terminal }}}
+.. L2
+
+{{{ Show slide with objectives }}}
+
+.. R2
+
+At the end of this tutorial, you will be able to,
+
+ 1. Access and change individual elements of arrays, both one
+ dimensional and multi-dimensional.
+ #. Access and change rows and columns of arrays.
+ #. Access and change other chunks from an array, using slicing
+ and striding.
+ #. Read images into arrays and perform processing on them, using
+ simple array manipulations.
+
+.. L3
+
+{{{ Switch to the pre-requisite slide }}}
+
+.. R3
+
+Before beginning this tutorial,we would suggest you to complete the
+tutorial on "Getting started with arrays".
+
+.. L4
+
+{{{ Open the terminal }}}
+
+.. R4
As usual, we start IPython, using
::
- ipython -pylab
+ ipython -pylab
+.. L5
{{ Show the slide with the arrays, A and C }}
+.. R5
+
+Let us begin with the help of an example.
Let us have two arrays, A and C, as the sample arrays that we will
use to work through this tutorial.
+.. L6
::
- A = array([12, 23, 34, 45, 56])
-
- C = array([[11, 12, 13, 14, 15],
- [21, 22, 23, 24, 25],
- [31, 32, 33, 34, 35],
- [41, 42, 43, 44, 45],
- [51, 52, 53, 54, 55]])
+ A = array([12, 23, 34, 45, 56])
-Pause the video here and make sure you have the arrays A and C,
-typed in correctly.
+ C = array([[11, 12, 13, 14, 15],
+ [21, 22, 23, 24, 25],
+ [31, 32, 33, 34, 35],
+ [41, 42, 43, 44, 45],
+ [51, 52, 53, 54, 55]])
-{{{ Pause the recording and type the arrays A,C }}}
+.. R6
+ Pause the recording and type the arrays A and C. also make sure
+ that you have typed the arrays correctly.
+ <Pause>
+
Let us begin with the most elementary thing, accessing individual
elements. Also, let us first do it with the one-dimensional array
A, and then do the same thing with the two-dimensional array.
-To access, the element 34 in A, we say,
+.. R7
+
+To access, the element 34 in array A, we say,
+A of 2, note that we are using square brackets.
+.. L7
::
- A[2]
+ A[2]
-A of 2, note that we are using square brackets.
+.. R8
Like lists, indexing starts from 0 in arrays, too. So, 34, the
third element has the index 2.
-Now, let us access the element 34 from C. To do this, we say
+Now, let us access the element 34 from C. To do this, we say,
+C of 2,3.
+
+.. L8
::
- C[2, 3]
+ C[2, 3]
-C of 2,3.
+.. R9
34 is in the third row and the fourth column, and since indexing
begins from zero, the row index is 2 and column index is 3.
Now, that we have accessed one element of the array, let us change
-it. We shall change the 34 to -34 in both A and C. To do this, we
+it. We shall change 34 to -34 in both A and C. To do this, we
simply assign the new value after accessing the element.
+
+.. L9
::
- A[2] = -34
- C[2, 3] = -34
+ A[2] = -34
+ C[2, 3] = -34
+
+.. R10
+
+Let us check our operations,
+
+.. L10
+::
+
+ A[2]
+ C[2,3]
+
+.. R11
Now that we have accessed and changed a single element, let us
access and change more than one element at a time; first rows and
then columns.
Let us access one row of C, say the third row. We do it by saying,
+
+.. L11
::
- C[2]
+ C[2]
+
+.. R12
How do we access the last row of C? We could say,
+
+.. L12
::
- C[4]
+ C[4]
+
+.. R13
-for the fifth row, or as with lists, use negative indexing and say
+or as with lists,we could use negative indexing and say,
+
+.. L13
::
- C[-1]
+ C[-1]
+
+.. R14
Now, we could change the last row into all zeros, using either
+
+.. L14
::
- C[-1] = [0, 0, 0, 0, 0]
+ C[-1] = [0, 0, 0, 0, 0]
+
+.. R15
-or
+or, we can use,
+.. L15
::
- C[-1] = 0
+ C[-1] = 0
+
+.. R16
Now, how do we access one column of C? As with accessing individual
elements, the column is the second parameter to be specified (after
the comma). The first parameter, is replaced with a ``:``. This
specifies that we want all the elements of that dimension, instead of
-just one particular element. We access the third column by
+just one particular element. We access the third column by saying,
+.. L16
::
C[:, 2]
-Following is an exercise that you must do.
+.. R17
+
+Pause the video here, try out the following exercise and resume the video.
-{{ show slide containing Question 1}}
+.. L17
-%%1%% Change the last column of C to zeroes.
+.. L18
-Please, pause the video here. Do the exercises and then continue.
+{{{ Show slide with exercise 1 }}}
+.. R18
+
+ Change the last column of C to zeroes.
+
+.. R19
+
+Switch to the terminal for solution.To change the entire last column of
+C to zeroes, we simply say,
+
+.. L19
+
+{{{ Continue from paused state }}}
+{{{ Switch to the terminal }}}
::
- C[:, -1] = 0
+ C[:, -1] = 0
+
+.. R20
Since A is one dimensional, rows and columns of A don't make much
-sense. It has just one row and
+sense. It has just one row and A of colon gives the whole of A.
+
+.. L20
::
- A[:]
+ A[:]
+
+.. R21
+
+Pause the video here, try out the following exercise and resume the video.
-gives the whole of A.
+.. L21
-Following is an exercise that you must do.
+.. L22
-{{ show slide containing Question 2}}
+{{{ show slide containing exercise 2 }}}
-%%2%% Change ``A`` to ``[11, 12, 13, 14, 15]``.
+.. R22
-Please, pause the video here. Do the exercises and then continue.
+ Change ``A`` to ``[11, 12, 13, 14, 15]``.
-To change A, we say
+.. R23
+
+Switch to the terminal for solution.
+To change A, we say,
+
+.. L23
+
+{{{continue from paused state}}}
+{{{ Switch to the terminal }}}
::
- A[:] = [11, 12, 13, 14, 15]
+ A[:] = [11, 12, 13, 14, 15]
+
+.. R24
Now, that we know how to access, rows and columns of an array, we
shall learn how to access other pieces of an array. For this
@@ -176,44 +285,72 @@ purpose, we will be using image arrays.
To read an image into an array, we use the ``imread`` command. We
shall use the image ``squares.png`` present in ``/home/fossee``. We
-shall first navigate to that path in the OS and see what the image
+first navigate to that path in the OS and see what the image
contains.
+.. L24
+
{{{ switch to the browser and show the image }}}
{{{ switch back to the ipython terminal }}}
+.. R25
+
Let us now read the data in ``squares.png`` into the array ``I``.
+
+.. L25
::
- I = imread('/home/fossee/squares.png')
+ I = imread('/home/fossee/squares.png')
+
+.. R26
We can see the contents of the image, using the command
-``imshow``. We say,
+``imshow``. We say, imshow(I) to see what has been read into ``I``.
+
+.. L26
::
- imshow(I)
+ imshow(I)
+
+.. R27
+
+We do not see white and black because, ``pylab`` has mapped
+white and black to different colors.
+This can be changed by using a different colormap.
-to see what has been read into ``I``. We do not see white and black
-because, ``pylab`` has mapped white and black to different
-colors. This can be changed by using a different colormap.
+To see that ``I`` is really, just an array, we say, I, at the prompt
-To see that ``I`` is really, just an array, we say,
+.. L27
::
- I
+ I
-at the prompt, and see that an array is displayed.
+.. R28
-To check the dimensions of any array, we can use ``.shape``. We say
+We see that an array is displayed.
+To check the dimensions of any array, we can use ``.shape`` function.
+
+.. L28
::
- I.shape
+ I.shape
+
+.. R29
-to get the dimensions of the image. As we can see, ``squares.png``
+As we can see,we got the dimensions of the image.The image,``squares.png``
has the dimensions of 300x300.
+.. L29
+
+.. L30
+
+{{{ Switch to slide squares.png }}}
+{{{ Point at top-left quadrant of the image }}}
+
+.. R30
+
Our goal for this part of the tutorial would be to get the
top-left quadrant of the image. To do this, we need to access, a
few of the rows and a few of the columns of the array.
@@ -224,203 +361,350 @@ modify this to access only the first three rows, of column three
of C.
We say,
+
+.. L31
::
- C[0:3, 2]
+ C[0:3, 2]
+
+.. R31
-to get the elements of rows indexed from 0 to 3, 3 not included
-and column indexed 2. Note that, the index before the colon is
+C[0:3, 2] gives, the elements of rows indexed from 0 to 3, 3 not
+included and column indexed 2. Note that, the index before the colon is
included and the index after it is not included in the slice that
we have obtained. This is very similar to the ``range`` function,
where ``range`` returns a list, in which the upper limit or stop
value is not included.
+.. R32
+
Now, if we wish to access the elements of row with index 2, and in
columns indexed 0 to 2 (included), we say,
+
+.. L32
::
- C[2, 0:3]
+ C[2, 0:3]
-Following is an exercise that you must do.
+.. R33
-{{ show slide containing Question 3 }}
+Pause the video here, try out the following exercise and resume the video.
-%%3%% First, obtain the elements [22, 23] from C. Then, obtain the
-elements [11, 21, 31, 41] from C. Finally, obtain the elements [21,
-31, 41, 0].
+.. L33
-Please, pause the video here. Do the exercises and then continue.
+.. L34
-{{ show slide containing Solution 3 }}
+{{{ show slide containing exercise 3 }}}
+.. R34
+
+First, obtain the elements [22, 23] from C. Then, obtain the
+elements [11, 21, 31, 41] from C. Finally, obtain the elements
+[21,31, 41, 0].
+<Pause>
+Switch to the terminal for solution.
+
+.. L35
+
+{{{continue from paused state}}}
+{{{ Switch to the terminal }}}
::
- C[1, 1:3]
+ C[1, 1:3]
+
+.. R35
-gives the elements [22, 23]
+C[1, 1:3] gives the elements [22, 23]
+
+.. L36
::
- C[0:4, 0]
+ C[0:4, 0]
+
+.. R36
+
+C[0:4, 0] gives the elements [11, 21, 31, 41]
-gives the elements [11, 21, 31, 41]
+.. L37
::
- C[1:5, 0]
+ C[1:5, 0]
-gives the elements [21, 31, 41, 0]
+.. R37
+
+C[1:5, 0] gives the elements [21, 31, 41, 0]
Note that when specifying ranges, if you are starting from the
beginning or going up-to the end, the corresponding element may be
dropped. So, in the previous example to obtain [11, 21, 31, 41], we
-could have simply said, ::
-
- C[:4, 0]
+could have simply said,
-and
+.. L38
::
- C[1:, 0]
+ C[:4, 0]
+ C[1:, 0]
-gives the elements [21, 31, 41, 0]. If we skip both the indexes,
+.. R38
+
+We get the elements [21, 31, 41, 0]. If we skip both the indexes,
we get the slice from end to end, as we already know.
-Following is an exercise that you must do.
+Pause the video here, try out the following exercise and resume the video.
-{{ show slide containing Question 4 }}
+.. L39
+
+{{{ show slide containing exercise 4 }}}
-%%4%% Obtain the elements [[23, 24], [33, -34]] from C.
+.. R39
-Please, pause the video here. Do the exercises and then continue.
+ Obtain the elements [[23, 24], [33, -34]] from C.
-{{ show slide containing Solution 4 }}
+.. L40
+{{{continue from paused state}}}
+{{{ Switch to the terminal }}}
::
- C[1:3, 2:4]
+ C[1:3, 2:4]
+
+.. R40
-gives us the elements, [[23, 24], [33, -34]].
+Switch to the terminal for solution.
+<Type the command>
+C[1:3, 2:4] will give us the required elements.
Now, we wish to obtain the top left quarter of the image. How do
-we go about doing it? Since, we know the shape of the image to be
-300, we know that we need to get the first 150 rows and first 150
+we go about doing it? Since, we know the shape of the image is
+300, we know that we need to get the first 150 rows and the first 150
columns.
+
+.. L41
::
- I[:150, :150]
+ I[:150, :150]
+
+.. R41
-gives us the top-left corner of the image.
+I[:150, :150] gives us the top-left corner of the image.
+
+.. R42
We use the ``imshow`` command to see the slice we obtained in the
form of an image and confirm.
+
+.. L42
::
- imshow(I[:150, :150])
+ imshow(I[:150, :150])
+
+.. R43
+
+Pause the video here, try out the following exercise and resume the video.
-Following is an exercise that you must do.
+.. L43
-{{ show slide containing Question 5 }}
+.. L44
-%%5%% Obtain the square in the center of the image.
+{{{ show slide containing exercise 5 }}}
-Please, pause the video here. Do the exercises and then continue.
+.. R44
-{{ show slide containing Solution 5 }}
+ Obtain the square in the center of the image.
+.. L45
+
+{{{continue from paused state}}}
+{{{ Switch to the terminal }}}
::
- imshow(I[75:225, 75:225])
+ imshow(I[75:225, 75:225])
+
+.. R45
+
+Switch to the terminal for solution.
+<Type the command>
+Hence, we get the center of the image.
Our next goal is to compress the image, using a very simple
-technique to reduce the space that the image takes on disk while
+technique, so as to reduce the space that the image takes on disk, while
not compromising too heavily on the image quality. The idea is to
drop alternate rows and columns of the image and save it. This way
-we will be reducing the data to a fourth of the original data but
-losing only so much of visual information.
+we will be reducing the data to one-fourth of the original data but
+losing only a little of visual information.
We shall first learn the idea of striding using the smaller array
C. Suppose we wish to access only the odd rows and columns (first,
third, fifth). We do this by,
+
+.. L46
::
- C[0:5:2, 0:5:2]
+ C[0:5:2, 0:5:2]
-if we wish to be explicit, or simply,
+.. R46
+
+.. R47
+
+if we wish to be explicit, we say,
+
+.. L47
::
- C[::2, ::2]
+ C[::2, ::2]
+
+.. R48
This is very similar to the step specified to the ``range``
function. It specifies, the jump or step in which to move, while
accessing the elements. If no step is specified, a default value
of 1 is assumed.
+
+.. L48
::
- C[1::2, ::2]
+ C[1::2, ::2]
-gives the elements, [[21, 23, 0], [41, 43, 0]]
+.. R49
-{{ show slide containing Question 6 }}
+we get the elements, [[21, 23, 0], [41, 43, 0]]
+Pause the video here, try out the following exercise and resume the video.
-Following is an exercise that you must do.
+.. L49
-%%6%% Obtain the following.
-[[12, 0], [42, 0]]
-[[12, 13, 14], [0, 0, 0]]
+.. L50
-Please, pause the video here. Do the exercises and then continue.
+{{{ show slide containing exercise 6 }}}
-{{ show slide containing Solution 6 }}
+.. R50
-::
+ Obtain the following.
+[[12, 0], [42, 0]]
+[[12, 13, 14], [0, 0, 0]]
- C[::3, 1::3]
+.. L51
-gives the elements [[12, 0], [42, 0]]
-::
+{{{continue from paused state}}}
+{{{ show slide containing Solution 6 }}}
- C[::4, 1:4]
+.. R51
-gives the elements [[12, 13, 14], [0, 0, 0]]
+The solution is on your screen.
Now, that we know how to stride over an array, we can drop
alternate rows and columns out of the image in I.
+
+.. L52
::
- I[::2, ::2]
+ I[::2, ::2]
+
+.. R52
To see this image, we say,
+
+.. L53
::
- imshow(I[::2, ::2])
+ imshow(I[::2, ::2])
+
+.. R53
This does not have much data to notice any real difference, but
notice that the scale has reduced to show that we have dropped
alternate rows and columns. If you notice carefully, you will be
able to observe some blurring near the edges. To notice this
effect more clearly, increase the step to 4.
+
+.. L54
::
- imshow(I[::4, ::4])
+ imshow(I[::4, ::4])
+
+.. R54
+
+.. L55
{{{ show summary slide }}}
-That brings us to the end of this tutorial. In this tutorial, we
-have learnt to access parts of arrays, specifically individual
-elements, rows and columns and larger pieces of arrays. We have
-also learnt how to modify arrays, element wise or in larger
-pieces.
+.. R55
+
+This brings us to the end of this tutorial. In this tutorial, we
+have learnt to,
+
+ 1. Manipulate single & multi dimensional arrays.
+ #. Access and change individual elements by using their index numbers.
+ #. Access and change rows and columns of arrays by specifying the row
+ and column numbers.
+ #. Slice and stride on arrays.
+ #. Read images into arrays and manipulate them.
+
+.. L56
+
+{{{Show self assessment questions slide}}}
+
+.. R56
+
+Here are some self assessment questions for you to solve
+
+1. Given the array, ``A = array([12, 15, 18, 21])``, how do we access
+ the element ``18``?
+
+
+2. Given the array,
+
+::
+
+ B = array([[10, 11, 12, 13],
+ [20, 21, 22, 23],
+ [30, 31, 32, 33],
+ [40, 41, 42, 43]])
+
+Obtain the elements, ``[[21, 22], [31, 32]]``
+
+
+3. Given the array,
+::
+
+ B = array([[10, 11, 12, 13],
+ [20, 21, 22, 23]])
+
+Change the array to
+::
+
+ B = array([[10, 11, 10, 11],
+ [20, 21, 20, 21]])
+
+.. L57
+
+{{{solution of self assessment questions on slide}}}
+
+.. R57
+
+And the answers,
+
+1. The element 18 in array A has index number 2.Hence, we access it as
+ A of 2
+::
+
+ A[2]
+
+2. To obtain the center four numbers in the array B, we say,B[1:3, 1:3]
+::
+
+ B[1:3, 1:3]
+
+3. We can change the elements of array C,by using slicing and striding
+::
+
+ B[:2, 2:] = B[:2, :2]
+
+.. L58
-{{{ Show the "sponsored by FOSSEE" slide }}}
+{{{ Show the Thank you slide }}}
-This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India
+.. R58
-Hope you have enjoyed and found it useful.
+Hope you have enjoyed this tutorial and found it useful.
Thank you!
-..
- Local Variables:
- mode: rst
- indent-tabs-mode: nil
- sentence-end-double-space: nil
- fill-column: 70
- End:
diff --git a/accessing_parts_of_arrays/slides.org b/accessing_parts_of_arrays/slides.org
index 82801ca..98d5923 100644
--- a/accessing_parts_of_arrays/slides.org
+++ b/accessing_parts_of_arrays/slides.org
@@ -18,7 +18,7 @@
#+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
#+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries}
-#+TITLE: Accessing parts of arrays
+#+TITLE:
#+AUTHOR: FOSSEE
#+EMAIL:
#+DATE:
@@ -29,12 +29,35 @@
#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
#+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
-* Outline
- - Manipulating one and multi dimensional arrays
- - Access and change individual elements
- - Access and change rows and columns
- - Slicing and striding on arrays to access chunks
- - Read images into arrays and manipulations
+*
+#+begin_latex
+\begin{center}
+\vspace{12pt}
+\textcolor{blue}{\huge Getting started with Arrays}
+\end{center}
+\vspace{18pt}
+\begin{center}
+\vspace{10pt}
+\includegraphics[scale=0.95]{../images/fossee-logo.png}\\
+\vspace{5pt}
+\scriptsize Developed by FOSSEE Team, IIT-Bombay. \\
+\scriptsize Funded by National Mission on Education through ICT\\
+\scriptsize MHRD,Govt. of India\\
+\includegraphics[scale=0.30]{../images/iitb-logo.png}\\
+\end{center}
+#+end_latex
+* Objectives
+ At the end of this tutorial, you will be able to,
+
+ - Access and change individual elements of arrays, both one
+ dimensional and multi-dimensional.
+ - Access and change rows and columns of arrays.
+ - Access and change other chunks from an array, using slicing
+ and striding.
+ - Read images into arrays and perform processing on them, using
+ simple array manipulations.
+* Pre-requisite
+ - Spoken tutorial on "Getting started with Arrays".
* Sample Arrays
#+begin_src python
In []: A = array([12, 23, 34, 45, 56])
@@ -46,47 +69,25 @@
[51, 52, 53, 54, 55]])
#+end_src
-* Question 1
+* Exercise 1
Change the last column of ~C~ to zeroes.
-* Solution 1
- #+begin_src python
- In []: C[:, -1] = 0
- #+end_src
-* Question 2
+* Exercise 2
Change ~A~ to ~[11, 12, 13, 14, 15]~.
-* Solution 2
- #+begin_src python
- In []: A[:] = [11, 12, 13, 14, 15]
- #+end_src
* squares.png
#+begin_latex
\begin{center}
\includegraphics[scale=0.6]{squares}
\end{center}
#+end_latex
-* Question 3
+* Exercise 3
- obtain ~[22, 23]~ from ~C~.
- obtain ~[11, 21, 31, 41]~ from ~C~.
- - obtain ~[21, 31, 41, 0]~.
-* Solution 3
- #+begin_src python
- In []: C[1, 1:3]
- In []: C[0:4, 0]
- In []: C[1:5, 0]
- #+end_src
-* Question 4
+ - obtain ~[21, 31, 41, 0]~.
+* Exercise 4
Obtain ~[[23, 24], [33, -34]]~ from ~C~
-* Solution 4
- #+begin_src python
- In []: C[1:3, 2:4]
- #+end_src
-* Question 5
+* Exercise 5
Obtain the square in the center of the image
-* Solution 5
- #+begin_src python
- In []: imshow(I[75:225, 75:225])
- #+end_src
-* Question 6
+* Exercise 6
Obtain the following
#+begin_src python
[[12, 0], [42, 0]]
@@ -99,25 +100,57 @@
In []: C[::4, 1:4]
#+end_src
* Summary
- You should now be able to --
- - Manipulate single \& multi dimensional arrays
- - Access and change individual elements
- - Access and change rows and columns
- - Slice and stride on arrays
+ In this tutorial, we have learnt to,
+
+ - Manipulate single & multi dimensional arrays.
+ - Access and change individual elements by using their index numbers.
+ - Access and change rows and columns of arrays by specifying the row
+ and column numbers.
+ - Slice and stride on arrays.
- Read images into arrays and manipulate them.
-* Thank you!
+* Evaluation
+ 1. Given the array, ``A = array([12, 15, 18, 21])``, how do we access
+ the element ``18``?
+
+
+ 2. Given the array,
+
+ C = array([[10, 11, 12, 13],
+ [20, 21, 22, 23],
+ [30, 31, 32, 33],
+ [40, 41, 42, 43]])
+
+ Obtain the elements, ``[[21, 22], [31, 32]]``
+
+
+ 3. Given the array,
+
+ C = array([[10, 11, 12, 13],
+ [20, 21, 22, 23]])
+
+ Change the array to
+
+ C = array([[10, 11, 10, 11],
+ [20, 21, 20, 21]])
+* Solutions
+ 1. A[ 2 ]
+
+ 2. B[1:3, 1:3]
+
+ 3. B[:2, 2:] = B[:2, :2]
+
+*
#+begin_latex
\begin{block}{}
\begin{center}
- This spoken tutorial has been produced by the
- \textcolor{blue}{FOSSEE} team, which is funded by the
+ \textcolor{blue}{\Large THANK YOU!}
\end{center}
+ \end{block}
+\begin{block}{}
\begin{center}
- \textcolor{blue}{National Mission on Education through \\
- Information \& Communication Technology \\
- MHRD, Govt. of India}.
+ For more Information, visit our website\\
+ \url{http://fossee.in/}
\end{center}
\end{block}
#+end_latex
-
diff --git a/accessing_parts_of_arrays/slides.org.orig b/accessing_parts_of_arrays/slides.org.orig
deleted file mode 100644
index 82801ca..0000000
--- a/accessing_parts_of_arrays/slides.org.orig
+++ /dev/null
@@ -1,123 +0,0 @@
-#+LaTeX_CLASS: beamer
-#+LaTeX_CLASS_OPTIONS: [presentation]
-#+BEAMER_FRAME_LEVEL: 1
-
-#+BEAMER_HEADER_EXTRA: \usetheme{Antibes}\usecolortheme{lily}\useoutertheme{infolines}\setbeamercovered{transparent}
-#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)
-#+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC
-
-#+LaTeX_CLASS: beamer
-#+LaTeX_CLASS_OPTIONS: [presentation]
-
-#+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl}
-#+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
-
-#+LaTeX_HEADER: \usepackage{listings}
-
-#+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries,
-#+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
-#+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries}
-
-#+TITLE: Accessing parts of arrays
-#+AUTHOR: FOSSEE
-#+EMAIL:
-#+DATE:
-
-#+DESCRIPTION:
-#+KEYWORDS:
-#+LANGUAGE: en
-#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
-#+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
-
-* Outline
- - Manipulating one and multi dimensional arrays
- - Access and change individual elements
- - Access and change rows and columns
- - Slicing and striding on arrays to access chunks
- - Read images into arrays and manipulations
-* Sample Arrays
- #+begin_src python
- In []: A = array([12, 23, 34, 45, 56])
-
- In []: C = array([[11, 12, 13, 14, 15],
- [21, 22, 23, 24, 25],
- [31, 32, 33, 34, 35],
- [41, 42, 43, 44, 45],
- [51, 52, 53, 54, 55]])
-
- #+end_src
-* Question 1
- Change the last column of ~C~ to zeroes.
-* Solution 1
- #+begin_src python
- In []: C[:, -1] = 0
- #+end_src
-* Question 2
- Change ~A~ to ~[11, 12, 13, 14, 15]~.
-* Solution 2
- #+begin_src python
- In []: A[:] = [11, 12, 13, 14, 15]
- #+end_src
-* squares.png
- #+begin_latex
- \begin{center}
- \includegraphics[scale=0.6]{squares}
- \end{center}
- #+end_latex
-* Question 3
- - obtain ~[22, 23]~ from ~C~.
- - obtain ~[11, 21, 31, 41]~ from ~C~.
- - obtain ~[21, 31, 41, 0]~.
-* Solution 3
- #+begin_src python
- In []: C[1, 1:3]
- In []: C[0:4, 0]
- In []: C[1:5, 0]
- #+end_src
-* Question 4
- Obtain ~[[23, 24], [33, -34]]~ from ~C~
-* Solution 4
- #+begin_src python
- In []: C[1:3, 2:4]
- #+end_src
-* Question 5
- Obtain the square in the center of the image
-* Solution 5
- #+begin_src python
- In []: imshow(I[75:225, 75:225])
- #+end_src
-* Question 6
- Obtain the following
- #+begin_src python
- [[12, 0], [42, 0]]
- [[12, 13, 14], [0, 0, 0]]
- #+end_src
-
-* Solution 6
- #+begin_src python
- In []: C[::3, 1::3]
- In []: C[::4, 1:4]
- #+end_src
-* Summary
- You should now be able to --
- - Manipulate single \& multi dimensional arrays
- - Access and change individual elements
- - Access and change rows and columns
- - Slice and stride on arrays
- - Read images into arrays and manipulate them.
-* Thank you!
-#+begin_latex
- \begin{block}{}
- \begin{center}
- This spoken tutorial has been produced by the
- \textcolor{blue}{FOSSEE} team, which is funded by the
- \end{center}
- \begin{center}
- \textcolor{blue}{National Mission on Education through \\
- Information \& Communication Technology \\
- MHRD, Govt. of India}.
- \end{center}
- \end{block}
-#+end_latex
-
-
diff --git a/accessing_parts_of_arrays/slides.tex b/accessing_parts_of_arrays/slides.tex
index a3e4c6d..6562a6b 100644
--- a/accessing_parts_of_arrays/slides.tex
+++ b/accessing_parts_of_arrays/slides.tex
@@ -1,11 +1,11 @@
-% Created 2010-11-02 Tue 17:47
+% Created 2011-05-30 Mon 16:58
\documentclass[presentation]{beamer}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}
\usepackage{graphicx}
\usepackage{longtable}
-\usepackage{float}
+\usepackage{float,caption,array,multirow}
\usepackage{wrapfig}
\usepackage{soul}
\usepackage{textcomp}
@@ -23,14 +23,14 @@ commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
showstringspaces=false, keywordstyle=\color{blue}\bfseries}
\providecommand{\alert}[1]{\textbf{#1}}
-\title{Accessing parts of arrays}
+\title{}
\author{FOSSEE}
\date{}
\usetheme{Antibes}\usecolortheme{lily}\useoutertheme{infolines}\setbeamercovered{transparent}
\begin{document}
-\maketitle
+
@@ -41,21 +41,52 @@ showstringspaces=false, keywordstyle=\color{blue}\bfseries}
\begin{frame}
-\frametitle{Outline}
-\label{sec-1}
+
+\begin{center}
+\vspace{12pt}
+\textcolor{blue}{\huge Getting started with Arrays}
+\end{center}
+\vspace{18pt}
+\begin{center}
+\vspace{10pt}
+\includegraphics[scale=0.95]{../images/fossee-logo.png}\\
+\vspace{5pt}
+\scriptsize Developed by FOSSEE Team, IIT-Bombay. \\
+\scriptsize Funded by National Mission on Education through ICT\\
+\scriptsize MHRD,Govt. of India\\
+\includegraphics[scale=0.30]{../images/iitb-logo.png}\\
+\end{center}
+\end{frame}
+\begin{frame}
+\frametitle{Objectives}
+\label{sec-2}
+
+ At the end of this tutorial, you will be able to,
+
\begin{itemize}
-\item Manipulating one and multi dimensional arrays
-\item Access and change individual elements
-\item Access and change rows and columns
-\item Slicing and striding on arrays to access chunks
-\item Read images into arrays and manipulations
+\item Access and change individual elements of arrays, both one
+ dimensional and multi-dimensional.
+\item Access and change rows and columns of arrays.
+\item Access and change other chunks from an array, using slicing
+ and striding.
+\item Read images into arrays and perform processing on them, using
+ simple array manipulations.
+\end{itemize}
+\end{frame}
+\begin{frame}
+\frametitle{Pre-requisite}
+\label{sec-3}
+
+
+Spoken tutorial on -
+\begin{itemize}
+\item Getting started with Arrays.
\end{itemize}
\end{frame}
\begin{frame}[fragile]
\frametitle{Sample Arrays}
-\label{sec-2}
-
+\label{sec-4}
\lstset{language=Python}
\begin{lstlisting}
In []: A = array([12, 23, 34, 45, 56])
@@ -68,34 +99,16 @@ In []: C = array([[11, 12, 13, 14, 15],
\end{lstlisting}
\end{frame}
\begin{frame}
-\frametitle{Question 1}
-\label{sec-3}
-
- Change the last column of \texttt{C} to zeroes.
-\end{frame}
-\begin{frame}[fragile]
-\frametitle{Solution 1}
-\label{sec-4}
-
-\lstset{language=Python}
-\begin{lstlisting}
-In []: C[:, -1] = 0
-\end{lstlisting}
-\end{frame}
-\begin{frame}
-\frametitle{Question 2}
+\frametitle{Exercise 1}
\label{sec-5}
- Change \texttt{A} to \texttt{[11, 12, 13, 14, 15]}.
+ Change the last column of \verb~C~ to zeroes.
\end{frame}
-\begin{frame}[fragile]
-\frametitle{Solution 2}
+\begin{frame}
+\frametitle{Exercise 2}
\label{sec-6}
-\lstset{language=Python}
-\begin{lstlisting}
-In []: A[:] = [11, 12, 13, 14, 15]
-\end{lstlisting}
+ Change \verb~A~ to \verb~[11, 12, 13, 14, 15]~.
\end{frame}
\begin{frame}
\frametitle{squares.png}
@@ -106,59 +119,31 @@ In []: A[:] = [11, 12, 13, 14, 15]
\end{center}
\end{frame}
\begin{frame}
-\frametitle{Question 3}
+\frametitle{Exercise 3}
\label{sec-8}
+
\begin{itemize}
-\item obtain \texttt{[22, 23]} from \texttt{C}.
-\item obtain \texttt{[11, 21, 31, 41]} from \texttt{C}.
-\item obtain \texttt{[21, 31, 41, 0]}.
+\item obtain \verb~[22, 23]~ from \verb~C~.
+\item obtain \verb~[11, 21, 31, 41]~ from \verb~C~.
+\item obtain \verb~[21, 31, 41, 0]~.
\end{itemize}
\end{frame}
-\begin{frame}[fragile]
-\frametitle{Solution 3}
+\begin{frame}
+\frametitle{Exercise 4}
\label{sec-9}
-\lstset{language=Python}
-\begin{lstlisting}
-In []: C[1, 1:3]
-In []: C[0:4, 0]
-In []: C[1:5, 0]
-\end{lstlisting}
+ Obtain \verb~[[23, 24], [33, -34]]~ from \verb~C~
\end{frame}
\begin{frame}
-\frametitle{Question 4}
+\frametitle{Exercise 5}
\label{sec-10}
- Obtain \texttt{[[23, 24], [33, -34]]} from \texttt{C}
-\end{frame}
-\begin{frame}[fragile]
-\frametitle{Solution 4}
-\label{sec-11}
-
-\lstset{language=Python}
-\begin{lstlisting}
-In []: C[1:3, 2:4]
-\end{lstlisting}
-\end{frame}
-\begin{frame}
-\frametitle{Question 5}
-\label{sec-12}
-
Obtain the square in the center of the image
\end{frame}
\begin{frame}[fragile]
-\frametitle{Solution 5}
-\label{sec-13}
-
-\lstset{language=Python}
-\begin{lstlisting}
-In []: imshow(I[75:225, 75:225])
-\end{lstlisting}
-\end{frame}
-\begin{frame}[fragile]
-\frametitle{Question 6}
-\label{sec-14}
+\frametitle{Exercise 6}
+\label{sec-11}
Obtain the following
\lstset{language=Python}
@@ -169,7 +154,7 @@ In []: imshow(I[75:225, 75:225])
\end{frame}
\begin{frame}[fragile]
\frametitle{Solution 6}
-\label{sec-15}
+\label{sec-12}
\lstset{language=Python}
\begin{lstlisting}
@@ -179,36 +164,77 @@ In []: C[::4, 1:4]
\end{frame}
\begin{frame}
\frametitle{Summary}
-\label{sec-16}
+\label{sec-13}
- You should now be able to --
-\begin{itemize}
-\item Manipulate single \& multi dimensional arrays
+ In this tutorial, we have learnt to,
+
\begin{itemize}
-\item Access and change individual elements
-\item Access and change rows and columns
-\item Slice and stride on arrays
-\end{itemize}
-
+\item Manipulate single \& multi dimensional arrays.
+\item Access and change individual elements by using their index numbers.
+\item Access and change rows and columns of arrays by specifying the row
+ and column numbers.
+\item Slice and stride on arrays.
\item Read images into arrays and manipulate them.
\end{itemize}
\end{frame}
\begin{frame}
-\frametitle{Thank you!}
-\label{sec-17}
+\frametitle{Evaluation}
+\label{sec-14}
+
+
+\begin{enumerate}
+\item Given the array,\\ A = array([12, 15, 18, 21]),\\ How do we access the element ``18''?
+\vspace{2pt}
+\item Given the array,\\
+B = array([[10, 11, 12, 13],\\
+\hspace{1.64cm}
+ [20, 21, 22, 23],\\
+\hspace{1.64cm}
+ [30, 31, 32, 33],\\
+\hspace{1.64cm}
+ [40, 41, 42, 43]])\\
+Obtain the elements, ``[[21, 22], [31, 32]].''
+\vspace{2pt}
+\item Given the array, \\
+
+ C = array([[10, 11, 12, 13],\\
+\hspace{1.64cm}
+ [20, 21, 22, 23]])\\
+
+ Change the array to, \\
+
+ C = array([[10, 11, 10, 11],\\
+\hspace{1.64cm}
+ [20, 21, 20, 21]])
+\end{enumerate}
+\end{frame}
+\begin{frame}
+\frametitle{Solutions}
+\label{sec-15}
+
+
+\begin{enumerate}
+\item A[ 2 ]
+\vspace{12pt}
+\item B[1:3, 1:3]
+\vspace{12pt}
+\item B[:2, 2:] = B[:2, :2]
+\end{enumerate}
+\end{frame}
+\begin{frame}
\begin{block}{}
\begin{center}
- This spoken tutorial has been produced by the
- \textcolor{blue}{FOSSEE} team, which is funded by the
+ \textcolor{blue}{\Large THANK YOU!}
\end{center}
+ \end{block}
+\begin{block}{}
\begin{center}
- \textcolor{blue}{National Mission on Education through \\
- Information \& Communication Technology \\
- MHRD, Govt. of India}.
+ For more Information, visit our website\\
+ \url{http://fossee.in/}
\end{center}
\end{block}
\end{frame}
-\end{document}
+\end{document} \ No newline at end of file
diff --git a/accessing_parts_of_arrays/slides.tex.orig b/accessing_parts_of_arrays/slides.tex.orig
deleted file mode 100644
index 91e8959..0000000
--- a/accessing_parts_of_arrays/slides.tex.orig
+++ /dev/null
@@ -1,199 +0,0 @@
-% Created 2010-11-03 Wed 15:37
-\documentclass[presentation]{beamer}
-\usetheme{Antibes}\usecolortheme{lily}\useoutertheme{infolines}\setbeamercovered{transparent}
-\usepackage[latin1]{inputenc}
-\usepackage[T1]{fontenc}
-\usepackage{graphicx}
-\usepackage{longtable}
-\usepackage{float}
-\usepackage{wrapfig}
-\usepackage{soul}
-\usepackage{amssymb}
-\usepackage{hyperref}
-\usepackage[english]{babel} \usepackage{ae,aecompl}
-\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
-\usepackage{listings}
-\lstset{language=Python, basicstyle=\ttfamily\bfseries,
-commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
-showstringspaces=false, keywordstyle=\color{blue}\bfseries}
-
-\title{Accessing parts of arrays}
-\author{FOSSEE}
-\date{}
-
-\begin{document}
-
-\maketitle
-
-
-
-
-
-
-
-
-
-\begin{frame}
-\frametitle{Outline}
-\label{sec-1}
-
-\begin{itemize}
-\item Manipulating one and multi dimensional arrays
-\item Access and change individual elements
-\item Access and change rows and columns
-\item Slicing and striding on arrays to access chunks
-\item Read images into arrays and manipulations
-\end{itemize}
-\end{frame}
-\begin{frame}[fragile]
-\frametitle{Sample Arrays}
-\label{sec-2}
-
-\begin{verbatim}
-In []: A = array([12, 23, 34, 45, 56])
-
-In []: C = array([[11, 12, 13, 14, 15],
- [21, 22, 23, 24, 25],
- [31, 32, 33, 34, 35],
- [41, 42, 43, 44, 45],
- [51, 52, 53, 54, 55]])
-\end{verbatim}
-\end{frame}
-\begin{frame}
-\frametitle{Question 1}
-\label{sec-3}
-
- Change the last column of \texttt{C} to zeroes.
-\end{frame}
-\begin{frame}[fragile]
-\frametitle{Solution 1}
-\label{sec-4}
-
-\begin{verbatim}
-In []: C[:, -1] = 0
-\end{verbatim}
-\end{frame}
-\begin{frame}
-\frametitle{Question 2}
-\label{sec-5}
-
- Change \texttt{A} to \texttt{[11, 12, 13, 14, 15]}.
-\end{frame}
-\begin{frame}[fragile]
-\frametitle{Solution 2}
-\label{sec-6}
-
-\begin{verbatim}
-In []: A[:] = [11, 12, 13, 14, 15]
-\end{verbatim}
-\end{frame}
-\begin{frame}
-\frametitle{squares.png}
-\label{sec-7}
-
- \begin{center}
- \includegraphics[scale=0.6]{squares}
- \end{center}
-\end{frame}
-\begin{frame}
-\frametitle{Question 3}
-\label{sec-8}
-
-\begin{itemize}
-\item obtain \texttt{[22, 23]} from \texttt{C}.
-\item obtain \texttt{[11, 21, 31, 41]} from \texttt{C}.
-\item obtain \texttt{[21, 31, 41, 0]}.
-\end{itemize}
-\end{frame}
-\begin{frame}[fragile]
-\frametitle{Solution 3}
-\label{sec-9}
-
-\begin{verbatim}
-In []: C[1, 1:3]
-In []: C[0:4, 0]
-In []: C[1:5, 0]
-\end{verbatim}
-\end{frame}
-\begin{frame}
-\frametitle{Question 4}
-\label{sec-10}
-
- Obtain \texttt{[[23, 24], [33, -34]]} from \texttt{C}
-\end{frame}
-\begin{frame}[fragile]
-\frametitle{Solution 4}
-\label{sec-11}
-
-\begin{verbatim}
-In []: C[1:3, 2:4]
-\end{verbatim}
-\end{frame}
-\begin{frame}
-\frametitle{Question 5}
-\label{sec-12}
-
- Obtain the square in the center of the image
-\end{frame}
-\begin{frame}[fragile]
-\frametitle{Solution 5}
-\label{sec-13}
-
-\begin{verbatim}
-In []: imshow(I[75:225, 75:225])
-\end{verbatim}
-\end{frame}
-\begin{frame}[fragile]
-\frametitle{Question 6}
-\label{sec-14}
-
- Obtain the following
-\begin{verbatim}
-[[12, 0], [42, 0]]
-[[12, 13, 14], [0, 0, 0]]
-\end{verbatim}
-\end{frame}
-\begin{frame}[fragile]
-\frametitle{Solution 6}
-\label{sec-15}
-
-\begin{verbatim}
-In []: C[::3, 1::3]
-In []: C[::4, 1:4]
-\end{verbatim}
-\end{frame}
-\begin{frame}
-\frametitle{Summary}
-\label{sec-16}
-
- You should now be able to --
-\begin{itemize}
-\item Manipulate single \& multi dimensional arrays
-
-\begin{itemize}
-\item Access and change individual elements
-\item Access and change rows and columns
-\item Slice and stride on arrays
-\end{itemize}
-
-\item Read images into arrays and manipulate them.
-\end{itemize}
-\end{frame}
-\begin{frame}
-\frametitle{Thank you!}
-\label{sec-17}
-
- \begin{block}{}
- \begin{center}
- This spoken tutorial has been produced by the
- \textcolor{blue}{FOSSEE} team, which is funded by the
- \end{center}
- \begin{center}
- \textcolor{blue}{National Mission on Education through \\
- Information \& Communication Technology \\
- MHRD, Govt. of India}.
- \end{center}
- \end{block}
-\end{frame}
-
-\end{document}