Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cvPyrDown vs cvResize for face detection optimization

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?

like image 817
Itay k Avatar asked Jan 18 '23 03:01

Itay k


2 Answers

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.

like image 58
mevatron Avatar answered Jan 30 '23 21:01

mevatron


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...

like image 39
Adrian Avatar answered Jan 30 '23 23:01

Adrian