Ask Your Question
0

rotation-Bicubic resampling -using OpenCV python

asked 2017-09-08 03:55:17 -0600

Arun1994 gravatar image

updated 2017-09-08 04:26:14 -0600

Hey !

I am trying to rotate an image using cv2.getRotationMatrix2D(center, angle, scale) .
dst = cv2.warpAffine(img,M,(cols,rows))

how do I manipulate the interpolation method? I would like to use bicubic method .

Thanks

edit retag flag offensive close merge delete

Comments

check cv.WarpAffine. you can set interpolation flag to INTER_CUBIC

Ziri gravatar imageZiri ( 2017-09-08 07:51:34 -0600 )edit

I get the following error

ModuleNotFoundError: No module named 'cv'

I have tried to use all possible installation methods to install 'cv' . cv2 works fine but not cv :(

Arun1994 gravatar imageArun1994 ( 2017-09-12 04:33:21 -0600 )edit

Using cv2.INTER_CUBIC, the flags work . cv.warpaffine does not work even using import cv2.cv as cv .

Arun1994 gravatar imageArun1994 ( 2017-09-13 06:16:17 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
0

answered 2017-09-12 07:32:57 -0600

Arun1994 gravatar image

This works for me now :)

import cv2
import matplotlib.pyplot as plt
img = cv2.imread('1.jpg',0)
rows,cols = img.shape
M = cv2.getRotationMatrix2D((cols/2,rows/2),-40,1) # the format is cv2.getRotationMatrix2D(center, angle, scale) 
dst = cv2.warpAffine(img,M,(cols,rows),flags=cv2.INTER_CUBIC)
plt.imshow(dst)
edit flag offensive delete link more
-2

answered 2017-09-08 08:49:51 -0600

supra56 gravatar image

The stackoverflow has answered for u. link

edit flag offensive delete link more

Comments

THe answer is in C++. Anyway thanks :)

Arun1994 gravatar imageArun1994 ( 2017-09-12 07:32:05 -0600 )edit

a link to stackoverflow is not a valid answer here.

berak gravatar imageberak ( 2017-09-12 07:46:39 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-09-08 03:55:17 -0600

Seen: 1,214 times

Last updated: Sep 12 '17