174 lines
3.6 KiB
Plaintext
174 lines
3.6 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import sys\n",
|
|
"from pathlib import Path\n",
|
|
"import numpy as np\n",
|
|
"import matplotlib.pyplot as plt\n",
|
|
"\n",
|
|
"triskele_path = Path('../triskele/python/')\n",
|
|
"sys.path.append(str(triskele_path.resolve()))\n",
|
|
"import triskele"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"def DFC_filter(raster):\n",
|
|
" raster[raster > 1e4] = raster[raster < 1e4].max()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## One raster"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"infile = Path('../Data/phase1_rasters/DSM_C12/UH17c_GEF051_TR.tif')\n",
|
|
"raster = triskele.read(infile)\n",
|
|
"DFC_filter(raster)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"t = triskele.Triskele(raster, verbose=False)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"area = np.array([10, 100, 1e3, 1e4, 1e5])\n",
|
|
"moi = np.array([.0, .01, .1, .2, .3, .4, .5, .9, .99, 1.])\n",
|
|
"\n",
|
|
"filtered = t.filter(tree='tos-tree')\n",
|
|
"filtered.shape"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"plt.figure(figsize=(16*1,5*1))\n",
|
|
"plt.imshow(filtered[:,:].astype(np.float))\n",
|
|
"plt.colorbar()\n",
|
|
"plt.show()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## More raster"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"infile1 = Path('../Data/phase1_rasters/DSM_C12/UH17c_GEF051_TR.tif')\n",
|
|
"infile2 = Path('../Data/phase1_rasters/Intensity_C1/UH17_GI1F051_TR.tif')\n",
|
|
"raster1 = triskele.read(infile1)\n",
|
|
"raster2 = triskele.read(infile2)\n",
|
|
"DFC_filter(raster1)\n",
|
|
"DFC_filter(raster2)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"plt.figure(figsize=(16*1,5*1))\n",
|
|
"plt.imshow(raster1[:,:].astype(np.float))\n",
|
|
"plt.colorbar()\n",
|
|
"plt.show()\n",
|
|
"\n",
|
|
"plt.figure(figsize=(16*1,5*1))\n",
|
|
"plt.imshow(raster2[:,:].astype(np.float))\n",
|
|
"plt.colorbar()\n",
|
|
"plt.show()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"data = np.stack((raster1, raster2), axis=2)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"t = triskele.Triskele(data, verbose=False)\n",
|
|
"f = t.filter(tree='tos-tree', area=area)\n",
|
|
"f.shape"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"for i in range(f.shape[2]):\n",
|
|
" plt.figure(figsize=(16*1,5*1))\n",
|
|
" plt.imshow(f[:,:,i].astype(np.float))\n",
|
|
" plt.colorbar()\n",
|
|
" plt.show()"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|