FAQ
We will try to post frequently asked questions from previous versions of the assignment and from new questions on Ed Discussions here.
General Testing & Grading
How are pixel differences evaluated in grading?
The autograder uses one of two methods depending on the function:
Exact match (for most functions):
self.assertTrue(np.allclose(reference, student))Your output should match the reference within NumPy's default tolerance.
Allow small differences (for convolution/filtering):
absdiff = np.abs(reference - student)
self.assertTrue(np.count_nonzero(np.where(absdiff > 1, absdiff, 0)) <= 3)At most 3 pixels can have intensity values that differ by more than 1 (when type is uint8). (e.g., your pixel is 127 but reference is 129). This accounts for rounding differences between valid implementations.
How can I visualize differences between my output and reference images?
- In the
NumPy_Tutorial, we have provided code for inspecting and visualizing image differences.
Is execution time part of the grading criteria?
For most functions, execution time is not directly graded. However, convolve_sep has a complexity test that verifies your separable implementation is actually faster than the naive 2D convolution approach.
Photography
white_balance()
Hint: You can hover over a
plt.imshow(...)image to inspect its value under your cursor.Hint: Choosing different grays from the color chart shouldn't make a big difference, if you have implemented your code correctly. That being said, our reference code use the third one in the last row.
Filtering
convolve()
Q: The instructions say I is a "2D numpy array" but I get dimension errors. What are the actual dimensions?
A: The image I has 3 dimensions: (height, width, channels). The "2D" refers to spatial dimensions. Use height, width = I.shape[:2] or height, width, channels = I.shape.
Q: What does "clamp the ranges to the width and height" mean?
A: When the filter window extends beyond image boundaries, only sum over the valid (in-bounds) portion of the filter. Do not sample outside [0, height) × [0, width). This effectively treats out-of-bounds as zero without explicitly padding.
Q: For even-sized filters, do I "cut off" rows/columns since the scan doesn't cover the full filter?
A: No. You use the entire filter — all filter weights are applied. The asymmetry for even-sized filters is in positioning (which image pixels to sample), not in which filter elements to use.
Q: How do I test even-sized or non-square filters without reference images?
A: Use fh//2 and fw//2 independently for each dimension to determine the filter center and sampling range. Test by verifying output shape matches input and manually checking a few pixels on simple test patterns.
convolve_sep()
Q: Should my implementation work for any separable filter, or just Gaussian ones? Do I need SVD?
A: Your implementation should work for any separable filter, but you do NOT need SVD.
A separable 2D filter is the outer product of two 1D filters.
unsharp_mask()
Q: What does "Use a filter with a radius of 3 times the standard deviation (rounded up to the nearest integer)" mean?
A: Use ceiling (round up): int(np.ceil(3 * sigma)). The filter dimension would then be 2 * radius + 1.