downsize_avg: Reducing size of an image using the method of averaging in...

Description Usage Arguments Details Value Note Examples

Description

This function is used for reducing size of an image by averaging its pixels in blocks.

Usage

1
downsize_avg(image, block_nrow = 2, block_ncol = 2)

Arguments

image

a pixel matrix or an array of the image for processing.

block_nrow

an integer number, which is the number of rows from a block. The reduced matrix is the average value within each block. For example, if block_nrow = 2 means you select every two rows of the input image as a block. Note that this number needed to be divisible by number of rows of the array of the input image.

block_ncol

an integer number, which is the number of columns from a block. The reduced matrix is the average value within each block. For example, if block_ncol = 2 means you select every two columns of the input image as a block. Note that this number needed to be divisible by number of columns of the array of the input image.

Details

This function is used to reduce the size of an image by dividing the original array into several blocks and calculate the average values within each block.

Value

a pixel array of the reduced image.

Note

block_nrow and block_ncol must be divisible by number of rows and columns of the pixel-arrary of the image, respectively. Otherwise, Errors will be reported as: "block_nrow(block_ncol) must be divisible by number of rows(columns) of the pixel-arrary of the image."

Examples

1
2
3
4
5
6
#read an RGB image
library(png)
image = readPNG(system.file("extdata", "image1.png",
                             package = "implant",
                             mustWork = TRUE))[ , ,c(1:3)]
downsize_avg(image, 2, 2)

rwang14/implant documentation built on Sept. 6, 2020, 3:21 a.m.