# Correct way to use Selection (Lasso, Box) on an Image

**URL:** <https://discourse.bokeh.org/t/correct-way-to-use-selection-lasso-box-on-an-image/7552>\
**Category:** Community Support\
**Tags:** bokehjs, server\
**Created:** [April 2, 2021, 12:57pm UTC](https://discourse.bokeh.org/t/correct-way-to-use-selection-lasso-box-on-an-image/7552 "2021-04-02T12:57:28Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Bryan](https://discourse.bokeh.org/user_avatar/discourse.bokeh.org/bryan/32/3625_2.png) [@Bryan](https://discourse.bokeh.org/u/Bryan)\
**Post date:** [April 3, 2021, 8:42pm UTC](https://discourse.bokeh.org/t/correct-way-to-use-selection-lasso-box-on-an-image/7552/3 "2021-04-03T20:42:47Z")

</div>

As a concrete example of the difficulties: lasso selections on images are especially problematic. Suppose you have a 2000x2000 pixel image. That is 4 million individual indices. How do you compactly represent a lasso selection on an image? In general, a lasso selection region can have a completely arbitrary (and even disjoint) shape, so I am not sure you can do anything other than enumerate all the individual indices inside. But with images that could _very_ easily grow to lists of hundreds of thousand or millions (or more) and that would have extremely bad performance implications.

As an alternative, you can get the raw [selection geometry events](https://docs.bokeh.org/en/latest/docs/reference/events.html#bokeh.events.SelectionGeometry) and do whatever you need to do based on those. Ultimately that may be the best/only bet, certainly at least for now. But especially if you require lasso selections. I think we could potentially support point and rect and line selections on images, but I am skeptical about lasso support ever being feasible.

---

_[View the full topic](https://discourse.bokeh.org/t/correct-way-to-use-selection-lasso-box-on-an-image/7552)._
