Note : Projection profile is calculated for a thresholded image or binarized image where a thresholded image is a grayscale image with pixel values as 0 or 255. Image pixels are replaced by 1 and 0 for pixel values 0 and 255 respectively.
The projection profile is calculated separately for different axes. The projection profile along the vertical axis is called the elevation profile. The elevation profile is calculated for each column as the sum of all the pixel values of the row within the column. Horizontal projection profile — this is the projection profile of the image along the horizontal axis. The ground profile is calculated for each row as the sum of all the pixel values of the column within the row.
Code implementation for the ground profile:
3 1 3 1 3
Code implementation for elevation profile:
5 3 3
Time complexity : O (rows * columns)
Space complexity : O (rows * columns)