Exercises
Use
cvFilter2D()
to create a filter that detects only 60 degree lines in an image. Display the results on a sufficiently interesting image scene.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.
Run this kernel on an image and display the results.
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 first 1D kernel and once with the second 1D kernel. Describe the results.Describe the order of complexity (number of operations) for the kernel in part a and for the kernels in part b. The difference is the advantage of being able to use separable kernels and the entire Gaussian class of filters—or any linearly decomposable filter that is separable, since convolution is a linear operation.
Can you make a separable kernel from the filter shown in Figure 6-5? If so, show what it looks like.
In a drawing program such as PowerPoint, draw a series of concentric circles forming a bull's-eye.
Make a series of lines going into the bull's-eye. Save the image.
Using a 3-by-3 aperture size, take and display the first-order x- and y-derivatives of your picture. Then increase the aperture size to 5-by-5, 9-by-9, and 13-by-13. Describe the results.
Create a new image that is just a 45 degree line, white on black. ...
Get Learning OpenCV now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.