{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# How to compute descriptors?" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import geomstats.backend as gs\n", "\n", "from geomfum.dataset import NotebooksDataset\n", "from geomfum.descriptor.spectral import HeatKernelSignature, WaveKernelSignature\n", "from geomfum.shape import TriangleMesh" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Load a mesh](00_load_mesh_from_file.ipynb)." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "dataset = NotebooksDataset()\n", "mesh = TriangleMesh.from_file(dataset.get_filename(\"cat-00\"))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Set Laplace eigenbasis](./01_mesh_laplacian_spectrum.ipynb)." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mesh.laplacian.find_spectrum(spectrum_size=10, set_as_basis=True)\n", "\n", "mesh.basis" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Heat kernel signature" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(3, 7207)" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "heat_signature = HeatKernelSignature.from_registry(\n", " scale=True, n_domain=3, use_landmarks=False\n", ")\n", "\n", "hsign = heat_signature(mesh)\n", "\n", "hsign.shape" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Use [landmarks](./06_landmarks.ipynb)." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(12, 7207)" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mesh.set_landmarks(gs.array([3177, 7178, 6565, 5472]))\n", "\n", "heat_signature.use_landmarks = True\n", "\n", "hsign = heat_signature(mesh)\n", "\n", "hsign.shape" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Tip: other descriptors work in the same manner." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Wave kernel signature" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(5, 7207)" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "wave_signature = WaveKernelSignature.from_registry(n_domain=5)\n", "\n", "wsign = wave_signature(mesh)\n", "\n", "wsign.shape" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Further reading\n", "\n", "* [How to create a descriptor pipeline?](./04_descriptor_pipeline.ipynb)\n", "\n", "* [How to use feature exactors for descriptors](./05_descriptors_with_feat_extractors.ipynb)\n", "\n", "* [How to set landmarks?](./06_landmarks.ipynb)" ] } ], "metadata": { "kernelspec": { "display_name": "py12", "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.12.3" } }, "nbformat": 4, "nbformat_minor": 2 }