{
"cells": [
{
"cell_type": "markdown",
"id": "da6d5a51-f8ac-4865-893e-10186189faa1",
"metadata": {},
"source": [
"# Gl\u00e4tten und Vereinfachen von Oberfl\u00e4chen\n",
"\n",
"Bei der Arbeit mit Oberfl\u00e4chennetzen ist es eine h\u00e4ufige Aufgabe, diese Netze zu vereinfachen, um ihre Analyse zu erm\u00f6glichen. Auch das Gl\u00e4tten kann notwendig sein, beispielsweise um die Messung von voxelierten Strukturen zu vermeiden."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "2c16dfdc-32ff-43e9-a9df-56f0deecaf10",
"metadata": {},
"outputs": [],
"source": [
"import napari_process_points_and_surfaces as nppas\n",
"import vedo"
]
},
{
"cell_type": "markdown",
"id": "47202a21-887b-46a7-ad4e-eadbcf5e965d",
"metadata": {},
"source": [
"Unser Ausgangspunkt ist das simulierte Branchoid, das wir fr\u00fcher in diesem Kapitel auf der Festplatte gespeichert haben."
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "12570e79-425d-4389-b9d0-31bcdd59144b",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"\n",
" \n",
" | \n",
"\n",
"nppas.SurfaceTuple \n",
"\n",
"origin (z/y/x) | [0. 0. 0.] | \n",
"center of mass(z/y/x) | 50.000,46.575,42.589 | \n",
"scale(z/y/x) | 1.000,1.000,1.000 | \n",
"bounds (z/y/x) | 25.500...74.500 2.500...88.500 2.500...83.500 | \n",
"average size | 31.277 | \n",
"number of vertices | 19040 | \n",
"number of faces | 38076 | \n",
"\n",
" \n",
"\n",
" | \n",
"
\n",
"
"
],
"text/plain": [
"(array([[25.5, 44. , 47. ],\n",
" [26. , 43.5, 47. ],\n",
" [26. , 44. , 46.5],\n",
" ...,\n",
" [74.5, 56. , 51. ],\n",
" [74.5, 56. , 52. ],\n",
" [74.5, 56. , 53. ]], dtype=float32),\n",
" array([[ 2, 1, 0],\n",
" [ 4, 3, 0],\n",
" [ 4, 0, 1],\n",
" ...,\n",
" [19038, 18870, 18872],\n",
" [19038, 18872, 19039],\n",
" [19039, 18872, 18852]], dtype=int64))"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"mesh = vedo.load(\"../../data/branchoid.ply\")\n",
"surface = nppas.to_napari_surface_data(mesh)\n",
"surface"
]
},
{
"cell_type": "markdown",
"id": "9d0c79fc-2dbe-4064-9e1c-d6df28434d9a",
"metadata": {},
"source": [
"## Gl\u00e4tten von Netzen\n",
"Die kreisf\u00f6rmigen Strukturen, die Sie in diesem Datensatz sehen, resultieren aus dem Ursprung der Daten: Die Oberfl\u00e4che wurde aus einem Bin\u00e4rbild erstellt. Die Linien entsprechen Voxelkanten. Eine Messung der Oberfl\u00e4che w\u00e4re irref\u00fchrend. Daher m\u00fcssen wir den Datensatz gl\u00e4tten, bevor wir quantitative Messungen durchf\u00fchren."
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "232c0325-2881-4211-9706-a349ae57bbef",
"metadata": {
"pycharm": {
"is_executing": true
}
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"\n",
" \n",
" | \n",
"\n",
"nppas.SurfaceTuple \n",
"\n",
"origin (z/y/x) | [0. 0. 0.] | \n",
"center of mass(z/y/x) | 50.000,46.578,42.588 | \n",
"scale(z/y/x) | 1.000,1.000,1.000 | \n",
"bounds (z/y/x) | 25.347...74.653 2.328...88.704 2.334...83.678 | \n",
"average size | 31.345 | \n",
"number of vertices | 19040 | \n",
"number of faces | 38076 | \n",
"\n",
" \n",
"\n",
" | \n",
"
\n",
"
"
],
"text/plain": [
"(array([[25.8801 , 44.178448, 46.409103],\n",
" [25.98807 , 43.647034, 46.834126],\n",
" [25.66813 , 44.284664, 47.229954],\n",
" ...,\n",
" [74.374275, 55.870167, 50.97586 ],\n",
" [74.372375, 55.849792, 51.9754 ],\n",
" [74.33187 , 55.632175, 53.02567 ]], dtype=float32),\n",
" array([[ 0, 1, 2],\n",
" [ 3, 4, 2],\n",
" [ 3, 2, 1],\n",
" ...,\n",
" [19038, 18871, 18873],\n",
" [19038, 18873, 19039],\n",
" [19039, 18873, 18852]], dtype=int64))"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"smoothed_surface = nppas.smooth_surface(surface)\n",
"smoothed_surface"
]
},
{
"cell_type": "markdown",
"id": "57988c4d-aff9-42a5-b09e-faac00c925a7",
"metadata": {},
"source": [
"Wir k\u00f6nnen auch anpassen, wie fein die Gl\u00e4ttung angewendet wird."
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "93452c0d-7953-44cf-9976-a26af0cd75e7",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"\n",
" \n",
" | \n",
"\n",
"nppas.SurfaceTuple \n",
"\n",
"origin (z/y/x) | [0. 0. 0.] | \n",
"center of mass(z/y/x) | 50.000,46.577,42.588 | \n",
"scale(z/y/x) | 1.000,1.000,1.000 | \n",
"bounds (z/y/x) | 25.360...74.640 2.296...88.797 2.302...83.693 | \n",
"average size | 31.349 | \n",
"number of vertices | 19040 | \n",
"number of faces | 38076 | \n",
"\n",
" \n",
"\n",
" | \n",
"
\n",
"
"
],
"text/plain": [
"(array([[25.876875, 44.27774 , 46.330605],\n",
" [25.971485, 43.719704, 46.732815],\n",
" [25.723366, 44.443665, 47.23411 ],\n",
" ...,\n",
" [74.32864 , 55.820503, 50.877747],\n",
" [74.31066 , 55.738045, 51.88742 ],\n",
" [74.276634, 55.50889 , 52.960915]], dtype=float32),\n",
" array([[ 0, 1, 2],\n",
" [ 3, 4, 2],\n",
" [ 3, 2, 1],\n",
" ...,\n",
" [19038, 18871, 18873],\n",
" [19038, 18873, 19039],\n",
" [19039, 18873, 18852]], dtype=int64))"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"smoothed_surface2 = nppas.smooth_surface(surface, pass_band=0.01)\n",
"smoothed_surface2"
]
},
{
"cell_type": "markdown",
"id": "5b0d79a7-5f3a-411c-b5d1-cc9aceb80e1f",
"metadata": {},
"source": [
"Die Parameter erlauben auch das Entfernen lokaler Strukturen, insbesondere durch die Anzahl der Iterationen."
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "d346b286-0c97-4030-bb61-2e756c8355b9",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"\n",
" \n",
" | \n",
"\n",
"nppas.SurfaceTuple \n",
"\n",
"origin (z/y/x) | [0. 0. 0.] | \n",
"center of mass(z/y/x) | 50.013,46.548,42.623 | \n",
"scale(z/y/x) | 1.000,1.000,1.000 | \n",
"bounds (z/y/x) | 27.575...72.373 6.941...82.192 7.009...79.894 | \n",
"average size | 29.331 | \n",
"number of vertices | 19040 | \n",
"number of faces | 38076 | \n",
"\n",
" \n",
"\n",
" | \n",
"
\n",
"
"
],
"text/plain": [
"(array([[28.019161, 46.668327, 48.092934],\n",
" [28.084337, 46.248135, 48.33528 ],\n",
" [27.932276, 46.792118, 48.730152],\n",
" ...,\n",
" [71.99732 , 53.424328, 49.847355],\n",
" [72.04024 , 53.235012, 50.53048 ],\n",
" [72.06986 , 52.989563, 51.258373]], dtype=float32),\n",
" array([[ 0, 1, 2],\n",
" [ 3, 4, 2],\n",
" [ 3, 2, 1],\n",
" ...,\n",
" [19038, 18871, 18873],\n",
" [19038, 18873, 19039],\n",
" [19039, 18873, 18852]], dtype=int64))"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"smoothed_surface3 = nppas.smooth_surface(surface, number_of_iterations=100,\n",
" pass_band=0.00001, \n",
" )\n",
"smoothed_surface3"
]
},
{
"cell_type": "markdown",
"id": "fc0c550f-09f9-4e3a-a770-0fd0321dbc2f",
"metadata": {
"pycharm": {
"is_executing": true
}
},
"source": [
"Es gibt auch weitere Funktionen zum Gl\u00e4tten von Oberfl\u00e4chen, z.B. basierend auf [Moving Least Squares](https://en.wikipedia.org/wiki/Moving_least_squares)."
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "37d621bb-e3e7-4494-9a69-03dd6fa611fc",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u001b[2m elapsed: 5s (3714.7 it/s) (3707.5 it/s) working ...\n"
]
},
{
"data": {
"text/html": [
"\n",
"\n",
"\n",
" \n",
" | \n",
"\n",
"nppas.SurfaceTuple \n",
"\n",
"origin (z/y/x) | [0. 0. 0.] | \n",
"center of mass(z/y/x) | 50.000,46.575,42.589 | \n",
"scale(z/y/x) | 1.000,1.000,1.000 | \n",
"bounds (z/y/x) | 25.500...74.500 2.500...88.488 2.500...83.500 | \n",
"average size | 31.218 | \n",
"number of vertices | 19040 | \n",
"number of faces | 38076 | \n",
"\n",
" \n",
"\n",
" | \n",
"
\n",
"
"
],
"text/plain": [
"(array([[25.98875 , 44.12809 , 47.057686],\n",
" [26.15397 , 43.54473 , 47.020836],\n",
" [26.077953, 44.021046, 46.511963],\n",
" ...,\n",
" [74.10477 , 55.90134 , 50.989483],\n",
" [74.068146, 55.883648, 51.968372],\n",
" [74.0037 , 55.863758, 52.942482]], dtype=float32),\n",
" array([[ 2, 1, 0],\n",
" [ 4, 3, 0],\n",
" [ 4, 0, 1],\n",
" ...,\n",
" [19038, 18870, 18872],\n",
" [19038, 18872, 19039],\n",
" [19039, 18872, 18852]], dtype=int64))"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"nppas.smooth_surface_moving_least_squares_2d(surface, smoothing_factor=0.2)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "fc8d5413",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u001b[2m elapsed: 5s (3572.6 it/s) (3577.5 it/s) working ...\n"
]
},
{
"data": {
"text/html": [
"\n",
"\n",
"\n",
" \n",
" | \n",
"\n",
"nppas.SurfaceTuple \n",
"\n",
"origin (z/y/x) | [0. 0. 0.] | \n",
"center of mass(z/y/x) | 50.000,46.575,42.589 | \n",
"scale(z/y/x) | 1.000,1.000,1.000 | \n",
"bounds (z/y/x) | 25.500...74.500 2.500...88.500 2.500...83.500 | \n",
"average size | 31.211 | \n",
"number of vertices | 19040 | \n",
"number of faces | 38076 | \n",
"\n",
" \n",
"\n",
" | \n",
"
\n",
"
"
],
"text/plain": [
"(array([[25.98293 , 44.12884 , 47.057266],\n",
" [26.142307, 43.538788, 47.017857],\n",
" [26.082615, 44.023262, 46.51221 ],\n",
" ...,\n",
" [74.13081 , 55.896233, 50.99272 ],\n",
" [74.08871 , 55.884872, 51.97385 ],\n",
" [74.017075, 55.87116 , 52.942734]], dtype=float32),\n",
" array([[ 2, 1, 0],\n",
" [ 4, 3, 0],\n",
" [ 4, 0, 1],\n",
" ...,\n",
" [19038, 18870, 18872],\n",
" [19038, 18872, 19039],\n",
" [19039, 18872, 18852]], dtype=int64))"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"nppas.smooth_surface_moving_least_squares_2d_radius(surface, smoothing_factor=0.2, radius=3)"
]
},
{
"cell_type": "markdown",
"id": "c596fd03-c02e-44e6-9c9c-7993aae3c99d",
"metadata": {
"pycharm": {
"is_executing": true
}
},
"source": [
"## Vereinfachen von Oberfl\u00e4chennetzen\n",
"Falls ein Oberfl\u00e4chennetz zu viele Vertices und Faces hat, kann die Verarbeitung lange dauern. Zu detaillierte Oberfl\u00e4chennetze bringen m\u00f6glicherweise auch keine zus\u00e4tzlichen Informationen. Daher kann es sinnvoll sein, Oberfl\u00e4chen zu vereinfachen, zum Beispiel indem die Anzahl der Vertices und Faces um die H\u00e4lfte reduziert wird."
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "56453af5-f8e1-4db1-bf76-9db97e276b15",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"\n",
" \n",
" | \n",
"\n",
"nppas.SurfaceTuple \n",
"\n",
"origin (z/y/x) | [0. 0. 0.] | \n",
"center of mass(z/y/x) | 50.024,46.096,39.540 | \n",
"scale(z/y/x) | 1.000,1.000,1.000 | \n",
"bounds (z/y/x) | 25.347...74.653 2.332...88.704 2.338...83.678 | \n",
"average size | 32.057 | \n",
"number of vertices | 9521 | \n",
"number of faces | 19038 | \n",
"\n",
" \n",
"\n",
" | \n",
"
\n",
"
"
],
"text/plain": [
"(array([[25.8801 , 44.178448, 46.409103],\n",
" [25.66813 , 44.284664, 47.229954],\n",
" [25.627625, 44.145462, 48.30988 ],\n",
" ...,\n",
" [74.374275, 55.870167, 50.97586 ],\n",
" [74.372375, 55.849792, 51.9754 ],\n",
" [74.33187 , 55.632175, 53.02567 ]], dtype=float32),\n",
" array([[ 107, 3, 2],\n",
" [ 107, 2, 1],\n",
" [ 108, 4, 3],\n",
" ...,\n",
" [9519, 9431, 9432],\n",
" [9519, 9432, 9520],\n",
" [9520, 9432, 9424]], dtype=int64))"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"simplified_surface = nppas.decimate_pro(smoothed_surface, fraction=0.5)\n",
"simplified_surface"
]
},
{
"cell_type": "markdown",
"id": "c18b2359-39d4-47c5-ad4a-6608de168177",
"metadata": {},
"source": [
"Wenn wir die Oberfl\u00e4che zu stark vereinfachen, k\u00f6nnen wir r\u00e4umliche Informationen und Aufl\u00f6sung verlieren. Das Objekt wird dann m\u00f6glicherweise nicht mehr angemessen dargestellt."
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "b9f5ff74-cb9e-4b20-ad47-5715829bea12",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"\n",
" \n",
" | \n",
"\n",
"nppas.SurfaceTuple \n",
"\n",
"origin (z/y/x) | [0. 0. 0.] | \n",
"center of mass(z/y/x) | 49.963,47.454,39.244 | \n",
"scale(z/y/x) | 1.000,1.000,1.000 | \n",
"bounds (z/y/x) | 25.366...74.634 2.312...88.678 2.318...83.672 | \n",
"average size | 31.565 | \n",
"number of vertices | 1905 | \n",
"number of faces | 3806 | \n",
"\n",
" \n",
"\n",
" | \n",
"
\n",
"
"
],
"text/plain": [
"(array([[26.206108, 42.87852 , 47.044594],\n",
" [25.50169 , 44.605286, 53.046658],\n",
" [25.496613, 44.702175, 47.20253 ],\n",
" ...,\n",
" [74.60994 , 53.51402 , 53.527515],\n",
" [74.63424 , 54.613785, 47.303745],\n",
" [74.49613 , 55.441647, 52.614532]], dtype=float32),\n",
" array([[ 0, 1, 2],\n",
" [ 3, 1, 0],\n",
" [ 2, 1, 4],\n",
" ...,\n",
" [1893, 1899, 1892],\n",
" [1903, 1893, 1904],\n",
" [1893, 1890, 1904]], dtype=int64))"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"simplified_surface2 = nppas.decimate_quadric(smoothed_surface, fraction=0.1)\n",
"simplified_surface2"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "b964105e-6dad-4c33-93bb-01d0fdf7b6b0",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"\n",
" \n",
" | \n",
"\n",
"nppas.SurfaceTuple \n",
"\n",
"origin (z/y/x) | [0. 0. 0.] | \n",
"center of mass(z/y/x) | 50.146,45.715,39.357 | \n",
"scale(z/y/x) | 1.000,1.000,1.000 | \n",
"bounds (z/y/x) | 25.440...74.623 2.344...88.258 2.412...83.760 | \n",
"average size | 31.898 | \n",
"number of vertices | 192 | \n",
"number of faces | 380 | \n",
"\n",
" \n",
"\n",
" | \n",
"
\n",
"
"
],
"text/plain": [
"(array([[26.68893 , 41.386234 , 54.343475 ],\n",
" [25.665216 , 45.986393 , 56.52883 ],\n",
" [25.439806 , 46.50671 , 44.638504 ],\n",
" [25.620443 , 53.69296 , 56.63574 ],\n",
" [26.560661 , 58.396793 , 45.893154 ],\n",
" [28.687128 , 56.69094 , 37.615738 ],\n",
" [27.710701 , 38.450787 , 46.96767 ],\n",
" [27.459593 , 46.988216 , 38.936283 ],\n",
" [28.853188 , 63.422825 , 54.582485 ],\n",
" [29.473408 , 37.64574 , 58.49952 ],\n",
" [29.529612 , 39.74972 , 39.24587 ],\n",
" [29.527447 , 59.589012 , 61.204815 ],\n",
" [31.330425 , 67.32442 , 47.900337 ],\n",
" [31.963932 , 32.075504 , 48.376293 ],\n",
" [32.6859 , 47.521767 , 70.15131 ],\n",
" [31.99785 , 49.04959 , 31.985273 ],\n",
" [34.828728 , 35.343822 , 35.504322 ],\n",
" [36.593826 , 51.56305 , 77.196236 ],\n",
" [34.2901 , 64.27009 , 35.855507 ],\n",
" [35.29054 , 64.950935 , 64.33926 ],\n",
" [35.361217 , 41.162434 , 70.78672 ],\n",
" [37.243984 , 29.662296 , 58.642696 ],\n",
" [35.613735 , 70.32884 , 45.356033 ],\n",
" [35.6032 , 35.159164 , 64.687454 ],\n",
" [36.620796 , 44.947166 , 28.916878 ],\n",
" [37.60989 , 54.86393 , 28.392506 ],\n",
" [37.23822 , 71.04382 , 56.43045 ],\n",
" [39.826775 , 29.319641 , 39.508713 ],\n",
" [38.36143 , 60.007275 , 74.17494 ],\n",
" [36.63893 , 16.344017 , 10.426262 ],\n",
" [36.366825 , 11.261889 , 16.198801 ],\n",
" [36.525665 , 21.1516 , 16.3251 ],\n",
" [37.169502 , 19.666199 , 22.061708 ],\n",
" [38.097126 , 20.731907 , 9.070139 ],\n",
" [39.36047 , 27.24296 , 46.624763 ],\n",
" [39.973576 , 41.775864 , 77.92608 ],\n",
" [37.64261 , 65.66177 , 33.97162 ],\n",
" [39.64327 , 60.725037 , 29.512444 ],\n",
" [41.45693 , 65.020836 , 70.52576 ],\n",
" [40.94294 , 72.06241 , 39.728542 ],\n",
" [39.39634 , 9.188879 , 8.6468 ],\n",
" [39.780582 , 6.006912 , 15.170123 ],\n",
" [39.696896 , 8.470722 , 23.03072 ],\n",
" [40.988796 , 26.84663 , 54.401314 ],\n",
" [40.433376 , 38.1792 , 29.723703 ],\n",
" [41.2404 , 46.1259 , 81.393394 ],\n",
" [40.30523 , 77.114944 , 45.647793 ],\n",
" [41.510914 , 16.467228 , 27.564823 ],\n",
" [43.299118 , 13.691551 , 3.1184416],\n",
" [40.585903 , 26.788107 , 16.351345 ],\n",
" [41.809185 , 35.415157 , 71.49992 ],\n",
" [42.350353 , 58.1487 , 79.94957 ],\n",
" [42.576504 , 81.747215 , 52.84743 ],\n",
" [45.207733 , 25.832605 , 27.28196 ],\n",
" [44.0175 , 70.96445 , 62.76304 ],\n",
" [41.653294 , 75.136604 , 28.59522 ],\n",
" [42.909546 , 77.45251 , 57.702137 ],\n",
" [45.868134 , 53.741474 , 83.54455 ],\n",
" [43.79853 , 57.917538 , 26.803473 ],\n",
" [42.364174 , 70.8033 , 23.716265 ],\n",
" [44.489887 , 4.0517473, 10.058916 ],\n",
" [45.764526 , 8.431024 , 4.349706 ],\n",
" [45.868694 , 8.705374 , 27.973577 ],\n",
" [43.35615 , 26.499603 , 8.611046 ],\n",
" [46.547344 , 21.693665 , 2.8103414],\n",
" [45.221115 , 25.46757 , 44.919884 ],\n",
" [46.16697 , 26.929514 , 59.479393 ],\n",
" [45.642536 , 29.74707 , 34.836777 ],\n",
" [47.14099 , 45.639877 , 25.09559 ],\n",
" [45.27639 , 48.555595 , 24.551157 ],\n",
" [45.004967 , 2.7245843, 19.429825 ],\n",
" [45.475456 , 28.244535 , 24.310375 ],\n",
" [48.058502 , 32.976463 , 70.89074 ],\n",
" [45.107895 , 78.76306 , 30.81979 ],\n",
" [45.99538 , 88.175735 , 49.117184 ],\n",
" [45.339073 , 29.431232 , 15.284614 ],\n",
" [46.960835 , 40.093826 , 80.787796 ],\n",
" [47.05903 , 66.235985 , 71.87344 ],\n",
" [45.77307 , 79.763794 , 17.817554 ],\n",
" [45.126537 , 80.07256 , 42.6345 ],\n",
" [47.887005 , 22.923447 , 29.671457 ],\n",
" [45.416065 , 33.973 , 30.142605 ],\n",
" [48.41933 , 35.7783 , 28.834436 ],\n",
" [50.998196 , 44.598274 , 83.760216 ],\n",
" [50.837845 , 62.010933 , 79.52458 ],\n",
" [48.012707 , 71.40827 , 19.049572 ],\n",
" [49.10983 , 76.78735 , 39.092693 ],\n",
" [48.181744 , 85.63972 , 16.509844 ],\n",
" [50.517117 , 2.343558 , 10.854712 ],\n",
" [49.138504 , 11.246079 , 29.491673 ],\n",
" [46.85801 , 53.911095 , 14.709483 ],\n",
" [46.079205 , 47.050503 , 14.567586 ],\n",
" [46.484818 , 53.92375 , 24.66554 ],\n",
" [48.04356 , 56.963867 , 25.703531 ],\n",
" [49.017956 , 88.25487 , 53.984276 ],\n",
" [50.66335 , 11.16585 , 2.4123256],\n",
" [49.63272 , 30.068512 , 23.00625 ],\n",
" [48.882576 , 51.322285 , 11.91716 ],\n",
" [48.96941 , 82.46196 , 25.967403 ],\n",
" [50.50267 , 2.4781375, 21.41084 ],\n",
" [53.843285 , 25.631973 , 56.539078 ],\n",
" [52.832363 , 36.9268 , 77.24441 ],\n",
" [51.26645 , 67.138885 , 20.704544 ],\n",
" [52.62428 , 76.45388 , 38.845867 ],\n",
" [50.89703 , 88.23891 , 45.985302 ],\n",
" [54.135838 , 8.818527 , 3.912562 ],\n",
" [52.158115 , 27.671795 , 7.758117 ],\n",
" [52.514416 , 29.022572 , 35.614056 ],\n",
" [51.625374 , 45.392643 , 15.056403 ],\n",
" [53.55102 , 54.00469 , 25.068209 ],\n",
" [52.14452 , 70.82117 , 64.266464 ],\n",
" [49.842625 , 82.43903 , 13.811695 ],\n",
" [51.803635 , 85.99478 , 16.895424 ],\n",
" [52.151424 , 45.40848 , 24.835764 ],\n",
" [54.046318 , 48.34163 , 13.283496 ],\n",
" [53.502277 , 53.66037 , 83.55736 ],\n",
" [53.77419 , 78.25886 , 59.277756 ],\n",
" [56.585304 , 6.6131396, 24.795723 ],\n",
" [54.175972 , 23.976437 , 29.02869 ],\n",
" [55.818203 , 29.279238 , 16.472105 ],\n",
" [54.246964 , 28.935507 , 24.053856 ],\n",
" [53.569843 , 53.348003 , 14.477694 ],\n",
" [53.590664 , 57.006264 , 26.073338 ],\n",
" [56.462223 , 3.2316732, 19.256979 ],\n",
" [56.83358 , 5.724794 , 8.223502 ],\n",
" [54.9847 , 12.1972885, 29.212175 ],\n",
" [55.750454 , 19.003325 , 2.8545864],\n",
" [56.056496 , 25.636187 , 45.721817 ],\n",
" [54.474648 , 34.697197 , 29.970778 ],\n",
" [56.602028 , 32.263657 , 67.62181 ],\n",
" [53.554962 , 76.66312 , 17.864351 ],\n",
" [56.05309 , 79.51415 , 42.927326 ],\n",
" [54.193836 , 81.978516 , 22.035086 ],\n",
" [54.180126 , 88.25802 , 50.65235 ],\n",
" [57.400646 , 27.631517 , 11.518268 ],\n",
" [54.554127 , 48.25213 , 24.164501 ],\n",
" [57.90638 , 80.56416 , 53.616657 ],\n",
" [54.5232 , 30.269846 , 34.298344 ],\n",
" [57.396935 , 42.440304 , 80.49458 ],\n",
" [56.185688 , 64.76287 , 23.936714 ],\n",
" [58.65987 , 64.3527 , 71.43539 ],\n",
" [56.826015 , 75.2197 , 22.748318 ],\n",
" [56.483547 , 77.93839 , 29.558249 ],\n",
" [60.551277 , 22.947561 , 8.833019 ],\n",
" [57.386032 , 58.05215 , 80.00785 ],\n",
" [58.431293 , 80.39552 , 47.56036 ],\n",
" [59.35114 , 42.10503 , 27.740356 ],\n",
" [61.778034 , 50.112427 , 79.744865 ],\n",
" [59.510567 , 71.418915 , 59.936607 ],\n",
" [59.652275 , 15.642144 , 5.3892994],\n",
" [58.148083 , 18.273296 , 27.334505 ],\n",
" [61.52146 , 22.237654 , 21.837057 ],\n",
" [61.3817 , 27.62247 , 53.458073 ],\n",
" [62.673817 , 29.271599 , 42.150547 ],\n",
" [59.461212 , 71.49436 , 39.69085 ],\n",
" [62.88566 , 8.974723 , 15.458117 ],\n",
" [62.260296 , 12.968527 , 23.231073 ],\n",
" [60.65359 , 33.855984 , 33.76867 ],\n",
" [59.741676 , 35.887066 , 70.59933 ],\n",
" [63.726467 , 54.52029 , 28.972319 ],\n",
" [61.340107 , 61.929672 , 30.38674 ],\n",
" [63.27536 , 30.112036 , 58.531403 ],\n",
" [63.28456 , 57.86164 , 73.930115 ],\n",
" [62.0791 , 67.18279 , 35.08083 ],\n",
" [63.30002 , 12.666501 , 10.499846 ],\n",
" [64.12408 , 41.070126 , 71.657005 ],\n",
" [63.05831 , 70.9414 , 44.614227 ],\n",
" [63.5037 , 21.075468 , 16.44134 ],\n",
" [66.05027 , 34.41544 , 61.8085 ],\n",
" [63.323097 , 70.56998 , 56.66402 ],\n",
" [64.93313 , 35.53218 , 35.113873 ],\n",
" [67.357414 , 45.166336 , 32.174694 ],\n",
" [66.96647 , 48.384304 , 71.17552 ],\n",
" [65.45087 , 64.09783 , 64.424194 ],\n",
" [67.75421 , 67.16673 , 44.045918 ],\n",
" [66.205505 , 53.919525 , 71.49664 ],\n",
" [65.3879 , 64.682846 , 35.848347 ],\n",
" [68.30203 , 51.30069 , 32.31369 ],\n",
" [67.70782 , 31.977118 , 47.249176 ],\n",
" [68.078896 , 68.06901 , 51.401676 ],\n",
" [70.75834 , 37.198 , 57.68462 ],\n",
" [70.14138 , 60.01469 , 61.631668 ],\n",
" [70.70051 , 59.431976 , 38.846725 ],\n",
" [71.8551 , 43.58004 , 38.21161 ],\n",
" [73.07746 , 46.18092 , 59.48887 ],\n",
" [72.30189 , 38.42125 , 47.38977 ],\n",
" [73.13591 , 40.924408 , 54.43151 ],\n",
" [74.45624 , 53.596233 , 56.166843 ],\n",
" [73.153595 , 59.058285 , 45.636127 ],\n",
" [72.64472 , 60.864326 , 53.24366 ],\n",
" [74.62288 , 44.928932 , 46.62226 ],\n",
" [74.52247 , 53.835606 , 44.56664 ]], dtype=float32),\n",
" array([[ 0, 1, 2],\n",
" [ 3, 2, 1],\n",
" [ 2, 4, 5],\n",
" ...,\n",
" [190, 191, 187],\n",
" [190, 187, 184],\n",
" [191, 189, 187]], dtype=int64))"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"simplified_surface2 = nppas.decimate_quadric(smoothed_surface, fraction=0.01)\n",
"simplified_surface2"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "8af2b93a-39ab-4c98-9c0a-cf978e225e26",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"\n",
" \n",
" | \n",
"\n",
"nppas.SurfaceTuple \n",
"\n",
"origin (z/y/x) | [0. 0. 0.] | \n",
"center of mass(z/y/x) | 49.941,45.866,38.671 | \n",
"scale(z/y/x) | 1.000,1.000,1.000 | \n",
"bounds (z/y/x) | 25.548...75.905 3.858...93.107 3.380...86.408 | \n",
"average size | 33.976 | \n",
"number of vertices | 22 | \n",
"number of faces | 38 | \n",
"\n",
" \n",
"\n",
" | \n",
"
\n",
"
"
],
"text/plain": [
"(array([[33.757137 , 64.358246 , 34.276196 ],\n",
" [25.547668 , 38.82257 , 48.193726 ],\n",
" [30.32451 , 63.011837 , 62.722202 ],\n",
" [42.62229 , 53.57565 , 86.408264 ],\n",
" [33.829075 , 42.52296 , 29.96235 ],\n",
" [38.116444 , 25.642138 , 52.785957 ],\n",
" [50.324127 , 93.10659 , 49.48144 ],\n",
" [47.212494 , 77.502106 , 38.622364 ],\n",
" [46.86817 , 3.8584783, 27.996782 ],\n",
" [50.192207 , 31.42654 , 29.835615 ],\n",
" [34.178185 , 13.580581 , 9.847408 ],\n",
" [47.122635 , 25.268085 , 4.1269727],\n",
" [50.35337 , 50.52534 , 23.139013 ],\n",
" [60.230705 , 8.142264 , 3.3798215],\n",
" [57.95781 , 43.667496 , 84.8449 ],\n",
" [49.871075 , 86.83135 , 12.335193 ],\n",
" [68.865906 , 29.205528 , 51.1599 ],\n",
" [61.517162 , 71.63598 , 60.14378 ],\n",
" [62.660267 , 17.478125 , 26.288834 ],\n",
" [63.26116 , 66.56682 , 33.362133 ],\n",
" [67.98476 , 43.71234 , 30.761446 ],\n",
" [75.90502 , 58.62036 , 51.077282 ]], dtype=float32),\n",
" array([[ 0, 1, 2],\n",
" [ 3, 2, 1],\n",
" [ 1, 0, 4],\n",
" [ 1, 5, 3],\n",
" [ 4, 5, 1],\n",
" [ 0, 6, 7],\n",
" [ 6, 0, 2],\n",
" [ 8, 9, 10],\n",
" [ 9, 11, 10],\n",
" [ 5, 4, 9],\n",
" [12, 4, 0],\n",
" [ 8, 10, 13],\n",
" [14, 3, 5],\n",
" [15, 0, 7],\n",
" [ 4, 12, 9],\n",
" [12, 0, 15],\n",
" [11, 13, 10],\n",
" [16, 14, 5],\n",
" [17, 6, 2],\n",
" [ 9, 8, 18],\n",
" [16, 5, 9],\n",
" [ 3, 17, 2],\n",
" [15, 19, 12],\n",
" [19, 15, 7],\n",
" [13, 11, 9],\n",
" [ 6, 19, 7],\n",
" [ 9, 20, 16],\n",
" [12, 20, 9],\n",
" [14, 17, 3],\n",
" [12, 19, 20],\n",
" [ 8, 13, 18],\n",
" [18, 13, 9],\n",
" [19, 6, 17],\n",
" [17, 21, 19],\n",
" [21, 17, 14],\n",
" [19, 21, 20],\n",
" [21, 14, 16],\n",
" [20, 21, 16]], dtype=int64))"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"simplified_surface2 = nppas.decimate_quadric(smoothed_surface, fraction=0.001)\n",
"simplified_surface2"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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",
"version": "3.9.15"
},
"vscode": {
"interpreter": {
"hash": "bffd3f721d7127ef2391d1b3b329910e3ca6998c35d437db3070140f7f84cfb6"
}
}
},
"nbformat": 4,
"nbformat_minor": 5
}