pythonimage-processingbinary-image

Calculate the highest distance among two pixels in any labeled area in binary image


I want to find the highest distance between two pixels in any labeled area or find the top and bottom pixels.How can do this? Can you explain algorithm that related this topic ,please ?Thank you...


Solution

  • let's say that you are going to find the area in a rectangle, or a a square spaced area. In order to find the longest distance between the pixels, you are willing to use the simple math here. As you know the longest straight line distance between 2 points is called as the diagonal of that figure, hence, you will need to use the following formula: https://gyazo.com/c2bd3e0342008642bfde579816cbfd5e

    As a result, by just putting in the coordinates of each point, you can achieve the longest distance!