author | Nishanth Amuluru <nishanth@fossee.in> |
Tue, 14 Dec 2010 23:15:36 +0530 | |
branch | scipyin2010 |
changeset 456 | a27ccfc118fb |
parent 448 | dc8d666a594a |
permissions | -rw-r--r-- |
294 | 1 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
2 |
%Tutorial slides on Python. |
|
3 |
% |
|
4 |
% Author: Prabhu Ramachandran <prabhu at aero.iitb.ac.in> |
|
5 |
% Copyright (c) 2005-2009, Prabhu Ramachandran |
|
6 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
7 |
||
8 |
\documentclass[14pt,compress]{beamer} |
|
9 |
%\documentclass[draft]{beamer} |
|
10 |
%\documentclass[compress,handout]{beamer} |
|
11 |
%\usepackage{pgfpages} |
|
12 |
%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm] |
|
13 |
||
14 |
% Modified from: generic-ornate-15min-45min.de.tex |
|
15 |
\mode<presentation> |
|
16 |
{ |
|
17 |
\usetheme{Warsaw} |
|
18 |
\useoutertheme{infolines} |
|
19 |
\setbeamercovered{transparent} |
|
20 |
} |
|
21 |
||
22 |
\usepackage[english]{babel} |
|
23 |
\usepackage[latin1]{inputenc} |
|
24 |
%\usepackage{times} |
|
25 |
\usepackage[T1]{fontenc} |
|
26 |
||
27 |
% Taken from Fernando's slides. |
|
28 |
\usepackage{ae,aecompl} |
|
29 |
\usepackage{mathpazo,courier,euler} |
|
30 |
\usepackage[scaled=.95]{helvet} |
|
31 |
||
32 |
\definecolor{darkgreen}{rgb}{0,0.5,0} |
|
33 |
||
34 |
\usepackage{listings} |
|
35 |
\lstset{language=Python, |
|
36 |
basicstyle=\ttfamily\bfseries, |
|
37 |
commentstyle=\color{red}\itshape, |
|
38 |
stringstyle=\color{darkgreen}, |
|
39 |
showstringspaces=false, |
|
40 |
keywordstyle=\color{blue}\bfseries} |
|
41 |
||
42 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
43 |
% Macros |
|
44 |
\setbeamercolor{emphbar}{bg=blue!20, fg=black} |
|
45 |
\newcommand{\emphbar}[1] |
|
46 |
{\begin{beamercolorbox}[rounded=true]{emphbar} |
|
47 |
{#1} |
|
48 |
\end{beamercolorbox} |
|
49 |
} |
|
50 |
\newcounter{time} |
|
51 |
\setcounter{time}{0} |
|
52 |
\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}} |
|
53 |
||
412
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
54 |
\newcommand{\typ}[1]{\lstinline{#1}} |
294 | 55 |
|
56 |
\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} } |
|
57 |
||
58 |
%%% This is from Fernando's setup. |
|
59 |
% \usepackage{color} |
|
60 |
% \definecolor{orange}{cmyk}{0,0.4,0.8,0.2} |
|
61 |
% % Use and configure listings package for nicely formatted code |
|
62 |
% \usepackage{listings} |
|
63 |
% \lstset{ |
|
64 |
% language=Python, |
|
65 |
% basicstyle=\small\ttfamily, |
|
66 |
% commentstyle=\ttfamily\color{blue}, |
|
67 |
% stringstyle=\ttfamily\color{orange}, |
|
68 |
% showstringspaces=false, |
|
69 |
% breaklines=true, |
|
70 |
% postbreak = \space\dots |
|
71 |
% } |
|
72 |
||
73 |
||
74 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
75 |
% Title page |
|
76 |
\title[Exercises]{Exercises} |
|
77 |
||
78 |
\author[FOSSEE] {FOSSEE} |
|
79 |
||
80 |
\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} |
|
448
dc8d666a594a
Changed date format in day1/session{3,4,5}.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents:
412
diff
changeset
|
81 |
\date[] {SciPy 2010, Tutorials} |
294 | 82 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
83 |
||
84 |
%\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo} |
|
85 |
%\logo{\pgfuseimage{iitmlogo}} |
|
86 |
||
87 |
||
88 |
%% Delete this, if you do not want the table of contents to pop up at |
|
89 |
%% the beginning of each subsection: |
|
90 |
\AtBeginSubsection[] |
|
91 |
{ |
|
92 |
\begin{frame}<beamer> |
|
93 |
\frametitle{Outline} |
|
94 |
\tableofcontents[currentsection,currentsubsection] |
|
95 |
\end{frame} |
|
96 |
} |
|
97 |
||
98 |
||
99 |
% If you wish to uncover everything in a step-wise fashion, uncomment |
|
100 |
% the following command: |
|
101 |
%\beamerdefaultoverlayspecification{<+->} |
|
102 |
||
103 |
%\includeonlyframes{current,current1,current2,current3,current4,current5,current6} |
|
104 |
||
105 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
106 |
% DOCUMENT STARTS |
|
107 |
\begin{document} |
|
108 |
||
109 |
\begin{frame} |
|
110 |
\titlepage |
|
111 |
\end{frame} |
|
112 |
||
113 |
||
336
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
114 |
\begin{frame}[fragile] |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
115 |
\frametitle{Problem 1} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
116 |
\begin{columns} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
117 |
\column{0.5\textwidth} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
118 |
\hspace*{-0.5in} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
119 |
\includegraphics[height=2in, interpolate=true]{data/L-Tsq.png} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
120 |
\column{0.45\textwidth} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
121 |
\begin{block}{Example code} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
122 |
\tiny |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
123 |
\begin{lstlisting} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
124 |
l = [] |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
125 |
t = [] |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
126 |
for line in open('pendulum.txt'): |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
127 |
point = line.split() |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
128 |
l.append(float(point[0])) |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
129 |
t.append(float(point[1])) |
366
ec4cb3ba7f09
Changed all sessions based on tot session.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
358
diff
changeset
|
130 |
plot(l, t, '.') |
336
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
131 |
\end{lstlisting} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
132 |
\end{block} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
133 |
\end{columns} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
134 |
\begin{block}{Problem Statement} |
412
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
135 |
Tweak above code to plot data in file \typ{pos.txt}. |
336
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
136 |
\end{block} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
137 |
\end{frame} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
138 |
|
294 | 139 |
\begin{frame} |
336
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
140 |
\frametitle{Problem 1 cont...} |
294 | 141 |
\begin{itemize} |
142 |
\item Label both the axes. |
|
143 |
\item What kind of motion is this? |
|
144 |
\item Title the graph accordingly. |
|
145 |
\item Annotate the position where vertical velocity is zero. |
|
146 |
\end{itemize} |
|
147 |
\end{frame} |
|
148 |
||
336
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
149 |
\begin{frame}[fragile] |
294 | 150 |
\frametitle{Problem 2} |
336
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
151 |
\begin{columns} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
152 |
\column{0.5\textwidth} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
153 |
\hspace*{-0.5in} |
379
682b6f66fe11
Updated for day1 of GRD workshop.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
378
diff
changeset
|
154 |
\includegraphics[height=2in, interpolate=true]{data/triangle} |
336
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
155 |
\column{0.45\textwidth} |
385
c70118cdde66
Minor corrections.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
382
diff
changeset
|
156 |
\begin{block}{Plot points given x and y coordinates} |
336
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
157 |
\tiny |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
158 |
\begin{lstlisting} |
385
c70118cdde66
Minor corrections.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
382
diff
changeset
|
159 |
In []: x = [3, 2, -2, 3] |
c70118cdde66
Minor corrections.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
382
diff
changeset
|
160 |
In []: y = [1, -3, 4, 1] |
336
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
161 |
In []: plot(x, y) |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
162 |
\end{lstlisting} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
163 |
\end{block} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
164 |
\end{columns} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
165 |
Line can be plotted using arrays of coordinates. |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
166 |
\pause |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
167 |
\begin{block}{Problem statement} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
168 |
Write a Program that plots a regular n-gon(Let n = 5). |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
169 |
\end{block} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
170 |
\end{frame} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
171 |
|
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
172 |
|
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
173 |
\begin{frame}[fragile] |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
174 |
\frametitle{Problem 3} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
175 |
\begin{columns} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
176 |
\column{0.5\textwidth} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
177 |
\hspace*{-0.5in} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
178 |
\includegraphics[height=2in, interpolate=true]{data/damp} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
179 |
\column{0.45\textwidth} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
180 |
\begin{block}{Damped Oscillation} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
181 |
\tiny |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
182 |
\begin{lstlisting} |
412
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
183 |
In []: t = linspace(0, 4*pi) |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
184 |
In []: plot(t, exp(t/10)*sin(t)) |
336
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
185 |
\end{lstlisting} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
186 |
\end{block} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
187 |
\end{columns} |
294 | 188 |
\end{frame} |
189 |
||
190 |
\begin{frame}[fragile] |
|
336
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
191 |
\frametitle{Problem 3 cont...} |
412
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
192 |
Create a sequence of images in which the damped |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
193 |
oscillator($e^{-t/10}sin(t)$) slowly evolves over time $t$. |
294 | 194 |
\begin{columns} |
195 |
\column{0.35\textwidth} |
|
196 |
\includegraphics[width=1.5in,height=1.5in, interpolate=true]{data/plot2} |
|
197 |
\column{0.35\textwidth} |
|
198 |
\includegraphics[width=1.5in,height=1.5in, interpolate=true]{data/plot4} |
|
199 |
\column{0.35\textwidth} |
|
200 |
\includegraphics[width=1.5in,height=1.5in, interpolate=true]{data/plot6} |
|
201 |
\end{columns} |
|
202 |
\begin{block}{Hint} |
|
203 |
\small |
|
204 |
\begin{lstlisting} |
|
412
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
205 |
savefig('plot'+str(i)+'.png') #i is some int |
294 | 206 |
\end{lstlisting} |
207 |
\end{block} |
|
208 |
\end{frame} |
|
209 |
||
336
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
210 |
\begin{frame}[fragile] |
294 | 211 |
\frametitle{Problem 4} |
336
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
212 |
\begin{lstlisting} |
412
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
213 |
In []: x = imread('smoothing.gif') |
336
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
214 |
In []: x.shape |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
215 |
Out[]: (256, 256) |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
216 |
In []: imshow(x,cmap=cm.gray) |
412
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
217 |
In []: colorbar() |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
218 |
\end{lstlisting} |
336
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
219 |
\emphbar{Replace each pixel with mean of neighboring pixels} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
220 |
\begin{center} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
221 |
\includegraphics[height=1in, interpolate=true]{data/neighbour} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
222 |
\end{center} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
223 |
\end{frame} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
224 |
|
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
225 |
\begin{frame} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
226 |
\begin{center} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
227 |
\includegraphics[height=3in, interpolate=true]{data/smoothing} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
228 |
\end{center} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
229 |
\end{frame} |
294 | 230 |
|
336
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
231 |
\begin{frame}[fragile] |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
232 |
\frametitle{Problem 4: Approach} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
233 |
For \typ{y} being resultant image: |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
234 |
\begin{lstlisting} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
235 |
y[1, 1] = x[0, 1]/4 + x[1, 0]/4 |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
236 |
+ x[2, 1]/4 + x[1, 2]/4 |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
237 |
\end{lstlisting} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
238 |
\begin{columns} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
239 |
\column{0.45\textwidth} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
240 |
\hspace*{-0.5in} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
241 |
\includegraphics[height=1.5in, interpolate=true]{data/smoothing} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
242 |
\column{0.45\textwidth} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
243 |
\hspace*{-0.5in} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
244 |
\includegraphics[height=1.5in, interpolate=true]{data/after-filter} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
245 |
\end{columns} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
246 |
\begin{block}{Hint:} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
247 |
Use array Slicing. |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
248 |
\end{block} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
249 |
\end{frame} |
294 | 250 |
|
336
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
251 |
\begin{frame}[fragile] |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
252 |
\frametitle{Solution} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
253 |
\begin{lstlisting} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
254 |
In []: y = zeros_like(x) |
412
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
255 |
In []: y[1:-1,1:-1] = x[:-2,1:-1]/4 + |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
256 |
x[2:,1:-1]/4 + |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
257 |
x[1:-1,2:]/4 + |
336
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
258 |
x[1:-1,:-2]/4 |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
259 |
In []: imshow(y,cmap=cm.gray) |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
260 |
\end{lstlisting} |
294 | 261 |
\end{frame} |
336
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
262 |
|
412
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
263 |
\begin{frame}[fragile] |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
264 |
\frametitle{Problem 4 cont\ldots} |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
265 |
\begin{itemize} |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
266 |
\item Apply the smoothing operation repeatedly to the original |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
267 |
image |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
268 |
|
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
269 |
\item Subtract the smoothed image from the original to obtain |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
270 |
the edges |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
271 |
\end{itemize} |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
272 |
\end{frame} |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
273 |
|
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
274 |
\begin{frame}[fragile] |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
275 |
\frametitle{Problem 5} |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
276 |
|
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
277 |
What if you did the following in problem 4? |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
278 |
\begin{lstlisting} |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
279 |
In []: y1[1:-1,1:-1] = (x[:-2,1:-1] + |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
280 |
x[2:,1:-1] + |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
281 |
x[1:-1,2:] + |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
282 |
x[1:-1,:-2])/4 |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
283 |
\end{lstlisting} |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
284 |
|
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
285 |
Are the answers different? |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
286 |
|
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
287 |
\end{frame} |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
288 |
|
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
289 |
\begin{frame}[fragile] |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
290 |
\frametitle{Problem 5 cont\ldots} |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
291 |
Why? The answer lies in the following: |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
292 |
\begin{lstlisting} |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
293 |
In []: x.dtype |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
294 |
Out[]: dtype('uint8') |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
295 |
|
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
296 |
In []: print x.itemsize |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
297 |
1 |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
298 |
|
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
299 |
In []: z = x/4.0 |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
300 |
|
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
301 |
In []: print z.dtype |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
302 |
float64 |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
303 |
|
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
304 |
\end{lstlisting} |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
305 |
\end{frame} |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
306 |
|
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
307 |
\begin{frame}[fragile] |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
308 |
\frametitle{Problem 5 cont\ldots} |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
309 |
What if you did this? |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
310 |
|
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
311 |
\begin{lstlisting} |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
312 |
x = imread('smoothing.gif') |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
313 |
y2 = zeros_like(x) |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
314 |
y2[1:-1,1:-1] = x[:-2,1:-1]/4. + |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
315 |
x[2:,1:-1]/4. + |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
316 |
x[1:-1,2:]/4. + |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
317 |
x[1:-1,:-2]/4. |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
318 |
\end{lstlisting} |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
319 |
\begin{itemize} |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
320 |
\item Will the answer be any different from \typ{y}? |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
321 |
\item What will the dtype of \typ{y2} be? |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
322 |
\item Discuss what is going on! |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
323 |
\end{itemize} |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
324 |
|
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
325 |
\end{frame} |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
326 |
|
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
327 |
\begin{frame}[fragile] |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
328 |
\frametitle{Problem 5 cont\ldots} |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
329 |
Did you do the right thing to find the edges earlier in problem 4? Fix it! |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
330 |
|
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
331 |
Note that: |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
332 |
\begin{lstlisting} |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
333 |
In []: print x.dtype |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
334 |
uint8 |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
335 |
In []: x1 = x.astype('float64') |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
336 |
In []: print x1.dtype |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
337 |
float64 |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
338 |
In []: print x.dtype.char |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
339 |
d |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
340 |
In []: x.dtype.<TAB> # Explore! |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
341 |
\end{lstlisting} |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
342 |
\end{frame} |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
343 |
|
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
344 |
\begin{frame}[fragile] |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
345 |
\frametitle{Problem 6} |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
346 |
|
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
347 |
Edge detection looks much nicer with \typ{lena.png}, try it! The |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
348 |
gotcha is that it is a 4 component RGBA image with elements in the |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
349 |
range $[0.0, 1.0]$. |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
350 |
|
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
351 |
\begin{lstlisting} |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
352 |
In []: x = imread('lena.png') |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
353 |
|
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
354 |
In []: print x.shape |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
355 |
(512, 512, 4) |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
356 |
|
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
357 |
In []: print x.min(), x.max() |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
358 |
0.0 1.0 |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
359 |
\end{lstlisting} |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
360 |
|
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
361 |
Repeat the edge detection with this image. |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
362 |
|
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
363 |
\end{frame} |
ca04d463c573
ENH: Enhanced the problem set building on the image handing and arrays.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents:
389
diff
changeset
|
364 |
|
336
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
365 |
|
294 | 366 |
\end{document} |
367 |
||
336
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
368 |
%% \begin{frame} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
369 |
%% \frametitle{Problem 4} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
370 |
%% Legendre polynomials $P_n(x)$ are defined by the following recurrence relation |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
371 |
|
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
372 |
%% \center{$(n+1)P_{n+1}(x) - (2n+1)xP_n(x) + nP_{n-1}(x) = 0$}\\ |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
373 |
|
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
374 |
%% with $P_0(x) = 1$, $P_1(x) = x$ and $P_2(x) = (3x^2 - 1)/2$. Compute the next three |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
375 |
%% Legendre polynomials and plot all 6 over the interval [-1,1]. |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
376 |
%% \end{frame} |
f2c89f9af85f
Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents:
330
diff
changeset
|
377 |
|
294 | 378 |
%% \begin{frame}[fragile] |
379 |
%% \frametitle{Problem Set 5} |
|
380 |
%% \begin{columns} |
|
381 |
%% \column{0.6\textwidth} |
|
382 |
%% \small{ |
|
383 |
%% \begin{itemize} |
|
384 |
%% \item[3] Consider the iteration $x_{n+1} = f(x_n)$ where $f(x) = kx(1-x)$. Plot the successive iterates of this process as explained below. |
|
385 |
%% \end{itemize}} |
|
386 |
%% \column{0.35\textwidth} |
|
387 |
%% \hspace*{-0.5in} |
|
388 |
%% \includegraphics[height=1.6in, interpolate=true]{data/cobweb} |
|
389 |
%% \end{columns} |
|
390 |
%% \end{frame} |
|
391 |
||
392 |
%% \begin{frame} |
|
393 |
%% \frametitle{Problem Set 5.3} |
|
394 |
%% Plot the cobweb plot as follows: |
|
395 |
%% \begin{enumerate} |
|
396 |
%% \item Start at $(x_0, 0)$ ($\implies$ i=0) |
|
397 |
%% \item Draw a line to $(x_i, f(x_i))$ |
|
398 |
%% \item Set $x_{i+1} = f(x_i)$ |
|
399 |
%% \item Draw a line to $(x_{i+1}, x_{i+1})$ |
|
400 |
%% \item $(i\implies i+1)$ |
|
401 |
%% \item Repeat from 2 for as long as you want |
|
402 |
%% \end{enumerate} |
|
403 |
%% \inctime{20} |
|
404 |
%% \end{frame} |