Skip to content

Commit 61121b9

Browse files
Amitav Baruahfacebook-github-bot
Amitav Baruah
authored andcommitted
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
1 parent 872ff8c commit 61121b9

File tree

1 file changed

+53
-1
lines changed

1 file changed

+53
-1
lines changed

docs/tutorials/render_colored_points.ipynb

+53-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"import matplotlib.pyplot as plt\n",
6363
"from skimage.io import imread\n",
6464
"\n",
65-
"# Util function for loading point clouds\n",
65+
"# Util function for loading point clouds|\n",
6666
"import numpy as np\n",
6767
"\n",
6868
"# Data structures and functions for rendering\n",
@@ -187,6 +187,32 @@
187187
"plt.axis(\"off\");"
188188
]
189189
},
190+
{
191+
"cell_type": "markdown",
192+
"metadata": {},
193+
"source": [
194+
"We will now modify the **renderer** to use **alpha compositing** with a set background color. "
195+
]
196+
},
197+
{
198+
"cell_type": "code",
199+
"execution_count": null,
200+
"metadata": {},
201+
"outputs": [],
202+
"source": [
203+
"renderer = PointsRenderer(\n",
204+
" rasterizer=PointsRasterizer(cameras=cameras, raster_settings=raster_settings),\n",
205+
" # Pass in background_color to the alpha compositor, setting the background color \n",
206+
" # to the 3 item tuple, representing rgb on a scale of 0 -> 1, in this case blue\n",
207+
" compositor=AlphaCompositor(background_color=(0, 0, 1))\n",
208+
")\n",
209+
"images = renderer(point_cloud)\n",
210+
"plt.figure(figsize=(10, 10))\n",
211+
"plt.imshow(images[0, ..., :3].cpu().numpy())\n",
212+
"plt.grid(\"off\")\n",
213+
"plt.axis(\"off\");"
214+
]
215+
},
190216
{
191217
"cell_type": "markdown",
192218
"metadata": {},
@@ -234,6 +260,32 @@
234260
"plt.grid(\"off\")\n",
235261
"plt.axis(\"off\");"
236262
]
263+
},
264+
{
265+
"cell_type": "markdown",
266+
"metadata": {},
267+
"source": [
268+
"We will now modify the **renderer** to use **weighted compositing** with a set background color. "
269+
]
270+
},
271+
{
272+
"cell_type": "code",
273+
"execution_count": null,
274+
"metadata": {},
275+
"outputs": [],
276+
"source": [
277+
"renderer = PointsRenderer(\n",
278+
" rasterizer=PointsRasterizer(cameras=cameras, raster_settings=raster_settings),\n",
279+
" # Pass in background_color to the norm weighted compositor, setting the background color \n",
280+
" # to the 3 item tuple, representing rgb on a scale of 0 -> 1, in this case red\n",
281+
" compositor=NormWeightedCompositor(background_color=(1,0,0))\n",
282+
")\n",
283+
"images = renderer(point_cloud)\n",
284+
"plt.figure(figsize=(10, 10))\n",
285+
"plt.imshow(images[0, ..., :3].cpu().numpy())\n",
286+
"plt.grid(\"off\")\n",
287+
"plt.axis(\"off\");"
288+
]
237289
}
238290
],
239291
"metadata": {

0 commit comments

Comments
 (0)