Ask Your Question
0

Custom size pyramidup and pyramiddown in python?

asked 2016-12-11 04:42:56 -0600

mani19 gravatar image

updated 2016-12-11 05:44:59 -0600

berak gravatar image

I have found C++ pyrUp and pyrDown functions which accepts the custom size i.e.

`pyrUp( tmp, dst, Size( tmp.cols*2, tmp.rows*2 )`

I need a similar python function where I can specify the size of downscaled or upscaled image as I want to down scale 75% while the default function does 50% and I want to upscale by 25% instead of 50%.

Edit: Can we do 3/4 subsampling/upsampling by using the following function.....

cv2.pyrUp(src[, dst[, dstsize[, borderType]]]) → dst


cv2.pyrDown(src[, dst[, dstsize[, borderType]]]) → dst
edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
1

answered 2016-12-11 05:05:52 -0600

berak gravatar image

updated 2016-12-11 05:35:07 -0600

then simply use cv::resize() , not pyrUp, or pyrDown (which are restricted to 50% size factor)

dst = cv2.resize(src, None, 1.25, 1.25, cv2.INTER_CUBBIC) # up
dst = cv2.resize(src, None, 0.75, 0.75, cv2.INTER_AREA) # down
edit flag offensive delete link more

Comments

can we do that using following function? cv2.pyrUp(src[, dst[, dstsize[, borderType]]]) → dst

mani19 gravatar imagemani19 ( 2016-12-11 05:12:08 -0600 )edit
1

sorry, missed the python tag, see update.

(and no, you cannot use pyrUp for arbitrary scale factors, the dstsize args are only there to fix even/odd rounding issues.)

berak gravatar imageberak ( 2016-12-11 05:33:25 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-12-11 04:42:56 -0600

Seen: 560 times

Last updated: Dec 11 '16