bytelinscale - scaled linearly to the range 0-255.

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import numpy as np def bytelinscale(floatarray): ''' Linearly rescales the input into the byte range. The lowest value becomes 0, the highest becomes 255, and the others are scaled linearly to that range according to their values relative to the pre-scale minimum and maximum values. Parameters ---------- floatarray : array_like Real-valued array to be rescaled. Returns ------- output : array_like This function returns an unsigned byte array of the same shape as the input in which the values have been
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: scaled linearly to the range 0-255. Examples-------->>> import numpy as np >>> import bytelinscale >>> bytelinscale.bytelinscale(np.array([2., 4., 6.])) array([ 0, 127, 255], dtype=uint8) Revisions---------2007-09-11 0.1 jh@physics.ucf.edu Initial version 2008-11-01 0.2 kevin218@knights.ucf.edu Updated docstring 2009-09-16 0.3 jh@physics.ucf.edu Updated docstring ''' return np.ubyte((floatarray - floatarray.min())* 255./ floatarray.ptp())...
View Full Document

This note was uploaded on 11/09/2009 for the course AST 4762 taught by Professor Harrington during the Fall '09 term at University of Central Florida.

Ask a homework question - tutors are online