mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-08-02 03:42:50 +08:00
Add example of rendering pointclouds with a background color.
Summary: Add cells to the rendering_colored_points tutorial showing how to initialize a renderer and compositor that will render pointclouds with a background color. {F333731292} {F334136799} Reviewed By: nikhilaravi Differential Revision: D23632503 fbshipit-source-id: e9ce0178b41e74baf912bd82ca1db41b680fc68f
This commit is contained in:
parent
872ff8c796
commit
61121b9f2c
@ -62,7 +62,7 @@
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"from skimage.io import imread\n",
|
||||
"\n",
|
||||
"# Util function for loading point clouds\n",
|
||||
"# Util function for loading point clouds|\n",
|
||||
"import numpy as np\n",
|
||||
"\n",
|
||||
"# Data structures and functions for rendering\n",
|
||||
@ -187,6 +187,32 @@
|
||||
"plt.axis(\"off\");"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"We will now modify the **renderer** to use **alpha compositing** with a set background color. "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"renderer = PointsRenderer(\n",
|
||||
" rasterizer=PointsRasterizer(cameras=cameras, raster_settings=raster_settings),\n",
|
||||
" # Pass in background_color to the alpha compositor, setting the background color \n",
|
||||
" # to the 3 item tuple, representing rgb on a scale of 0 -> 1, in this case blue\n",
|
||||
" compositor=AlphaCompositor(background_color=(0, 0, 1))\n",
|
||||
")\n",
|
||||
"images = renderer(point_cloud)\n",
|
||||
"plt.figure(figsize=(10, 10))\n",
|
||||
"plt.imshow(images[0, ..., :3].cpu().numpy())\n",
|
||||
"plt.grid(\"off\")\n",
|
||||
"plt.axis(\"off\");"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
@ -234,6 +260,32 @@
|
||||
"plt.grid(\"off\")\n",
|
||||
"plt.axis(\"off\");"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"We will now modify the **renderer** to use **weighted compositing** with a set background color. "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"renderer = PointsRenderer(\n",
|
||||
" rasterizer=PointsRasterizer(cameras=cameras, raster_settings=raster_settings),\n",
|
||||
" # Pass in background_color to the norm weighted compositor, setting the background color \n",
|
||||
" # to the 3 item tuple, representing rgb on a scale of 0 -> 1, in this case red\n",
|
||||
" compositor=NormWeightedCompositor(background_color=(1,0,0))\n",
|
||||
")\n",
|
||||
"images = renderer(point_cloud)\n",
|
||||
"plt.figure(figsize=(10, 10))\n",
|
||||
"plt.imshow(images[0, ..., :3].cpu().numpy())\n",
|
||||
"plt.grid(\"off\")\n",
|
||||
"plt.axis(\"off\");"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user