deephealthproject / ecvl

European Computer Vision Library (ECVL). A general-purpose computer vision library developed to support healthcare use cases within the DeepHealth project, with the aim of facilitating the integration of existing state-of-the-art libraries.
https://deephealthproject.github.io/ecvl
MIT License
17 stars 1 forks source link

Multiple OpenSlideRead calls performance #41

Closed mdrio closed 2 years ago

mdrio commented 2 years ago

Hi, I need to read small regions from a slide multiple times. I noticed that calling many times OpenSlideRead is very slow compared to the equivalent call of OpenSlide read_region.

Here is a basic example in Python:

In [4]: n_patches = 100

In [5]: patch_size = 256

In [6]: %time _ = [ecvl.OpenSlideRead(slide_fn,0, (i, i, patch_size, patch_size)) for i in range(0, n_patches*patch_size, patch_size)]
CPU times: user 5.32 s, sys: 111 ms, total: 5.43 s
Wall time: 5.44 s

In [10]: %time _ = [ os_slide.read_region((i, i), 0, (patch_size, patch_size)) for i in range(0, n_patches*patch_size, patch_size)]
CPU times: user 50.2 ms, sys: 10.1 ms, total: 60.3 ms
Wall time: 59.2 ms

Actually my use case is more complex and reading larger regions at once and then applying some filter is non suitable.

Is there a way to read multiple regions with similar performance of OpenSlide in ECVL?

lauracanalini commented 2 years ago

Hi @mdrio, I think it's because in our OpenSlideRead we also open and close the file, and in multiple reading this will cause a great overhead. We will provide a different interface to extract regions of an openslide image as soon as possible. Thank you!

mdrio commented 2 years ago

Ok, thanks!

lauracanalini commented 2 years ago

Hi @mdrio, we have changed the interface between OpenSlide and ECVL. In the master branch, you can check the new way to load with OpenSlide and read region in ECVL Images in the _exampleopenslide. You can also compute the performance and see that now they are slightly higher (for the conversion to ECVL image) but comparable.

simleo commented 2 years ago

This sounds great @lauracanalini! Can you make a new ECVL release so we can update the bindings? Thanks again :slightly_smiling_face:

mdrio commented 2 years ago

great, thanks!

simleo commented 2 years ago

Can you make a new ECVL release so we can update the bindings?

Could you please include https://github.com/deephealthproject/ecvl/pull/43 in the release? Thanks!

lauracanalini commented 2 years ago

Sure!

lauracanalini commented 2 years ago

This sounds great @lauracanalini! Can you make a new ECVL release so we can update the bindings? Thanks again 🙂

ECVL 1.0.1 released ✌