Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Replies: 1   Last Post: Jan 2, 2012 2:39 AM

 Mark McClure Posts: 193 Registered: 9/12/07
Posted: Jan 2, 2012 2:39 AM

On Fri, Dec 30, 2011 at 7:06 AM, nlko <niko@homebound.de> wrote:

> I want to follow a horizontal movement of a black object on white
> background in an AVI.

It just so happens that I need to solve a similar question. Here's a
very short clip of a flying saucer from The Day the Earth Stood Still.

movie = Import["http://facstaff.unca.edu/mcmcclur/Saucer.mov",
"GraphicsList"];
ListAnimate[Image /@ movie]

We can find the location of the ship using Binarize. In this case,
we've got to block out the bottom since the white building has a color
similar to the ship. This is accomplished using ImageMultiply with a
black bottomed image.

marker = Image[Join[Table[1, {100}, {480}],
Table[0, {260}, {480}], 1]];
binaryMovie = Table[Binarize[ImageMultiply[frame, marker], 0.9],
{frame, movie}];

Let's check how it worked.

ListAnimate[binaryMovie]

If you need something like a center of mass, I guess you do to the following.

locations = Table[
Mean[N[Position[ImageData[frame], 1]]],
{frame, binaryMovie}];
locations = {#[[2]], 360 - #[[1]]} & /@ locations;

Here's a look.

ListAnimate[Image /@ Table[Graphics[Point[loc],
PlotRange -> {{0, 480}, {0, 360}}],
{loc, locations}]]

Mark McClure