day1/session4.tex
changeset 282 b2dafce03b8d
parent 281 ce818f645f6b
child 285 e072cadee389
equal deleted inserted replaced
281:ce818f645f6b 282:b2dafce03b8d
   256   \end{small}
   256   \end{small}
   257 \end{frame}
   257 \end{frame}
   258 
   258 
   259 \begin{frame}[fragile]
   259 \begin{frame}[fragile]
   260   \frametitle{Slicing \& Striding Exercises}
   260   \frametitle{Slicing \& Striding Exercises}
   261   \begin{lstlisting}
   261 \begin{small}
   262   \end{lstlisting}
   262   \begin{lstlisting}
   263 \end{frame}
   263 In []: A = imread('lena.png')
   264 
   264 
   265 \subsection{Basic Operations}
   265 In []: imshow(A)
       
   266 Out[]: <matplotlib.image.AxesImage object at 0xa0384cc>
       
   267 
       
   268 In []: A.shape 
       
   269 Out[]: (512, 512, 4)
       
   270   \end{lstlisting}
       
   271 \end{small}
       
   272   \begin{itemize}
       
   273   \item Crop the image to get the top-left quarter
       
   274   \item Crop the image to get only the face
       
   275   \item Resize image to half by dropping alternate pixels
       
   276   \end{itemize}
       
   277 \end{frame}
       
   278 
       
   279 \begin{frame}[fragile]
       
   280   \frametitle{Slicing \& Striding Exercises \ldots}
       
   281 \begin{small}
       
   282   \begin{lstlisting}
       
   283 In []: imshow(A[:256,:256])
       
   284 Out[]: <matplotlib.image.AxesImage object at 0xb6f658c>
       
   285 
       
   286 In []: imshow(A[200:400,200:400])
       
   287 Out[]: <matplotlib.image.AxesImage object at 0xb757c2c>
       
   288 
       
   289 In []: imshow(A[::2,::2])
       
   290 Out[]: <matplotlib.image.AxesImage object at 0xb765c8c>
       
   291   \end{lstlisting}
       
   292 \end{small}
       
   293 \end{frame}
   266 
   294 
   267 \begin{frame}[fragile]
   295 \begin{frame}[fragile]
   268 \frametitle{Transpose of a Matrix}
   296 \frametitle{Transpose of a Matrix}
   269 \begin{lstlisting}
   297 \begin{lstlisting}
   270 In []: A.T
   298 In []: A.T
   399 \section{Least Squares Fit}
   427 \section{Least Squares Fit}
   400 \begin{frame}[fragile]
   428 \begin{frame}[fragile]
   401 \frametitle{$L$ vs. $T^2$}
   429 \frametitle{$L$ vs. $T^2$}
   402 \vspace{-0.15in}
   430 \vspace{-0.15in}
   403 \begin{figure}
   431 \begin{figure}
   404 \includegraphics[width=4in]{data/L-Tsq-points.png}
   432 \includegraphics[width=4in]{data/L-Tsq-points}
   405 \end{figure}
   433 \end{figure}
   406 \end{frame}
   434 \end{frame}
   407 
   435 
   408 \begin{frame}[fragile]
   436 \begin{frame}[fragile]
   409 \frametitle{$L$ vs. $T^2$}
   437 \frametitle{$L$ vs. $T^2$}
   410 \vspace{-0.15in}
   438 \vspace{-0.15in}
   411 \begin{figure}
   439 \begin{figure}
   412 \includegraphics[width=4in]{data/L-Tsq-Line.png}
   440 \includegraphics[width=4in]{data/L-Tsq-Line}
   413 \end{figure}
   441 \end{figure}
   414 \end{frame}
   442 \end{frame}
   415 
   443 
   416 \begin{frame}[fragile]
   444 \begin{frame}[fragile]
   417 \frametitle{Least Squares Fit}
   445 \frametitle{Least Squares Fit}
   418 \vspace{-0.15in}
   446 \vspace{-0.15in}
   419 \begin{figure}
   447 \begin{figure}
   420 \includegraphics[width=4in]{data/least-sq-fit.png}
   448 \includegraphics[width=4in]{data/least-sq-fit}
   421 \end{figure}
   449 \end{figure}
   422 \end{frame}
   450 \end{frame}
   423 
   451 
   424 \begin{frame}
   452 \begin{frame}
   425 \frametitle{Least Square Fit Curve}
   453 \frametitle{Least Square Fit Curve}
   492 In []: result = lstsq(A,TSq)
   520 In []: result = lstsq(A,TSq)
   493 In []: coef = result[0]
   521 In []: coef = result[0]
   494 \end{lstlisting}
   522 \end{lstlisting}
   495 \end{frame}
   523 \end{frame}
   496 
   524 
   497 \subsection{Plotting}
       
   498 \begin{frame}[fragile]
   525 \begin{frame}[fragile]
   499 \frametitle{Least Square Fit Line \ldots}
   526 \frametitle{Least Square Fit Line \ldots}
   500 We get the points of the line from \typ{coef}
   527 We get the points of the line from \typ{coef}
   501 \begin{lstlisting}
   528 \begin{lstlisting}
   502 In []: Tline = coef[0]*L + coef[1]
   529 In []: Tline = coef[0]*L + coef[1]