Learn R Programming

OpenImageR (version 1.3.0)

NormalizeObject: normalize a vector, matrix or array (in the range between 0 and 1)

Description

normalize a vector, matrix or array (in the range between 0 and 1)

Usage

NormalizeObject(x)

Value

either a normalized vector, matrix, or array

Arguments

x

either a vector, matrix, data frame or array

Author

Lampros Mouselimis

Details

This is a helper function which normalizes all pixel values of the object to the range between 0 and 1. The function takes either a vector, matrix, data frame or array as input and returns a normalized object of the same type (in case of data frame it returns a matrix).

Examples

Run this code

# vector
x = 1:10

res = NormalizeObject(x)


# matrix
x = matrix(runif(100), 10, 10)

res = NormalizeObject(x)


# data frame
x = data.frame(matrix(runif(100), 10, 10))

res = NormalizeObject(x)


# array
x = array(runif(300), dim = c(10, 10, 3))

res = NormalizeObject(x)

Run the code above in your browser using DataLab