pnm mod.crop

From DavinciWiki
Jump to: navigation, search


Description

Automatically crops the blackspace out of an image.

Located in "pnm_mod" module.

Arguments and Return Values

Inputs: a Val (byte or other) and the sides desired to be manipulated

Outputs: a Val that has had the blackspace removed on the sides specified

Usage

Syntax: pnm_mod.cut(data = VAL, left = BOOL, right = BOOL, top = BOOL, bottom = BOOL)

data:     any davinci array (most likely a  byte image array)
left:     1 to crop this side; 0 to leave it alone (default is 0)
right:    1 to crop this side; 0 to leave it alone (default  is 0)
top:      1 to crop this side; 0 to leave it alone (default  is 0)
bottom:   1 to crop this side; 0 to leave it alone (default  is 0)

NOTE: the color of the blackspace is automatically determined by simple image analysis

Examples

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

dv> b=pnm_mod.pad(a,0,70,30,150,20)
740x700x3 array of byte, bip format [1,554,000 bytes]

dv> c=pnm_mod.crop(b,1,0,1,1)
669x529x3 array of byte, bip format [1,061,703 bytes]

dv> display(a)
Writing /tmp/dv_7970/p4ScRL: 640x530x3 PNG file.
dv> display(b)
Writing /tmp/dv_7970/zagRah: 740x700x3 PNG file.
dv> display(c)
Writing /tmp/dv_7970/AbO3Hp: 669x529x3 PNG file.

Images

llama face.jpgllama face pad.jpgllama face crop.jpg

Three images where the leftmost is the original, the center is padded and the right has been cropped on 3 sides

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