00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <iostream>
00022 #include <sys/types.h>
00023 #include <sys/stat.h>
00024 #include <stdlib.h>
00025 #include "GaborGlobal.h"
00026 #include "GaborJet.h"
00027 #include "ContrastFilter.h"
00028
00029 #include "Utilities.h"
00030 #include "CelesteGlobals.h"
00031 #define kUseContrast 1
00032
00033 using namespace std;
00034
00035 namespace celeste
00036 {
00037 float* ProcessChannel( float** image, int w, int h, int gNumLocs, int**& gLocations, int gRadius, float* response, int* len){
00038
00039 ContrastFilter* contrastFilter = NULL;
00040 GaborJet* gaborJet = NULL;
00041 int height = h;
00042 int width = w;
00043 float** pixels;
00044 int gflen, dummy;
00045 int i, j, offset = 0;
00046 char filename[256], suffix[5];
00047
00048
00049 pixels = image;
00050
00051 #if kUseContrast
00052
00053
00054 contrastFilter = new ContrastFilter( image, height, width );
00055 char file[] = "gabor_filters/celeste";
00056
00057 if ( kSaveFilter == 1 ) {
00058 contrastFilter->SetFileName( file );
00059 contrastFilter->Save();
00060 }
00061 pixels = contrastFilter->GetContrast();
00062 width = contrastFilter->GetWidth();
00063 height = contrastFilter->GetHeight();
00064 #endif
00065
00066
00067 gaborJet = new GaborJet;
00068 if ( kSaveFilter == 1 )
00069 {
00070 strcpy( filename, file );
00071 sprintf( suffix, "%d-", 0 );
00072 strcat( filename, suffix );
00073 gaborJet->SetFileName( filename );
00074 }
00075 gaborJet->Initialize( height, width, gLocations[0][0], gLocations[0][1],
00076 gRadius, gS, gF, gU, gL, gA, kSaveFilter );
00077
00078
00079
00080
00081 gaborJet->Filter( pixels, &gflen );
00082
00083 if ( *len == 0 )
00084 {
00085 *len = gflen * gNumLocs;
00086 response = new float[(*len)];
00087
00088 }
00089
00090
00091
00092 for ( i = 0; i < gflen; i++ ){
00093
00094
00095 response[i+offset] = gaborJet->GetResponse(i);
00096
00097 }
00098
00099 delete gaborJet;
00100
00101
00102 kSaveFilter = 0;
00103
00104
00105
00106 for ( i = 1; i < gNumLocs; i++ )
00107 {
00108 offset = offset + gflen;
00109
00110 gaborJet = new GaborJet;
00111 if ( kSaveFilter == 1 )
00112 {
00113 strcpy( filename, file );
00114 sprintf( suffix, "%d-", i );
00115 strcat( filename, suffix );
00116 gaborJet->SetFileName( filename );
00117 }
00118 gaborJet->Initialize( height, width, gLocations[i][0], gLocations[i][1],
00119 gRadius, gS, gF, gU, gL, gA );
00120
00121
00122
00123 gaborJet->Filter( pixels, &dummy );
00124 for ( j = 0; j < gflen; j++ ) response[j+offset] = gaborJet->GetResponse(j);
00125 delete gaborJet;
00126 }
00127
00128 #if kUseContrast
00129 delete contrastFilter;
00130 #endif
00131
00132 return response;
00133 }
00134 };