Package pyrobot :: Package vision :: Class PyrobotImage
[frames | no frames]

Class PyrobotImage

Known Subclasses:
Bitmap, Camera, Histogram

A Basic Image class.

Method Summary
  __init__(self, width, height, depth, init_val, r, g, b)
Constructor.
  convolve(self, convmask, bit, threshold)
  cropPixels(self, l, t, r, b)
cropPixels() ------------ crops pixels in the amount specified from left, top, right, and bottom if unspecified, right is assumed to be the same as left and bottom the same as top.
  display(self)
Display PyrobotImage in ASCII Art.
  get(self, x, y, offset)
Get a pixel value.
  getBitmap(self, cutoff, cutoff2, mode)
getBitmap()...
  getCol(self, x)
Get the entire col, in tuples...
  getColorFilter(self, r, g, b)
returns a filtered image r,g,b values indicate percentage of each color to keep eg.
  getDim(self)
  getGrayScale(self)
Method to convert depth 3 color into depth 1 grayscale...
  getPlane(self, colorPlane)
  getRow(self, y)
Get the entire row, in tuples...
  getScaledImage(self, xscale, yscale, mode)
return a scaled version of the current image...
  getVal(self, x, y)
Get the entire color value of the pixel in quetion, returned as a tuple.
  histogram(self, cols, rows, initvals)
Creates a histogram.
  incr(self, x, y, offset)
Method to increment a pixel value.
  loadFromFile(self, filename)
Method to load image from file.
  reset(self, vector)
Reset an image to a vector.
  resetToColor(self, r, g, b)
reset the image to a specified color...
  saveToFile(self, filename)
Method to save image to a file.
  setVal(self, x, y, val)
Method to set the entire RGB value of a pixel.
  swapPlanes(self, plane1, plane2)

Method Details

__init__(self, width=0, height=0, depth=3, init_val=0, r=0, g=0, b=0)
(Constructor)

Constructor. Depth is bytes per pixel.

cropPixels(self, l, t='unset', r='unset', b='unset')

cropPixels()
------------
crops pixels in the amount specified from left, top, right, and bottom
if unspecified, right is assumed to be the same as left and bottom the
same as top.  if top is unspecified it is assumed to be the same as left

display(self)

Display PyrobotImage in ASCII Art.

get(self, x, y, offset=0)

Get a pixel value. offset is r, g, b = 0, 1, 2.

getBitmap(self, cutoff, cutoff2='unset', mode='brightness')

getBitmap()
-----------
constructs a bitmap from the image based on one of four modes
----------------------
the default mode is 'brightness', which only keeps pixels of the
brightness specified by cutoff (here cutoff2 is ignored)
----------------------
the remaining modes construct bitmaps based on ratioing
('rg/b', 'rb/g', and 'gb/r', with support for the reverse permutation of
the first two letters)
this is most easily explained with an example, take 'rg/b':
at each pixel, we keep it only if r/b > cutoff and if g/b > cutoff2
if cutoff2 is unspecified, it is set to cutoff
cutoff always applies to the first color and cutoff2 to the second
(so if you do 'gr/b' cutoff applies to g and cutoff2 to r)

getCol(self, x)

Get the entire col, in tuples

getColorFilter(self, r, g, b)

returns a filtered image
r,g,b values indicate percentage of each color to keep
eg. self.getColorFilter(0.0,1.0,1.0) filters out all the red
eg. self.getColorFilter(1.0,0.5,0.0) creates an orange image

getGrayScale(self)

Method to convert depth 3 color into depth 1 grayscale

getRow(self, y)

Get the entire row, in tuples

getScaledImage(self, xscale=0.5, yscale='unset', mode='sample')

return a scaled version of the current image
if used without arguments, will return a 1/2 scale image
if yscale is unspecified, the image is uniformly scaled
currently you get wacky results unless you use scale values that
fit evenly into 1.0 (i recommend 0.5, 0.333, 0.25, 0.125 ...)

getVal(self, x, y)

Get the entire color value of the pixel in quetion, returned as a tuple.
If this is an RGB image, it will be of the form (r, g, b).

histogram(self, cols=20, rows=20, initvals=0)

Creates a histogram.

incr(self, x, y, offset=0)

Method to increment a pixel value. offset is r, g, b (0, 1, 2)

loadFromFile(self, filename)

Method to load image from file. Currently must be in PBM P6 Format
(color binary).

reset(self, vector)

Reset an image to a vector.

resetToColor(self, r, g, b)

reset the image to a specified color

saveToFile(self, filename)

Method to save image to a file. Currently will save PBM P5/P6 Format.

setVal(self, x, y, val)

Method to set the entire RGB value of a pixel.
val should be an n-tuple (or length n list), where n is the depth of the
image.  For RGB, it should be of the form (r, g, b)

Generated by Epydoc 2.1 on Mon Jul 25 01:39:28 2005 http://epydoc.sf.net