From c3ae9e6f2d776c43898172486b4d13c9ca6e1ead Mon Sep 17 00:00:00 2001 From: Bob Jamison Date: Thu, 30 Mar 2006 12:13:29 +0000 Subject: WIP. siox election progress. fix api a bit. (bzr r372) --- src/trace/siox.cpp | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'src/trace/siox.cpp') diff --git a/src/trace/siox.cpp b/src/trace/siox.cpp index be1dd3995..7975d9400 100644 --- a/src/trace/siox.cpp +++ b/src/trace/siox.cpp @@ -949,7 +949,9 @@ SioxSegmentator::SioxSegmentator(int w, int h, float *limitsArg, int limitsSize) imgWidth = w; imgHeight = h; - labelField = new int[imgWidth*imgHeight]; + pixelCount = imgWidth * imgHeight; + + labelField = new int[pixelCount]; if (!limitsArg) { limits = new float[3]; @@ -1009,8 +1011,8 @@ void SioxSegmentator::trace(char *fmt, ...) -bool SioxSegmentator::segmentate(unsigned long *image, int imageSize, - float *cm, int cmSize, +bool SioxSegmentator::segmentate(unsigned long *image, + float *cm, int smoothness, double sizeFactorToKeep) { segmentated=false; @@ -1018,12 +1020,12 @@ bool SioxSegmentator::segmentate(unsigned long *image, int imageSize, hs.clear(); // save image for drb - origImage=new long[imageSize]; - for (int i=0 ; i=FOREGROUND_CONFIDENCE) @@ -1040,7 +1042,7 @@ bool SioxSegmentator::segmentate(unsigned long *image, int imageSize, // classify using color signatures, // classification cached in hashmap for drb and speedup purposes - for (int i=0; i=FOREGROUND_CONFIDENCE) { cm[i]=CERTAIN_FOREGROUND_CONFIDENCE; continue; @@ -1097,17 +1099,17 @@ bool SioxSegmentator::segmentate(unsigned long *image, int imageSize, // postprocessing smoothcm(cm, imgWidth, imgHeight, 0.33f, 0.33f, 0.33f); // average - normalizeMatrix(cm, cmSize); + normalizeMatrix(cm, pixelCount); erode(cm, imgWidth, imgHeight); - keepOnlyLargeComponents(cm, cmSize, UNKNOWN_REGION_CONFIDENCE, sizeFactorToKeep); + keepOnlyLargeComponents(cm, UNKNOWN_REGION_CONFIDENCE, sizeFactorToKeep); for (int i=0; i=UNKNOWN_REGION_CONFIDENCE) { cm[i]=CERTAIN_FOREGROUND_CONFIDENCE; } else { @@ -1115,8 +1117,8 @@ bool SioxSegmentator::segmentate(unsigned long *image, int imageSize, } } - keepOnlyLargeComponents(cm, cmSize, UNKNOWN_REGION_CONFIDENCE, sizeFactorToKeep); - fillColorRegions(cm, cmSize, image); + keepOnlyLargeComponents(cm, UNKNOWN_REGION_CONFIDENCE, sizeFactorToKeep); + fillColorRegions(cm, image); dilate(cm, imgWidth, imgHeight); segmentated=true; @@ -1125,7 +1127,7 @@ bool SioxSegmentator::segmentate(unsigned long *image, int imageSize, -void SioxSegmentator::keepOnlyLargeComponents(float *cm, int cmSize, +void SioxSegmentator::keepOnlyLargeComponents(float *cm, float threshold, double sizeFactorToKeep) { @@ -1140,7 +1142,7 @@ void SioxSegmentator::keepOnlyLargeComponents(float *cm, int cmSize, // slow but easy to understand: std::vector labelSizes; - for (int i=0 ; i=threshold) { regionCount=depthFirstSearch(cm, i, threshold, curlabel++); @@ -1153,7 +1155,7 @@ void SioxSegmentator::keepOnlyLargeComponents(float *cm, int cmSize, } } - for (int i=0 ; i pixelsToVisit; - for (int i=0; i