diff options
author | Puneeth Chaganti | 2009-11-05 22:37:50 +0530 |
---|---|---|
committer | Puneeth Chaganti | 2009-11-05 22:37:50 +0530 |
commit | 82969f158c93d4faed88c7567ff86f66a1ada2ed (patch) | |
tree | c03fe1610143dcbad310e3fa5c5ad8e542fc8ed5 | |
parent | cc9fd2d817d443d80a6c8a5e5d18c52d6c242017 (diff) | |
download | workshops-82969f158c93d4faed88c7567ff86f66a1ada2ed.tar.gz workshops-82969f158c93d4faed88c7567ff86f66a1ada2ed.tar.bz2 workshops-82969f158c93d4faed88c7567ff86f66a1ada2ed.zip |
Added Slicing and Striding exercises.
-rw-r--r-- | day1/session4.tex | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/day1/session4.tex b/day1/session4.tex index 373e342..7a335fd 100644 --- a/day1/session4.tex +++ b/day1/session4.tex @@ -258,11 +258,39 @@ array([[ 1, 2], \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 @@ Out[]: array([-1., 8., -1.]) \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 @@ Out[]: array([-1., 8., -1.]) \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 @@ Out[]: array([-1., 8., -1.]) \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 @@ In []: coef = result[0] \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} |