This commit is contained in:
Florent Guiotte 2018-07-09 11:54:56 +02:00
parent 27184025c9
commit 1badfb9710
2 changed files with 56 additions and 28 deletions

View File

@ -34,7 +34,7 @@
"sys.path.append(str(Path('..').resolve()))\n",
"import ld2dap\n",
"\n",
"sys.path.append(str(Path('../triskele/').resolve()))\n",
"sys.path.append(str(Path('../triskele/python').resolve()))\n",
"import triskele"
]
},
@ -77,7 +77,7 @@
" '../Data/phase1_rasters/Intensity_C3/UH17_GI3F051_TR.tif',\n",
" #'../Data/ground_truth/2018_IEEE_GRSS_DFC_GT_TR.tif',\n",
" #'../Res/HVR/C123_num_returns_0_5_nearest.tif',\n",
" '../Res/HVR noisy/C123_num_returns_0_5_nearest.tif'\n",
" #'../Res/HVR noisy/C123_num_returns_0_5_nearest.tif'\n",
"\n",
"]"
]
@ -177,15 +177,6 @@
"out_vectors.run()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"out_vectors.data.shape"
]
},
{
"cell_type": "markdown",
"metadata": {},
@ -209,6 +200,35 @@
"### Vectors"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"out_vectors.data.shape"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Ground Truth"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"gt = triskele.read('../Data/ground_truth/2018_IEEE_GRSS_DFC_GT_TR.tif')\n",
"\n",
"plt.figure(figsize=figsize)\n",
"plt.imshow(gt)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,

View File

@ -13,7 +13,7 @@
"# Triskele\n",
"import sys\n",
"from pathlib import Path\n",
"triskele_path = Path('../triskele/python/')\n",
"triskele_path = Path('../triskele')\n",
"sys.path.append(str(triskele_path.resolve()))\n",
"import triskele"
]
@ -62,7 +62,7 @@
"outputs": [],
"source": [
"count = np.unique(gt, return_counts=True)\n",
"lbl = pd.read_csv('../Data/ground_truth/labels.csv', header=None, names=['Label'], index_col=0)\n",
"lbl = pd.read_csv('../labels.csv', index_col=0)\n",
"lbl['Count'] = count[1]\n",
"lbl"
]
@ -74,11 +74,11 @@
"outputs": [],
"source": [
"plt.bar(*count, log=True)\n",
"plt.xticks(lbl.index.values,lbl['Label'], rotation=90)\n",
"plt.xticks(lbl.index.values,lbl['label'], rotation=90)\n",
"plt.show()\n",
"\n",
"plt.bar(count[0][1:], count[1][1:])\n",
"plt.xticks(lbl.index.values[1:], lbl['Label'][1:], rotation=90)\n",
"plt.xticks(lbl.index.values[1:], lbl['label'][1:], rotation=90)\n",
"plt.show()"
]
},
@ -134,23 +134,31 @@
"outputs": [],
"source": [
"nb_split = 10\n",
"step = 0\n",
"\n",
"test_part = 1 / nb_split\n",
"def semantic_cvg(gt, nb_split, step=0):\n",
" test_part = 1 / nb_split\n",
"\n",
"split = np.zeros_like(gt)\n",
" split = np.zeros_like(gt)\n",
"\n",
"for lbli, lblc in zip(count[0][1:], count[1][1:]):\n",
" treshold = int(lblc * test_part)\n",
" #print('lbli:{}, count:{}, train:{}'.format(lbli, lblc, treshold))\n",
" f = np.nonzero(gt == lbli)\n",
" train, test\n",
" split[f[0][treshold * step:treshold * (step + 1)], f[1][:treshold]] = 2\n",
" split[f[0][treshold:], f[1][treshold:]] = 1\n",
" \n",
"plt.figure(figsize=fs)\n",
"plt.imshow(split)\n",
" for lbli, lblc in zip(count[0][1:], count[1][1:]):\n",
" treshold = int(lblc * test_part)\n",
" #print('lbli:{}, count:{}, train:{}'.format(lbli, lblc, treshold))\n",
" f = np.nonzero(gt == lbli)\n",
" t_int, t_ext = treshold * step, treshold * (step + 1)\n",
" split[f[0], f[1]] = 1\n",
" split[f[0][t_int:t_ext], f[1][t_int:t_ext]] = 2\n",
"\n",
" return split\n",
"\n",
"fig, axs = plt.subplots(nb_split, figsize=fs * nb_split)\n",
"\n",
"for i in range(nb_split):\n",
" split = semantic_cvg(gt, nb_split, i)\n",
"\n",
" axs[i].imshow(split)\n",
" axs[i].set_title(i)\n",
"#plt.imshow(split * (gt==1))\n",
"plt.savefig('../Res/cross_valid_split_{}.png'.format(nb_split))\n",
"plt.show()"
]
},