question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Significant performance degradation with rasterize(image) * Overlay(objects)?

See original GitHub issue

Wondering 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:closed
  • Created 5 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
philippjfrcommented, Aug 19, 2018

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) with hv.Path(hv_ellipses) but we should be able to achieve a major speedup using Overlays too.

1reaction
philippjfrcommented, Nov 26, 2018

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rasterisation - Wikipedia
Rasterization may refer to the technique of drawing 3D models, or the conversion of 2D rendering primitives such as polygons, line segments into...
Read more >
Recognizing Vector Graphics without Rasterization
We propose an efficient vector graphics based recognition method without rasterization, and takes textual document of the vector graphics as input.
Read more >
rasterio.features module - Read the Docs
Functions for working with features in a raster dataset. ... mask is intended for use as a numpy mask, where pixels that overlap...
Read more >
Working with large data using datashader — HoloViews v1.15.3
... dynspread, spread from holoviews.operation.datashader import rasterize, ... With much larger datasets, these issues will quickly make it impossible to ...
Read more >
Combining Multiple True 3D Ultrasound Image Volumes ...
Reregistering 3DUS images before rasterization significantly increased the consistency of image content in overlapping regions. The average magnitude of ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found