Reputation: 113
I'm trying to stretch the contrast of an image to the range of 0-255 using cvNormalize. But when I print out the output pixel values, Some negative numbers appear as the pixel value. I appreciate if you help me find out where the origin of the problem is. This is the code:
cvNormalize(srcImage, dstImage, 0, 255, CV_MINMAX );
for ( int pixel = 0; pixel < dstImage->height * dstImage->width; pixel++ ) {
printf("%d\t",*(dstImage->imageData + pixel));
}
Upvotes: 4
Views: 6780
Reputation: 8725
Because imageData
's type is char*
and char
can be nagative (range is [-128, 127]). Try casting to unsigned char
.
See docs.
Upvotes: 4