Meta: Median filter over a k-by-k window of an image buffer
Problem. You receive an input image buffer, an output buffer, the image width and height, and an odd kernel width k. For every pixel, write to the output the median of the k by k block of input pixels centered on that pixel. When a block holds an even number of values, the median is the mean of the two middle values. You may assume a sort routine is already available.
Constraints given. k is odd and positive. Nothing else was stated, so behavior at the image borders, where the window falls partly outside the image, is something to clarify.
How it went. This was the second question of an E5 onsite coding round, after a custom string ordering problem. The candidate spent 10 to 12 minutes just making sure they understood the setup before writing code. In the same round the interviewer hesitated when the candidate wanted to start coding right away, so they first walked through edge cases. Another round in the loop asked a range sum over a binary search tree and a Caesar-cipher grouping question.
Comments 0
No comments yet. Ask the author something, or add what happened in your own round.