Skip to content

Commit 76d405e

Browse files
authored
Update proj2.html
1 parent 54464c1 commit 76d405e

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

project-2/proj2.html

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ <h2>Part 1: Filters and Edges</h2>
2626
<h3>Part 1.1: Convolutions from Scratch!</h3>
2727
<p>
2828
Using the definition of convolution:
29+
</p>
2930

3031
<pre><code>
3132
for result_i in range(result.shape[0]):
@@ -38,34 +39,37 @@ <h3>Part 1.1: Convolutions from Scratch!</h3>
3839
return result
3940
</code></pre>
4041

41-
where <code>ffker</code> is the <i>xy</i>-flipped kernel and <code>result</code> is the output 2D array, we can slightly speed up the computation by replacing the 2 inner for-loops with <code>result[result_i, result_j] = np.dot(img_flat, ffker.flatten())</code>, where <code>img_flat</code> is the flattened 1D array of the current patch of <code>img</code> based on the position of the kernel. Although this optimztion produces a noticable speed-up compared to using 4 for-loops, the fastest way is still to use <code>scipy.signal.convolve2d</code>. Below is a timing comparsion of the 3 methods above using a 5x5 kernel:
42+
<p>
43+
where <code>ffker</code> is the <i>xy</i>-flipped kernel and <code>result</code> is the output 2D array, we can slightly speed up the computation by replacing the 2 inner for-loops with <code>result[result_i, result_j] = np.dot(img_flat, ffker.flatten())</code>, where <code>img_flat</code> is the flattened 1D array of the current patch of <code>img</code> based on the position of the kernel. Although this optimization produces a noticeable speed-up compared to using 4 for-loops, the fastest way is still to use <code>scipy.signal.convolve2d</code>. Below is a timing comparison of the 3 methods above using a 5x5 kernel:
44+
</p>
45+
46+
<div align="center">
47+
<img src="images/scipy.png" alt="scipy.png" width="50%">
48+
</div>
49+
50+
<p>
51+
To demonstrate an application of convolution, we can convolve an image with the <strong>box filter</strong>, a kernel with entries that sum to 1 that contains only 1 unique value. We can also convolve with the difference operators <img src="images/diff_op.png" alt="diff_op.png" width="50%"> for edge detection. Each kernel computes the difference in the <i>x</i>- or <i>y</i>-direction, so edges where the brightness of the pixel changes significantly will show up as white and black pixels on the output. Using <code>box_9x9</code> = <i>J<sub>9</sub> / 9<sup>2</sup></i> as the box filter, we get the following results:
52+
</p>
4253

43-
<
54+
<div align="center">
55+
<img src="images/one.png" alt="one.png" width="50%">
56+
</div>
4457

58+
</article>
4559

4660
<!-- 1.2 -->
4761
<article id="part1-2">
48-
<h3>Part 1.2. Partial Derivatives, Gradient Magnitude, and Binarized Edge Image</h3>
62+
<h3>Part 1.2: Finite Difference Operator</h3>
4963
<p>
50-
<strong>Goal:</strong> Show derivative images in x and y, compute the gradient magnitude, and present a binarized edge map. Justify any thresholding or denoising choices.
64+
Given the following image:
5165
</p>
52-
<figure>
53-
<img src="images/partial_dx.png" alt="Partial derivative in x" />
54-
<figcaption>Partial derivative in x.</figcaption>
55-
</figure>
56-
<figure>
57-
<img src="images/partial_dy.png" alt="Partial derivative in y" />
58-
<figcaption>Partial derivative in y.</figcaption>
59-
</figure>
60-
<figure>
61-
<img src="images/grad_mag.png" alt="Gradient magnitude image" />
62-
<figcaption>Gradient magnitude image.</figcaption>
63-
</figure>
64-
<figure>
65-
<img src="images/binary_edges.png" alt="Binarized edge image" />
66-
<figcaption>Binarized edge image with chosen threshold(s).</figcaption>
67-
</figure>
68-
<p><strong>Tradeoffs &amp; Justification:</strong> [Explain choice of thresholds, smoothing, and how you balanced noise vs completeness of edges.]</p>
66+
67+
<div align="center">
68+
<img src="images/cameraman.png" alt="cameraman.png" width="50%">
69+
</div>
70+
71+
we can convolve
72+
6973
</article>
7074

7175
<!-- 1.3 -->

0 commit comments

Comments
 (0)