homework 1, version 3
+xxxxxxxxxx
md"_homework 1, version 3_"
Submission by: Jazzy Doe (jazz@mit.edu)
+xxxxxxxxxx
md"""
Homework 1 - convolutions
+18.S191
, fall 2020
This notebook contains built-in, live answer checks! In some exercises you will see a coloured box, which runs a test case on your code, and provides feedback based on the result. Simply edit the code, run it, and the check runs again.
+For MIT students: there will also be some additional (secret) test cases that will be run as part of the grading process, and we will look at your notebook and write comments.
+Feel free to ask questions!
+xxxxxxxxxx
md"""
"Jazzy Doe"
"jazz"
xxxxxxxxxx
# edit the code below to set your name and kerberos ID (i.e. email without @mit.edu)
student = (name = "Jazzy Doe", kerberos_id = "jazz")
# press the ▶ button in the bottom right of this cell to run your edits
# or use Shift+Enter
# you might need to wait until all other cells in this notebook have completed running.
# scroll down the page to see what's up
Let's create a package environment:
+xxxxxxxxxx
md"_Let's create a package environment:_"
xxxxxxxxxx
begin
import Pkg
Pkg.activate(mktempdir())
end
We set up Images.jl again:
+xxxxxxxxxx
md"_We set up Images.jl again:_"
xxxxxxxxxx
begin
Pkg.add(["Images", "ImageIO", "ImageMagick"])
using Images
end
xxxxxxxxxx
bigbreak
Exercise 1 - Manipulating vectors (1D images)
+A Vector
is a 1D array. We can think of that as a 1D image.
xxxxxxxxxx
md"""
0.5
0.4
0.3
0.2
0.1
0.0
0.7
0.0
0.7
0.9
xxxxxxxxxx
example_vector = [0.5, 0.4, 0.3, 0.2, 0.1, 0.0, 0.7, 0.0, 0.7, 0.9]
xxxxxxxxxx
colored_line(example_vector)
Exerise 1.1
+👉 Make a random vector random_vect
of length 10 using the rand
function.
xxxxxxxxxx
md"#### Exerise 1.1
missing
xxxxxxxxxx
random_vect = missing # replace this with your code!
xxxxxxxxxx
colored_line(random_vect)
Here we go!
Replace missing
with your answer.
xxxxxxxxxx
if ! (random_vect)
Hint
You can find out more about any function (like rand
) by creating a new cell and typing:
?rand
+Once the Live Docs are open, you can select any code to learn more about it. It might be useful to leave it open all the time, and get documentation while you type code.
+ +xxxxxxxxxx
hint(md"You can find out more about any function (like `rand`) by creating a new cell and typing:
👉 Make a function mean
using a for
loop, which computes the mean/average of a vector of numbers.
xxxxxxxxxx
md"👉 Make a function `mean` using a `for` loop, which computes the mean/average of a vector of numbers."
mean (generic function with 1 method)
xxxxxxxxxx
function mean(x)
return missing
end
missing
xxxxxxxxxx
mean([1, 2, 3])
Here we go!
Replace missing
with your answer.
xxxxxxxxxx
if ! (mean)
👉 Define m
to be the mean of random_vect
.
xxxxxxxxxx
md"👉 Define `m` to be the mean of `random_vect`."
missing
xxxxxxxxxx
m = missing
Here we go!
Replace missing
with your answer.
xxxxxxxxxx
if ! (m)
👉 Write a function demean
, which takes a vector x
and subtracts the mean from each value in x
.
xxxxxxxxxx
md"""👉 Write a function `demean`, which takes a vector `x` and subtracts the mean from each value in `x`."""
demean (generic function with 1 method)
xxxxxxxxxx
function demean(x)
return missing
end
Let's check that the mean of the demean(random_vect)
is 0:
Due to floating-point round-off error it may not be exactly 0.
+xxxxxxxxxx
md"Let's check that the mean of the `demean(random_vect)` is 0:
Info
The following cells error because random_vect
is not yet defined. Have you done the first exercise?
xxxxxxxxxx
if ismissing(random_vect)
UndefVarError: copy_of_random_vect not defined
- top-level scope@Local: 1
- top-level scope@Parse.jl:111
- (::Distributed.var"#103#104"{Distributed.CallMsg{:call}})()@process_messages.jl:290
- run_work_thunk(::Distributed.var"#103#104"{Distributed.CallMsg{:call}}, ::Bool)@process_messages.jl:79
- run_work_thunk(::Distributed.RemoteValue, ::Function)@process_messages.jl:88
- (::Distributed.var"#96#98"{Distributed.RemoteValue,Distributed.var"#103#104"{Distributed.CallMsg{:call}}})()@task.jl:356
xxxxxxxxxx
mean(demean(copy_of_random_vect))
MethodError: no method matching copy(::Missing)
Closest candidates are:
copy(!Matched::Random.DSFMT.GF2X) at /build/julia/src/julia-1.5.0/usr/share/julia/stdlib/v1.5/Random/src/DSFMT.jl:111
copy(!Matched::DataStructures.IntSet) at /home/shashi/.julia/packages/DataStructures/6txFj/src/int_set.jl:11
copy(!Matched::Markdown.MD) at /build/julia/src/julia-1.5.0/usr/share/julia/stdlib/v1.5/Markdown/src/parse/parse.jl:30
...
- top-level scope@Local: 1
- top-level scope@Parse.jl:111
- (::Distributed.var"#103#104"{Distributed.CallMsg{:call}})()@process_messages.jl:290
- run_work_thunk(::Distributed.var"#103#104"{Distributed.CallMsg{:call}}, ::Bool)@process_messages.jl:79
- run_work_thunk(::Distributed.RemoteValue, ::Function)@process_messages.jl:88
- (::Distributed.var"#96#98"{Distributed.RemoteValue,Distributed.var"#103#104"{Distributed.CallMsg{:call}}})()@task.jl:356
xxxxxxxxxx
copy_of_random_vect = copy(random_vect); # in case demean modifies `x`
Exercise 1.2
+👉 Generate a vector of 100 zeros. Change the center 20 elements to 1.
+xxxxxxxxxx
md"""
create_bar (generic function with 1 method)
xxxxxxxxxx
function create_bar()
return missing
end
xxxxxxxxxx
colored_line(create_bar())
Here we go!
Replace missing
with your answer.
xxxxxxxxxx
if ! (create_bar)
Exercise 1.3
+👉 Write a function that turns a Vector
of Vector
s into a Matrix
.
xxxxxxxxxx
md"""
vecvec_to_matrix (generic function with 1 method)
xxxxxxxxxx
function vecvec_to_matrix(vecvec)
return missing
end
missing
xxxxxxxxxx
vecvec_to_matrix([[1,2], [3,4]])
Here we go!
Replace missing
with your answer.
xxxxxxxxxx
if ! (vecvec_to_matrix)
👉 Write a function that turns a Matrix
into aVector
of Vector
s .
xxxxxxxxxx
md"""
matrix_to_vecvec (generic function with 1 method)
xxxxxxxxxx
function matrix_to_vecvec(matrix)
return missing
end
missing
xxxxxxxxxx
matrix_to_vecvec([6 7; 8 9])
Here we go!
Replace missing
with your answer.
xxxxxxxxxx
if ! (matrix_to_vecvec)
colored_line (generic function with 2 methods)
xxxxxxxxxx
begin
xxxxxxxxxx
bigbreak
Exercise 2 - Manipulating images
+In this exercise we will get familiar with matrices (2D arrays) in Julia, by manipulating images. Recall that in Julia images are matrices of RGB
color objects.
Let's load a picture of Philip again.
+xxxxxxxxxx
md"""
"/tmp/jl_4reFYZ"
xxxxxxxxxx
philip_file = download("https://i.imgur.com/VGPeJ6s.jpg")
xxxxxxxxxx
philip = let
original = Images.load(philip_file)
decimate(original, 8)
end
Hi there Philip
+xxxxxxxxxx
md"_Hi there Philip_"
Exercise 2.1
+👉 Write a function mean_colors
that accepts an object called image
. It should calculate the mean (average) amounts of red, green and blue in the image and return a tuple (r, g, b)
of those means.
xxxxxxxxxx
md"""
mean_colors (generic function with 1 method)
xxxxxxxxxx
function mean_colors(image)
return missing
end
missing
xxxxxxxxxx
mean_colors(philip)
Here we go!
Replace missing
with your answer.
xxxxxxxxxx
if ! (mean_colors)
Enter cell code...
xxxxxxxxxx
Exercise 2.2
+👉 Look up the documentation on the floor
function. Use it to write a function quantize(x::Number)
that takes in a value
xxxxxxxxxx
md"""
quantize (generic function with 3 methods)
xxxxxxxxxx
begin
function quantize(x::Number)
return missing
end
function quantize(color::AbstractRGB)
# you will write me in a later exercise!
return missing
end
function quantize(image::AbstractMatrix)
# you will write me in a later exercise!
return missing
end
end
missing
missing
xxxxxxxxxx
quantize(0.267), quantize(0.91)
Here we go!
Replace missing
with your answer.
xxxxxxxxxx
if ! (quantize)
Exercise 2.3
+👉 Write the second method of the function quantize
, i.e. a new version of the function with the same name. This method will accept a color object called color
, of the type AbstractRGB
.
Write the function in the same cell as quantize(x::Number)
from the last exercise. 👆
Here, ::AbstractRGB
is a type annotation. This ensures that this version of the function will be chosen when passing in an object whose type is a subtype of the AbstractRGB
abstract type. For example, both the RGB
and RGBX
types satisfy this.
The method you write should return a new RGB
object, in which each component (
xxxxxxxxxx
md"""
Exercise 2.4
+👉 Write a method quantize(image::AbstractMatrix)
that quantizes an image by quantizing each pixel in the image. (You may assume that the matrix is a matrix of color objects.)
Write the function in the same cell as quantize(x::Number)
from the last exercise. 👆
xxxxxxxxxx
md"""
Let's apply your method!
+xxxxxxxxxx
md"Let's apply your method!"
missing
xxxxxxxxxx
quantize(philip)
Exercise 2.5
+👉 Write a function invert
that inverts a color, i.e. sends
xxxxxxxxxx
md"""
invert (generic function with 1 method)
xxxxxxxxxx
function invert(color::AbstractRGB)
return missing
end
Let's invert some colors:
+xxxxxxxxxx
md"Let's invert some colors:"
xxxxxxxxxx
black = RGB(0.0, 0.0, 0.0)
missing
xxxxxxxxxx
invert(black)
xxxxxxxxxx
red = RGB(0.8, 0.1, 0.1)
missing
xxxxxxxxxx
invert(red)
Can you invert the picture of Philip?
+xxxxxxxxxx
md"Can you invert the picture of Philip?"
missing
xxxxxxxxxx
philip_inverted = missing
Exercise 2.6
+👉 Write a function noisify(x::Number, s)
to add randomness of intensity clamp
function, but you should write your own function myclamp(x)
.)
xxxxxxxxxx
md"""
noisify (generic function with 3 methods)
xxxxxxxxxx
begin
function noisify(x::Number, s)
return missing
end
function noisify(color::AbstractRGB, s)
# you will write me in a later exercise!
return missing
end
function noisify(image::AbstractMatrix, s)
# you will write me in a later exercise!
return missing
end
end
Hint
The rand
function generates (uniform) random floating-point numbers between
xxxxxxxxxx
hint(md"The `rand` function generates (uniform) random floating-point numbers between $0$ and $1$.")
👉 Write the second method noisify(c::AbstractRGB, s)
to add random noise of intensity
Write the function in the same cell as noisify(x::Number)
from the last exercise. 👆
xxxxxxxxxx
md"""
xxxxxxxxxx
color_noise Slider(0:0.01:1, show_value=true)
missing
xxxxxxxxxx
noisify(red, color_noise)
Enter cell code...
xxxxxxxxxx
👉 Write the third method noisify(image::AbstractMatrix, s)
to noisify each pixel of an image.
Write the function in the same cell as noisify(x::Number)
from the last exercise. 👆
xxxxxxxxxx
md"""
xxxxxxxxxx
philip_noise Slider(0:0.01:8, show_value=true)
missing
xxxxxxxxxx
noisify(philip, philip_noise)
Enter cell code...
xxxxxxxxxx
👉 For which noise intensity does it become unrecognisable?
+You may need noise intensities larger than 1. Why?
+xxxxxxxxxx
md"""
The image is unrecognisable with intensity ...
+xxxxxxxxxx
answer_about_noise_intensity = md"""
The image is unrecognisable with intensity ...
"""
Enter cell code...
xxxxxxxxxx
xxxxxxxxxx
begin
Pkg.add("PlutoUI")
using PlutoUI
end
decimate (generic function with 2 methods)
xxxxxxxxxx
decimate(image, ratio=5) = image[1:ratio:end, 1:ratio:end]
xxxxxxxxxx
bigbreak
Exercise 3 - Convolutions
+As we have seen in the videos, we can produce cool effects using the mathematical technique of convolutions. We input one image
Conceptually we think of Matrix
of color objects, and we may need to take that into account. Ideally, however, we should write a generic function that will work for any type of data contained in the matrix.
A convolution works on a small window of an image, i.e. a region centered around a given point
The result of the convolution over a given window, centred at the point
To get started let's restrict ourselves to convolutions in 1D. So a window is just a 1D region from
xxxxxxxxxx
md"""
+
Let's create a vector v
of random numbers of length n=100
.
xxxxxxxxxx
md"""
100
xxxxxxxxxx
n = 100
0.64771
0.22933
0.415342
0.703819
0.854471
0.27837
0.446598
0.686857
0.511744
0.191256
0.558569
0.0947994
0.276961
0.521417
0.987073
0.616009
0.332129
0.755946
0.7061
0.560034
0.857643
0.947328
0.161807
0.447422
0.496497
0.222904
0.368214
0.647241
0.625254
0.83159
0.103692
0.62409
0.0142629
0.344406
0.677014
0.926745
0.574309
0.65493
0.614455
0.92009
0.707832
0.470791
0.931427
0.965792
0.656162
0.413477
0.154902
0.76583
0.487643
0.530998
xxxxxxxxxx
v = rand(n)
Feel free to experiment with different values!
+xxxxxxxxxx
md"_Feel free to experiment with different values!_"
Exercise 3.1
+You've seen some colored lines in this notebook to visualize arrays. Can you make another one?
+👉 Try plotting our vector v
using colored_line(v)
.
xxxxxxxxxx
md"""
Enter cell code...
xxxxxxxxxx
Try changing n
and v
around. Notice that you can run the cell v = rand(n)
again to regenerate new random values.
xxxxxxxxxx
md"Try changing `n` and `v` around. Notice that you can run the cell `v = rand(n)` again to regenerate new random values."
Exercise 3.2
+We need to decide how to handle the boundary conditions, i.e. what happens if we try to access a position in the vector v
beyond 1:n
. The simplest solution is to assume that
A better solution is to use the closest value that is inside the vector. Effectively we are extending the vector and copying the extreme values into the extended positions. (Indeed, this is one way we could implement this; these extra positions are called ghost cells.)
+👉 Write a function extend(v, i)
that checks whether the position 1:n
. If so, return the v
; otherwise, return the nearest end value.
xxxxxxxxxx
md"""
extend (generic function with 1 method)
xxxxxxxxxx
function extend(v, i)
return missing
end
Some test cases:
+xxxxxxxxxx
md"_Some test cases:_"
missing
xxxxxxxxxx
extend(v, 1)
missing
xxxxxxxxxx
extend(v, -8)
missing
xxxxxxxxxx
extend(v, n + 10)
Extended with 0:
+xxxxxxxxxx
md"Extended with 0:"
xxxxxxxxxx
colored_line([0, 0, example_vector..., 0, 0])
Extended with your extend
:
xxxxxxxxxx
md"Extended with your `extend`:"
missing
xxxxxxxxxx
if extend(v,1) === missing
Here we go!
Replace missing
with your answer.
xxxxxxxxxx
if ! (extend)
Exercise 3.3
+👉 Write a function blur_1D(v, l)
that blurs a vector v
with a window of length l
by averaging the elements within a window from
xxxxxxxxxx
md"""
blur_1D (generic function with 1 method)
xxxxxxxxxx
function blur_1D(v, l)
return missing
end
xxxxxxxxxx
let
Exercise 3.4
+👉 Apply the box blur to your vector v
. Show the original and the new vector by creating two cells that call colored_line
. Make the parameter l_box
instead of just l
to avoid a variable naming conflict.
xxxxxxxxxx
md"""
Enter cell code...
xxxxxxxxxx
Hint
Have a look at Exercise 2 to see an example of adding interactivity with a slider. You can read the Interactivity and the PlutoUI sample notebooks (right click -> Open in new tab) to learn more.
+ +xxxxxxxxxx
hint(md"Have a look at Exercise 2 to see an example of adding interactivity with a slider. You can read the [Interactivity](./sample/Interactivity.jl) and the [PlutoUI](./sample/PlutoUI.jl) sample notebooks _(right click -> Open in new tab)_ to learn more.")
Exercise 3.5
+The box blur is a simple example of a convolution, i.e. a linear function of a window around each point, given by
+where
Again, we need to take care about what happens if
👉 Write a function convolve_vector(v, k)
that performs this convolution. You need to think of the vector
xxxxxxxxxx
md"""
convolve_vector (generic function with 1 method)
xxxxxxxxxx
function convolve_vector(v, k)
return missing
end
Hint
l = (length(k) - 1) ÷ 2
xxxxxxxxxx
hint(md"`l = (length(k) - 1) ÷ 2`")
xxxxxxxxxx
colored_line(test_convolution)
missing
xxxxxxxxxx
test_convolution = let
v = [1, 10, 100, 1000, 10000]
k = [0, 1, 0]
convolve_vector(v, k)
end
Edit the cell above, or create a new cell with your own test cases!
+xxxxxxxxxx
md"_Edit the cell above, or create a new cell with your own test cases!_"
Here we go!
Replace missing
with your answer.
xxxxxxxxxx
if ! (convolve_vector)
Exercise 3.6
+👉 Write a function gaussian_kernel
.
The definition of a Gaussian in 1D is
+We need to sample (i.e. evaluate) this at each pixel in a region of size
For simplicity you can take
xxxxxxxxxx
md"""
gaussian_kernel (generic function with 1 method)
xxxxxxxxxx
function gaussian_kernel(n)
return missing
end
Let's test your kernel function!
+xxxxxxxxxx
md"Let's test your kernel function!"
3
xxxxxxxxxx
gaussian_kernel_size_1D = 3 # change this value, or turn me into a slider!
xxxxxxxxxx
colored_line(test_gauss_1D_a)
xxxxxxxxxx
test_gauss_1D_a = let
v = random_vect
k = gaussian_kernel(gaussian_kernel_size_1D)
if k !== missing
convolve_vector(v, k)
end
end
xxxxxxxxxx
colored_line(test_gauss_1D_b)
xxxxxxxxxx
test_gauss_1D_b = let
v = create_bar()
k = gaussian_kernel(gaussian_kernel_size_1D)
if k !== missing
convolve_vector(v, k)
end
end
xxxxxxxxxx
bigbreak
Exercise 4 - Convolutions of images
+Now let's move to 2D images. The convolution is then given by a kernel matrix
where the sum is over the possible values of
A common notation for this operation is
xxxxxxxxxx
md"""
## **Exercise 4** - _Convolutions of images_
Now let's move to 2D images. The convolution is then given by a **kernel** matrix $K$:
$$M'_{i, j} = \sum_{k, l} \, M_{i- k, j - l} \, K_{k, l},$$
where the sum is over the possible values of $k$ and $l$ in the window. Again we think of the window as being *centered* at $(i, j)$.
A common notation for this operation is $*$:
$$M' = M * K.$$
"""
Exercise 4.1
+👉 Write a function extend_mat
that takes a matrix M
and indices i
and j
, and returns the closest element of the matrix.
xxxxxxxxxx
md"""
extend_mat (generic function with 1 method)
xxxxxxxxxx
function extend_mat(M::AbstractMatrix, i, j)
return missing
end
Hint
num_rows, num_columns = size(M)
xxxxxxxxxx
hint(md"`num_rows, num_columns = size(M)`")
Let's test it!
+xxxxxxxxxx
md"_Let's test it!_"
xxxxxxxxxx
small_image = Gray.(rand(5,5))
Extended with 0
:
xxxxxxxxxx
md"Extended with `0`:"
xxxxxxxxxx
[get(small_image, (i, j), Gray(0)) for (i,j) in Iterators.product(-1:7,-1:7)]
Extended with your extend
:
xxxxxxxxxx
md"Extended with your `extend`:"
9×9 Array{Missing,2}:
+ missing missing missing missing missing missing missing missing missing
+ missing missing missing missing missing missing missing missing missing
+ missing missing missing missing missing missing missing missing missing
+ missing missing missing missing missing missing missing missing missing
+ missing missing missing missing missing missing missing missing missing
+ missing missing missing missing missing missing missing missing missing
+ missing missing missing missing missing missing missing missing missing
+ missing missing missing missing missing missing missing missing missing
+ missing missing missing missing missing missing missing missing missing
xxxxxxxxxx
[extend_mat(small_image, i, j) for (i,j) in Iterators.product(-1:7,-1:7)]
Here we go!
Replace missing
with your answer.
xxxxxxxxxx
if ! (extend_mat)
283×223 Array{Missing,2}:
+ missing missing missing missing missing … missing missing missing missing
+ missing missing missing missing missing missing missing missing missing
+ missing missing missing missing missing missing missing missing missing
+ missing missing missing missing missing missing missing missing missing
+ missing missing missing missing missing missing missing missing missing
+ missing missing missing missing missing … missing missing missing missing
+ missing missing missing missing missing missing missing missing missing
+ ⋮ ⋱ ⋮
+ missing missing missing missing missing missing missing missing missing
+ missing missing missing missing missing missing missing missing missing
+ missing missing missing missing missing missing missing missing missing
+ missing missing missing missing missing … missing missing missing missing
+ missing missing missing missing missing missing missing missing missing
+ missing missing missing missing missing missing missing missing missing
xxxxxxxxxx
let
Exercise 4.2
+👉 Implement a function convolve_image(M, K)
.
xxxxxxxxxx
md"""
convolve_image (generic function with 1 method)
xxxxxxxxxx
function convolve_image(M::AbstractMatrix, K::AbstractMatrix)
return missing
end
Hint
num_rows, num_columns = size(K)
xxxxxxxxxx
hint(md"`num_rows, num_columns = size(K)`")
Let's test it out! 🎃
+xxxxxxxxxx
md"_Let's test it out! 🎃_"
xxxxxxxxxx
test_image_with_border = [get(small_image, (i, j), Gray(0)) for (i,j) in Iterators.product(-1:7,-1:7)]
3×3 Array{Float64,2}:
+ 0.0 0.0 0.0
+ 0.5 0.0 0.5
+ 0.0 0.0 0.0
xxxxxxxxxx
K_test = [
0 0 0
1/2 0 1/2
0 0 0
]
missing
xxxxxxxxxx
convolve_image(test_image_with_border, K_test)
Edit K_test
to create your own test case!
xxxxxxxxxx
md"_Edit_ `K_test` _to create your own test case!_"
missing
xxxxxxxxxx
convolve_image(philip, K_test)
+
You can create all sorts of effects by choosing the kernel in a smart way. Today, we will implement two special kernels, to produce a Gaussian blur and a Sobel edge detect filter.
+Make sure that you have watched the lecture about convolutions!
+xxxxxxxxxx
md"""
Exercise 4.3
+👉 Apply a Gaussian blur to an image.
+Here, the 2D Gaussian kernel will be defined as
+xxxxxxxxxx
md"""
#### Exercise 4.3
👉 Apply a **Gaussian blur** to an image.
Here, the 2D Gaussian kernel will be defined as
$$G(x,y)=\frac{1}{2\pi \sigma^2}e^{\frac{-(x^2+y^2)}{2\sigma^2}}$$
"""
with_gaussian_blur (generic function with 1 method)
xxxxxxxxxx
function with_gaussian_blur(image)
return missing
end
Let's make it interactive. 💫
+xxxxxxxxxx
md"_Let's make it interactive. 💫_"
xxxxxxxxxx
gauss_raw_camera_data camera_input(;max_size=100)
missing
xxxxxxxxxx
with_gaussian_blur(gauss_camera_image)
xxxxxxxxxx
Exercise 4.4
+👉 Create a Sobel edge detection filter.
+Here, we will need to create two separate filters that separately detect edges in the horizontal and vertical directions:
+Here
Then we combine them by finding the magnitude of the gradient (in the sense of multivariate calculus) by defining
+For simplicity you can choose one of the "channels" (colours) in the image to apply this to.
+xxxxxxxxxx
md"""
with_sobel_edge_detect (generic function with 1 method)
xxxxxxxxxx
function with_sobel_edge_detect(image)
return missing
end
xxxxxxxxxx
sobel_raw_camera_data camera_input(;max_size=100)
missing
xxxxxxxxxx
with_sobel_edge_detect(sobel_camera_image)
xxxxxxxxxx
xxxxxxxxxx
bigbreak
Exercise 5 - Lecture transcript
+(MIT students only)
+Please see the Canvas post for transcript document for week 1 here.
+We need each of you to correct about 100 lines (see instructions in the beginning of the document.)
+👉 Please mention the name of the video and the line ranges you edited:
+x
md"""
## **Exercise 5** - _Lecture transcript_
_(MIT students only)_
Please see the Canvas post for transcript document for week 1 [here](https://canvas.mit.edu/courses/5637/discussion_topics/27880).
We need each of you to correct about 100 lines (see instructions in the beginning of the document.)
👉 Please mention the name of the video and the line ranges you edited:
"""
Convolution, lines 100-0 (for example)
+x
lines_i_edited = md"""
Convolution, lines 100-0 (_for example_)
"""
xxxxxxxxxx
bigbreak
Oops!
Before you submit, remember to fill in your name and kerberos ID at the top of this notebook!
+xxxxxxxxxx
if student.kerberos_id === "jazz"
xxxxxxxxxx
bigbreak
hint (generic function with 1 method)
xxxxxxxxxx
hint(text) = Markdown.MD(Markdown.Admonition("hint", "Hint", [text]))
almost (generic function with 1 method)
xxxxxxxxxx
almost(text) = Markdown.MD(Markdown.Admonition("warning", "Almost there!", [text]))
still_missing (generic function with 2 methods)
xxxxxxxxxx
still_missing(text=md"Replace `missing` with your answer.") = Markdown.MD(Markdown.Admonition("warning", "Here we go!", [text]))
keep_working (generic function with 2 methods)
xxxxxxxxxx
keep_working(text=md"The answer is not quite right.") = Markdown.MD(Markdown.Admonition("danger", "Keep working on it!", [text]))
Great!
+Yay ❤
+Great! 🎉
+Well done!
+Keep it up!
+Good job!
+Awesome!
+You got the right answer!
+Let's move on to the next section.
+xxxxxxxxxx
yays = [md"Great!", md"Yay ❤", md"Great! 🎉", md"Well done!", md"Keep it up!", md"Good job!", md"Awesome!", md"You got the right answer!", md"Let's move on to the next section."]
correct (generic function with 2 methods)
xxxxxxxxxx
correct(text=rand(yays)) = Markdown.MD(Markdown.Admonition("correct", "Got it!", [text]))
not_defined (generic function with 1 method)
xxxxxxxxxx
not_defined(variable_name) = Markdown.MD(Markdown.Admonition("danger", "Oopsie!", [md"Make sure that you define a variable called **$(Markdown.Code(string(variable_name)))**"]))
xxxxxxxxxx
bigbreak = html"<br><br><br><br><br>";
camera_input (generic function with 1 method)
xxxxxxxxxx
function camera_input(;max_size=200, default_url="https://i.imgur.com/SUmi94P.png")
process_raw_camera_data (generic function with 1 method)
xxxxxxxxxx