The Machine Perception Toolbox

[Introduction]- [News]- [Download]- [Screenshots]- [Manual (pdf)]- [Forums]- [API Reference]- [Repository ]

 

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

MPColorTools Class Reference

#include <color.h>

List of all members.

Public Member Functions

void DrawRGBBox (FFImage< RGBTRIPLE > &rgbimage, int x, int y, int xSize, int ySize, RGBCOLOR color, double alpha=1)
 MPColorTools (float low=0.00, float high=1.00)
bool RGBtoHSV (const unsigned char *pix, float &h, float &s, float &v)
RGBTRIPLE setRGBColor (RGBTRIPLE &x, const int color, double fadeAmount=1.0) const

Static Public Member Functions

void hilitePixel (void *pix, const int &type)

Private Attributes

float m_high
float m_low


Constructor & Destructor Documentation

MPColorTools float  low = 0.00,
float  high = 1.00
[inline]
 

Definition at line 30 of file color.h.

00030                                                            {
00031          m_low = low;
00032          m_high = high; 
00033         };


Member Function Documentation

void DrawRGBBox FFImage< RGBTRIPLE > &  rgbimage,
int  x,
int  y,
int  xSize,
int  ySize,
RGBCOLOR  color,
double  alpha = 1
[inline]
 

Definition at line 89 of file color.h.

References RImage::array, color, RImage::height, i, FFImage::isFlipped(), max, min(), RGBTRIPLE, RImage::width, and y.

Referenced by FilterInterface::DrawBoxes().

00089                                                                                                                                    {
00090                 
00091                 
00092                 int leftX, rightX, topY, bottomY, i;
00093                 RGBTRIPLE *ptr1, *ptr2;
00094                 leftX = max(x, 0);
00095                 rightX = min(x + xSize, rgbimage.width-1);
00096                 if(rgbimage.isFlipped()) {
00097                         topY = min(y + ySize, rgbimage.height-1);
00098                         bottomY = max(y, 0);
00099                 }
00100                 topY = max(y, 0);
00101                 bottomY = min(y + ySize, rgbimage.height-1);
00102                 ptr1 = rgbimage.array + leftX + rgbimage.width*((rgbimage.height-1) - topY);
00103                 ptr2 = rgbimage.array + leftX + rgbimage.width*((rgbimage.height-1) - bottomY);
00104                 for(i = leftX; i <= rightX; ++i, *ptr1++, *ptr2++){
00105                         setRGBColor(*ptr1, color, alpha);
00106                         setRGBColor(*ptr2, color, alpha);
00107                 }
00108                 ptr1 = rgbimage.array + leftX + rgbimage.width*((rgbimage.height-1) - bottomY);
00109                 ptr2 = rgbimage.array + rightX + rgbimage.width*((rgbimage.height-1) - bottomY);
00110                 for(i = topY; i < bottomY; ++i){
00111                         setRGBColor(*ptr1, color, alpha);
00112                         setRGBColor(*ptr2, color, alpha);
00113                         ptr1+=rgbimage.width; ptr2+=rgbimage.width;
00114                 }
00115         }

Here is the call graph for this function:

void hilitePixel void *  pix,
const int &  type
[static]
 

Definition at line 64 of file color.cpp.

References color, r, RGBBLUE, RGBGREEN, RGBRED, and RGBTRIPLE.

00065 {
00066         static const unsigned char color = static_cast<unsigned char>(255);
00067         RGBTRIPLE *rpix = (RGBTRIPLE *)pix;
00068         unsigned char &r = rpix->rgbtRed;
00069         unsigned char &g = rpix->rgbtGreen;
00070         unsigned char &b = rpix->rgbtBlue;
00071         r = g = b = 0;
00072         switch (type) {
00073                 case RGBRED:
00074                         r = color;
00075                         break;
00076                 case RGBGREEN:
00077                         g = color;
00078                         break;
00079                 case RGBBLUE:
00080                         b = color;
00081                         break;
00082         }
00083 }

bool RGBtoHSV const unsigned char *  pix,
float &  h,
float &  s,
float &  v
 

Definition at line 17 of file color.cpp.

References max, r, RGBTRIPLE, s, and v.

Referenced by histogram_hue::rgb2bin().

00018 {       
00019         const RGBTRIPLE *rpix = (RGBTRIPLE *)pix;
00020         const int ri = rpix->rgbtRed;
00021         const int gi = rpix->rgbtGreen;
00022         const int bi = rpix->rgbtBlue;
00023 
00024         const float r = (float)ri/255.f;
00025         const float g = (float)gi/255.f;
00026         const float b = (float)bi/255.f;
00027 
00028         float max, min;
00029         if (r >= g) {
00030                 max = r; 
00031                 min = g;
00032         } else { 
00033                 max = g; 
00034                 min = r; 
00035         }
00036         if (b > max) 
00037                 max = b; 
00038         else if (b < min) 
00039                 min = b;
00040         v = max;
00041         
00042         float delta = max-min;
00043 
00044         if (v == 0 || delta == 0) {
00045                 h = -1;
00046                 return (false);
00047         } else if (r == v) {
00048                 h = 60.f*(g-b)/delta;
00049         } else if (g == v) {
00050                 h = 120.f + 60.f*(b-r)/delta;
00051         } else if (b == v) {
00052           h = 240.f + 60.f*(r-g)/delta;
00053         }
00054 
00055         h /= 2.0;
00056         s *= 255.0;
00057         v *= 255.0;
00058 
00059         return(true);
00060 }

RGBTRIPLE setRGBColor RGBTRIPLE &  x,
const int  color,
double  fadeAmount = 1.0
const [inline]
 

Definition at line 39 of file color.h.

References RGBBLUE, RGBGREEN, RGBPURPLE, RGBRED, RGBTRIPLE, RGBTURQ, RGBWHITE, and RGBYELLOW.

Referenced by FilterInterface::ShowBlinkResults().

00039                                                                                                   {     
00040                 switch (color) {
00041                 case RGBRED:
00042                         x.rgbtRed = (unsigned char) (fadeAmount*255.0 + (1.0-fadeAmount)*(double) x.rgbtRed);   
00043                         x.rgbtBlue = (unsigned char) ((1.0-fadeAmount)*(double) x.rgbtBlue);     
00044                         x.rgbtGreen = (unsigned char) ((1.0-fadeAmount)*(double) x.rgbtGreen);
00045                         return x;
00046                         break;
00047                 case RGBBLUE:
00048                         x.rgbtRed = (unsigned char) ((1.0-fadeAmount)*(double) x.rgbtRed);      
00049                         x.rgbtBlue = (unsigned char) (fadeAmount*255.0 + (1.0-fadeAmount)*(double) x.rgbtBlue);  
00050                         x.rgbtGreen = (unsigned char) ((1.0-fadeAmount)*(double) x.rgbtGreen);
00051                         return x;
00052                         break;
00053                 case RGBGREEN:
00054                         x.rgbtRed = (unsigned char) ((1.0-fadeAmount)*(double) x.rgbtRed);      
00055                         x.rgbtBlue = (unsigned char) ((1.0-fadeAmount)*(double) x.rgbtBlue);     
00056                         x.rgbtGreen = (unsigned char) (fadeAmount*255.0 + (1.0-fadeAmount)*(double) x.rgbtGreen);
00057                         return x;
00058                         break;
00059                 case RGBWHITE:
00060                         x.rgbtRed = (unsigned char) (fadeAmount*255.0 + (1.0-fadeAmount)*(double) x.rgbtRed);   
00061                         x.rgbtBlue = (unsigned char) (fadeAmount*255.0 + (1.0-fadeAmount)*(double) x.rgbtBlue);  
00062                         x.rgbtGreen = (unsigned char) (fadeAmount*255.0 + (1.0-fadeAmount)*(double) x.rgbtGreen);
00063                         return x;
00064                         break;
00065                 case RGBTURQ:
00066                         x.rgbtRed = (unsigned char) ((1.0-fadeAmount)*(double) x.rgbtRed);      
00067                         x.rgbtBlue = (unsigned char) (fadeAmount*255.0 + (1.0-fadeAmount)*(double) x.rgbtBlue);  
00068                         x.rgbtGreen = (unsigned char) (fadeAmount*255.0 + (1.0-fadeAmount)*(double) x.rgbtGreen);
00069                         return x;
00070                         break;
00071                 case RGBPURPLE:
00072                         x.rgbtRed = (unsigned char) (fadeAmount*255.0 + (1.0-fadeAmount)*(double) x.rgbtRed);   
00073                         x.rgbtBlue = (unsigned char) (fadeAmount*255.0 + (1.0-fadeAmount)*(double) x.rgbtBlue);  
00074                         x.rgbtGreen = (unsigned char) ((1.0-fadeAmount)*(double) x.rgbtGreen);
00075                         return x;
00076                         break;
00077                 case RGBYELLOW:
00078                         x.rgbtRed = (unsigned char) (fadeAmount*255.0 + (1.0-fadeAmount)*(double) x.rgbtRed);   
00079                         x.rgbtBlue = (unsigned char) ((1.0-fadeAmount)*(double) x.rgbtBlue);     
00080                         x.rgbtGreen = (unsigned char) (fadeAmount*255.0 + (1.0-fadeAmount)*(double) x.rgbtGreen);
00081                         return x;
00082                         break;
00083                 }
00084                 return x;
00085         }


Member Data Documentation

float m_high [private]
 

Definition at line 28 of file color.h.

float m_low [private]
 

Definition at line 27 of file color.h.


The documentation for this class was generated from the following files:
Generated on Mon Nov 8 17:08:33 2004 for MPT by  doxygen 1.3.9.1