Image Processing: Gaussian Blurring
Description:
You hate having your picture taken, but instead of hiding you decide to load a blur program into your family camera. Basically you need to apply a blur kernel to a pixel and it's neighbors. For simplicity your blur kernel will be 3x3 grid. You need to multiply the each value of the kernel with the pixel or neighbor and sum together. The kernel and image will be given as 2d lists.
Here is a sample kernel:
[0.1, 0.12, 0.1]
[0.12, 0.2, 0.12]
[0.1, 0.12, 0.1]
Here is an image and we will blur the middle pixel (20)
13 14 14
15 20 21
15 20 25
Step 1 (multiply pixel and neighbors by the kernel values):
13*.1 14*.12 14*.1
15*.12 20*.2 21*.12
15*.1 20*.12 25*.1
Step 2 (sum together and round), the middle point has a new value of 19 (1.3 + 1.68 + 1.4 + 1.8 + 4 + 2.52 + 1.5 + 2.4 + 2.5 = 19.1
)
This has to be done for each pixel based on the original pixel value, not on previously blurred pixels.
Given an image representation
A B C
F G H
K L M
Edges and corners use their own values as the neighbors. For example if you blur corner pixel A
, the neighbors would look like
A A B
A A B
F F G
And for edge pixel B
A B C
A B C
F G H
Similar Kata:
Stats:
Created | Dec 2, 2016 |
Published | Dec 2, 2016 |
Warriors Trained | 71 |
Total Skips | 6 |
Total Code Submissions | 103 |
Total Times Completed | 14 |
Python Completions | 14 |
Total Stars | 2 |
% of votes with a positive feedback rating | 81% of 8 |
Total "Very Satisfied" Votes | 5 |
Total "Somewhat Satisfied" Votes | 3 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 8 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 6 kyu |