You are on page 1of 2

Programming assignment 1

Dr. Mohamed El Ansari Associate Professor Department of Computer Science, Faculty of Science University of Ibn Zohr, Morocco melansari@gmail.com Visiting Professor EMARO, Erasmus Mundus Master Ecole Centrale de Nantes, France

Exercise-1
Use camera to take a picture (textured area). The picture should be grabbed from your camera using OpenCV functions. Smooth the image in several ways. You can use the following function: void cvFilter2D( const CvArr* src, CvArr* dst, const CvMat* kernel, CvPoint anchor=cvPoint(-1,-1)); which convolves an image with a kernel. 1. Use a symmetric 3-by-3, 5-by-5, 9-by-9 and 11-by-11 smoothing window size and display the results. 2. Are the output results nearly the same by smoothing the image twice with a 5-by-5 lter as when you smooth once with two 11-by-11 lters? Why or why not?

Exercise-2
Separable kernels. Create a 3-by-3 Gaussian kernel using rows [(1/16, 2/16, 1/16),(2/16, 4/16, 2/16), (1/16, 2/16, 1/16)] and with anchor point in the middle. 1. Run this kernel on an image and display the results. 2. Now create two one-dimensional kernels with anchors in the center: one going across (1/4, 2/4, 1/4), and one going down (1/4, 2/4, 1/4). Load the same original image and use cvFilter2D() to convolve the image twice, once with the rst 1D kernel and once with the second 1D kernel. Describe the results. 3. Describe the order of complexity (number of operations) for the kernel in part 1 and for the kernels in part 2. The dierence is the advantage of being able to use separable kernels and the entire Gaussian class of ltersor any linearly decomposable lter that is separable, since convolution is a linear operation.

Exercise-3
Load an image of a checkerboard pattern, e.g., one of those used to calibrate cameras. 1. Use the Canny operator to detect edge. You will use the function 1

void cvCanny( const CvArr* image, CvArr* edges, double threshold1, double threshold2, int aperture_size=3 ); 2. Use Hough transform to detect the straight lines of the image. The method should be applied to the edge image (the output of cvCanny()). There dierent functions available in OpenCV. You can call the following one; CvSeq* cvHoughLines2( CvArr* image, void* line_storage, int method, double rho, double theta, int threshold, double param1=0, double param2=0 ); You can see the examples included in the directory where OpenCV is installed to get help on how to use this function. 3. Compute all the points where the detected lines intersect in the image. 4. Draw the detected lines and their intersections on the original image. The intersection points should be represented by small circles drawn at their positions.

What to turn in?


You are to turn in the following items: I- A print-out report including: 1. C/C++ source les. They should be commented. 2. The results obtained, i.e., output images and discussions. 3. Answers to the questions. 4. A brief summary of what you have learned. II- You also need to send me by email: The C/C++ source les, which shall be commented and named as exercise-1.cpp, exercise-2.cpp and exercise-3.cpp The pdf le of your report.

You might also like