Added Slicing and Striding exercises.
authorPuneeth Chaganti <punchagan@fossee.in>
Thu, 05 Nov 2009 22:37:50 +0530
changeset 282 b2dafce03b8d
parent 281 ce818f645f6b
child 283 5d7ca20e955f
Added Slicing and Striding exercises.
day1/session4.tex
--- a/day1/session4.tex	Thu Nov 05 21:04:23 2009 +0530
+++ b/day1/session4.tex	Thu Nov 05 22:37:50 2009 +0530
@@ -258,11 +258,39 @@
 
 \begin{frame}[fragile]
   \frametitle{Slicing \& Striding Exercises}
+\begin{small}
   \begin{lstlisting}
+In []: A = imread('lena.png')
+
+In []: imshow(A)
+Out[]: <matplotlib.image.AxesImage object at 0xa0384cc>
+
+In []: A.shape 
+Out[]: (512, 512, 4)
   \end{lstlisting}
+\end{small}
+  \begin{itemize}
+  \item Crop the image to get the top-left quarter
+  \item Crop the image to get only the face
+  \item Resize image to half by dropping alternate pixels
+  \end{itemize}
 \end{frame}
 
-\subsection{Basic Operations}
+\begin{frame}[fragile]
+  \frametitle{Slicing \& Striding Exercises \ldots}
+\begin{small}
+  \begin{lstlisting}
+In []: imshow(A[:256,:256])
+Out[]: <matplotlib.image.AxesImage object at 0xb6f658c>
+
+In []: imshow(A[200:400,200:400])
+Out[]: <matplotlib.image.AxesImage object at 0xb757c2c>
+
+In []: imshow(A[::2,::2])
+Out[]: <matplotlib.image.AxesImage object at 0xb765c8c>
+  \end{lstlisting}
+\end{small}
+\end{frame}
 
 \begin{frame}[fragile]
 \frametitle{Transpose of a Matrix}
@@ -401,7 +429,7 @@
 \frametitle{$L$ vs. $T^2$}
 \vspace{-0.15in}
 \begin{figure}
-\includegraphics[width=4in]{data/L-Tsq-points.png}
+\includegraphics[width=4in]{data/L-Tsq-points}
 \end{figure}
 \end{frame}
 
@@ -409,7 +437,7 @@
 \frametitle{$L$ vs. $T^2$}
 \vspace{-0.15in}
 \begin{figure}
-\includegraphics[width=4in]{data/L-Tsq-Line.png}
+\includegraphics[width=4in]{data/L-Tsq-Line}
 \end{figure}
 \end{frame}
 
@@ -417,7 +445,7 @@
 \frametitle{Least Squares Fit}
 \vspace{-0.15in}
 \begin{figure}
-\includegraphics[width=4in]{data/least-sq-fit.png}
+\includegraphics[width=4in]{data/least-sq-fit}
 \end{figure}
 \end{frame}
 
@@ -494,7 +522,6 @@
 \end{lstlisting}
 \end{frame}
 
-\subsection{Plotting}
 \begin{frame}[fragile]
 \frametitle{Least Square Fit Line \ldots}
 We get the points of the line from \typ{coef}