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]]
I am using the below code to change the values around the Proposed_example_array
to increase values by 100
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 of the erosion such that it only erodes one side, two sides or three sides of the image and not entirely around the image to produce the below Existing_example_arrays
? I read through the SciPy Manual, but couldn't find any information on the topic.
1 iteration eroded from the 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]]
1 iteration eroded from the 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]]