Excise 3.2 Matric Operation

Excise 3.2 

2010-07-27

2. Th is exercise will accustom you to the idea of many functions taking matrix types. Create a two-dimensional matrix with three channels of type byte with data size 100-by-100. Set all the values to 0.

a. Draw a circle in the matrix using void cvCircle( CvArr* img, CvPoint center, intradius, CvScalar color, int thickness=1, int line_type=8, int shift=0 ).

b. Display this image using methods described in Chapter 2.

 

#!/usr/bin/env python from opencv.cv import * from opencv.highgui import * #Create Matric mat=cvCreateMat(100,100,CV_8UC3) #Set to be 0 cvSetZero(mat) #Set Value cv.Set(mat, 1.0) mat[3,1]+=88 #print matric element mat[3,1] print [mat[3,i] for i in range(5)] #Getsubrect sub = cvGetSubRect(img, (60, 70, 32, 32)) #Draw Circle: cvCircle( CvArr* img, CvPoint center, intradius, CvScalar color, int thickness=1, int line_type=8, int shift=0 ) cvCircle(mat,(49,49),10,(25,45,35)) #Save Image cvSaveImage("Circle.png",mat)

你可能感兴趣的:(image,import,byte,idea,Matrix,methods)