import cv2
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import csv








img1=cv2.imread('dilation_for_ROADS_robot.pgm',cv2.IMREAD_COLOR)
img2=cv2.imread('cleaned_skeleton_ROADS_robot.pgm',0)
help=img1.copy()
for i in range(len(img2)):
    for j in range(len(img2[i])):
        if(img2[i][j]!=0):
            help[i][j]=[0,0,255]
cv2.imwrite('dilat3-skeleton3.png', help)

img3=cv2.imread('dilation_for_ROADS_robot.pgm',0)
img4=cv2.imread('dilat3-skeleton3.png',cv2.IMREAD_COLOR)

for i in range(len(img3)):
    for j in range(len(img3[i])):
        if(img3[i][j]==1 and img4[i][j][2]!=255):
            img4[i][j]=[255,255,255]
cv2.imwrite('dilat3-skeleton3.png', img4)
######################################################################

img8=cv2.imread('dilat3-skeleton3.png',cv2.IMREAD_COLOR)
Pixels_of_customizable_help = []
with open('Skeleton1-SkeletonFinal.csv', 'r') as csvfile:
    reader = csv.reader(csvfile)
    for row in reader:
        Pixels_of_customizable_help.append([int(val) for val in row])
#print(Pixels_of_customizable_help)
for i in Pixels_of_customizable_help:
    img8[i[0],i[1]]=[162,255,0]
cv2.imwrite('spolocnePixle.png', img8)

######################################################################
img10=mpimg.imread('spolocnePixle.png')



imgplot = plt.imshow(img10, cmap='gray',extent=[0,19,0,124])
plt.title("Spoločné pixely prvotnej a finálnej cesty")
plt.xlabel("Súradnica x [m]")
plt.ylabel("Súradnica y [m]")
plt.ylim(90,100)




plt.show()
