Here my more elaborate answer... Hopefully the comments are clear enough!
import matplotlib.pyplot as plt
import imageio
import os
import numpy as np
# Load the image with imageio...
base_path = r'D:\temp'
im_name = 'arrow_image.png'
im_dir = os.path.join(base_path, im_name)
A = imageio.imread(im_dir)
# Get all the points that have a value in the A[:,:,0]-dimension of the image
pts2 = np.array([[j,i] for i in range(A.shape[0]) for j in range(A.shape[1]) if A[i,j,0] > 0])
# Using convexhull.. get an overlay of vertices for these found points
ch = ConvexHull(pts2)
# If you want to visualize them.. you can do that by
plt.plot(pts2[:, 0], pts2[:, 1], 'ko', markersize=10)
plt.show()
# Be aware that in this whole process your image might look like it has rotated.. so be aware of the dimension (and the way stuff is visualized)
# Get the indices of the hull points.
hull_indices = ch.vertices
# These are the actual points.
hull_pts = pts2[hull_indices, :]
# With this you are able to determine the 'end' points of your arrow. Fiddle around with it, know what you are trying to get and understand it.
z = [np.linalg.norm(x) for x in pts2]
z_max_norm = np.where(z==max(z))
z_min_norm = np.where(z==min(z))
y_max = np.where(pts2[:,1] == min(pts2[:,1]))[0]
x_min = np.where(pts2[:,0] == min(pts2[:,0]))[0]
# And here some more visualization tricks
plt.fill(hull_pts[:,0], hull_pts[:,1], fill=False, edgecolor='b')
# plt.scatter(pts2[z_min,0],pts2[z_min, 1])
# plt.scatter(pts2[z_max,0],pts2[z_max, 1])
plt.scatter(pts2[y_max,0],pts2[y_max, 1])
plt.scatter(pts2[x_min,0],pts2[x_min, 1])
plt.show()
This uses the same strategy that is posed in the answer of @GPPK. My other solution was a transformation of the data to 1d... you can think of transformations like
pts3 = np.array([A[i,j,0]*i*np.log(j) for i in range(A.shape[0]) for j in range(A.shape[1]) if A[i,j,0] > 0])
plt.plot(pts3)
plt.show()
But you have to test this a little bit, maybe change some of the parameters. The idea is that you discount certain dimensions in order to get back the shape of the arrow.