I want to optimize my face detection algorithm by scaling down the image. What is the best way? should I use cvPyrDown (as I saw in one example and yielded poor results so far), cvResize or another function?
If you only want to scale the image, use cvResize
as Adrian Popovici suggested.
cvPyrDown
will apply a Gaussian blur to smooth the image, then by default it will down-sample the image by a factor of two by rejecting even columns and rows. This smoothing may be degrading your performance (I'm not sure how it affects the detection algorithm). Another possibility for the poor performance might be the discontinuities created by just dropping even rows and columns; whereas, the smooth interpolations (assuming you interpolated with something other than nearest neighbor) by cvResize
allow the face detection to work better. Here is the documentation on cvPyrDown
for more information on the exact kernel that is used.
For scaling down images I would use :
void cvResize(const CvArr* src, CvArr* dst, int interpolation=CV_INTER_LINEAR )
To shrink an image, it will generally look best with CV_INTER_AREA interpolation, whereas to enlarge an image, it will generally look best with CV_INTER_CUBIC (slow) or CV_INTER_LINEAR (faster but still looks OK).
But also I haven't used cvPyrDown so far so i don't know it's performances...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With