AURobotServers  4
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
UPixel Class Reference

#include <ucommon.h>

Public Member Functions

UPixel asBGR (int fromFormat)
 
UPixel asCromaBGR (int fromFormat)
 
UPixel asRGB (int fromFormat)
 
UPixel asYUV (int fromFormat)
 
void clear ()
 
float colorDist (UPixel *pix)
 
float colorDistIHS (UPixel *pix)
 
CvScalar cvRGB ()
 
unsigned char getBlue (int fromFormat)
 
unsigned char getGreen (int fromFormat)
 
unsigned int getInt ()
 
unsigned char getRed (int fromFormat)
 
int getSum ()
 
UPixel grayToColor (unsigned char gray)
 
UPixel grayToColorInv (unsigned char gray)
 
void print (char *prestring)
 
void set (unsigned char channel1, unsigned char channel2, unsigned char channel3)
 
void set (int serial, int palSize)
 
void set (URRgb rrgb)
 
void setRGBPix8 (int colorIndex, int intensity=255)
 
void setRGBto (const unsigned char ir, const unsigned char ig, const unsigned char ib, const int toFormat)
 
void setYUVPix8 (int colorIndex, int intensity=255)
 
void setYUVto (const unsigned char iy, const unsigned char iu, const unsigned char iv, const int toFormat)
 
void swapRB ()
 
void tone (UPixel other, int pct)
 
UPixel toned (UPixel other, int pct)
 
 UPixel ()
 
 UPixel (unsigned char ir, unsigned char ig, unsigned char ib)
 
 ~UPixel ()
 

Static Public Member Functions

static unsigned char LIMIT_RGB (int x)
 
static UPixel pixRGB (unsigned char p1, unsigned char p2, unsigned char p3)
 
static UPixel RGBtoYUV (unsigned char ir, unsigned char ig, unsigned char ib)
 
static CvScalar toCvRGB (int pix)
 
static UPixel YUVtoBGR (unsigned char iy, unsigned char iu, unsigned char iv)
 
static UPixel YUVtoRGB (unsigned char iy, unsigned char iu, unsigned char iv)
 

Public Attributes

union {
   unsigned char   p1
 
   unsigned char   y
 
}; 
 
union {
   unsigned char   p2
 
   unsigned char   u
 
}; 
 
union {
   unsigned char   p3
 
   unsigned char   v
 
}; 
 

Detailed Description

The pixel class is a 24 bit color code in r,g,b or y,u,v format. Each color is an unsigned char. NB! first channel may be red (and thus not blue), if converted to RGB and not BGR, as is the default coding in openCV

Constructor & Destructor Documentation

UPixel::UPixel ( )

Constructor

UPixel::UPixel ( unsigned char  ir,
unsigned char  ig,
unsigned char  ib 
)

Constructor from rgb values

UPixel::~UPixel ( )

Destructor

Member Function Documentation

UPixel UPixel::asBGR ( int  fromFormat)

Returns a pixel, where this YUV pixel is converted to RGB. there is no test to se if source is realy YUV.

References p1, p2, p3, PIX_PLANES_BGR, PIX_PLANES_BW, PIX_PLANES_RGB, PIX_PLANES_YUV, set(), u, v, y, and YUVtoBGR().

Referenced by asCromaBGR(), UImageAna::findRoadCroma(), UClientFuncImgGui::getCroma(), UFuncFz::getCroma(), UImage::getPix(), UImage::saveBMP(), UResDisp::showUVImage(), and testColourConvert().

UPixel UPixel::asCromaBGR ( int  fromFormat)

Return a cromatisity pixel version of this pixel assuming that this pixel is in format 'fromFormat'

References asBGR(), p1, p2, p3, PIX_PLANES_BGR, PIX_PLANES_BW, PIX_PLANES_RGB, and PIX_PLANES_YUV.

Referenced by UImage::toCromaBGR().

UPixel UPixel::asRGB ( int  fromFormat)

Returns a pixel, where this YUV pixel is converted to RGB. there is no test to se if source is realy YUV.

References p1, p2, p3, PIX_PLANES_BGR, PIX_PLANES_BW, PIX_PLANES_RGB, PIX_PLANES_YUV, set(), u, v, y, and YUVtoRGB().

Referenced by UImageAna::findRoadFill(), UImage::getPix(), and testColourConvert().

UPixel UPixel::asYUV ( int  fromFormat)

Returns a pixel, where this RGB pixel is converted to YUV. there is no test to se if source is realy RGB.

References p1, p2, p3, PIX_PLANES_BGR, PIX_PLANES_BW, PIX_PLANES_RGB, PIX_PLANES_YUV, RGBtoYUV(), u, v, and y.

Referenced by UCalibrationComponents::doFindCodeCellIntensity(), UImageAna::findRoadCroma(), UImageAna::findRoadFill(), UImage::getPix(), UClientFuncImgGui::showUVImage(), UResDisp::showUVImage(), and testColourConvert().

void UPixel::clear ( void  )

Clear all channels to zero.

References p1, p2, and p3.

Referenced by harris(), UFuncStereo::processImages(), and testEigenvector().

float UPixel::colorDist ( UPixel pix)

Get color diatance to this pixel (3D og RGB basis)

References p1, p2, p3, and sqr().

float UPixel::colorDistIHS ( UPixel pix)

Get distance in IHS space.

References UIUVPixel::colorDist().

CvScalar UPixel::cvRGB ( )
inline
unsigned char UPixel::getBlue ( int  fromFormat)

Get blue value assuming color format is as specified. Reurns 0 if colorformat is unknown.

References p1, p3, PIX_PLANES_BGR, PIX_PLANES_BW, PIX_PLANES_RGB, PIX_PLANES_YUV, u, v, y, and YUVtoRGB().

unsigned char UPixel::getGreen ( int  fromFormat)

Get green value assuming color format is as specified. Reurns 0 if colorformat is unknown.

References p1, p2, PIX_PLANES_BGR, PIX_PLANES_BW, PIX_PLANES_RGB, PIX_PLANES_YUV, u, v, y, and YUVtoRGB().

Referenced by UClientFuncImgGui::showUVImage(), and UResDisp::showUVImage().

unsigned int UPixel::getInt ( )
inline

Get pixel as integer value 0xRRGGBB

Referenced by UFuncKinect::makeObj3Dcloud(), and UFuncStereo::processImages().

unsigned char UPixel::getRed ( int  fromFormat)

Get red value assuming color format is as specified. Reurns 0 if colorformat is unknown.

References p1, p3, PIX_PLANES_BGR, PIX_PLANES_BW, PIX_PLANES_RGB, PIX_PLANES_YUV, u, v, y, and YUVtoRGB().

Referenced by UClientFuncImgGui::showUVImage(), and UResDisp::showUVImage().

int UPixel::getSum ( )
inline
UPixel UPixel::grayToColor ( unsigned char  gray)
inline

Convert gray level to color where 255 towards 0 becomes white->red->green->blue->magenta->dark->black

UPixel UPixel::grayToColorInv ( unsigned char  gray)
inline

Convert gray level to color 0 towards 255 becomes white->red->green->blue->magenta->dark->black

static unsigned char UPixel::LIMIT_RGB ( int  x)
inlinestatic

Reduce range to 0..255

static UPixel UPixel::pixRGB ( unsigned char  p1,
unsigned char  p2,
unsigned char  p3 
)
inlinestatic
void UPixel::print ( char *  prestring)

Print pixel values to console with this prestring

References p1, p2, and p3.

static UPixel UPixel::RGBtoYUV ( unsigned char  ir,
unsigned char  ig,
unsigned char  ib 
)
inlinestatic

convert to RGB format (non standard byte order) Convert a pixel from RGB to YUV format. Expects parameter order as (Red, Green, Blue)

References u, v, and y.

Referenced by asYUV(), UFunctionImgPool::handleImageGetCommand(), UImage::pixRGB(), setRGBto(), setYUVPix8(), and UImage::toYUV().

void UPixel::set ( unsigned char  channel1,
unsigned char  channel2,
unsigned char  channel3 
)
inline
void UPixel::set ( int  serial,
int  palSize 
)

Sets to a palette serial color out of palSize available colors

References p1, p2, and p3.

void UPixel::set ( URRgb  rrgb)

From real color values.

References URRgb::b, URRgb::g, maxd(), mind(), p1, p2, p3, URRgb::r, and roundi().

void UPixel::setRGBPix8 ( int  colorIndex,
int  intensity = 255 
)

Set pixel value using a color palette with 8 colors corresponding to 8 major directions in color space. Intensity is default maksimum. 0 is red, 1 is yellow, 2 is yellowgreen, 3 is green, 4 is cyan, 5 is blue 6 magenta, 7 is purpel-red. Pixel is in RGB scheme.

References maxi(), mini(), p1, p2, and p3.

Referenced by setYUVPix8().

void UPixel::setRGBto ( const unsigned char  ir,
const unsigned char  ig,
const unsigned char  ib,
const int  toFormat 
)
void UPixel::setYUVPix8 ( int  colorIndex,
int  intensity = 255 
)

Set pixel value using a color palette with 8 colors corresponding to 8 major directions in color space. Intensity is default maksimum. 0 is red, 1 is yellow, 2 is yellowgreen, 3 is green, 4 is cyan, 5 is blue 6 magenta, 7 is purpel-red. Pixel is in YUV scheme.

References p1, p2, p3, RGBtoYUV(), and setRGBPix8().

Referenced by UCalibrationComponent::PaintNeighbors().

void UPixel::setYUVto ( const unsigned char  iy,
const unsigned char  iu,
const unsigned char  iv,
const int  toFormat 
)
void UPixel::swapRB ( )
inline

Convert pixle from RGB to BGR or the other way.

Referenced by UImgPolyProj::doPolygonMap(), UImgProj::doPolygonMap(), and UFuncStereo::processImages().

static CvScalar UPixel::toCvRGB ( int  pix)
inlinestatic

convert from integer representation to openCV RGB structure

Referenced by UResObj3d::paintGndPlane().

void UPixel::tone ( UPixel  other,
int  pct 
)

Tone pixel between this and 'other' value for 'pct' of this and the rest from the 'other' value.

References u, UIUVPixel::u, v, UIUVPixel::v, and y.

Referenced by UImgPolyProj::doProject(), UImgProj::doProject(), UClientFuncImgGui::showUVImage(), UResDisp::showUVImage(), and toned().

UPixel UPixel::toned ( UPixel  other,
int  pct 
)

Tone pixel between this and 'other' value for 'pct' of this and the rest from the 'other' value. Returns the toned resuld without changing this pixel

References tone().

static UPixel UPixel::YUVtoBGR ( unsigned char  iy,
unsigned char  iu,
unsigned char  iv 
)
inlinestatic

Convert a pixel from YUV to BGR format

References p1, p2, and p3.

Referenced by asBGR(), UImage::pixYUV(), setYUVto(), UImage::yuv422toBGR(), and UImage::yuv422toBGRhalf().

static UPixel UPixel::YUVtoRGB ( unsigned char  iy,
unsigned char  iu,
unsigned char  iv 
)
inlinestatic

Member Data Documentation

union { ... }

first byte (plane 1) is either blue (b) or intensity (y) NB! may be red, if converted to RGB and not BGR, as isthe default coding in openCV

union { ... }

Second byte is either green (g) or u component of heu-saturation in rectangluar coordinates

union { ... }

Third byte is either blue (b) or v color component

unsigned char UPixel::p1

Referenced by UFuzzyPixel::addCovariance(), UFuzzyPixel::addPosition(), asBGR(), asCromaBGR(), asRGB(), asYUV(), UFuncCog::calculateCOG(), clear(), UGroundPatch::colorAnalysis(), colorDist(), UImage::colourSaturate(), UImAna::findContourPoly(), UImageAna::findContourPoly(), UImAna::findContourPolyCroma(), UImageAna::findContourPolyCroma(), UImagePoly::findContourPolyCroma(), UImageAna::findRoad(), UImageAna::findRoadCroma(), UImAna::findRoadPoly(), UImageAna::findRoadPoly(), UImagePoly::findRoadPoly(), fire(), UImAna::getAvgVar(), UImageAna::getAvgVar(), UImagePoly::getAvgVar(), getBlue(), UClientFuncImgGui::getCroma(), UFuncFz::getCroma(), getGreen(), UImAna::getMahalonobisDist(), UImageAna::getMahalonobisDist(), UImagePoly::getMahalonobisDist(), UImAna::getMahalonobisDistCroma(), UImageAna::getMahalonobisDistCroma(), UImagePoly::getMahalonobisDistCroma(), UImage::getPixInt(), getRed(), UFuncKinect::GetXYZCoordinates(), UImage::gridLine(), UFunctionImgPool::handleImageGetCommand(), UImage::hLine(), UImageAna::imageContour2(), UImagePoly::imageContour2(), UImAna::imageContourMaha(), UImageAna::imageContourMaha(), UImagePoly::imageContourMaha(), UImAna::imageContourMahaCroma(), UImageAna::imageContourMahaCroma(), UImagePoly::imageContourMahaCroma(), UImAna::imageUsable(), UImageAna::imageUsable(), UImagePoly::imageUsable(), UFuncFz::initializeClassesFromLine(), UImage::lineInGrid(), UFuncPCLTest::MakeMap(), UProbGrid::makeProbGrid(), UImagePoly::makeSimilarImage3(), UFuncBallKL::maskColors(), UFuncBall_improved::maskColors(), UFuncCropRow::maskColors(), UFuncImSeg::meanShiftSegment(), UImage::moveBGGRToHalfBGR(), UImage::movePixToHalf(), UImage::moveYUV420ToHalf(), UImAna::pixCmp(), UImageAna::pixCmp(), UImagePoly::pixCmp(), UImage::pixCmp(), UFuzzyPixel::print(), print(), UFuncStereo::processImages(), UFuncPiCam::run(), UGroundPatches::saveMatlabScript(), set(), UFuzzyPixel::setDistance(), UIUVPixel::SetPix(), setRGBPix8(), setRGBto(), setYUVPix8(), UClientFuncImgGui::showFocusNumber(), UClientFuncImgGui::showLine(), UClientFuncImgGui::showUVImage(), UResDisp::showUVImage(), UImage::sobel(), testColourConvert(), UImage::toBGR(), UImage::toBW(), UImage::toCromaBGR(), UImage::tone(), UImage::toRGB(), UImage::toYUV(), UImage::vLine(), YUVtoBGR(), and YUVtoRGB().

unsigned char UPixel::p2

Referenced by UFuzzyPixel::addCovariance(), UFuzzyPixel::addPosition(), asBGR(), asCromaBGR(), asRGB(), asYUV(), UFuncCog::calculateCOG(), clear(), UGroundPatch::colorAnalysis(), colorDist(), UImage::colourSaturate(), UImgPolyProj::doPolygonMap(), UImgProj::doPolygonMap(), UImAna::findContourPoly(), UImageAna::findContourPoly(), UImAna::findContourPolyCroma(), UImageAna::findContourPolyCroma(), UImagePoly::findContourPolyCroma(), UImageAna::findRoad(), UImageAna::findRoadCroma(), UImAna::findRoadPoly(), UImageAna::findRoadPoly(), UImagePoly::findRoadPoly(), fire(), UImAna::getAvgVar(), UImageAna::getAvgVar(), UImagePoly::getAvgVar(), UImagePoly::getAvgVar2(), UClientFuncImgGui::getCroma(), UFuncFz::getCroma(), getGreen(), UImAna::getMahalonobisDist(), UImageAna::getMahalonobisDist(), UImagePoly::getMahalonobisDist(), UImAna::getMahalonobisDistCroma(), UImageAna::getMahalonobisDistCroma(), UImagePoly::getMahalonobisDistCroma(), UImage::getPixInt(), UFuncKinect::GetXYZCoordinates(), UImage::gridLine(), UFunctionImgPool::handleImageGetCommand(), UImage::hLine(), UImageAna::imageContour2(), UImagePoly::imageContour2(), UImAna::imageContourMaha(), UImageAna::imageContourMaha(), UImagePoly::imageContourMaha(), UImAna::imageContourMahaCroma(), UImageAna::imageContourMahaCroma(), UImagePoly::imageContourMahaCroma(), UImAna::imageUsable(), UImageAna::imageUsable(), UImagePoly::imageUsable(), UFuncFz::initializeClassesFromLine(), UImage::lineInGrid(), UFuncPCLTest::MakeMap(), UProbGrid::makeProbGrid(), UProbGrid::makeProbGrid2(), UImagePoly::makeSimilarImage2(), UImagePoly::makeSimilarImage3(), UFuncBallKL::maskColors(), UFuncPiPi::maskColors(), UFuncBall::maskColors(), UFuncBall_improved::maskColors(), UFuncCropRow::maskColors(), UFuncLinefinder::maskColors(), UFuncImSeg::meanShiftSegment(), UImage::moveBGGRToHalfBGR(), UImage::movePixToHalf(), UImage::moveYUV420ToHalf(), UClientFuncImgGui::paintClustPixels(), UFuncFz::paintClustPixels(), UImAna::pixCmp(), UImageAna::pixCmp(), UImagePoly::pixCmp(), UImage::pixCmp(), UFuzzyPixel::print(), print(), UFuncStereo::processImages(), UFuncPiCam::run(), UProbGrid::saveMatlab(), UGroundPatches::saveMatlabScript(), set(), UFuzzyPixel::setDistance(), UIUVPixel::SetPix(), setRGBPix8(), setRGBto(), setYUVPix8(), UClientFuncImgGui::showFocusNumber(), UClientFuncImgGui::showLine(), UClientFuncImgGui::showUVImage(), UResDisp::showUVImage(), UImage::sobel(), testColourConvert(), UImage::toBGR(), UImage::toBW(), UImage::toCromaBGR(), UImage::tone(), UImage::toRGB(), UImage::toYUV(), UImage::vLine(), YUVtoBGR(), and YUVtoRGB().

unsigned char UPixel::p3

Referenced by UFuzzyPixel::addCovariance(), UFuzzyPixel::addPosition(), asBGR(), asCromaBGR(), asRGB(), asYUV(), UFuncCog::calculateCOG(), clear(), UGroundPatch::colorAnalysis(), colorDist(), UImage::colourSaturate(), UFuncStraightLine::crop(), UImgPolyProj::doProject(), UImgProj::doProject(), UImAna::findContourPoly(), UImageAna::findContourPoly(), UImAna::findContourPolyCroma(), UImageAna::findContourPolyCroma(), UImagePoly::findContourPolyCroma(), UImageAna::findRoad(), UImageAna::findRoadCroma(), UImAna::findRoadPoly(), UImageAna::findRoadPoly(), UImagePoly::findRoadPoly(), fire(), UImAna::getAvgVar(), UImageAna::getAvgVar(), UImagePoly::getAvgVar(), UImagePoly::getAvgVar2(), getBlue(), UClientFuncImgGui::getCroma(), UFuncFz::getCroma(), UImAna::getMahalonobisDist(), UImageAna::getMahalonobisDist(), UImagePoly::getMahalonobisDist(), UImAna::getMahalonobisDistCroma(), UImageAna::getMahalonobisDistCroma(), UImagePoly::getMahalonobisDistCroma(), UImage::getPixInt(), getRed(), UFuncKinect::GetXYZCoordinates(), UImage::gridLine(), UFunctionImgPool::handleImageGetCommand(), UImage::hLine(), UImageAna::imageContour2(), UImagePoly::imageContour2(), UImAna::imageContourMaha(), UImageAna::imageContourMaha(), UImagePoly::imageContourMaha(), UImAna::imageContourMahaCroma(), UImageAna::imageContourMahaCroma(), UImagePoly::imageContourMahaCroma(), UImAna::imageUsable(), UImageAna::imageUsable(), UImagePoly::imageUsable(), UFuncFz::initializeClassesFromLine(), UImage::lineInGrid(), UFuncPCLTest::MakeMap(), UImagePoly::makeSimilarImage2(), UImagePoly::makeSimilarImage3(), UFuncBallKL::maskColors(), UFuncPiPi::maskColors(), UFuncBall::maskColors(), UFuncBall_improved::maskColors(), UFuncCropRow::maskColors(), UFuncLinefinder::maskColors(), UFuncImSeg::meanShiftSegment(), UImage::moveBGGRToHalfBGR(), UImage::movePixToHalf(), UImage::moveYUV420ToHalf(), UClientFuncImgGui::paintClustPixels(), UFuncFz::paintClustPixels(), UImAna::pixCmp(), UImageAna::pixCmp(), UImagePoly::pixCmp(), UImage::pixCmp(), UFuzzyPixel::print(), print(), UFuncStraightLine::printLine(), UFuncStereo::processImages(), UFuncPiCam::run(), UGroundPatches::saveMatlabScript(), set(), UFuzzyPixel::setDistance(), UIUVPixel::SetPix(), setRGBPix8(), setRGBto(), setYUVPix8(), UClientFuncImgGui::showFocusNumber(), UClientFuncImgGui::showLine(), UClientFuncImgGui::showUVImage(), UResDisp::showUVImage(), UImage::sobel(), testColourConvert(), UImage::toBGR(), UImage::toBW(), UImage::toCromaBGR(), UImage::tone(), UImage::toRGB(), UImage::toYUV(), UImage::vLine(), YUVtoBGR(), and YUVtoRGB().

unsigned char UPixel::u
unsigned char UPixel::v
unsigned char UPixel::y

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