pnm mod.scale

From DavinciWiki
Jump to: navigation, search


Description

Resizes the specified array using bilinear interpolation.

Located in "pnm_mod" module.

Arguments and Return Values

Inputs: a Val (byte or other) and the scaling parameters

Outputs: a Val that has been resized

Usage

Syntax: pnm_mod.scale(data = VAL [, xsize = INT][, ysize = INT][, xscale = FLOAT][, yscale = FLOAT])

data:     any davinci array (most likely  a  byte image array)
xsize:    size of the x direction
ysize:    size of the y direction 
xscale:   ratio of the x direction to resize by
yscale:   ratio of the y direction to resize by

You may specify a SINGLE axis change. For example, xsize OR xscale. The aspect ratio will be maintained.

You may also specify BOTH axis. For example, xscale & yscale.

SIZE values are literal (i.e., pixels) whereas SCALE values are factors. I.e., < 1 implies SHRINK, > 1 implies GROW.

Examples

dv> a=read("http://davinci.asu.edu/images/d/df/llama_face.jpg")
Downloading..done.
..................................................
/tmp/dv_7970/nGBCmR: bip JPEG image: 640x530x3, 8 bits
640x530x3 array of byte, bip format [1,017,600 bytes]

dv> b=pnm_mod.scale(a,xsize=150,ysize=150)
150x150x3 array of byte, bip format [67,500 bytes]
dv> c=pnm_mod.scale(a,xscale=1.2)
768x636x3 array of byte, bip format [1,465,344 bytes]

dv> display(a)
Writing /tmp/dv_7970/YplXVV: 640x530x3 PNG file.
dv> display(b)
Writing /tmp/dv_7970/MrqA07: 150x150x3 PNG file.
dv> display(c)
Writing /tmp/dv_7970/HVDGpx: 768x636x3 PNG file.

Images

llama face.jpgllama face scale small.jpgllama face scale large.jpg

Three images where the leftmost is the original, the center is asymmetrically scaled down and the right has been up-scaled using a single scale axis

DavinciWiki Mini-Nav Bar

Contents


Contact Developers

  • davinci-dev [AT] mars.asu.edu

All other topics

  • See navigation on the left

Recent Core Changes

Modified On: 02-26-2010

Personal tools