I want to use OpenCV2.0 and Python2.6 to show resized images. I used and adopted the example at http://opencv.willowgarage.com/documentation/python/cookbook.html but unfortunately this code is for OpenCV2.1 and seem not to be working on 2.0. Here my code:
import os, glob import cv ulpath = "exampleshq/" for infile in glob.glob( os.path.join(ulpath, "*.jpg") ): im = cv.LoadImage(infile) thumbnail = cv.CreateMat(im.rows/10, im.cols/10, cv.CV_8UC3) cv.Resize(im, thumbnail) cv.NamedWindow(infile) cv.ShowImage(infile, thumbnail) cv.WaitKey(0) cv.DestroyWindow(name)
Since I cannot use
instead, which was no problem in other applications. Nevertheless cv.iplimage has no attribute rows, cols or size. Can anyone give me a hint, how to solve this problem? Thanks.
If you wish to use CV2, you need to use the
For example, this will resize both axes by half:
small = cv2.resize(image, (0,0), fx=0.5, fy=0.5)
and this will resize the image to have 100 cols (width) and 50 rows (height):
resized_image = cv2.resize(image, (100, 50))
Another option is to use
scipy module, by using:
small = scipy.misc.imresize(image, 0.5)
According to the SciPy documentation:
imresizeis deprecated in SciPy 1.0.0, and will be removed in 1.2.0.
Note that if you're looking to resize by a factor, you may actually want