Monday, July 12, 2010

Massively multi-player games: an epidemiologist's workshop

I've been engrossed in reading This Gaming Life by Jim Rossignol recently. A significant portion of the book discusses the oddities of the role of video games (and games in general) across world cultures. This book also presents the most comprehensive defense of playing video games recreationally, that video games are not a pointless time-sink and that the players are not simply "blinking lizards, motionless, absorbed, only the twitching of their hands showing they are still conscious [B. Johnson]."

The most fascinating content of this book is the discussion of how people behave in multi-player online games. Numerous examples are given, ranging from piracy and espionage in EVE online to collaborative meeting spaces in 2nd Life. Such aspects of gaming really hit on my own personal research interests of human behavior in technology mediated social networks. One example of human gaming behavior in particular highlights an unexpected application of online gaming worlds: modeling the spread of disease, or epidemiology.

At one point the game World of Warcraft had a game play mechanic where players could contract a disease called "corrupted blood". This disease caused physical harm to the players' characters, and was communicable from one player to another. The disease was never intended to appear except under very controlled circumstances. Once the disease was unleashed, Blizzard had to run rolling restarts of their servers to eradicate the plague.


Epidemiologist use complicated statistical models and utility function driven multi-agent simulations to try and predict the spread of diseases. One problem with these models is that they are missing a human component. The models are designed to approximate human behavior on a large scale, but this can only truly be accomplished by measuring actual human behavior.

I'm a little late to the party with this story, but Nina Fefferman has been featured extensively in the press for her 2007 paper with Eric Lofgren titled "The Untapped Potential of Virtual Game Worlds to Shed Light on Real World Epidemics," published in The Lancet Infectious Diseases. Nina has recognized that online gaming worlds contain a wealth of data about human social behavior and that this could be used for epidemiology.

According to Rossignol, these data can be harvested from games without affecting the gamers' experience in any way. An online community could be infected with a disease which exhibits no symptoms at all, but merely spreads in a non-deterministic way. As long as the characters carrying the the disease (or payload) can be identified then useful data will be available to researchers.

Harvesting human behavior patterns for epidemiology is just one of the ways in which modern gaming can benefit society. Passionate gamers and radical scientists like Rossignol and Fefferman are helping to give gaming a good name.

Friday, June 4, 2010

More colors on a mobile device = bad?

Intuition says that more colors is better than fewer colors, right? Many mobile devices use size of the color palette as a marketing point. The hotly anticipated new Android phone, the HTC Evo 4G, has come under criticism for supporting "only" 65K colors (16-bit) while the competition (iPhone) supports 4 times as many (18-bit or 262,144 colors).

Are these colors really necessary? Is there any reason why would a new flagship model have only 1/4th of the colors of the reigning champ? Mike Calligaro from the Windows Mobile Team Blog has the answer.

First, it is very difficult to efficiently utilize the circuitry needed to drive 262,144 colors. This many colors requires 18 bits (2^18) per pixel. These data bits are held in a specialized memory location called a frame buffer. They are fed to the frame buffer by the CPU (or perhaps a GPU). Nearly all mobile devices work on a 32 bit CPU. Nearly all modern processors are designed around powers of two, and that is why we commonly see 32 and 64 bit processors today. One register in a 32 bit CPU can store the data for 2 pixels, with no wasted space in the register, and operations can be performed on two pixels in a single pass. Processing an 18 bit pixel with a 32 bit CPU means that only one pixel can be fit in the data register and 14 bits (32-18) of the computational cycle is wasted. One way to combat this is with sophisticated programming and circuitry to spread a portion of the next pixel over the remaining CPU space. This difficulty is explained more thoroughly in the blog post.

So what does this mean? This means the CPU has to do significantly more work to drive the same number of pixels for these extra colors. Mobile devices in particular are often CPU constrained in an attempt to save energy usage and meet a target cost. Wasting CPU power on extra colors could result in sluggish performance.
(click to enlarge)

Secondly, after a point the number of colors means little more than a line of marketing propaganda. The screens on mobile devices are typically 3.5" to 4.3" at best. Even at larger sizes it is often impossible to distinguish between the higher color depths. The Windows Mobile Team Blog has provided a very simple app which encodes a 24-bit source image into 18, 16, and 12 bit color depths. The 12 bit is quite noticeably poorer in color fidelity, but the remaining images are difficult to distinguish, and almost certainly not worth the performance hit that higher color depths require. So remember when comparing the specs on new devices that the numbers alone do not tell the whole story.

Monday, May 17, 2010

Image Error Level Analysis

Image Error Level Analysis is a great online tool for detecting digitally manipulated images. Digital images are ubiquitous. Most cell phones now have a built-in digital camera. Popular internet destinations such as Facebook, Ebay, and dating sites rely almost entirely on digital images. Digital images drive e-commerce, social networking, advertising, dating, and many other web enterprises. Digital images are even admissible in federal and state court in the US. So how do we know if they have been tampered with?

Photo editing software has been available for decades, and it gains more sophisticated capabilities. Everybody knows image editors can be used to tweak the colors of prepared dishes on a recipe web site or enhance photos on dating sites. Adobe Photoshop CS5 has a powerful new tool called "content-aware fill" which is capable of erasing portions of a picture and generating new content to seamlessly patch the missing pieces. One fascinating example can be seen below (images thanks to osici on SomethingAwful). The first image shows the surface of Mars as taken in a series of photographs from a Mars rover. Four rectangular photographs have been stitched together to form a panorama of the Mars surface. Because the camera was not perfectly horizontal, stitching together the images creates a black sawtooth border. The second image has been modified using the content-aware fill tool to generate content to place over the black border. The rocks, dirt, and sky shown in the second photo where there exists only black in the first are generated completely algorithmically. These portions were never part of any picture which was sent back by the rover.



This is very impressive technology which can have many good or bad uses. So how do we know if an image has been tampered with? Aside from noticing small details like a missing shadow or illogical lighting and reflections in the image, the digital encoding of an image file itself can leave many clues. Image Error Level Analysis has an ingenious way of detecting tampered images.

Photographs on the internet are almost always encoded using JPEG compression. This is a lossy compression technique which leaves behind visual artifacts, which act as a signature. Sometimes these artifacts are too subtle to be seen with the naked eye, but image analysis software can detect them. When images are manipulated, often source material from other photos is added in some way. These other photos are also compressed using JPEG compression, and have a slightly different signature. Even edits directly to a single source image often result in the recompression of a portion of the image. This variation in compression level across a single image is a tell-tale indicator that an image has been altered. Image Error Level Analysis is an online tool for detecting if an image has been altered. The user simply supplies a URL to an image, and the program generates a corresponding image which is a mapping of quality level differences.

In the author's words:
"It works by resaving an image at a known quality, and comparing that to the original image. As a jpeg image is resaved over and over again, its image quality decreases. When we resave an image and compare it to the original, we can guess just how many times the image has been resaved. If an image has not been manipulated, all parts of the image should have been saved an equal amount of times. If parts of the image are from different source files, they may have been saved a number of different times, and thus they will stand out as a different colour in the ELA test.

Error level analysis allows you see to see the difference in quality level, represented by brightness. Things which are very bright have been edited most recently, whilst duller parts have been resaved multiple times. This allows you to see not just which parts of the image have been changed, but in what order the changes occurred."


The above image clearly shows where the original photo was digitally manipulated, thus indicating that it is not the original image. This tool does not guarantee conclusive findings, but it can certainly be helpful in detecting manipulated images. Also, the image creator could increase the likelihood of a false negative by monitoring and altering the compression levels. This is definitely a fascinating and well-implemented online tool for attacking a very interesting problem.