imdownsample {imageUtilities}R Documentation

downsamples an image

Description

downsamples an image

Usage

  imdownsample(imgA, dx, dy = dx,
    method = c("every", "mean"), border.fill = 0)

  imsubsample(imgA, dx, dy = dx,
    method = c("every", "mean"), border.fill = 0)

Arguments

imgA

input image to be downsampled

dx

window size (horizontal dimension)

dy

window size (vertical dimension), default dx.

method

one of "every" or "mean". If "every", every dx and dy'th pixel will be kept (starting from the first) If "mean", the mean of every non-overlapping dx by dy box will be calculated and that is retained.

border.fill

if the image dimensions are not exactly divisible by dx or dy, then what value will be used in the border (right/bottom)? Default 0, but 'NA' is another option. Only relevant for 'mean' method.

Details

The method="mean" mode is very slow at the moment. It takes ~11 user-seconds on a 5000x1000x3 image with dx=3, and ~28 user-seconds on a 5000x3000x3 image, dx=3. Consider whether you actually need the mean in each cell before using this method; for display purposes method="every" does fine.

UPDATE (v1.1): method="mean" has been sped up and now takes about 6 user-seconds on 5000x3000x3, dx=3 (but still a decent amount of time overall).

It is **much much** faster if dx and dy exactly divide the dimensions of the input array, or else it makes a copy of the input array which slows it down (TODO: remove this bottle-neck).

Value

downsampled image, of size ceiling(dim(imgA)/c(dy,dx)), where pixel (i,j) is calculated according to parameter "method".

Note

imsubsample and imdownsample are aliases for the same function.

See Also

Other subsample: subsample.cols, subsample.rows


[Package imageUtilities version 1.0.3 Index]