• To: mathgroup at smc.vnet.net
• Subject: [mg123936] Re: Follow point in AVI
• From: Mark McClure <mcmcclur at unca.edu>
• Date: Mon, 2 Jan 2012 02:39:20 -0500 (EST)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• References: <201112301206.HAA08399@smc.vnet.net>

```On Fri, Dec 30, 2011 at 7:06 AM, nlko <niko at 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

```

• Prev by Date: Re: beginner question regarding units in equations
• Next by Date: Re: Does this make sense?
• Previous by thread: Re: Using Mathematica output in other programs
• Next by thread: Rule replacement doesn't work after NDSolve?