filter2.prepared: Calculate spatial filtering on precomputed objects

Description Usage Arguments Functions Examples

View source: R/filter2.R

Description

Calculate spatial filtering on precomputed objects

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
prep_filter.img(
  x,
  filter_dims,
  boundary = c("circular", "replicate"),
  val = NULL
)

prep_filter.filter(filter, dim_x_proc)

filter2.prepared(
  prep_x,
  raw_x = prep_x,
  fft_x = fftwtools::fftw2d(prep_x),
  dims_x,
  dims_x_orig,
  prep_filter,
  x_dimnames = NULL,
  boundary = c("circular", "replicate")
)

Arguments

boundary

any of "circular", "replicate", or a numeric value to use

prep_x

a prepared image file

raw_x

non-prepared image file, defaults to raw_x

fft_x

output of the prepared image in 'fftwtools::fftw2d'

dims_x

dimensions output from the image processing

dims_x_orig

dimension of the original image file

prep_filter

prepared filtering function, output of 'prep_filter.filter'

x_dimnames

dimension names of the original image file

Functions

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
f = system.file("images", "sample.png", package="EBImage")
img = EBImage::readImage(f)
my_filter <- EBImage::makeBrush(31, "gaussian", sigma = 4)

prepd_filt <- prep_filter.filter(filter = my_filter, dim_x = dim(img))
fft_img <- fftwtools::fftw2d(img)

# Image preprocessing can be skiped if using circular to handle boundries...
filtered_img <- filter2.prepared(
  prep_x = img,
  fft_x = fft_img,
  dims_x = dim(img),
  dims_x_orig = dim(img),
  x_dimnames = dimnames(img),
  prep_filter = prepd_filt)

oldschool_filtered <- EBImage::filter2(img, my_filter)
all(oldschool_filtered == filtered_img)
# [1] TRUE

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