Sunday, February 7, 2010

crop image in opencv

from opencv.cv import *
from opencv.highgui import *


if __name__ == '__main__':
   
    new_width = 120
    new_height = 110
    ipl = cvLoadImage("/home/selva/Desktop/me.jpg");
    cropped = cvCreateImage( cvSize(new_width, new_height), 8, 3)
    src_region = cvGetSubRect(ipl, cvRect(110, 120, new_width, new_height) )
    cvCopy(src_region, cropped)

   
    cvNamedWindow("image pop", CV_WINDOW_AUTOSIZE)
    cvShowImage("image pop",cropped)
    cvWaitKey()

No comments:

Post a Comment