classify_img: Classify Images

Description Usage Arguments Examples

View source: R/workflow.R

Description

Classify Images

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
classify_img(
  classifier,
  path = NULL,
  img = NULL,
  feature_frame = NULL,
  filter_widths,
  shape_sizes,
  class_highlight = NULL,
  dims = NULL,
  preprocess_fun_img = NULL
)

Arguments

classifier

an object returned from ranger to use as a classifier

path

the path of the image to classify

img

an EBImage image

feature_frame

a data frame with the calculated features

filter_widths

filters widths to use when calculating features

class_highlight

classifier to show as white in the final mask

dims

dimensions of the images to classify, only required if using the feature_frmae interface

This classifier by default will fall back to file, trying in order of priority a 'feature_frame' > 'img' > 'path', please note that since the 'feature_frame' does not contain the dimensions of the image, it has to be provided in the 'dims' argument in addition.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
params_df <- tibble::tibble(
    file = c(
        system.file(
            "extdata", "tiny_4T1-shNT-1_layer1.png",
            package = "clasifierrr"),
        system.file(
            "extdata", "tiny_4T1-shNT-1_layer2.png",
            package = "clasifierrr")),
    classif = c("spheroid", "bg"),
    related_file = system.file(
        "extdata", "tiny_4T1-shNT-1.png",
        package = "clasifierrr")
    )
trainset <- build_train_multi(
    params_df, filter_widths = c(3, 5, 15),
    shape_sizes = c(21, 51))
trainset$pixel_class <- trainset$pixel_class == "spheroid"
model_simple_glm <- glm(pixel_class~.,data = trainset, family = binomial(link = "logit"))
class_img <- classify_img(
    model_simple_glm, path = params_df[[3]][[1]],
    filter_widths = c(3, 5, 15), shape_sizes = c(21, 51))
# plot(as.raster(class_img))

jspaezp/clasifierrr documentation built on March 2, 2020, 11:20 a.m.