diff options
author | Puneeth Chaganti | 2010-12-01 16:51:35 +0530 |
---|---|---|
committer | Puneeth Chaganti | 2010-12-01 16:51:35 +0530 |
commit | f3a34dfb4e879f3eb7274704f44546aac4add88f (patch) | |
tree | 1cb0a8cc5dbd5ee2b374350915ed2addfa0fb447 /accessing-pieces-arrays | |
parent | 347866ed0d29db61ee062563b1e1616cfb85588c (diff) | |
download | st-scripts-f3a34dfb4e879f3eb7274704f44546aac4add88f.tar.gz st-scripts-f3a34dfb4e879f3eb7274704f44546aac4add88f.tar.bz2 st-scripts-f3a34dfb4e879f3eb7274704f44546aac4add88f.zip |
Renamed all LOs to match with their names in progress.org.
Diffstat (limited to 'accessing-pieces-arrays')
-rw-r--r-- | accessing-pieces-arrays/quickref.tex | 12 | ||||
-rw-r--r-- | accessing-pieces-arrays/script.rst | 426 | ||||
-rw-r--r-- | accessing-pieces-arrays/slides.org | 123 | ||||
-rw-r--r-- | accessing-pieces-arrays/slides.org.orig | 123 | ||||
-rw-r--r-- | accessing-pieces-arrays/slides.tex | 214 | ||||
-rw-r--r-- | accessing-pieces-arrays/slides.tex.orig | 199 | ||||
-rw-r--r-- | accessing-pieces-arrays/squares.png | bin | 480 -> 0 bytes | |||
-rw-r--r-- | accessing-pieces-arrays/tagore-einstein.png | bin | 121404 -> 0 bytes |
8 files changed, 0 insertions, 1097 deletions
diff --git a/accessing-pieces-arrays/quickref.tex b/accessing-pieces-arrays/quickref.tex deleted file mode 100644 index 6226b91..0000000 --- a/accessing-pieces-arrays/quickref.tex +++ /dev/null @@ -1,12 +0,0 @@ -\textbf{Accessing parts of arrays} - -\lstinline|C[i-1, j-1]| to access element i, j in C (mxn). -\lstinline|C[i-1]| to access i^{th} row -\lstinline|C[:, j-1]| to access j^{th} column - -Assigning to accessed elements, changes them. - -\lstinline|A[m:n:o]| accesses the rows from \lstinline|m| -to \lstinline|n| (excluded) in steps of \lstinline|o| - -Similarly, \lstinline|C[m:n:o, p:q:r]| diff --git a/accessing-pieces-arrays/script.rst b/accessing-pieces-arrays/script.rst deleted file mode 100644 index b6567a4..0000000 --- a/accessing-pieces-arrays/script.rst +++ /dev/null @@ -1,426 +0,0 @@ -.. Objectives -.. ---------- - - .. By the end of this tutorial, you will be able to: - - .. 1. Access and change individual elements of arrays, both one - .. dimensional and multi-dimensional. - .. 2. Access and change rows and columns of arrays. - .. 3. Access and change other chunks from an array, using slicing - .. and striding. - .. 4. Read images into arrays and perform processing on them, using - .. simple array manipulations. - -.. Prerequisites -.. ------------- - -.. 1. getting started with arrays - -.. #[anand: internal reviewer not mentioned] -.. Author : Puneeth - Internal Reviewer : - External Reviewer : - Language Reviewer : Bhanukiran - Checklist OK? : <06-11-2010, Anand, OK> [2010-10-05] - -Script ------- - -{{{ Screen shows welcome slide }}} - -Welcome to the tutorial on accessing pieces of arrays - -{{{ Show the outline for this tutorial }}} - -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. - -{{{ switch back to the terminal }}} - -As usual, we start IPython, using -:: - - ipython -pylab - - -{{ Show the slide with the arrays, A and C }} - -Let us have two arrays, A and C, as the sample arrays that we will -use to work through this tutorial. - -:: - - 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]]) - -Pause the video here and make sure you have the arrays A and C, -typed in correctly. - -{{{ Pause the recording and type the arrays A,C }}} - -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, - -:: - - A[2] - -A of 2, note that we are using square brackets. - -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 -:: - - C[2, 3] - -C of 2,3. - -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 -simply assign the new value after accessing the element. -:: - - A[2] = -34 - C[2, 3] = -34 - -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, -:: - - C[2] - -How do we access the last row of C? We could say, -:: - - C[4] - -for the fifth row, or as with lists, use negative indexing and say -:: - - C[-1] - -Now, we could change the last row into all zeros, using either -:: - - C[-1] = [0, 0, 0, 0, 0] - -or - -:: - - C[-1] = 0 - -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 - -:: - - C[:, 2] - -Following is an exercise that you must do. - -{{ show slide containing Question 1}} - -%%1%% Change the last column of C to zeroes. - -Please, pause the video here. Do the exercises and then continue. - -:: - - C[:, -1] = 0 - -Since A is one dimensional, rows and columns of A don't make much -sense. It has just one row and -:: - - A[:] - -gives the whole of A. - -Following is an exercise that you must do. - -{{ show slide containing Question 2}} - -%%2%% Change ``A`` to ``[11, 12, 13, 14, 15]``. - -Please, pause the video here. Do the exercises and then continue. - -To change A, we say -:: - - A[:] = [11, 12, 13, 14, 15] - -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 -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 -contains. - -{{{ switch to the browser and show the image }}} - -{{{ switch back to the ipython terminal }}} - -Let us now read the data in ``squares.png`` into the array ``I``. -:: - - I = imread('/home/fossee/squares.png') - -We can see the contents of the image, using the command -``imshow``. We say, -:: - - imshow(I) - -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, and see that an array is displayed. - -To check the dimensions of any array, we can use ``.shape``. We say - -:: - - I.shape - -to get the dimensions of the image. As we can see, ``squares.png`` -has the dimensions of 300x300. - -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. - -To access, the third column of C, we said, ``C[:, 2]``. Essentially, -we are accessing all the rows in column three of C. Now, let us -modify this to access only the first three rows, of column three -of C. - -We say, -:: - - C[0:3, 2] - -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 -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. - -Now, if we wish to access the elements of row with index 2, and in -columns indexed 0 to 2 (included), we say, -:: - - C[2, 0:3] - -Following is an exercise that you must do. - -{{ show slide containing Question 3 }} - -%%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]. - -Please, pause the video here. Do the exercises and then continue. - -{{ show slide containing Solution 3 }} - -:: - - C[1, 1:3] - -gives the elements [22, 23] -:: - - C[0:4, 0] - -gives the elements [11, 21, 31, 41] -:: - - 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] - -and -:: - - C[1:, 0] - -gives 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. - -{{ show slide containing Question 4 }} - -%%4%% Obtain the elements [[23, 24], [33, -34]] from C. - -Please, pause the video here. Do the exercises and then continue. - -{{ show slide containing Solution 4 }} - -:: - - C[1:3, 2:4] - -gives us the elements, [[23, 24], [33, -34]]. - -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 -columns. -:: - - I[:150, :150] - -gives us the top-left corner of the image. - -We use the ``imshow`` command to see the slice we obtained in the -form of an image and confirm. -:: - - imshow(I[:150, :150]) - -Following is an exercise that you must do. - -{{ show slide containing Question 5 }} - -%%5%% Obtain the square in the center of the image. - -Please, pause the video here. Do the exercises and then continue. - -{{ show slide containing Solution 5 }} - -:: - - imshow(I[75:225, 75:225]) - -Our next goal is to compress the image, using a very simple -technique 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 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, -:: - - C[0:5:2, 0:5:2] - -if we wish to be explicit, or simply, -:: - - C[::2, ::2] - -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. -:: - - C[1::2, ::2] - -gives the elements, [[21, 23, 0], [41, 43, 0]] - -{{ show slide containing Question 6 }} - -Following is an exercise that you must do. - -%%6%% Obtain the following. -[[12, 0], [42, 0]] -[[12, 13, 14], [0, 0, 0]] - -Please, pause the video here. Do the exercises and then continue. - -{{ show slide containing Solution 6 }} - -:: - - C[::3, 1::3] - -gives the elements [[12, 0], [42, 0]] -:: - - C[::4, 1:4] - -gives the elements [[12, 13, 14], [0, 0, 0]] - -Now, that we know how to stride over an array, we can drop -alternate rows and columns out of the image in I. -:: - - I[::2, ::2] - -To see this image, we say, -:: - - imshow(I[::2, ::2]) - -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. -:: - - imshow(I[::4, ::4]) - -{{{ 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. - -{{{ Show the "sponsored by FOSSEE" slide }}} - -This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India - -Hope you have enjoyed 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-pieces-arrays/slides.org b/accessing-pieces-arrays/slides.org deleted file mode 100644 index 82801ca..0000000 --- a/accessing-pieces-arrays/slides.org +++ /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-pieces-arrays/slides.org.orig b/accessing-pieces-arrays/slides.org.orig deleted file mode 100644 index 82801ca..0000000 --- a/accessing-pieces-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-pieces-arrays/slides.tex b/accessing-pieces-arrays/slides.tex deleted file mode 100644 index a3e4c6d..0000000 --- a/accessing-pieces-arrays/slides.tex +++ /dev/null @@ -1,214 +0,0 @@ -% Created 2010-11-02 Tue 17:47 -\documentclass[presentation]{beamer} -\usepackage[latin1]{inputenc} -\usepackage[T1]{fontenc} -\usepackage{fixltx2e} -\usepackage{graphicx} -\usepackage{longtable} -\usepackage{float} -\usepackage{wrapfig} -\usepackage{soul} -\usepackage{textcomp} -\usepackage{marvosym} -\usepackage{wasysym} -\usepackage{latexsym} -\usepackage{amssymb} -\usepackage{hyperref} -\tolerance=1000 -\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} -\providecommand{\alert}[1]{\textbf{#1}} - -\title{Accessing parts of arrays} -\author{FOSSEE} -\date{} - -\usetheme{Antibes}\usecolortheme{lily}\useoutertheme{infolines}\setbeamercovered{transparent} -\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} - -\lstset{language=Python} -\begin{lstlisting} -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{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} -\label{sec-5} - - Change \texttt{A} to \texttt{[11, 12, 13, 14, 15]}. -\end{frame} -\begin{frame}[fragile] -\frametitle{Solution 2} -\label{sec-6} - -\lstset{language=Python} -\begin{lstlisting} -In []: A[:] = [11, 12, 13, 14, 15] -\end{lstlisting} -\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} - -\lstset{language=Python} -\begin{lstlisting} -In []: C[1, 1:3] -In []: C[0:4, 0] -In []: C[1:5, 0] -\end{lstlisting} -\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} - -\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} - - Obtain the following -\lstset{language=Python} -\begin{lstlisting} -[[12, 0], [42, 0]] -[[12, 13, 14], [0, 0, 0]] -\end{lstlisting} -\end{frame} -\begin{frame}[fragile] -\frametitle{Solution 6} -\label{sec-15} - -\lstset{language=Python} -\begin{lstlisting} -In []: C[::3, 1::3] -In []: C[::4, 1:4] -\end{lstlisting} -\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} diff --git a/accessing-pieces-arrays/slides.tex.orig b/accessing-pieces-arrays/slides.tex.orig deleted file mode 100644 index 91e8959..0000000 --- a/accessing-pieces-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} diff --git a/accessing-pieces-arrays/squares.png b/accessing-pieces-arrays/squares.png Binary files differdeleted file mode 100644 index ee102e6..0000000 --- a/accessing-pieces-arrays/squares.png +++ /dev/null diff --git a/accessing-pieces-arrays/tagore-einstein.png b/accessing-pieces-arrays/tagore-einstein.png Binary files differdeleted file mode 100644 index 0841dd0..0000000 --- a/accessing-pieces-arrays/tagore-einstein.png +++ /dev/null |