Scaletouint8

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search

Purpose

Scales a matrix to 0 to 255 then converts to unint8.

Synopsis

x = scaletouint8(sx,minx,rangx)
[sx,minx,rangx] = scaletouint8(x)

Description

The input (x) is a matrix to scale. Outputs are (sx) which is (x) with columns scaled to have a range of 0 to 255 and then converted to UINT8, (minx) the minimum of the columns of (x), and (rangx) the range of the columns of (x). Scaling is performed down columns (mode 1).

INPUTS

  • x = MxNxK image / matrix to scale.

OPTIONAL INPUTS

  • minx = minimum value of (x) to scale to.
  • rangx = range of (x) to scale to.

OUTPUTS

  • sx = is (x) with columns scaled to have a range of 0 to 255 and then converted to UINT8.
  • minx = minimum of the columns of (x).
  • rangx = range of the columns of (x).

If three inputs are used then (sx) is a UNIT8 matrix to scale back to double using (minx) and (rangx). The output (x) is the rescaled matrix e.g.

[sx,minx,rangx] = scaleouint8(x);
x2 = scaletouint8(sx,minx,rangx);

Output (x2) is an approximation of the original input (x). However, due to rounding when converting to UINT8 in the first command (x2) Does Not generally Equal (x). Warning! Due to round off error:

scaletoint8(scaletoint8(X),min(X),max(X)-min(X))

Does Not generally Equal (X).

See Also

auto