About the method of finding the farthest distance of the color block

I have a small problem in my project about how to find the distance between the longest two points and the shortest two points in an irregular block of color on a picture, rest assured that a straight line can pass through the area without a block of color, and I would like to ask if you have any ideas

Do you have an example image?