@pixero said:
Would it be possible to make it simpler with just extending edges until it meets a edge?
For a case like in the image above that would work for all but one. (The diagonal edge.)
Yes, it is the diagonal edges that complicate the problem but I'm still thinking about it.