Assignment 2: Image Understanding and Simple Knowledge Representation
|
CSE 415: Introduction to Artificial Intelligence
The University of Washington, Seattle, Autumn 2010
|
|
The reading for this assignment is
(a) "Image Analysis", and
(b) "Knowledge Representation"
|
Parts I and III due Friday, October 15 through
Catalyst CollectIt
at 2:00 PM. Part II due Wednesday, October 20
through Catalyst CollectIt also at 2:00 PM.
(the extension on Part II was announced in class and updated
here on Wednesday, Oct. 13)
The subject matter of this assignment comes from two broad topics:
image understanding and knowledge representation. The relevant
reading for the image understanding part is the "Image-Analysis.pdf"
file linked from the Textbooks page of our course website.
The relevant reading for knowledge representation is
from the chapter on knowledge representation in Part 2 of "The Elements of Artificial
Intelligence Using Python", pages 99-116 (also linked from the Textbooks page).
You should turn in a plain ASCII text file named A2PartI.txt for Part I.
(Updated on Oct. 14:) For Part III, turn in a Python file (similar to the MyLinneus.py file
that you turned in for Lab 2).
Parts II should be turned in as a document in Word (.doc or .docx) or Open Office (.odt)
or PDF, with the name A2PartII.doc (or one of the other extensions).
This document will contain a combination of textual answers, and embedded images.
|
Part I. Written Answers (40 points).
At the end of the Image Analysis reading are several exercises.
Let's call these IA 1, IA 2, IA 3, etc. At the end of the
knowledge representation chapter are also exercises. Let's
call these KR 1, KR 2, etc. Do the following eight exercises.
They are worth 5 points each.
-
IA 7. (about polar lines)
-
IA 8. (also about polar lines)
-
IA 11. (about connected components)
-
IA 15a. (about erosion)
-
IA 15b. (about dilation)
-
Design a structuring element for the hit-or-miss transform
that fits into a 3-rows by 4-columns array that will detect
the right endpoints of horizontal line segments.
-
KR 3. (about ISA hierarchies)
-
KR 5. (about partial orders).
You can render the diagram using character graphics (be sure
to use a monspaced font such as Courier or Courier New), or
you can create (see Part II) and include a PNG image near the beginning of your document for Parts II and III with
the label "Diagram for Part I problem 8".
|
Part II. Image Understanding Experiments (20 points plus up to 15 points of extra credit).
-
(5 points)
Apply Roberts' edge detection operator to the stamps and
coins image (available from PixelMath in INFACT as "StampsAndCoinsReduced.jpg"). Save your results as Edges.jpg. Show the image in your document
and answer the question: "To what extent have the edges of the stamps and
coins been identified?"
-
(15 points)
Use the Hough transform (the code is available in INFACT
from the PixelMath Python File menu, "Load From Server" option)
to find the lines that border the stamps in the image.
Modify the code as necessary, and include your modified version
of the code in your report.
Show the Hough Transform (parameter space) image itself in your report.
Then backproject the lines onto the original image.
Save this as StampLines.jpg and include it in your report.
What value did you use as a cutoff for deciding whether
a peak in the Hough array was significant enough to consider
as a stamp border line?
-
Optional, for extra credit (5 points):
Modify an implementation of the Hough Transform so that
pixels only vote for lines in a narrow band of directions.
To determine the dominant direction of an edge, you should use
the Sobel gradients, rather than the Roberts Cross operator.
Then get the angle of the gradient using either the
Python math.atan2 function or the PixelMath calculator function
angle(dx,dy). The latter works only as part of a formula within
the PixelMath calculator.
-
Optional, for extra credit (5 points).
Modify your Hough Transform code so that
it detects circles rather than lines. You may wish to set it up
so that it takes the radius as a top-level argument. Your code
can then call the Hought Transform routine several times to find
circles of different radii.
Apply your circle detection code to the StampsAndCoinsReduced.jpg
image.
-
Optional, for extra credit (5 points). Using your circle detection
code as a starting point, add functionality to
output a list of hypotheses about how much money there is in
the photo and an indication of the weight on that hypothesis.
For example, one hypothesis might be that there is $1.43 showing
in the image and another that there is $1.52. These two might
differ because it is difficult to tell whether a particular circle
represents a penny or a dime, which are, by-the-way, almost the
same size and shape. Because the color of the coin is slightly
brown, a higher weight may be put on the $1.43 hypothesis.
After adjusting your system to get the right answer on the
first image, try it on another coin image (Coins-abutting-reduced.jpg), and show the results.
Include your code and its output in your report.
|
Part III. ISA Hierarchy Manipulation (20 points plus up to 15 points of extra credit).
The Python code for a program called Linneus that manages a small knowledge base is available
here.
Add the following features to the Linneus program:
-
cycle detection (5 points). Have Linneus detect possible cycles in the database,
so it can have the following type of dialog.
> A a being is a creature.
I understand.
> A creature is an animal.
I understand.
> An animal is a being.
Yes, but a being is an animal, because a being is a creature and a creature is an animal.
I'm not going to remember that an animal is a being unless you insist.
> OK
I don't understand.
-
cycle processing (15 points). Have Linneus handle cycles by making one element of a cycle the
representative in the ISA hierarchy and making others into synonyms without separate
nodes. It should be able to carry on the following continuation of the above dialog.
> I insist that an animal is a being.
Then I am inferring that an animal, a being, and a creature
are all names for the same thing.
I will use the name animal for this class, and I will
consider the others to be aliases for it.
> What is a creature?
Creature is another name for animal.
> A creature is an organism.
I'll remember that an animal is an organism.
> What is an animal?
An animal is an organism.
> An organism is a living-thing.
I understand.
> A living-thing is an organism.
Yes, but a living thing is an organism, because you told me that.
I'm not going to remember that a living-thing is an organism unless you insist.
> I insist that a living thing is an organism.
Then I am inferring that a living-thing, and an organism
are both names for the same thing.
I will use the name living-thing for this class, and I will
consider the other to be an alias for it.
> Is a being an organism?
Yes, an animal is a living-thing.
-
Optional, for extra credit.
(2 points) Extend your Linneus program's functionality to be able to handle the following
kind of continuation of the previous conversation.
> Why is a being an organism?
Because being is another name for animal, an animal is a living-thing, and
organism is another name for living-thing.
-
Optional, for extra credit.
(5 points)
Add memory for what the user entered, as distinct from
changes to the main ISA and INCLUDES databases, and the possibility of
retraction. Thus you should keep a separate list of the user's
inputs, together with corresponding flags, each of which indicates whether
the statement has been retracted.
> A cat is an animal.
I understand.
> Forget I said a lion is an animal.
I have no record that you ever said a lion is an animal.
> Forget I said a cat is an animal.
OK
> Is a cat an animal?
No, as far as I have been informed, it is not.
(You don't have to handle aliases here.)
-
Extra credit.
Retraction of inferrable consequences.
(5 points). Add the capability to engage in the following kind of dialog.
> An A is a B.
I understand.
> A B is a C.
I understand.
> Is an A a C?
Yes, it is.
> It can't be that an A is a C.
Shall I forget that an A is a B?
> No
Shall I forget that a B is a C?
> Yes.
OK, it is no longer the case that a B is a C.
(You don't have to handle aliases here.)
-
Optional, for extra credit.
Persistence.
(3 points).
Have Linneus read in a file of facts, isa-data.txt, at the beginning of
its session and write out the (updated) file at the end.
Ideally, it will also automatically make a backup copy of isa-data.txt
with the name isa-data.txt.bak or similar name involving a version number,
before it writes out the new version.
|
Updates and Corrections
If necessary, updates and corrections will be posted here and mentioned in class or on
GoPost. Update #1: In Part I, numbers 4 and 5 (about erosion and dilation),
assume that the structuring element's origin is in its center.
Update #2: For Part II, number 2, I have posted a shortcut that your
program can use to access the input data image directly from the server.
It's in GoPost in response to the question from Phil McGuire.
Note that the due date for Part II has been changed so that you have
5 more days to work on it. How to turn in Parts II and III has been
updated, too.
|