Skip to content

Custom delayed operations #127

@Artur-man

Description

@Artur-man

Dear @hpages,

I am working on devising lazy image transformations for HelenaLC/spatialdataR#162.

I was wondering if it is possible to use showtree or .rec_showtree methods (or similar methods) for external classes that facilitate delayed operations.

I have tried below, but it requires me to define additional methods for these classes that contain DelayedOp:

setClass(
  "DelayedAffineSeed",
  contains = "DelayedOp",
  slots = c(
    seed = "ANY",
    dim = "integer",
    dimnames = "list",
    m = "matrix",
    axes = "character",
    filter = "character",
    bg.col = "character",
    antialias = "logical",
    trace = "logical"
  )
)

setClass(
  "DelayedTranslateSeed",
  contains = "DelayedOp",
  slots = c(
    seed = "ANY",
    dim = "integer",
    dimnames = "list",
    shift = "numeric",
    axes = "character"
  )
)
# save as zarr
td <- tempfile(fileext = ".zarr")
delayed_img <- writeZarrArray(x = EBImage::imageData(img), zarr_path = td) 

# affine
rotated_delayed_img <- lazy_affine(delayed_img, m = m, filter = "bilinear")

# translate
translate_delayed_img <- lazy_translate(rotated_delayed_img, shift = c(100,200))

# subset
subset_delayed_img <- translate_delayed_img[100:200, 100:200]
> subset_delayed_img@seed
101x101 double: Subset
└─ 1024x512 double: DelayedTranslateSeed object
Error: unable to find an inherited method for function ‘getArrayElement’ for signature ‘x = "DelayedTranslateSeed"’

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions