""" Tis file creates a dictionnary of the known contours with the specie idnetification

Marjorie Roscian 2018"""

import os
import cv2
from Images.Freemancode import *
from Analysis.AnthoRPhytoClus import *


def dic_ref():
    # Open contours
    os.chdir('/home/roscian/Bureau/roscian/Images')
    akashiwo = cv2.imread('akashiwo.tif', 0)
    akashiwo = FreemanChainCode(akashiwo)
    akashiwo = np.asarray(akashiwo)

    boiteacam = cv2.imread('boiteacam.tif', 0)
    boiteacam = FreemanChainCode(boiteacam)
    boiteacam = np.asarray(boiteacam)

    chaetoceros1 = cv2.imread('chaetoceros.tif', 0)
    chaetoceros1 = FreemanChainCode(chaetoceros1)
    chaetoceros1 = np.asarray(chaetoceros1)

    chaetoceros2 = cv2.imread('chaetoceros2.tif', 0)
    chaetoceros2 = FreemanChainCode(chaetoceros2)
    chaetoceros2 = np.asarray(chaetoceros2)

    chaetoceros3 = cv2.imread('chaetoceros3.tif', 0)
    chaetoceros3 = FreemanChainCode(chaetoceros3)
    chaetoceros3 = np.asarray(chaetoceros3)

    larve1 = cv2.imread('larve1.tif', 0)
    larve1 = FreemanChainCode(larve1)
    larve1 = np.asarray(larve1)

    larve2 = cv2.imread('larve2.tif', 0)
    larve2 = FreemanChainCode(larve2)
    larve2 = np.asarray(larve2)

    larve3 = cv2.imread('larve3.tif', 0)
    larve3 = FreemanChainCode(larve3)
    larve3 = np.asarray(larve3)

    larve4 = cv2.imread('larve4.tif', 0)
    larve4 = FreemanChainCode(larve4)
    larve4 = np.asarray(larve4)

    lev1 = cv2.imread('lev.tif', 0)
    lev1 = FreemanChainCode(lev1)
    lev1 = np.asarray(lev1)

    lev2 = cv2.imread('lev2.tif', 0)
    lev2 = FreemanChainCode(lev2)
    lev2 = np.asarray(lev2)

    lev3 = cv2.imread('lev3.tif', 0)
    lev3 = FreemanChainCode(lev3)
    lev3 = np.asarray(lev3)

    prorocentrum = cv2.imread('prorocentrum.tif', 0)
    prorocentrum = FreemanChainCode(prorocentrum)
    prorocentrum = np.asarray(prorocentrum)

    pseudonischtia = cv2.imread('pseudonischtia.tif', 0)
    pseudonischtia = FreemanChainCode(pseudonischtia)
    pseudonischtia = np.asarray(pseudonischtia)

    strombidium = cv2.imread('strombidium.tif', 0)
    strombidium = FreemanChainCode(strombidium)
    strombidium = np.asarray(strombidium)

    # Create matrix
    dict_1 = [akashiwo, boiteacam, chaetoceros1, chaetoceros2, chaetoceros3, larve1, larve2, larve3, larve4, lev1,
              lev2, lev3, prorocentrum, pseudonischtia, strombidium]
    dict_1 = np.asarray(dict_1)

    # From discrete to curves
    dict_curve = data_to_function(dict_1, 21, 2)
    dict_curve = np.asarray(dict_curve)

    # Create the dictionary
    final_dict = {'akashiwo': dict_curve[0], 'boiteacam': dict_curve[1], 'chaetoceros1': dict_curve[2],
                  'chaeotceros2': dict_curve[3], 'chaetoceros3': dict_curve[4], 'larve1': dict_curve[5],
                  'larve2': dict_curve[6], 'larve3': dict_curve[7], 'larve4': dict_curve[8], 'diatomee1': dict_curve[9],
                  'diatomee2': dict_curve[10], 'diatomee3': dict_curve[11], 'prorocentrum': dict_curve[12],
                  'pseudonischtia': dict_curve[13], 'strombidium': dict_curve[14]}

    return final_dict
