# Getting index to retrieve image

**URL:** <https://forum.tiledb.com/t/getting-index-to-retrieve-image/683>\
**Category:** Uncategorized\
**Created:** [April 25, 2024, 3:16pm UTC](https://forum.tiledb.com/t/getting-index-to-retrieve-image/683 "2024-04-25T15:16:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tim\_Turner](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.tiledb.com/tim_turner/32/328_2.png) [@Tim\_Turner](https://forum.tiledb.com/u/Tim_Turner)\
**Post date:** [April 25, 2024, 3:16pm UTC](https://forum.tiledb.com/t/getting-index-to-retrieve-image/683/1 "2024-04-25T15:16:06Z")

</div>

I am trying to understand what is returned when I write/ingest image into tiledb. The docs say an index is not returned.

In this tiledb cloud ingestion example it also doesn’t return anything. How do I retrieve it later?

> **[TileDB](https://cloud.tiledb.com/notebooks/details/PathoPixel-Innov-Demo/cb73883b-e726-4cbc-b946-3b2dd112bedd/preview?_gl=1*15c7ur1*_ga*MTQ2NTM1NDk1MC4xNzA0Njc5NjE5*_ga_9R31D7DKGS*MTcxNDA1NzQ5MS4yMy4xLjE3MTQwNTc4MTYuMzEuMC4w)**
>
> Data management made universal

---

<div class="post-metadata">

**Author:** ![spencerseale](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.tiledb.com/spencerseale/32/340_2.png) [@spencerseale](https://forum.tiledb.com/u/spencerseale)\
**Post date:** [April 25, 2024, 4:03pm UTC](https://forum.tiledb.com/t/getting-index-to-retrieve-image/683/2 "2024-04-25T16:03:07Z")

</div>

Hey @Tim_Turner,

Thank you for the question!

Across TileDB language and domain-specific APIs (such as `tiledb.bioimg`), TileDB asset creations write to a specified URI. That URI is environment agnostic, so the URI could point to your local, a cloud object store, or your TileDB Cloud account. The return is usually `NoneType` and the contents exist on disk at the requested destination.

To subsequently view the contents of the TileDB array(s) you just ingested, you would open up that array and view it. In Python, you can do this via `tiledb` or `tiledb.bioimg`. You can also view the contents in TileDB Cloud if you have signed up for an account there.

Think of the _writing_ as an ingestion into a database on disk. That is a process of its own and in many cases a separate task from the actual viewing/analysis.

In your particular case, assuming you’ve written your image into a TileDB array on your local, retrieve it via:

> **[BioImaging | TileDB Embedded Docs](https://docs.tiledb.com/main/integrations-and-extensions/bioimaging#openslide-python-api)**

```auto
from tiledb.bioimg.openslide import TileDBOpenSlide

# Construct OpenSlide API wrapper
img = TileDBOpenSlide(tiledb_image_path)

# Read image data at `level`
# from starting `(x0,y0)` location to
# `(x + size_x, y + size_y)`
# Returns NumPy array
data = img.read_level((x0, y0), level, (size_x, size_y))

# when done
img.close()

```

Because these assets are TileDB arrays and TileDB groups, you can alse use the open-source `tiledb` API to view particular arrays that constitute your ingested image!  
[https://docs.tiledb.com/main/how-to/arrays/reading-arrays/reading-the-array-schema](https://docs.tiledb.com/main/how-to/arrays/reading-arrays/reading-the-array-schema)

Let me know if you have any other questions!  
Spencer

---

<div class="post-metadata">

**Author:** ![Tim\_Turner](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.tiledb.com/tim_turner/32/328_2.png) [@Tim\_Turner](https://forum.tiledb.com/u/Tim_Turner)\
**Post date:** [August 7, 2024, 8:10pm UTC](https://forum.tiledb.com/t/getting-index-to-retrieve-image/683/3 "2024-08-07T20:10:28Z")

</div>

> [@spencerseale](#):
>
> `img = TileDBOpenSlide(tiledb_image_path)`

In your code sample, you do not show how you set the tiledb\_image\_path.

I already have a local tiledb database and have figured out how to create stores with specific schemas and read and write from them. Trying to ingest/write some tiff images, store pre-made ids and names for each image, then read them back out…

---

<div class="post-metadata">

**Author:** ![spencerseale](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.tiledb.com/spencerseale/32/340_2.png) [@spencerseale](https://forum.tiledb.com/u/spencerseale)\
**Post date:** [August 7, 2024, 8:55pm UTC](https://forum.tiledb.com/t/getting-index-to-retrieve-image/683/4 "2024-08-07T20:55:09Z")

</div>

Hi @Tim_Turner,

`tiledb_image_path` in my example is just a path to a local image represented as a TileDB Group (containing arrays) written to disk. This could be something like `tiledb_image_path = 'tiledb_images/my_local_bioimage'` or a AWS S3 URI. This is the constructor you would use once you have converted your tiff images into a TileDB arrays and want to interact with them.

Stepping back a step, if you’d like to convert your TIFF images into TileDB arrays see these [examples](https://github.com/TileDB-Inc/TileDB-BioImaging/tree/main?tab=readme-ov-file#examples).

Generally the flow for our `tiledb-bioimg` API is first convert your raw images via one of our converters and then direct the `TileDBOpenSlide` constructor to the URIs where those images were ingested. From there you can call various methods to query regions etc.

Let me know if this sparks any additional questions,  
Spencer  
TileDB Team

---

<div class="post-metadata">

**Author:** ![Tim\_Turner](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.tiledb.com/tim_turner/32/328_2.png) [@Tim\_Turner](https://forum.tiledb.com/u/Tim_Turner)\
**Post date:** [August 8, 2024, 2:41am UTC](https://forum.tiledb.com/t/getting-index-to-retrieve-image/683/5 "2024-08-08T02:41:40Z")

</div>

Thanks I will be digging into this this evening and rest of the week…will let you know if I have questions.
