Developer Documentation
Centre for Vision, Speech & Signal Processing
USER IN NAMESPACE AMMA TREE ROOT AMMA SEARCH AMMA HOME
 

  PUBLIC
BaseRangeC::ExtremesForSubImage(const ImageRectangleC &)
BaseRangeC::TestFace(const Vector3dC &,const Vector3dC &,const Vector3dC &,const RealT)
BaseRangeC::InsertFace(IntT &,ImageC &,DListC &,DListC &,const PixelC,const PixelC,const PixelC)
BaseRangeC::BaseRangeC(void)
BaseRangeC::BaseRangeC(int,int)
BaseRangeC::BaseRangeC(const BaseRangeC &)
BaseRangeC::operator=(const BaseRangeC &)
BaseRangeC::~BaseRangeC(void)
BaseRangeC::NRows(void) const
BaseRangeC::NCols(void) const
BaseRangeC::Min(void) const
BaseRangeC::Max(void) const
BaseRangeC::GridMin(void) const
BaseRangeC::GridMax(void) const
BaseRangeC::GridSize(void) const
BaseRangeC::GetByteZ(const PixelC &) const
BaseRangeC::GetFloatZ(const PixelC &) const
BaseRangeC::GetVect(const PixelC &) const
BaseRangeC::PutByteZ(const PixelC &,ByteGreyValueT)
BaseRangeC::PutFloatZ(const PixelC &,float)
BaseRangeC::PutVect(const PixelC &,Vector3dC)
BaseRangeC::PutVect(const Vector3dC)
BaseRangeC::IsValid(const PixelC &) const
BaseRangeC::IsInside(const Vector3dC) const
BaseRangeC::IsInsideXY(const Vector3dC) const
BaseRangeC::OfVect(const Vector3dC) const
BaseRangeC::SetXGridExtremes(double,double)
BaseRangeC::SetYGridExtremes(double,double)
BaseRangeC::SetZGridExtremes(double,double)
BaseRangeC::SoftLoad(char *)
BaseRangeC::Load(char *)
BaseRangeC::SoftSave(char *)
BaseRangeC::Save(char *)
BaseRangeC::CalculateExtremes(void)
BaseRangeC::ExportZasByte(int)
BaseRangeC::ExportDXasByte(void)
BaseRangeC::ExportDYasByte(void)
BaseRangeC::ExportValidasByte(void)
BaseRangeC::ExportPol(double)
BaseRangeC::ExportPol2(double)
BaseRangeC::operator<<(ostream &,const BaseRangeC &)
BaseRangeC
 
Base class for range images.
 
include "amma/BaseRange.hh"
User Level:Default
Library:Range
Example: poltool.cc
Section:default.Robert Crida
In Scope:std

Comments:
BaseRangeC is a virtual abstract base class from which ByteRangeC, FloatRangeC and VectRangeC will be inherited.

The i/o routines do have basic error checks.

A valid image point is one in which a range measurement is available. How it is stored is dependent on the data structure but can be checked by calling the function IsValid(). In byte format, 0 is invalid and in vector format, z=-MAXFLOAT is invalid.

Range data is much more complicated than image data. It can be sampled on a regular grid or not, the grid spacings may vary. Together ByteRangeC, FloatRangeC and VectRangeC provide a powerful set of functionality. For accurate results it is important to understand precisely how the system is set up.

Firstly we explain the conventions for "gridded data". Consider a 4 pixel image row or column.

 ---   <-- 0.0    xgridmin=0.0
 |                 ____ box center = 0.5
 |              
 ___   <-- 1.0
 |
 |
 ___   <-- 2.0
 |
 |
 ___   <-- 3.0    xgridmax=3.0
 |
 |
 ___   <-- 4.0
 
There are nrows=4 rows, i.e. r=0..3=nrows-1. Each bin hase size 1 and the total range is 0.0 - 3.9999999. For gridded data the pixels are deemed to be in the centers of the boxes, i.e. at 0.5, 1.5, 2.5, 3.5.

With each range image, the minimum and maximum x, y and z values are stored. In each case, the values are obtained by scanning all of the valid image points and finding the extremes in each dimension. These values are kept in xmin,xmax,ymin,ymax,zmin,zmax.

For conversions between row and column and x and y we use gridxmin,gridxmax,gridymin,gridymax. They are defined as shown above in the picture. In this example

 For gridded data the xgridmin=0.0  xgridmax=3.0,
                      xmin=0.5      xmax=3.5      
 asuming valid pixels in the border rows.
 
These values are obtained if possible from the data file.

To summarize the conversion is as follows:

gridsize.X = (gridmax.X - gridmin.X) / (ncols-1)

 PixelC OfVect(const Vector3dC vect) const
 {
   return PixelC (int(floor((vect.Y()-gridmin.Y())/gridsize.Y())),
                  int(floor((vect.X()-gridmin.X())/gridsize.X())));
 }

 Vector3dC GetVect(const PixelC & pxl) const
 {
   return Vector3dC ((pxl.Col()+0.5)*gridsize.X()+gridmin.X(), 
                     (pxl.Row()+0.5)*gridsize.Y()+gridmin.Y(), 
                     f_data[pxl]);
 }
 
The conversion from to a ByteRangeC uses the same scheme for z noting that the range of valid pixels is 1..255, "nrows"=255.

A vector range image may contain any vector in any pixel. If the operation MaptoGrid is called, however each pixel must contain a vector in the bin.

Any conversion from a vector representation will result in a rounding down of the x and y values to the grid positions. To compensate for this conversion from byte to vector will round up the positions to the centre of the grid boxes.

All loads are soft except Load, soft means no exit on error.

A left hand coordinate system is used with x and y increasing horizontally and vertically, respectively (col,row). z increases away from the camera with the result that when viewed using normal image viewers, greater distances will appear brighter unless photometric inversion is employed.

Files that can be read .pgm .dep .ris .nrcc .txt .vec .jrc .XYZim

Files that can be written .pgm .dep .ris

Derived Classes: Variables:
const double DefaultMax;

const double DefaultMin;

const double DefaultMax = -1e38;

const double DefaultMin = 1e38;

int nrows;

int ncols;

Vector3dC min;

Vector3dC max;

Vector3dC gridmin;

Vector3dC gridmax;

Vector3dC gridsize;

int isgridded;

Methods:
void ExtremesForSubImage(const ImageRectangleC & rect)
Calculates new grid extreme values
Determined using the spacing and ratios of the overall size

BooleanT TestFace(const Vector3dC & v0,const Vector3dC & v1,const Vector3dC & v2,const RealT min_cos_angle)
Test if cos angle of face normal to z-axis is > min_cos_angle

void InsertFace(IntT & counter,ImageC<int> & countimage,DListC<Vector3dC> & v_list,DListC<FaceT> & f_list,const PixelC p0,const PixelC p1,const PixelC p2)
function used in ExportPol2 to insert a triangle in the mesh

BaseRangeC()
Constructs an empty Range image

BaseRangeC(int rows,int cols)
Constructs a Range with space allocated

BaseRangeC(const BaseRangeC & range)
Copy constructor

BaseRangeC & operator=(const BaseRangeC & range)
Assignment

~BaseRangeC()
Destructor

Access to parameters


int NRows() const
Access number of rows

int NCols() const
Access number of cols

Vector3dC Min() const
Access minimum corner of bounding box

Vector3dC Max() const
Access maximum corner of bounding box

Vector3dC GridMin() const
Access minimum corner of grid bounding box

Vector3dC GridMax() const
Access maximum corner of grid bounding box

Vector3dC GridSize() const
Access spacing of the grid

ByteGreyValueT GetByteZ(const PixelC & pxl) const
Access depth given position

float GetFloatZ(const PixelC & pxl) const
Access depth given position

Vector3dC GetVect(const PixelC & pxl) const
Access vector given grid position

void PutByteZ(const PixelC & pxl,ByteGreyValueT z)
Set depth at given position

void PutFloatZ(const PixelC & pxl,float z)
Set depth at a given position

void PutVect(const PixelC & pxl,Vector3dC vect)
Set vector at given position

void PutVect(const Vector3dC vect)
Determines position in array and inserts vector. Must pass IsInside()

int IsValid(const PixelC & pixel) const
Determine whether given pixel is valid

int IsInside(const Vector3dC vect) const
Determines whether a vector is within the grid extremes

int IsInsideXY(const Vector3dC vect) const
Determines whether x,y of vect is within the grid extremes

PixelC OfVect(const Vector3dC vect) const
Determines pixel position in array of a vector

void SetXGridExtremes(double xmin,double xmax)
Sets extremes and determines spacing

void SetYGridExtremes(double ymin,double ymax)
Sets extremes and determines spacing

void SetZGridExtremes(double zmin,double zmax)
Sets extremes and determines spacing

Loading and Saving


int SoftLoad(char * fname)
load from any file, if error then return 0 else 1

void Load(char * fname)
load from any file, if error then exit

int SoftSave(char * fname)
save to file, if error then return 0 else 1

void Save(char * fname)
save to file

void CalculateExtremes()
Determines extreme values of x,y and z
This determines the max and min x,y,z values for the valid image points. If the image is not gridded then grid min and max values are extrapolated to give result that would be achieved if the invalid points had been included in the calculation.

Conversion to other representations


ByteImageC ExportZasByte(int reversevideo = 0)
generate a byteimage of the z data

ByteImageC ExportDXasByte()
generate a byteimage of the x data

ByteImageC ExportDYasByte()
generate a byteimage of the y data

ByteImageC ExportValidasByte()
generate a byte image of the valid points

PolopsC ExportPol(double steepestslope = 100.0)
generate a polops class of the data.
Steepest slope is a ratio of dz/sqrt(dx^2+dy*2)

PolopsC ExportPol2(double steepestslope = 100.0)
generate a triangulation mesh.
steepest slope is max angle of triangle to z-axis. NB: Trianglation indexed without using Polops().Purify() for effieciency

ostream & operator<<(ostream & s,const BaseRangeC & range)


Programmer:Robert Crida lib=Range, Documentation by CxxDoc: Tue Mar 20 10:49:27 2001