I have an elevation array from a .tif LiDAR surface. Example array below.
Existing_example_arrayV0 = [[ 0, 0, 1, 0, 0, 0, 0],
[ 0, 1, 1, 1, 0, 0, 0],
[ 0, 1, 1, 1, 1, 0, 0],
[ 1, 1, 1, 1, 1, 0, 0],
[ 0, 1, 1, 1, 1, 0, 0],
[ 0, 1, 1, 0, 0, 0, 0]]
The below code erodes the image equally from all sides.
for i in range(0, 1):
erosion_mask = binary_erosion(Existing_example_arrayV0 >= 100, structure=np.ones((3, 3)), iterations=i)
Existing_example_arrayV0[erosion_mask] += 100
Proposed_example_array = [[ 0, 0, 1, 0, 0, 0, 0],
[ 0, 1, 101, 1, 0, 0, 0],
[ 0, 1, 101, 101, 1, 0, 0],
[ 1, 100, 101, 101, 1, 0, 0],
[ 0, 1, 101, 101, 1, 0, 0],
[ 0, 1, 1, 0, 0, 0, 0]]
Is there a way to change the structure to only erode the image from one side to produce the below proposed_example_array
?
Eroded from left only:
Proposed_example_array = [[ 0, 0, 1, 0, 0, 0, 0],
[ 0, 1, 101, 101, 0, 0, 0],
[ 0, 1, 101, 101, 101, 0, 0],
[ 1, 100, 101, 101, 101, 0, 0],
[ 0, 1, 101, 101, 101, 0, 0],
[ 0, 1, 101, 0, 0, 0, 0]]
Eroded from right only:
Proposed_example_array = [[ 0, 0, 1, 0, 0, 0, 0],
[ 0, 101, 101, 1, 0, 0, 0],
[ 0, 101, 101, 101, 1, 0, 0],
[ 101, 101, 101, 101, 1, 0, 0],
[ 0, 101, 101, 101, 1, 0, 0],
[ 0, 101, 1, 0, 0, 0, 0]]