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

MPColorTrackerImage.cpp

Go to the documentation of this file.
00001 /*
00002  *  ffimage.cpp
00003  *  
00004  *
00005  *  Created by Ian Fasel on Mon Nov 18 2002.
00006  *  Copyright (c) 2002 __MyCompanyName__. All rights reserved.
00007  *
00008  */
00009 
00010 #include "ffimage.h"
00011 #include "mpisearch.h"
00012 
00013 // Ideally, we'd have a subclass derived from ostream....
00014 // In the meantime, we have this thingy
00015 static void debug_message(const char* message){
00016 #ifdef DEBUG_FFIMAGE
00017   cout << message << endl;
00018 #endif
00019 }
00020 
00021 // A fast RGBTRIPLE to MPISEARCH_PIXEL_TYPE converting copy constructor
00022 FFImage<MPISEARCH_PIXEL_TYPE>::FFImage<MPISEARCH_PIXEL_TYPE>(const FFImage<RGBTRIPLE> &source){
00023   debug_message( "FFImage::FFImage(): Converting from RGBTRIPLE to MPISEARCH_PIXEL_TYPE" );
00024   MPISEARCH_PIXEL_TYPE one_over_255 = 1.0f/255.0f;
00025   setSize(source.width,source.height,FALSE);
00026   int numpixels = width*height;
00027   char message[256];
00028   sprintf(message,"FFImage::FFImage(): Source image %d", source.isFlipped());
00029   debug_message( message );
00030   MPISEARCH_PIXEL_TYPE *dest_ptr = array;
00031   RGBTRIPLE *source_ptr = source.array;
00032   if(!source.isFlipped()){
00033         for(int i = 0; i < numpixels; i++){
00034           *(dest_ptr++) = static_cast<MPISEARCH_PIXEL_TYPE>((source_ptr->rgbtBlue*.11f
00035                                                                                                           + source_ptr->rgbtGreen*.59f
00036                                                                                                           + source_ptr->rgbtRed*.3f)*one_over_255);
00037           source_ptr++;
00038         }
00039   } else{
00040         RGBTRIPLE *temp;
00041         for (int y=height-1; y >= 0; y--) {
00042           temp = source_ptr + y * width;
00043           for (int x = 0; x < width; x++, temp++) {
00044                 *(dest_ptr++)  = static_cast<MPISEARCH_PIXEL_TYPE>(( temp->rgbtBlue*.11f +
00045                                                                                                             temp->rgbtGreen*.59f +
00046                                                                                                             temp->rgbtRed*.3f )*one_over_255);
00047           }
00048         }
00049   }
00050 
00051   //m_flipped = FALSE;  // since we un-flipped it here, the resulting image is not flipped!
00052 }
00053 

Generated on Mon Nov 8 17:07:43 2004 for MPT by  doxygen 1.3.9.1