#vyrobenie skeletonu

import cv2
from skimage import morphology, color
import matplotlib.pyplot as plt
from skan import draw

#musime invertovat image kvoli skeletonizacii
image = cv2.imread('dilation_for_2_robot.pgm',0)
for i in range(len(image)):
    for j in range(len(image[i])):
        if(image[i][j]==1):
            image[i][j]=0
        elif(image[i][j]==0):
            image[i][j]=1
cv2.imwrite('dilation_for_2_robot.pgm', image)

image = cv2.imread('dilation_for_2_robot.pgm')
skeleton = morphology.skeletonize(image)
gray = cv2.cvtColor(skeleton, cv2.COLOR_BGR2GRAY)
cv2.imwrite('skeleton_2_robot.pgm', gray)
