as.Roi: Accessory functions for class "Roi"

View source: R/ROI-methods.R

as.RoiR Documentation

Accessory functions for class "Roi"

Description

Convert an Image object into an Roi object

Usage

as.Roi(img, ...)

as.ROI(img, ...)

Arguments

img

object of class Image

resize

re-assign "loc" slot if TRUE

Details

This adds the class "Roi" to Image objects and places the dimensions of the image in the slot named "loc." Roi objects passed as an argument will be considered an error unless resize = TRUE.

Value

Roi object of the same dimensions as the

Examples


# Region of interest from sample image in EBImage package
  birds <- readImage(system.file("images", "sample-color.png", package="EBImage"))
  roi <- getROI(birds, 160, 255, w = 200, h = 240)

# Examine effect on Image object
  attr(birds, "loc") # nothing here
  attr(as.Roi(birds), "loc") # returned an Roi

# Examine effect on 'Roi'
  pp <- attr(roi, "loc") # original
  roi2 <- resize(roi, w = 400)
  pp2 <- attr(roi2, "loc") 
  identical(pp, pp2) # re-sizing the image has no effect on 'loc'

# Compare with resize = TRUE
  attr(roi, "loc") 
  attr(as.Roi(roi, resize = TRUE), "loc") 


ornelles/EBImageExtra documentation built on Aug. 10, 2022, 11:44 p.m.