accessing-pieces-arrays/slides.tex.orig
author Amit Sethi
Tue, 09 Nov 2010 15:40:53 +0530
changeset 418 8a42b4203f6d
permissions -rw-r--r--
"Merging heads"
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
     1
% Created 2010-11-03 Wed 15:37
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
     2
\documentclass[presentation]{beamer}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
     3
\usetheme{Antibes}\usecolortheme{lily}\useoutertheme{infolines}\setbeamercovered{transparent}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
     4
\usepackage[latin1]{inputenc}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
     5
\usepackage[T1]{fontenc}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
     6
\usepackage{graphicx}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
     7
\usepackage{longtable}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
     8
\usepackage{float}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
     9
\usepackage{wrapfig}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    10
\usepackage{soul}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    11
\usepackage{amssymb}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    12
\usepackage{hyperref}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    13
\usepackage[english]{babel} \usepackage{ae,aecompl}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    14
\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    15
\usepackage{listings}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    16
\lstset{language=Python, basicstyle=\ttfamily\bfseries,
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    17
commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    18
showstringspaces=false, keywordstyle=\color{blue}\bfseries}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    19
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    20
\title{Accessing parts of arrays}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    21
\author{FOSSEE}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    22
\date{}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    23
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    24
\begin{document}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    25
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    26
\maketitle
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    27
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    28
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    29
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    30
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    31
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    32
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    33
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    34
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    35
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    36
\begin{frame}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    37
\frametitle{Outline}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    38
\label{sec-1}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    39
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    40
\begin{itemize}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    41
\item Manipulating one and multi dimensional arrays
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    42
\item Access and change individual elements
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    43
\item Access and change rows and columns
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    44
\item Slicing and striding on arrays to access chunks
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    45
\item Read images into arrays and manipulations
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    46
\end{itemize}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    47
\end{frame}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    48
\begin{frame}[fragile]
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    49
\frametitle{Sample Arrays}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    50
\label{sec-2}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    51
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    52
\begin{verbatim}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    53
In []: A = array([12, 23, 34, 45, 56])
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    54
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    55
In []: C = array([[11, 12, 13, 14, 15],
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    56
                  [21, 22, 23, 24, 25],
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    57
                  [31, 32, 33, 34, 35],
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    58
                  [41, 42, 43, 44, 45],
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    59
                  [51, 52, 53, 54, 55]])
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    60
\end{verbatim}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    61
\end{frame}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    62
\begin{frame}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    63
\frametitle{Question 1}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    64
\label{sec-3}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    65
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    66
  Change the last column of \texttt{C} to zeroes. 
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    67
\end{frame}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    68
\begin{frame}[fragile]
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    69
\frametitle{Solution 1}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    70
\label{sec-4}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    71
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    72
\begin{verbatim}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    73
In []:  C[:, -1] = 0
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    74
\end{verbatim}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    75
\end{frame}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    76
\begin{frame}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    77
\frametitle{Question 2}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    78
\label{sec-5}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    79
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    80
  Change \texttt{A} to \texttt{[11, 12, 13, 14, 15]}. 
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    81
\end{frame}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    82
\begin{frame}[fragile]
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    83
\frametitle{Solution 2}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    84
\label{sec-6}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    85
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    86
\begin{verbatim}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    87
In []:  A[:] = [11, 12, 13, 14, 15]
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    88
\end{verbatim}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    89
\end{frame}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    90
\begin{frame}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    91
\frametitle{squares.png}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    92
\label{sec-7}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    93
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    94
    \begin{center}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    95
      \includegraphics[scale=0.6]{squares}    
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    96
    \end{center}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    97
\end{frame}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    98
\begin{frame}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    99
\frametitle{Question 3}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   100
\label{sec-8}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   101
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   102
\begin{itemize}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   103
\item obtain \texttt{[22, 23]} from \texttt{C}.
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   104
\item obtain \texttt{[11, 21, 31, 41]} from \texttt{C}.
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   105
\item obtain \texttt{[21, 31, 41, 0]}.
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   106
\end{itemize}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   107
\end{frame}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   108
\begin{frame}[fragile]
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   109
\frametitle{Solution 3}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   110
\label{sec-9}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   111
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   112
\begin{verbatim}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   113
In []:  C[1, 1:3]
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   114
In []:  C[0:4, 0]
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   115
In []:  C[1:5, 0]
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   116
\end{verbatim}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   117
\end{frame}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   118
\begin{frame}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   119
\frametitle{Question 4}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   120
\label{sec-10}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   121
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   122
  Obtain \texttt{[[23, 24], [33, -34]]} from \texttt{C}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   123
\end{frame}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   124
\begin{frame}[fragile]
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   125
\frametitle{Solution 4}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   126
\label{sec-11}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   127
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   128
\begin{verbatim}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   129
In []:  C[1:3, 2:4]
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   130
\end{verbatim}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   131
\end{frame}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   132
\begin{frame}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   133
\frametitle{Question 5}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   134
\label{sec-12}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   135
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   136
  Obtain the square in the center of the image
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   137
\end{frame}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   138
\begin{frame}[fragile]
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   139
\frametitle{Solution 5}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   140
\label{sec-13}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   141
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   142
\begin{verbatim}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   143
In []: imshow(I[75:225, 75:225])
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   144
\end{verbatim}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   145
\end{frame}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   146
\begin{frame}[fragile]
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   147
\frametitle{Question 6}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   148
\label{sec-14}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   149
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   150
  Obtain the following
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   151
\begin{verbatim}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   152
[[12, 0], [42, 0]]
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   153
[[12, 13, 14], [0, 0, 0]]
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   154
\end{verbatim}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   155
\end{frame}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   156
\begin{frame}[fragile]
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   157
\frametitle{Solution 6}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   158
\label{sec-15}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   159
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   160
\begin{verbatim}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   161
In []: C[::3, 1::3]
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   162
In []: C[::4, 1:4]
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   163
\end{verbatim}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   164
\end{frame}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   165
\begin{frame}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   166
\frametitle{Summary}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   167
\label{sec-16}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   168
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   169
  You should now be able to --
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   170
\begin{itemize}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   171
\item Manipulate single \& multi dimensional arrays
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   172
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   173
\begin{itemize}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   174
\item Access and change individual elements
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   175
\item Access and change rows and columns
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   176
\item Slice and stride on arrays
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   177
\end{itemize}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   178
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   179
\item Read images into arrays and manipulate them.
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   180
\end{itemize}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   181
\end{frame}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   182
\begin{frame}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   183
\frametitle{Thank you!}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   184
\label{sec-17}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   185
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   186
  \begin{block}{}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   187
  \begin{center}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   188
  This spoken tutorial has been produced by the
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   189
  \textcolor{blue}{FOSSEE} team, which is funded by the 
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   190
  \end{center}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   191
  \begin{center}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   192
    \textcolor{blue}{National Mission on Education through \\
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   193
      Information \& Communication Technology \\ 
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   194
      MHRD, Govt. of India}.
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   195
  \end{center}  
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   196
  \end{block}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   197
\end{frame}
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   198
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   199
\end{document}