From: Dominic L. <ma...@us...> - 2005-06-08 14:19:19
|
Update of /cvsroot/robotflow/RobotFlow/Vision/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28244 Modified Files: ExtractSentence_v2.cc StatIntensityAnalyser.cc Log Message: removed comments, added avg and std dev outputs Index: StatIntensityAnalyser.cc =================================================================== RCS file: /cvsroot/robotflow/RobotFlow/Vision/src/StatIntensityAnalyser.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** StatIntensityAnalyser.cc 29 Mar 2005 15:20:48 -0000 1.4 --- StatIntensityAnalyser.cc 8 Jun 2005 14:19:07 -0000 1.5 *************** *** 58,63 **** * @output_description Minimum intensity of analysed sample on a 0-1 scale * ! ! END*/ --- 58,69 ---- * @output_description Minimum intensity of analysed sample on a 0-1 scale * ! * @output_name AVG_INTENSITY ! * @output_type float ! * @output_description Average intensity ! * ! * @output_name STD_INTENSITY ! * @output_type float ! * @output_description Intensity standard deviation ! * END*/ *************** *** 69,73 **** int mMaxIntensityID; int mMinIntensityID; ! int mAverageIntensityID; // parameters --- 75,80 ---- int mMaxIntensityID; int mMinIntensityID; ! int m_avgIntensityID; ! int m_stdIntensityID; // parameters *************** *** 85,88 **** --- 92,97 ---- mMaxIntensityID = addOutput("MAX_INTENSITY"); mMinIntensityID = addOutput("MIN_INTENSITY"); + m_avgIntensityID = addOutput("AVG_INTENSITY"); + m_stdIntensityID = addOutput("STD_INTENSITY"); //parameters *************** *** 100,108 **** (*outputs[mMaxIntensityID].buffer)[count] = ObjectRef (Float::alloc( 0 )); (*outputs[mMinIntensityID].buffer)[count] = ObjectRef (Float::alloc( 0 )); ! return; } // Acquiring image Image &image = object_cast<Image>(dataInValue); unsigned short *pSourceImage = (unsigned short*) image.get_data(); --- 109,126 ---- (*outputs[mMaxIntensityID].buffer)[count] = ObjectRef (Float::alloc( 0 )); (*outputs[mMinIntensityID].buffer)[count] = ObjectRef (Float::alloc( 0 )); ! (*outputs[m_avgIntensityID].buffer)[count] = ObjectRef (Float::alloc( 0 )); ! (*outputs[m_stdIntensityID].buffer)[count] = ObjectRef (Float::alloc( 0 )); ! return; } // Acquiring image Image &image = object_cast<Image>(dataInValue); + + + if (image.get_pixelsize() != 2) { + throw new GeneralException("Pixelsize !=2",__FILE__,__LINE__); + } + + unsigned short *pSourceImage = (unsigned short*) image.get_data(); *************** *** 160,166 **** float minIntensity = *(min_element( intensityVector.begin(), intensityVector.end() )); (*outputs[mMaxIntensityID].buffer)[count] = ObjectRef (Float::alloc( maxIntensity )); (*outputs[mMinIntensityID].buffer)[count] = ObjectRef (Float::alloc( minIntensity )); ! }//calculate_behavior }; --- 178,201 ---- float minIntensity = *(min_element( intensityVector.begin(), intensityVector.end() )); + float average = 0; + float std_dev = 0; + + //average + for (int i = 0; i < intensityVector.size(); i++) { + average += intensityVector[i]; + } + average /= (float) intensityVector.size(); + + //std dev + for (int i = 0; i < intensityVector.size(); i++) { + std_dev += (intensityVector[i] - average) * (intensityVector[i] - average); + } + + std_dev = sqrt(std_dev); + (*outputs[mMaxIntensityID].buffer)[count] = ObjectRef (Float::alloc( maxIntensity )); (*outputs[mMinIntensityID].buffer)[count] = ObjectRef (Float::alloc( minIntensity )); ! (*outputs[m_avgIntensityID].buffer)[count] = ObjectRef (Float::alloc( average )); ! (*outputs[m_stdIntensityID].buffer)[count] = ObjectRef (Float::alloc( std_dev )); }//calculate_behavior }; Index: ExtractSentence_v2.cc =================================================================== RCS file: /cvsroot/robotflow/RobotFlow/Vision/src/ExtractSentence_v2.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ExtractSentence_v2.cc 29 Mar 2005 15:20:47 -0000 1.3 --- ExtractSentence_v2.cc 8 Jun 2005 14:19:07 -0000 1.4 *************** *** 124,128 **** Vector<String> &dict = object_cast<Vector<String> >(getInput(mDictID,count)); ! cerr<<"dict size "<<dict.size()<<endl; //invalid input, returning empty string! --- 124,128 ---- Vector<String> &dict = object_cast<Vector<String> >(getInput(mDictID,count)); ! //cerr<<"dict size "<<dict.size()<<endl; //invalid input, returning empty string! |