📘
Maximum Brightness Window
MediumSliding Window, Deque
Problem Statement
In image analysis, we often need to find the brightest region of a fixed size. Given a 1D array of pixel intensities and a window size k, find the maximum value in each sliding window position.
This is equivalent to applying a max filter (dilation in morphological operations).
Applications
- Feature detection (finding local maxima)
- Morphological dilation
- Finding brightest regions for exposure adjustment
Constraints
- 1≤len(pixels)≤10000
- 1≤k≤len(pixels)
- 0≤pixels[i]≤255
Example:
Input:
pixels = [1, 3, 2, 5, 4, 1, 3], k = 3
Output:
[3, 5, 5, 5, 4]
Reasoning:
Windows: [1,3,2]→3, [3,2,5]→5, [2,5,4]→5, [5,4,1]→5, [4,1,3]→4
Editor
Python 3.13.1
Test Results
0/0Run code to see test results.