# Local OME-NGFF Demo

### Demo

    library(pizzarr)

    # The path to the root of the OME-NGFF Zarr store.
    root <- pizzarr_sample("dog.ome.zarr")

    # Open the OME-NGFF as a DirectoryStore.
    store <- DirectoryStore$new(root)
    g <- zarr_open_group(store)

    # Using the OME metadata, get the path to the first resolution of the image pyramid.
    attrs <- g$get_attrs()$to_list()
    resolution_paths <- attrs$multiscales[[1]]$datasets[[1]]$path
    first_resolution <- resolution_paths[[1]]

    # Load the 3-dimensional array of RGB pixels (as a ZarrArray instance).
    zarr_arr <- g$get_item(first_resolution)

    print(zarr_arr$get_shape())
    # [1]   3 500 750

    # Load the 3-dimensional array of RGB pixels (as a NestedArray instance).
    nested_arr <- zarr_arr$get_item("...")

    # Extract the NestedArray contents as a base R array.
    arr <- nested_arr$data

    # Plot the RGB image using base R rasterImage().
    dm <- dim(arr)
    plot.new()
    plot.window(c(0, dm[3]), c(0, dm[2]), asp = 1)
    rasterImage(aperm(arr, c(2, 3, 1)) / 255, 0, 0, dm[3], dm[2])