Image Sharpening with Unsharp Mask
Given a 2D image, sigma, and an amount parameter, apply unsharp mask sharpening:
- Generate a Gaussian kernel with kernel_size = 3
- Blur the image using valid convolution
- For each pixel in the valid region:
The original pixel at position in the blurred output corresponds to pixel in the original image (since kernel_size=3, offset is 1).
Return the sharpened image rounded to 4 decimal places.
Example
image = [[10, 10, 10], [10, 10, 10], [10, 10, 10]] sigma = 1.0, amount = 1.0
[[10.0]]
- The given image is , but since the kernel size is , the valid region for convolution is , resulting in a blurred image of size .
- The Gaussian kernel with is generated, but since the image is uniform ( everywhere), the blurred pixel will also be .
- For the single pixel in the valid region, the sharpened value is calculated as: .
- The final sharpened image, rounded to decimal places, is , but since the problem asks for a output and the input image is , only the center pixel is considered, resulting in being the only value, thus the output is which can be simplified to in a matrix, so the output is which in this context is equivalent to but following the exact format of the question the answer should be in a matrix format: is the same as saying the output is in a matrix, hence the answer is .
Constraints
- image is a 2D list (at least 3x3)
- sigma is a positive float
- amount is a non-negative float
- kernel_size is fixed at 3
- Return 2D list of sharpened values rounded to 4 decimal places