In my current data analysis, I have some segmented images, such as below.
My problem is that I would like to place a polynomial or spline (s.th. one-dimension) in a specific area (red) in a segmented image. (the result will be a black line).
Usually I would use something like orthogonal distance regression, the problem is that it needs some suitable function, which I donβt have in this case. So what would be the best way to do this with python / numpy? Maybe some standard algorithm for this kind of problem?

UPDATE: it seems that my drawing skills are probably not the best, the red area in the picture may also have some random noise and should not be fully connected (there may be small gaps due to noise).
UPDATE2: The general goal would be to have a parameterized curve p (t) that returns the position, that is, p (t) => (x, y) for t in [0,1]. where t = 0 is the beginning of the black line, t = 1 is the end of the black line.
jrsm source share