def zhang_suen(self, image):
        # now = time.time()
        image_thinned = image.copy()  # deepcopy to protect the original image
        changing1 = changing2 = 1  # the points to be removed (set as 0)
        while changing1 or changing2:  # iterates until no further changes occur in the image
            # Step 1
            changing1 = []
            max = len(image_thinned) - 1
            pass_list = [1, max]
            # rows, columns = image_thinned.shape  # x for rows, y for columns

            # for x in range(1, rows - 1):         # No. of  rows
            # for y in range(1, columns - 1):  # No. of columns
            for x, y in non_zero_coord(image_thinned):
                if x not in pass_list and y not in pass_list:
                    # if image_thinned[x][y] == 1:  # Condition 0: Point P1 in the object regions
                    P2, P3, P4, P5, P6, P7, P8, P9 = n = self.get_neighbours(x, y, image_thinned)
                    if (2 <= sum(n) <= 6 and    # Condition 1: 2<= N(P1) <= 6
                        P2 * P4 * P6 == 0 and    # Condition 3
                        P4 * P6 * P8 == 0 and   # Condition 4
                        self.transitions(n) == 1):    # Condition 2: S(P1)=1
                        changing1.append((x, y))
            for x, y in changing1:
                image_thinned[x][y] = 0
            # Step 2
            changing2 = []

            # for x in range(1, rows - 1):
            # for y in range(1, columns - 1):
            for x, y in non_zero_coord(image_thinned):
                if x not in pass_list and y not in pass_list:
                    # if image_thinned[x][y] == 1:  # Condition 0
                    P2, P3, P4, P5, P6, P7, P8, P9 = n = self.get_neighbours(x, y, image_thinned)
                    if (2 <= sum(n) <= 6 and       # Condition 1
                        P2 * P4 * P8 == 0 and       # Condition 3
                        P2 * P6 * P8 == 0 and  # Condition 4
                        self.transitions(n) == 1):    # Condition 2
                        changing2.append((x, y))
            for x, y in changing2:
                image_thinned[x][y] = 0
        # t = time.time() - now
        # print 't thinning: ', t
        return image_thinned


# ----------------------------------------------------------------------------------------------------------------------
# HAUSDORFF'S DISTANCE -------------------------------------------------------------------------------------------------
the Zhang-Suen Thinning Algorithm
dataset/ETHPy150Open neuropoly/spinalcordtoolbox/scripts/sct_compute_hausdorff_distance.py/Thinning.zhang_suen