Archive for September, 2007

Vision Basics

Friday, September 28th, 2007

“How do you pick out an object from a scene?” If this has been a burning question for you, as it has for me, I have a few answers. The basic question I had is “what identifies the object”? Well, it seems so obvious. If its a log, then look for something “log-like” – longer than it is wide at least. And pick the biggest one in the image.

Everything is easy until you try to do it. So, sitting down writing a program to pick out a log is much harder than just saying “do it!” Do you look for a brown thing? What happens when lighting changes – even by a small amount? What if there are other brown things. And anywise, even if you find brown, what does that mean – one brown pixel is not enough. You must connect them.

Turns out, in some cases, it can be as simple as follows:

  1. Background subtraction – just take a picture before and after the object is in view. This is “fair” in many cases, as in when the camera is fixed and the object in view is not.
  2. Thresholding – whether you have an image or not, you can use an auto-thresholding algorithm to separate the background from the foreground. Now you can say what “is” and “is not” the object.
  3. Connected-component labeling – actually, you may have thresholded several potential objects. Labeling each one separately, we can now perform calcuations on things such as elongation, center of mass, etc.

This is all very basic, and as my teacher would warn “there is no one way to do computer vision.” These ideas are just a starting point. For an example of what I have described, here is my writeup of an assignment. Writeup

BYU Housing Fiasco

Friday, September 21st, 2007

This is a hot topic for anyone who is or will be attending BYU. The BYU Housing fiasco. My introduction to this topic started a week before school started. I decided to start looking for a house since, after all, it was about time to start school. Sure, I had procrastinated, but I reasoned that there might be a housing glut just as there is in Idaho. To my horror, it turned out that every single one of the two dozen or so complexes I called was full. How could this be?

Before I continue, rest assure I did find an awesome place. No worries.

The situation is this: BYU, as all church schools, provides a list of approved housing. To be on this list, a housing complex must meet certain quality requirements. Additionally, it must ensure that its tenants are enrolled in institute, or something equivalent. In the end, this is good as it places a check on both the land owners to keep their places up, for fear of losing approval; this in turn means loss of tenants, as BYU students, at least, must live in BYU approved housing. Further, it ensures that bad apples are less common.

One of the requirements BYU makes is also that the housing unit must be within a certain distance of the school. E.G., you cannot open a housing complex in Alabama, no matter how much you want, and get it BYU approved. This radius in the past extended into Orem, only a couple miles north, until recently. The radius is now just two miles from campus. This means more people in a smaller area. More demand. Less supply. Economics = very bad.

Then today, while looking for research papers, I broke into a discussion with a few grad students who have had to deal with this issue for some time. Turns out the Provo council has been urged to impose new limits on housing density in certain areas around campus. Instead of unlimited number of tenants per house, it is now limited in some areas to two non-related persons. Note that this would effectively eliminate the appeal of an owner to rent out the house – two tenants are way too few to make renting profitable. But this is exactly the intended response the council hoped for. In addition, the city wants to start a zany new policy that would require everyone to have tags in order to park their cars in certain neighborhoods. Worse, they are trying to push everyone into high density housing in one part of town with the hope that single students will stay out of the rest of town. The most sinister part of this plan is that the high density housing is going to be built without parking. This forces students to simply not have cars – an stated goal of the city council’s plan. Scary.

Worsening this problem, BYU just demolished housing for hundreds if not thousands of students who used to live in the DI towers.

I mention this, not because I want to raise a raucous, but because this is an issue that will affect BYU undergrad students for years to come. The sad part is that the city council can take advantage of the transient nature of students. Even if a student stayed here continuously during his or her undergraduate work, they would be gone in about three or four years – during which time, likely, they would not even care about things a few years down the road. When the time for change did come, students would protest in vain, as the changes would already be well underway. This is a continuity problem. City council members don’t have to cater to the students, because students aren’t there long enough, and are way to busy, to make an issue of petty things like parking or housing zones.

Anywise, just a heads up. If everyone united on this issue, we could probably get the city council to take the appropriate action: cancel their weirdo plan to force the provo area around BYU into an overpriced housing fiasco wherein students can’t own cars. (sounds like a communist micro-city).

Mac OS X dyld problems

Friday, September 21st, 2007

For anyone who has received an error message such as:

dyld: Library not loaded
Reason: image not found

I offer a few insights. First, this is a problem caused by the dynamic loader in OS X. This loader is a lot more complex than ld on, say, your standard Linux distro. A good description of someof the nuances of dyld is available at the fink site.

The basic problem is that dyld, as a good dynamic loader should, dynamically tries to load the libraries bound to an application when it is run. The problem, it turns out, was that I had somehow decided to manually compile and install the particular application, netpbm, in one spot. I then installed it via fink and MacPorts. Don’t ask why three separate installs, but do understand it witnesses a certain frustration was latent.

In any case, after a good old search of my system for other copies of the library, I found that, indeed, three separate copies were floating around. This in turn confused the heck out of dyld, which was loading the wrong one. Once I deleted this library, it was solved.

Summary: Delete multiple copies of libraries to remove conflicts

As an aside, if ere you ask yourself “Which libraries does this application depend on?”, I have an answer. This question came up when I was trying to get OpenCV to work on my macbook. The sample app was not loading. Working through this problem led me to find that otool, available on os x, can list the libraries available in an application. Use the -L switch, and away you go.

Matlab Vector Fields

Thursday, September 20th, 2007

I made up some nifty code to generate a tangential potential field using vectors in Matlab. It was especially fun figuring out that you can flatten portions of the vector matrix using conditional matrix selection!

Code is posted below with a sample.

x=[-50:1:50]
y=[-50:1:50]
[X,Y]=meshgrid(x,y)
U=(sqrt(X.*X+Y.*Y) > 5) .*max(1-( sqrt(Y.*Y+X.*X) – 5)/38, 0) .* cos(atan2(Y,X) + 3.1415/2.0)
V=(sqrt(X.*X+Y.*Y) > 5) .*max(1-( sqrt(Y.*Y+X.*X) – 5)/38, 0) .* sin(atan2(Y,X) + 3.1415/2.0)
quiver(X,Y,U,V)

Tangential Potential Field

Good Mac vs. Windows Quote

Wednesday, September 19th, 2007

This is taken from the Mac-TeX site:

If you booted up your machine and aren’t sure if your using a Mac, don’t be embarassed. If Windows converges any more to the mac it will actually boot with Welcome to Macintosh.

I couldn’t resist posting this, especially after just getting out of a Microsoft recruiting session (which featured my key attractor: pizza).

Tank Passed

Wednesday, September 19th, 2007

After one of the most intense coding sessions I have ever done, I finished coding ten minutes before it was time to pass off the tank code which steers a tank through obstacles to a flag, then returns the flag to base. Hmmph. Not so cool sounding. Well, since that’s the typical reaction to most computer science stuff, I’ll just move on to lessons learned:

  1. BzTank does weird stuff with bounds. It also has some quarks that can make it look like you’re algorithms broken. In my case, I tried using, essentially, square potential fields (to fit around my square obstacles!) instead of round ones. The BzFlags bounds weirdness made that an expensive choice. One hour before due time, I switched and…well, see the title of this article. Lesson: Always spend more time verifying that your assumptions are correct than tweaking parameters in the hope that it’ll all work out magically.
  2. It takes a long time to do things well if you have never done them before. I think this lab could honestly have taken 20 minutes if I’d had some familiarity with any of the “new” things, including: 1) bztank, 2) the whole notion of steering towards objects in code, or 3) the lab bztank environment. Lesson: Start these things two weeks before the due date. Finish them a week early. Then start on the next one.
  3. As it relates to testing your assumptions, I did learn a valuable technique, which is to use yourself as a bot before worrying about using the real bots. This lets you poke around the world and see what happens under certain conditions as you determine. This is what finally helped me after days and days of observing the real bots fail. Lesson: Get things under your control as soon as possible.

Seven Years Later…

Wednesday, September 19th, 2007

Just today I finished reading the last words of the Old Testament. I think I started some time near the start of my mission in 2001. We are very near to 2008 now, so I have spent roughly seven years plodding through every single word of that “book.” No short-cuts or chapter heading skimming; no, I read every detail on the construction of the tabernacle, every list of begatting, and every single curse and blessing on Israel. I did skip the Song of Solomon, which has been called Scriptural Trash by some General Authorities. But other than that, I read it. It was good.

Quotable Emerson

Monday, September 17th, 2007

On the long drive to Rexburg to get my car registered in Idaho, I listened to a couple of talks from Emerson (though I do not plan on ever moving back…yet do I continue to be an Idaho resident) They were inspiring, so I have to quote them here. He had a talk on circles that sounded great, but I was mainly drawn to his remarks in a talk entitled “The American Scholar“.

The first time I listened to this, I almost fell asleep, until a few good quotes came along. The 2nd time I listened to it, I realized he had a very reasonable organization to his thoughts. The third time, I was enthralled. I found he was speaking about the american scholar’s influences (nature, books, experience) and responsibilities.

On books, he said:

“As no air-pump can by any means make a perfect vacuum, so neither can any artist entirely exclude the conventional, the local, the perishable from his book, or write a book of pure thought, that shall be as efficient, in all respects, to a remote posterity, as to contemporaries, or rather to the second age. Each age, it is found, must write its own books.”

Interesting; more inspiring:

Books are the best of things, well used; abused, among the worst. What is the right use? What is the one end, which all means go to effect? They are for nothing but to inspire.

Then Emerson goes on to explain that “The one thing in the world, of value, is the active soul…The soul active sees absolute truth; and utters truth, or creates”. Here Emerson is urging that books are meant to inspire us to action. Not to become simple bookworms.

When he goes on to talk of experience he comments further that “Action is with the scholar subordinate, but it is essential. Without it, he is not yet man. Without it, thought can never ripen into truth.” Then my favorite part: “The true scholar grudges every opportunity of action past by, as a loss of power.” Why is this a loss of power? Certainly knowledge is power, and we learn by doing, but I don’t think Emerson was just referring to, say, applying a particular theory to a single vocation. In his talk he speaks of the scholar as being balanced. This means reaching beyond one narrow discipline or one slice of humanity. We thus build a “vocabulary” of life, as he explains later:

“Life is our dictionary. Years are well spent in country labors; in town,–in the insight into trades and manufactures; in frank intercourse with many men and women; in science; in art; to the one end of mastering in all their facts a language by which to illustrate and embody our perceptions. I learn immediately from any speaker how much he has already lived, through the poverty or the splendor of his speech. “

How often do I realize that I am simply looking at things with short-sighted vision? Very often, even with friends or people I’ve known for some time, I misjudge; I assume I know their motives when I do not. Emerson, I think, encourages the kind of experience that wears away at the misconceptions of inexperience. “A great soul should be strong to live, as well as strong to think.” This refining experience is so much needed in an intolerant world.

Further, on this note, Emerson comments on the literary shift of focus from concern only for the exotic to the local:

“I ask not for the great, the remote, the romantic; what is doing in Italy or Arabia; what is Greek art, or Provencal minstrelsy; I embrace the common, I explore and sit at the feet of the familiar, the low. Give me insight into to-day, and you may have the antique and future worlds.”

As it relates to life experience, it does not seem necessary to travel to Europe or Africa to “live.” Try understanding what’s under your nose, for – in Emerson’s words – “things near are not less beautiful and wondrous than things remote. The near explains the far…there is no trifle; there is no puzzle; but one design unites and animates the farthest pinnacle and the lowest trench.”

Ah, refreshing to not have to look far to gain relevant understanding; also refreshing is the thought that the kind of understanding Emerson argues for is broad and hard-earned through life experience. That seems inspiring partly because it is so attainable – I am alive, and thus able to try.

Translations of Faust

Monday, September 17th, 2007

I stumbled across a small room in our great library (3rd in the nation!) that contains only copies of literary classics. Upon inspection, I found what I consider to be classics – Faust, Moby Dick, Origin of the Species, etc. But these, like icing on the cake, were all on the top shelves. The three shelves below these classics were stuffed with sci-fi and fantasy books. Since I don’t read sci-fi or fantasy, I can’t attest to these books classicity.

But, I did find Faust and so began to read it. I’ve heard this book used in speeches but never been impressed with its content until this time. I’ve concluded that part of the problem with my prior reading may be related to translation. The translation I found was apparently just very well done. I was impressed with one line of it and wanted to copy it down. I searched the Internet for online versions of Faust; but, all the translations I found didn’t say it quite like the version in the library. Here’s the original (IE, the one I like, making it the baseline):

“Who deems himself complete is hard to please,
A maturing soul is grateful evermore.”

This translation was done by Alice Raphael. Its more better, in my book. Yea, even the bestest.

Here are the inferior ones:

“Your finish’d gentlemen you ne’er can please;
A growing mind alone will grateful prove.”
[1]

Hmmm….to a non-english major, I struggle to find what “finish’d gentlemen” means.

“What’s finished you can never alter after:
Minds still in growth will be grateful though.”
[2]

Still, not quite as good as what I read…Yet another:

“A mind once formed finds naught made right thereafter;
A growing mind will thank you evermore.”
[3]

The other versions just don’t make as much sense to me.

Fluid Simulation

Thursday, September 13th, 2007

When the pirates of the caribbean movie first came out several years ago, I with millions of others went to see it in the theaters. It was not only visually impressive but it also had an entertaining story line. In addition, it reminded me of the actual ride in Disneyland – so there was an element of nostalgia. Then pirates two cameout, which was little more than a teaser for pirates three, which was better than two, but still “a bit out there.” Some would even replace “a bit out there” with “a druggies day dream.”

Anywise, I think for my graphics class, which demands we write a game, that I want to do a simulation of the black pearl. I envision the black perl in 3D, with the torn sails flapping in the wind, and water leaping across the bow. Things are usually harder than they seem, however, and I may have to reduce my vision (and as a result, I may end up with a solid square for a sail and a plane of stationary blue “water”, none of which lappeth on the bow). Either way, some people have supported me in my idea. They referred me to a fluid simulation paper that breaks down the navier-stokes equation into something the common man can read. The paper is titled “Fluid Flow for the Rest of Us” and is found here.

What I’m shooting for: Black Pearl Game
What I’ll have time for: What I’ll have time for