Black and White
img is a 2-D array of grayscale pixels from 0 to 255. Return a new array of the same shape in which every pixel that is at least cutoff becomes 255 and every other pixel becomes 0.
Example 1
img [[10,200],[128,127]]
cutoff 128
returns [[0,255],[255,0]]
200 and 128 reach the cutoff; 10 and 127 do not.
Constraints
1 <= rows, columns <= 100 <= cutoff <= 255
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More NumPy problems
- Celsius to FahrenheitBeginner
- Clip ScoresBeginner
- CorrelationBeginner
- Count DistinctBeginner
- Count PositivesBeginner
- Count Target in GridBeginner
- Count the MaximumBeginner
- Cumulative MaxBeginner