Prechádzať zdrojové kódy

fixed nasty sign bug

Alexander Freytag 12 rokov pred
rodič
commit
3c5e120913
2 zmenil súbory, kde vykonal 3 pridanie a 9 odobranie
  1. 1 7
      segment-image-labelOutput.h
  2. 2 2
      segmentFelzenszwalb.cpp

+ 1 - 7
segment-image-labelOutput.h

@@ -95,11 +95,6 @@ image<int> *segment_image_labelOutput(image<rgb> *im, float sigma, float c, int
   *num_ccs = u->num_sets();
 
   image<int> *output = new image<int>(width, height);
-
-  // pick random colors for each component
-  rgb *colors = new rgb[width*height];
-  for (int i = 0; i < width*height; i++)
-    colors[i] = random_rgb();
   
   for (int y = 0; y < height; y++) {
     for (int x = 0; x < width; x++) {
@@ -107,8 +102,7 @@ image<int> *segment_image_labelOutput(image<rgb> *im, float sigma, float c, int
       imRef(output, x, y) = comp;
     }
   }  
-
-  delete [] colors;  
+ 
   delete u;
 
   return output;

+ 2 - 2
segmentFelzenszwalb.cpp

@@ -248,7 +248,7 @@ void mexFunction(int nOutput, mxArray *pOutput[], /* Output variables */
 	int width ( imgResult->width() );
 	int height (imgResult->height() ); 
         int dims[] = {height, width};
-       	pOutput[0] = mxCreateNumericArray (2, dims, mxINT8_CLASS, mxREAL);
+       	pOutput[0] = mxCreateNumericArray (2, dims, mxUINT8_CLASS, mxREAL);
 	unsigned char *out1; /* pointer to output 1 */
 	out1 = (unsigned char *)mxGetPr( pOutput[0] ); /* pointer to output 1 */
 	
@@ -258,7 +258,7 @@ void mexFunction(int nOutput, mxArray *pOutput[], /* Output variables */
 	  uint rowOffset ( x*height );
 	  for ( uint y = 0; y < height; y++)
 	  {
-	      out1[rowOffset + y ] = (double) (imRef(imgResult, x, y));
+	      out1[rowOffset + y ] = (uint) (imRef(imgResult, x, y));
 	  }
 	}
      }