{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Render a depth image\n\nPlot a depth image as viewed from a camera overlooking the \\\"hills\\\"\nexample mesh.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\n\nimport pyvista as pv\nfrom pyvista import examples\n\n# Load an interesting example of geometry\nmesh = examples.load_random_hills()\n\n# Establish geometry within a pv.Plotter()\np = pv.Plotter()\np.add_mesh(mesh, color=True)\np.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Record depth image without and with a custom fill value\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "zval = p.get_image_depth()\nzval_filled_by_42s = p.get_image_depth(fill_value=42.0)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Visualize depth images\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "plt.figure()\nplt.imshow(zval)\nplt.colorbar(label='Distance to Camera')\nplt.title('Depth image')\nplt.xlabel('X Pixel')\nplt.ylabel('Y Pixel')\nplt.show()"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "plt.figure()\nplt.imshow(zval_filled_by_42s)\nplt.title('Depth image (custom fill_value)')\nplt.colorbar(label='Distance to Camera')\nplt.xlabel('X Pixel')\nplt.ylabel('Y Pixel')\nplt.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",
      "version": "3.12.2"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}