OpenCV Image Processing Assignments for CS/ECE 181B, Winter 2009, Assignments of Linguistics

Information about four programming assignments for the computer vision course cs/ece 181b at the university of california, berkeley, during the winter 2009 semester. Each assignment involves writing an opencv program to perform various image processing tasks, such as converting images to grayscale, masking, channel exchange, image scaling, rotation, edge detection, and gaussian image pyramid creation. Students are required to write code for each problem, display the outputs in windows, and save the results as jpg files.

Typology: Assignments

Pre 2010

Uploaded on 09/17/2009

koofers-user-wfd
koofers-user-wfd 🇺🇸

10 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS/ECE 181B – Computer Vision, Winter 2009
Assignment #3
Due Wednesday, February 18 by 2:00pm
Notes:
Be sure to re-read the “Policy on Academic Integrity” on the course syllabus.
This assignment is to be done individually. General help is fine (e.g., “When was that
covered?” “What does that mean again?” etc.), but the problems are to be worked on, and
the answers conceived, on your own.
Any updates or corrections will be posted on the Announcements page (home page for
the course), so check there occasionally.
For each problem, create a separate directory (called hw1-1, hw1-2, hw1-3,
and hw1-4) including urn in a single source file that contains all the code for that
problem, the executable, and the image output(s).
Turn in the files using the CSIL turnin command, as described on the Assignments
page on the course web site. (No hardcopy is required for this assignment.)
Be aware of the late policy in the course syllabus.
Problem #1 [10 points]
Write an OpenCV program called ImageConvert to load an RGB image from file and
perform the following operations on the image:
(a) Convert it to an 8-bit grayscale image.
(b) Mask the least significant six bits of the grayscale image (leaving just four
different values in the image).
(c) Exchange the red and blue channels of the original color image.
(These operations should be done via your code, not by any built-in OpenCV operations.)
The program should take one argument, the input image, e.g.:
% ImageConvert flower.jpg
Display the outputs of (a), (b), and (c) in windows with appropriate titles. Also write the
three images to files in the local directory, in 'jpg' format, called imname-gray.jpg,
imname-masked.jpg, and imname-recolor.jpg (where imname is replaced by
the name of the input image, such as “flower” in the example above).
v. 1.0
pf3
pf4

Partial preview of the text

Download OpenCV Image Processing Assignments for CS/ECE 181B, Winter 2009 and more Assignments Linguistics in PDF only on Docsity!

CS/ECE 181B – Computer Vision, Winter 2009

Assignment

Due Wednesday, February 18 by 2:00pm

Notes: ƒ Be sure to re-read the “Policy on Academic Integrity” on the course syllabus. ƒ This assignment is to be done individually. General help is fine (e.g., “When was that covered?” “What does that mean again?” etc.), but the problems are to be worked on, and the answers conceived, on your own. ƒ Any updates or corrections will be posted on the Announcements page (home page for the course), so check there occasionally. ƒ For each problem, create a separate directory (called hw1-1, hw1-2, hw1-3, and hw1-4) including urn in a single source file that contains all the code for that problem, the executable, and the image output(s). ƒ Turn in the files using the CSIL turnin command, as described on the Assignments page on the course web site. (No hardcopy is required for this assignment.) ƒ Be aware of the late policy in the course syllabus.

Problem #1 [10 points] Write an OpenCV program called ImageConvert to load an RGB image from file and perform the following operations on the image:

(a) Convert it to an 8-bit grayscale image. (b) Mask the least significant six bits of the grayscale image (leaving just four different values in the image). (c) Exchange the red and blue channels of the original color image.

(These operations should be done via your code, not by any built-in OpenCV operations.)

The program should take one argument, the input image, e.g.:

% ImageConvert flower.jpg

Display the outputs of (a), (b), and (c) in windows with appropriate titles. Also write the three images to files in the local directory, in 'jpg' format, called imname-gray.jpg, imname-masked.jpg, and imname-recolor.jpg (where imname is replaced by the name of the input image, such as “flower” in the example above).

v. 1.

Problem #2 [10 points]

Write an OpenCV program to perform the following operations on an input image:

(a) Scale the image with a spatial scale factor of k (a real-valued scalar). This creates an image of size ( k x oldwidth, k x oldheight). (b) Rotate the scaled image by theta degrees in the clockwise direction, around the center of the image.

You may use any OpenCV functions to accomplish these operations. (Hint: Use cv2DRotationMatrix() to calculate the transformation matrix and cvGetQuadrangleSubPix() to apply the transformation matrix.)

The program should take three arguments (the input image, the value of k , and the value of theta ), e.g.:

% ImageTransform flower.jpg 0.5 45

Display the outputs of (a) and (b) in windows with appropriate titles. Also write the image outputs of (a) and (b) to files in 'jpg' format, called imname-scaled.jpg and imname-rotated.jpg (where imname is replaced by the name of the input image, such as “flower” in the example above).

Problem #3 [15 points]

Write an OpenCV program that loads an RGB or grayscale image, converts it to grayscale if it is not already, and then performs the following operations:

(a) Compute the 8-bit edge image using first order derivative Sobel operator, with a 3x3 kernel, using the cvSobel function. (b) Compute the 8-bit Laplacian of the image with a 3x3 kernel using the cvLaplace function. (c) Compute the 8-bit edge image using Canny edge detector (cvCanny) with thresholds 50 and 150 using a 3x3 kernel. (d) Compute the 8-bit absolute difference image D = | (a) - (b) |. (e) Compute the 8-bit absolute difference image E = | (a) - (c) |.

You may use any OpenCV functions to accomplish these operations.

The program should take one argument, the input image, e.g.:

% ImageEdges flower.jpg

Display the K pyramid images in windows with appropriate titles. Also write the pyramid images to files in 'jpg' format, called imname-py1.jpg, imname-pyr2.jpg, etc. (where imname is replaced by the name of the input image, such as “einstein” in the example above).