Center Crop a Grayscale Image
Problem statement
Given a rectangular grayscale image image, return its centered cropHeight × cropWidth crop.
The parity guarantees make the unused rows and columns split evenly across opposite sides.
Function
centerCrop(image: int[][], cropHeight: int, cropWidth: int) → int[][]Examples
Example 1
image = [[1,2,3,4],[5,6,7,8],[9,10,11,12]]cropHeight = 1cropWidth = 2return = [[6,7]]One row and one column are removed evenly from opposite sides.
Constraints
1 <= image.length, image[i].length <= 200.1 <= cropHeight <= image.lengthand1 <= cropWidth <= image[i].length.(image.length - cropHeight)and(image[i].length - cropWidth)are even.