Professional Documents
Culture Documents
AHMAD 1
II. Q UESTION N O . 1
1) Download and install Python/Anaconda.
2) Configure OpenCV with jupyter notebook. No other IDE is allowed.
3) Install the required libraries and run a simple program for loading and displaying a color image to
test your installation.
III. Q UESTION N O . 2
Use color.2.Convert the color image into a binary image. Print the pixel values of the grayscale image
and finally convert the grayscale image into the binary image and print both the original color and grayscale
image.
IV. Q UESTION N O . 3
Test the following OpenCV built-in functions for edge detection on your loaded image. Make individual
blocks for each of the following functions and print the actual image along with the detected images.
1) filter2D: The OpenCV function filter2D to create your own linear filters. filter2D(src, dst, ddepth ,
kernel, anchor, delta, BORDER DEFAULT)
2) Gaussian filter: Probably the most useful filter (although not the fastest). Gaussian filtering is done
by convolving each point in the input array with a Gaussian kernel and then summing them all to
produce the output array. GaussianBlur( src, dst, Size( i, i ), 0, 0)
3) Gradient X and gradient Y: Gradient is the partial derivative (a derivative of multiple variables).
We can derivate the image row-wise (in x) Ix and column-wise (in y) Iy .
4) Gradient magnitude: Magnitude shows the intensity of the change that ranges from low to high.
Later we can decide on the magnitude value to keep the pixel as edge or non-edge.
5) Sobel: The Soble and Prewitt are the sample edge detector. We can use the straight-away function
provided by OpenCV to get Sobel edges.
6) Canny: The most popular edge detector. The OpenCV also provides a built-in function for the
Canny edge detector.
V. Q UESTION N O . 4
Finally, implement the Edge detector in Jupyter notebook by yourself using the following steps.
• Get the image and convert it into gray-scale.
• Build the Gaussian filter from the filter2D function and apply it to the image.
• Apply the x-derivative (gradient) and y-derivative (gradient)
• Compute the gradient magnitude
• Threshold the final image.
• Finally, implement Laplacian of Gaussian (LoG) for comparison.