Tuesday, December 14th, 2010...11:26 am

A bedazzling hexing combination

Jump to Comments

Let’s continue to explore the use of linear algebra by placing a bedazzling hex on Harry Potter which will make his appearance look the exact same as the image behind him. Harry could, of course, stand behind his invisibility cloak but we’ll assume he’s misplaced it as the word hex conveniently rhymes with convex, which will be an important mathematical tool!

We’ll have Harry stand in the hall of Hogwarts seen below.

The image can be found at Wired.com. To place Harry in the scene, we grab an image of the young wizard, like the one below that can be found at http://www.bbc.co.uk/blogs/ni/Harry-Potter.jpg.

With a wave of the magic wand of Photoshop, Harry teleports from the gray background into the hall of Hogwarts as seen below.

How do we place the bedazzling hex on Harry? A little bit at a time, which can be quite vexing…convexing, actually! Let X be the matrix containing the pixel information for the image of Hogwarts with Harry. Let Y be the matrix containing the colors where Harry is not in the image.

We then progressively calculate a new matrix N = alpha Y + (1 - alpha)X
where  0 le alpha le 1. We begin with alpha = 0 in which case N = X. Incrementally, the amount of pixel information from X is decreased as the amount of Y is increased until at the end alpha = 1 and N = Y.

Can you verify that any pixel in X that is not part of Harry’s image that disappears to create Y will stay the same for any new picture we calculate? Keep in mind that this is called a convex combination since the coefficients in our linear combination are non-negative and sum to 1.

If we place all the images into a movie, we see Harry disappear before our eyes!

Would you like Harry to return? Create new images where alpha starts at 1 and decreases incrementally to 0. Then the hex will be removed through the convex combination!

Leave a Reply