Sum of each column opencv -
in matlab, if matrix, sum(a) treats columns of vectors, returning row vector of sums of each column.
sum(image); how done opencv?
for 8 bit greyscale image, following should work (i think). shouldn't hard expand different image types.
int imgstep = image->widthstep; uchar* imagedata = (uchar*)image->imagedata; uint result[image->width]; memset(result, 0, sizeof(uchar) * image->width); (int col = 0; col < image->width; col++) { (int row = 0; row < image->height; row++) { result[col] += imagedata[row * imgstep + col]; } } // desired vector in result
Comments
Post a Comment