PiXFrame Class Reference

The camera frame. More...

List of all members.

Public Member Functions

 PiXFrame (PiXCam *cam, int num)
void clear ()
 Clear all.
void clean ()
 Clear all except the filename and VidBuf.
uchar * p_vid (ushort x, ushort y)
 Returns pointer to the data at (x, y) in VidBuf.
float * p_luv (uint src)
 Returns pointer to color layer specified by src.
float lum (uint addr)
 ! Returns pointer to luminance color layer at address addr
float urg (uint addr)
 Returns pointer to red-green color layer at address addr.
float vyb (uint addr)
 Returns pointer to yellow-blue color layer at address addr.
float chr (uint addr)
 Returns pointer to chroma color layer at address addr.
float hue (uint addr)
 Returns pointer to hue color layer at address addr.
uint * canv_ba (char type)
 Returns pointer to the canvas layer for the base type.
uint * canv_ba (uchar type_num)
 Returns pointer to the canvas layer for the base type_num.
uint num_bases (char type)
 Returns number of bases of base->type();.
Basep_ba (uint n, char type)
 Returns a pointer to base number n of type type.
Basep_ba (uint n, uchar type_num)
 Returns a pointer to base number n of type type_num.
Blobp_bb (uint n)
 Returns a pointer to blob number n.
CentLinep_cc (uint n)
 Returns a pointer to CentLine number n.
Linep_ln (uint n)
 Returns a pointer to line number n.
Regionp_rg (uint n)
 Returns a pointer to region number n.
Spotp_spt (uint n)
 Returns a pointer to spot number n.
Baseadd_base (char type)
 Add a base-object of type type and assign it a number.
Blobadd_blob ()
 Allocate a Blob and assign it a number.
CentLineadd_cent ()
 Allocate a CentLine and assign it a number.
Lineadd_line ()
 Allocate a Line and assign it a number.
Regionadd_region ()
 Allocate a Region and assign it a number.
Spotadd_spot ()
 Allocate a Spot and assign it a number.
void remove_base (uint ba_num, uchar type_num)
 Removes base-object.
void remove_base (uint num, uint new_num, char type)
 Removes base and writes new_num to canvas.
void remove_base (uint num, uint new_num, uchar type_num)
 Removes base and writes new_num to canvas.
void remove_bases (char type)
 Removes all bases of type. The canvas for type is cleared.
int num ()
 Returns frame number assigned by camera.
PiXCamcam ()
 Returns pointer to camera.
ushort H ()
 Returns the number of lines for the camera.
ushort W ()
 Returns the number of pixels per line for the camera.
uchar C ()
 Returns the number of colors per pixel for the camera.
ushort Y ()
 Returns the value of Y at the origin of the frame.
uint addr (ushort x, ushort y)
 Returns index into all layers except VidBuf from x and y values.
XY< ushort > x_y (uint addr)
 Returns x and y values corresponding to addr.
float radius (uint ad0, uint ad1)
 Returns distance in pixels between two points on a layer.
uint radius_sqr (uint ad0, uint ad1)
 Returns distance squared between two points on a layer.
template<class T>
uint addr (XY< T > xy)
 Returns index into all layers except VidBuf from x and y values.
XY< float > * p_roof (uchar source, uint index)
 Returns pointer to roof layer.
XY< float > * p_slope (uchar source, uint index)
 Returns pointer to slope layer.
uint roof_max_index (uchar source)
 Returns the maximum roof index available.
uint roof_width (uint i)
 Returns width in pixels for the index specified.
bool make_roof_buf (uchar GS, uchar GI, Base *ba=0)
 Makes the layers specified for both roof and slope.
uint len_VidBuf ()
 Returns length of the VidBuf.
uint len_LuvBuf ()
 Returns length of the Luminance buffer. May be zero.
uchar * make_VidBuf ()
 Allocates or re-allocates memory for the VidBuf and returns a pointer.
void make_RGB_LUV ()
 Create the LUV color layers from the VidBuf using gain and offset.
void make_calib (fRGB &ref_light, fRGB &ref_dark, fRGB &set_light, fRGB &set_dark)
 Sets gain and offset using two references in the picture.
float r_gain ()
 Returns red_gain.
float g_gain ()
 Returns green_gain.
float b_gain ()
 Returns blue_gain.
float r_off ()
 Returns red_offset.
float g_off ()
 Returns green_offset.
float b_off ()
 Returns blue_offset.
void r_gain (float r)
 sets red_gain_=r
void g_gain (float g)
 sets green_gain_=g
void b_gain (float b)
 sets blue_gain_=b
void r_off (float z)
 sets red_offset_=z
void g_off (float z)
 sets greenffset_=z
void b_off (float z)
 sets blue_offset_=z
bool apply_cal_values ()
 Compensates for the illumination not being even over the picture.
void exchange_top_bottom (PiXFrame *pf)
 This puts the top line at the bottom of the picture.
void exchange_left_right (PiXFrame *pf)
 This puts the left edge pixels on the right edge.
void remove_pix_lines (uint start_line, uint end_line)
 This function removes lines from the VidBuf.
ushort set_clip ()
 This transfers the clip data from the camera PiXCam to the frame.
float center_contrast (XY< float > *roof, uint ad, int dir)
 Find contrast for a line using a roof and line direction.
bool line_cent_trace_neur (FeedForward &ff, uchar GS, uchar GI, Base *bkd=0, float contrast=8, uint min_len=3, char dark=-1, uchar rad_mult=1)
 Find potential line centers using a neural net technique.
bool line_cent_trace (uchar GS, uchar GI, char dark=-1, Base *bkd=0, float contrast=8, uint min_len=3)
 Find potential line centers using roof values.
void line_cent_connections (uint max_gap=5, uint min_len=3)
 Find connections between centlines, store in sd_beg and sd_end.
bool base_trace (char type, uchar GS, uchar GI, float contrast=32, Base *bkd=0, bool sort_by_size=true, bool in_bkd=true)
 Finds base-objects using roof and slope values.
bool base_threshold (char type, float below[3], float above[3], uchar source[3], uint min_area=10, bool sort_by_size=true)
 Find base-objects using thresholds.
void list_bb (std::ostream &ostr, std::vector< uint > &list, const char *title)
 Make a list of the blobs and their characteristics.
void list_cc (std::ostream &ostr, std::vector< uint > &list, const char *title)
 Make a list of the centlines and their characteristics.
void list_ln (std::ostream &ostr, std::vector< uint > &list, const char *title)
 Make a list of the lines and their characteristics.
void list_rg (std::ostream &ostr, std::vector< uint > &list, const char *title)
 Make a list of the regions and their characteristics.
void list_spt (std::ostream &ostr, std::vector< uint > &list, const char *title)
 Make a list of the spots and their characteristics.

Public Attributes

ushort xL
 left edge clip limit
ushort xR
 right edge clip limit
ushort yB
 bottom edge clip limit
ushort yT
 top edge clip limit
PiXFileName filename
 Storage for filename on disk.
std::vector< uint > ba_num_fnd [PiXTrace::NUM_BASE_TYPES]
 temporary storage for routines

Friends

class PiXCam
class Base


Detailed Description

The camera frame.

There can be multiple cameras, each having multiple frames. Each frame has its own set of Regions, Blobs, Spots, CentLines, and Lines. There is no communication between frames or cameras. That is left to the application.

Each frame has a set of color layers, canvas layers, roof layers, and slope layers. These all start from a VidBuf which is where the traditional 8-bit RGB values from the camera or disk file are loaded.

Three of the color layers are Red, Green, and Blue which are created from the VidBuf using the gain and offset for each color provided by the application. From the Red, Green, and Blue are created the CIELUV color space colors of L, U, and V where L represents luminance, U the red-green axis, and V the yellow-blue axis. CIELUV is a color space adopted by the International Commission on Illumination to define an encoding with uniformity in the perceptibility of color differences. Dark differences are emphasized and light color differences are de-emphasized.

Chroma and Hue layers are also computed from the LUV values as they are sometimes useful.

There is a Blob canvas where all of the Blobs are plotted by placing their assigned number at the (x,y) positions that they occupy. This makes it easy to find out which blobs are neighbors of a given blob. There is also a Region canvas, a Spot canvas, a CentLine canvas, and a Line canvas. A blob can be connected with the region it lies in by checking the region canvas for what is at the same location. The canvases are very useful when objects are being created from the color layers.

The roof and slope layers are allocated as needed. They are distinguished by their color source (one of the color layers) and the width in pixels of the roof/slope. (The roof/slope layer called LUV is actually the three layers for L, U, and V).

All of the layers are continuous - they are not x-y arrays. The advantage of this is that only one parameter, usually called "addr", is needed to check values in any of the layers. An (x, y) address can be translated into addr for this purpose.

The frames also keep track of the allocation and numbering of the Regions, Blobs, Spots, CentLines, and Lines belonging to the frame.


Constructor & Destructor Documentation

PiXFrame::PiXFrame ( PiXCam cam,
int  num 
) [inline]

constucts frame

Parameters:
cam pointer to camera the frame belongs to.
num number assigned by PiXCam.
Always use PiXCam::Pf(uint fn) to create frames, so correct number will be used.


Member Function Documentation

void PiXFrame::clear (  ) 

Clear all.

The PiXFrame::num() which was assigned by the camera class, PiXCam, is not changed, nor is its pointer to its camera.

void PiXFrame::clean (  ) 

Clear all except the filename and VidBuf.

This allows an application to try a new approach using the same data. The PiXFrame::num() which was assigned by the camera class, PiXCam, is not changed, nor is its pointer to its camera.

uchar * PiXFrame::p_vid ( ushort  x,
ushort  y 
) [inline]

Returns pointer to the data at (x, y) in VidBuf.

This is the only layer that cannot be addressed using addr unless this is a monochrome application. VidBuf is normally a sequence of red, green, and blue values for a given pixel.

Returns zero if no VidBuf or x and y are out of bounds

float * PiXFrame::p_luv ( uint  src  )  [inline]

Returns pointer to color layer specified by src.

Parameters:
src can be PiXTrace::LUM, URG, VYB, CHR, HUE. Returns zero if color layer does not exist

float PiXFrame::lum ( uint  addr  )  [inline]

! Returns pointer to luminance color layer at address addr

Returns zero if layer does not exist. addr should be pre-checked

float PiXFrame::urg ( uint  addr  )  [inline]

Returns pointer to red-green color layer at address addr.

Returns zero if layer does not exist. addr should be pre-checked

float PiXFrame::vyb ( uint  addr  )  [inline]

Returns pointer to yellow-blue color layer at address addr.

Returns zero if layer does not exist. addr should be pre-checked

float PiXFrame::chr ( uint  addr  )  [inline]

Returns pointer to chroma color layer at address addr.

Returns zero if layer does not exist. addr should be pre-checked

float PiXFrame::hue ( uint  addr  )  [inline]

Returns pointer to hue color layer at address addr.

Returns zero if layer does not exist. addr should be pre-checked

uint * PiXFrame::canv_ba ( char  type  )  [inline]

Returns pointer to the canvas layer for the base type.

Parameters:
type must be the char 'B', 'C', 'L', 'S', or 'R'.

uint * PiXFrame::canv_ba ( uchar  type_num  )  [inline]

Returns pointer to the canvas layer for the base type_num.

Parameters:
type_num must be B_TYPE, C_TYPE, L_TYPE, S_TYPE, or R_TYPE.
Using uchar type_num instead of char type may be slightly faster.

uint PiXFrame::num_bases ( char  type  )  [inline]

Returns number of bases of base->type();.

Parameters:
type must be the char 'B', 'C', 'L', 'S', or 'R'.
This will give the maximum assigned number of the Regions, Blobs, or Lines, etc. Some of the intermediates may not be in existence anymore.

Base * PiXFrame::p_ba ( uint  n,
char  type 
) [inline]

Returns a pointer to base number n of type type.

Parameters:
n number assigned by add_base()
type must be the char 'B', 'C', 'L', 'S', or 'R'.
Returns:
pointer to base or zero if it does not exist
This is used quite often. Do not use the return to delete the base-object; use instead, remove_base() so that necessary book-keeping can take place.

Base * PiXFrame::p_ba ( uint  n,
uchar  type_num 
) [inline]

Returns a pointer to base number n of type type_num.

Parameters:
n number assigned by add_base()
type_num must be B_TYPE, C_TYPE, L_TYPE, S_TYPE, or R_TYPE.
Returns:
pointer to base or zero if it does not exist
This is used quite often. Do not use the return to delete the base-object; use instead, remove_base() so that necessary book-keeping can take place.

Blob * PiXFrame::p_bb ( uint  n  )  [inline]

Returns a pointer to blob number n.

Parameters:
n number assigned by add_base() or add_blob()
Returns:
pointer to blob or zero if it does not exist
This is used quite often. Do not use the return to delete the blob; use instead remove_base() so that necessary book-keeping can take place.

CentLine * PiXFrame::p_cc ( uint  n  )  [inline]

Returns a pointer to CentLine number n.

Parameters:
n number assigned by add_base() or add_cent()
Returns:
pointer to CentLine or zero if it does not exist
This is used quite often. Do not use the return to delete the CentLine; use instead remove_base() so that necessary book-keeping can take place.

Line * PiXFrame::p_ln ( uint  n  )  [inline]

Returns a pointer to line number n.

Parameters:
n number assigned by add_base() or add_line()
Returns:
pointer to blob or zero if it does not exist
This is used quite often. Do not use the return to delete the line; use instead remove_base() so that necessary book-keeping can take place.

Region * PiXFrame::p_rg ( uint  n  )  [inline]

Returns a pointer to region number n.

Parameters:
n number assigned by add_base() or add_region()
Returns:
pointer to region or zero if it does not exist
This is used quite often. Do not use the return to delete the region; use instead remove_base() so that necessary book-keeping can take place.

Spot * PiXFrame::p_spt ( uint  n  )  [inline]

Returns a pointer to spot number n.

Parameters:
n number assigned by add_base() or add_spot()
Returns:
pointer to spot or zero if it does not exist
This is used quite often. Do not use the return to delete the spot; use instead remove_base() so that necessary book-keeping can take place.

Base * PiXFrame::add_base ( char  type  ) 

Add a base-object of type type and assign it a number.

Returns:
pointer to new base-object, or zero if failure.
This is where the Blobs, Regions, Lines, etc. are allocated and assigned a number. "Holes" in the assignment list are filled if possible.
Parameters:
type  'B', 'C', 'L', 'R', or 'S'

Blob * PiXFrame::add_blob (  )  [inline]

Allocate a Blob and assign it a number.

Returns:
pointer to Blob or zero if failure.
This calls add_base(), and is only for programming convenience. Do not use the return to delete the blob;

CentLine * PiXFrame::add_cent (  )  [inline]

Allocate a CentLine and assign it a number.

Returns:
pointer to CentLine or zero if failure.
This calls add_base(), and is only for programming convenience. Do not use the return to delete the CentLine;

Line * PiXFrame::add_line (  )  [inline]

Allocate a Line and assign it a number.

Returns:
pointer to line or zero if failure.
This calls add_base(), and is only for programming convenience. Do not use the return to delete the line;

Region * PiXFrame::add_region (  )  [inline]

Allocate a Region and assign it a number.

Returns:
pointer to region or zero if failure.
This calls add_base(), and is only for programming convenience. Do not use the return to delete the region;

Spot * PiXFrame::add_spot (  )  [inline]

Allocate a Spot and assign it a number.

Returns:
pointer to spot or zero if failure.
This calls add_base(), and is only for programming convenience. Do not use the return to delete the spot;

void PiXFrame::remove_base ( uint  ba_num,
uchar  type_num 
)

Removes base-object.

This version does not write to canvas. It should only be used when the base-object has not been placed on the canvas.

Parameters:
ba_num  base-object assigned number
type_num  number that identifies type of base-object.

void PiXFrame::remove_base ( uint  num,
uint  new_num,
char  type 
) [inline]

Removes base and writes new_num to canvas.

Parameters:
num base-object assigned number.
new_num number of replacement base-object or zero if no replacement.
type 'B', 'C', 'L', 'R', or 'S'.
This function converts the char type to a type_num and calls the other remove_base function.

void PiXFrame::remove_base ( uint  ba_num,
uint  new_num,
uchar  type_num 
)

Removes base and writes new_num to canvas.

If a base-object is merged with another base-object, then new_num should be the number of the base-object merged into. Otherwise new_num should be zero to clear the canvas.

Parameters:
ba_num  base-object assigned number
new_num  number of replacement base-object or zero if none
type_num  B_TYPE, C_TYPE, L_TYPE, S_TYPE, or R_TYPE.

void PiXFrame::remove_bases ( char  type  ) 

Removes all bases of type. The canvas for type is cleared.

If the type is a CentLine, the CentLine lists in all of the Lines are also cleared.

Parameters:
type  'B', 'C', 'L', 'R', or 'S'.

int PiXFrame::num (  )  [inline]

Returns frame number assigned by camera.

Returns:
frame number, should never be zero.

PiXCam * PiXFrame::cam (  )  [inline]

Returns pointer to camera.

Returns:
pointer to PiXCam, should never be zero.

ushort PiXFrame::H (  )  [inline]

Returns the number of lines for the camera.

Returns:
number of lines or zero if problem.

ushort PiXFrame::W (  )  [inline]

Returns the number of pixels per line for the camera.

Returns:
number of pixels or zero if problem.

uchar PiXFrame::C (  )  [inline]

Returns the number of colors per pixel for the camera.

Returns:
number of colors or zero if problem.

ushort PiXFrame::Y (  )  [inline]

Returns the value of Y at the origin of the frame.

This will be zero for pictures, but not for web scans.

uint PiXFrame::addr ( ushort  x,
ushort  y 
) [inline]

Returns index into all layers except VidBuf from x and y values.

Returns:
address or zero if number of pixels per line is zero. This function checks to make sure x and y are within bounds and corrects them if necessary.

XY< ushort > PiXFrame::x_y ( uint  addr  )  [inline]

Returns x and y values corresponding to addr.

Parameters:
addr index into layers
Returns:
an x,y pair which will be zero if number of pixels per line is zero.

float PiXFrame::radius ( uint  ad0,
uint  ad1 
) [inline]

Returns distance in pixels between two points on a layer.

Parameters:
ad0 index into layers of first point.
ad1 index into layers of second point.
Returns:
distance in pixels or 0 if number of pixels per line is zero.

uint PiXFrame::radius_sqr ( uint  ad0,
uint  ad1 
) [inline]

Returns distance squared between two points on a layer.

Parameters:
ad0 index into layers of first point.
ad1 index into layers of second point.
Returns:
distance squared in pixels squared or 0 if number of pixels per line is zero. This squared version should be used when comparing distances, since it eliminates a sqrare root calculation.

template<class T>
uint PiXFrame::addr ( XY< T >  xy  )  [inline]

Returns index into all layers except VidBuf from x and y values.

Returns:
address or zero if number of pixels per line is zero. This function checks to make sure x and y are within bounds and corrects them if necessary.

XY< float > * PiXFrame::p_roof ( uchar  source,
uint  index 
) [inline]

Returns pointer to roof layer.

Returns:
pointer to layer.
Parameters:
source must be LUM, URG, VYB, CHR, or HUE.
index for pixel width of the roof per roof_width().
Returns:
pointer to roof layer or zero if the roof layer does not exist.

XY< float > * PiXFrame::p_slope ( uchar  source,
uint  index 
) [inline]

Returns pointer to slope layer.

Returns:
pointer to layer.
Parameters:
source must be LUM, URG, VYB, CHR, or HUE.
index for pixel width of the roof per roof_width().
Returns:
pointer to slope layer or zero if the slope layer does not exist.

uint PiXFrame::roof_max_index ( uchar  source  )  [inline]

Returns the maximum roof index available.

Returns:
maximum index or zero if none available.
Parameters:
source must be LUM, URG, VYB, CHR, or HUE.

uint PiXFrame::roof_width ( uint  i  )  [inline]

Returns width in pixels for the index specified.

Parameters:
i width index 1, 2, 3, 4, 5, ...
Returns:
0 if i==0, otherwise 1, 2, 3, 5, 8, 12, 18, 27, ... for i==1, 2, 3, 4, 5, 6, 7, 8, ...
The reason for indexing the roof width like this is that while the roof/slope can be calculated for any width, the difference in performance of a roof with a width in pixels of say 8 is not in general much different from a roof with a width in pixels of 9 or one with a width of 7.

bool PiXFrame::make_roof_buf ( uchar  GS,
uchar  GI,
Base ba = 0 
)

Makes the layers specified for both roof and slope.

Parameters:
GS the color layer to use, PiXTrace::LUM, URG, VYB, CHR, or HUE.
GI the roof width index to use. See PiXFrame::roof_width().
ba is zero or the only part of the roof and the slope layers to write to. This enables finding of the internal color areas of the base-object without interference from the surrounding color areas. If ba is zero, the entire picture is used. For an index of one, the entire picture is always used.
Returns:
is true if success

uint PiXFrame::len_VidBuf (  )  [inline]

Returns length of the VidBuf.

Returns:
length of the VidBuf in pixels. Will be zero if VidBuf not allocated.
The VidBuf is an array of uchars, either monochromatic or red-green-blue sequences for each pixel. It is what comes from cameras or disk drives.

uint PiXFrame::len_LuvBuf (  )  [inline]

Returns length of the Luminance buffer. May be zero.

Returns:
length of the buffer layer in pixels.
The luminance buffer is an array of floats. It is used with the other color buffers for color or by itself for monochromatic. It is a calibrated version of the VidBuf.

uchar * PiXFrame::make_VidBuf (  )  [inline]

Allocates or re-allocates memory for the VidBuf and returns a pointer.

Returns:
pointer to VidBuf made per PiXCam settings or zero if problem.

void PiXFrame::make_RGB_LUV (  ) 

Create the LUV color layers from the VidBuf using gain and offset.

The data from the camera or disk drive input are converted to the LUV format by this routine. Calibrations in the form of red gain and red offset, green gain and green offset, and blue gain and blue offset should have been preset by the application unless the defaults of 1 for the gains and 0 for the offsets are to be used.

If the LUV buffers already exist, they will be overwritten - which might be the case if they were created with default gain and offset so that a calibration reference could be found.

For the monochromatic case, the r_gain and r_offset are used. Run make_calib() or manually set these using r_gain(float r), r_off(float z) etc. if some other values are needed.

void PiXFrame::make_calib ( fRGB &  ref_light,
fRGB &  ref_dark,
fRGB &  set_light,
fRGB &  set_dark 
)

Sets gain and offset using two references in the picture.

When a camera is set up to take pictures for sorting or grading, compensation for the lighting variations over time is often required. One way of doing this is to pick two easily identifiable parts of the picture that will be the same in every picture. Their color is recorded, and for each picture the calibrations are adjusted to compensate for color changes.

If the two references are light and dark, and the red value of the light reference is ref_light.R and the red value of the dark reference is ref_dark.R, then the solution of the equations below will give the corrected values of r_gain_ and r_off_. The recorded values of the two references are set_light.R and set_dark.R. Similar equations will work for the green and blue signals.

Want (ref_light.R + r_off) * r_gain = set_light.R

and (ref_dark.R + r_off) * r_gain = set_dark.R

so r_off = (ref_light.R * set_dark.R - ref_dark.R * set_light.R) / (set_light.R - set_dark.R);

and r_gain = (set_light.R - set_dark.R) / (ref_light.R - ref_dark.R)

If apply_cal_values() is also being used, it should be applied to the VidBuf first. This routine changes only the LUV layers, not the VidBuf.

Parameters:
ref_light  Measured value of light reference
ref_dark  Measured value of dark reference
set_light  Desired value for light reference
set_dark  Desired value for dark reference

float PiXFrame::r_gain (  )  [inline]

Returns red_gain.

Normally set by make_calib() and used by make_RGB_LUV()

float PiXFrame::g_gain (  )  [inline]

Returns green_gain.

Normally set by make_calib() and used by make_RGB_LUV()

float PiXFrame::b_gain (  )  [inline]

Returns blue_gain.

Normally set by make_calib() and used by make_RGB_LUV()

float PiXFrame::r_off (  )  [inline]

Returns red_offset.

Normally set by make_calib() and used by make_RGB_LUV()

float PiXFrame::g_off (  )  [inline]

Returns green_offset.

Normally set by make_calib() and used by make_RGB_LUV()

float PiXFrame::b_off (  )  [inline]

Returns blue_offset.

Normally set by make_calib() and used by make_RGB_LUV()

void PiXFrame::r_gain ( float  r  )  [inline]

sets red_gain_=r

For setting by an application for use with make_RGB_LUV()

void PiXFrame::g_gain ( float  g  )  [inline]

sets green_gain_=g

For setting by an application for use with make_RGB_LUV()

void PiXFrame::b_gain ( float  b  )  [inline]

sets blue_gain_=b

For setting by an application for use with make_RGB_LUV()

void PiXFrame::r_off ( float  z  )  [inline]

sets red_offset_=z

For setting by an application for use with make_RGB_LUV()

void PiXFrame::g_off ( float  z  )  [inline]

sets greenffset_=z

For setting by an application for use with make_RGB_LUV()

void PiXFrame::b_off ( float  z  )  [inline]

sets blue_offset_=z

For setting by an application for use with make_RGB_LUV()

bool PiXFrame::apply_cal_values (  ) 

Compensates for the illumination not being even over the picture.

To compensate for the illumination not being constant over the field of view or to compensate for varying sensitivity of the camera pixels and for black level variations, two calibration pictures can be taken. The first should be of a solid white background and the second of a solid black background (just put the lens cover on!). The two pictures are stored in PiXCam using PiXCam::copy_VidBuf_to_white() and PiXCam::copy_VidBuf_to_black(). Each frame from the camera can then be corrected using this function.

Note that the make_calib() can also be used with this to compensate for minor lighting and dark current changes during a session of picture taking.

void PiXFrame::exchange_top_bottom ( PiXFrame pf  ) 

This puts the top line at the bottom of the picture.

This can be used to see how consistent the edge and line finding routines are. It does not rotate the picture.

Parameters:
pf  frame of source to be turned over

void PiXFrame::exchange_left_right ( PiXFrame pf  ) 

This puts the left edge pixels on the right edge.

This can be used to see how consistent the edge and line finding routines are. It does not rotate the picture.

Parameters:
pf  frame of source to be turned around

void PiXFrame::remove_pix_lines ( uint  start_line,
uint  end_line 
)

This function removes lines from the VidBuf.

Do this before generating the RGB and LUV layers.

Parameters:
start_line  y value to start removal at
end_line  y value to stop removal before

ushort PiXFrame::set_clip (  )  [inline]

This transfers the clip data from the camera PiXCam to the frame.

This function is used to restrict activity to a portion of the picture.

float PiXFrame::center_contrast ( XY< float > *  roof,
uint  ad,
int  dir 
)

Find contrast for a line using a roof and line direction.

Used with line_cent_trace_neur() to evaluate line candidates.

bool PiXFrame::line_cent_trace_neur ( FeedForward &  ff,
uchar  GS,
uchar  GI,
Base bkd = 0,
float  contrast = 8,
uint  min_len = 3,
char  dark = -1,
uchar  rad_mult = 1 
)

Find potential line centers using a neural net technique.

This uses a neural net that has been trained to find lines with particular characteristics. For example, the lines might have light centers with black edges. It looks at a circle of pixels with a typical radius of 6 pixels, to find a potential line with a direction of one of eight possible values. This circle is moved along the potential line to trace it out.

The routine first finds high contrast points to start at. It then moves in both directions from that point. The results are called LineCents or line centers, which are then assembled into actual lines by the line_trace() routine.

The roof layer is only used to determine the contrast of the line center points.

Returns:
true if succeeds.
See also:
line_cent_trace(), line_trace().
Parameters:
ff  the neural net to scan with.
GS  source of the roof layer.
GI  index of the roof layer.
bkd  the base-object to constrain the search to. If zero, the entire picture is used.
contrast  the minimum contrast to accept.
min_len  the minimum length to allow.
dark  dark==1 allows only dark lines, dark==0 allows only light lines, dark==-1 allows both.
rad_mult  Increase scan radius by skipping pixels.

bool PiXFrame::line_cent_trace ( uchar  GS,
uchar  GI,
char  dark_cc = -1,
Base bkd = 0,
float  contrast = 8,
uint  min_len = 3 
)

Find potential line centers using roof values.

Roof values will be high for a line pixel, so it possible to trace lines by finding combinations of pixels that provide the straightest and strongest contrast.

Returns:
true if succeeds.
See also:
line_cent_trace_neur(), line_trace().
Parameters:
GS  source of the roof layer.
GI  index of the roof layer.
dark_cc  dark_cc==1 allows only dark lines, dark_cc==0 allows only light lines, dark_cc==-1 allows both.
bkd  the base-object to constrain the search to. If zero, the entire picture is used.
contrast  the minimum contrast to accept.
min_len  the minimum length to allow.

void PiXFrame::line_cent_connections ( uint  max_gap = 5,
uint  min_len = 3 
)

Find connections between centlines, store in sd_beg and sd_end.

This is required before running line_trace().

See also:
line_cent_trace(), line_cent_trace_neur(), line_trace().
Parameters:
max_gap  the minimum gap between points to allow.
min_len  the minimum length to allow.

bool PiXFrame::base_trace ( char  type,
uchar  GS,
uchar  GI,
float  contrast = 32,
Base bkd = 0,
bool  sort_by_size = true,
bool  in_bkd = true 
)

Finds base-objects using roof and slope values.

This finds base-objects whose edges are where the roof changes signs and the absolute value of the slope is greater than a contrast level.

If the specified roof layers do not exist, they will be constructed.

Note that there are no edge pixels, since edges are found to be between pixels.

Parameters:
type to build Regions use 'R', Blobs use 'B', Spots use 'S'
GS the color layer to use. If PiXTrace::NUM_SOURCES, then all three of the LUV layers are used.
GI the roof width index to use. See PiXFrame::roof_width().
contrast the value the absolute value of the slope must be at a point where the roof changes signs to call that point and edge.
bkd where to look for edges. If bkd is zero, the entire picture is used.
in_bkd If true and bkd is not zero, the search is conducted inside the boundaries of the bkd; if false and bkd is not zero, the search will be outside the bkd boundaries.
sort_by_size Sort by size when done so that the base-object with the lowest assigned number is the largest.

bool PiXFrame::base_threshold ( char  type,
float  lower[3],
float  upper[3],
uchar  source[3],
uint  min_area = 10,
bool  sort_by_size = true 
)

Find base-objects using thresholds.

Most of this library is devoted to using roof and slope techniques to find base-objects, but the traditional way of finding objects is with thresholds, which simply look for pixels above or below some brightness level for some color. This produces a black and white picture on which morphological techniques can be applied. The purpose of this function is to allow testing to see if thresholding would be a good technique for a particular problem. It is not the most efficient or fastest thresholding routine that can be written.

Each pixel must pass three color tests by being above the lower level and/or being below the upper level. If the upper level is set above the lower level, the pixel value must be between the lower level and the upper level. Otherwise, it can be either above the lower level or below the upper level. Any colors that are not to be used, should have the lower level set to zero and the upper level set to 255.

Parameters:
type to build Regions use 'R', Blobs use 'B', Spots use 'S'
lower brightness for each of the three color sources must be above this vlaue.
upper brightness for each of the three color sources must be below this vlaue.
source the three color sources in the same sequence as the lower and upper limits. Use LUM, URG, VYB, CHR, or HUE.
min_area areas of base-objects found must be above or equal to min_area
sort_by_size Sort by size when done so that the base-object with the lowest assigned number is the largest.

void PiXFrame::list_bb ( std::ostream &  ostr,
std::vector< uint > &  list,
const char *  title 
)

Make a list of the blobs and their characteristics.

This is used mainly by VanGogh to describe any other base-object that contains blobs. It is placed here because it is describing blobs.

void PiXFrame::list_cc ( std::ostream &  ostr,
std::vector< uint > &  list,
const char *  title 
)

Make a list of the centlines and their characteristics.

This is used mainly by VanGogh to describe any other base-object that contains centlines. It is placed here because it is describing centlines.

void PiXFrame::list_ln ( std::ostream &  ostr,
std::vector< uint > &  list,
const char *  title 
)

Make a list of the lines and their characteristics.

This is used mainly by VanGogh to describe any other base-object that contains lines. It is placed here because it is describing lines.

void PiXFrame::list_rg ( std::ostream &  ostr,
std::vector< uint > &  list,
const char *  title 
)

Make a list of the regions and their characteristics.

This is used mainly by VanGogh to describe any other base-object that contains regions. It is placed here because it is describing regions.

void PiXFrame::list_spt ( std::ostream &  ostr,
std::vector< uint > &  list,
const char *  title 
)

Make a list of the spots and their characteristics.

This is used mainly by VanGogh to describe any other base-object that contains spots. It is placed here because it is describing spots.


The documentation for this class was generated from the following files:

Generated on Fri Aug 1 22:02:12 2008 for pixtrace by  doxygen 1.5.5