Significant performance degradation with rasterize(image) * Overlay(objects)?
See original GitHub issueWondering if this is expected given the data I’m working with.
Let’s say I have a 2048x2048 image that I have localized ~150 objects in. I then go to plot this image, and because it is large, I rasterize()
it with Datashader. Each object is indicated on top of this raster with an hv.Ellipse
(which are compiled into an hv.Overlay
).
Any sort of zooming / scrolling redraws on the raster are then immensely slowed down if I overlay the rasterized image with the ellipse overlay.
Skeleton example:
hv_ellipses = [
hv.Ellipse(centroid[1], centroid[0], 4 * centroid[2])
for centroid in centroids
]
rasterize(hv.Image(image, bounds=(0, 0, image.shape[1], image.shape[0])).options(
title_format=f'Movie frame with identified objects',
colorbar=True
)) * hv.Overlay(hv_ellipses)
I’ve noted that the slowdown scales with the number of ellipses.
Do you guys think this is expected given the number of ellipses I am drawing? I just realized that in this particular case, I could just draw a scatter plot with transparent faces and circular markers, but I guess I was wondering if more in general (like if I wanted to draw many lines for object trajectories, for example) it is untenable to have many objects overlaid on top of a raster and achieve good performance on raster redraws in response to axes changes.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (5 by maintainers)
Top GitHub Comments
I can reproduce a pretty large slow down caused by ranges being computed for all 150 ROIs each time, fairly inefficiently. In general it’s probably a good idea to replace
hv.Overlay(hv_ellipses)
withhv.Path(hv_ellipses)
but we should be able to achieve a major speedup using Overlays too.The main recommendation here is still to combine all the polygons into a single element but the overlay based approach is now also much faster so I’ll close this.