You Are Viewing All Posts In The Archive Category

FixOutlook mosaic avatar finder (part 2)

Yesterday I wrote about the avatar finder I was building. I posted a comment to the blog of the Email Standards Project asking for avatars. digirati replied and send me their avatar, but unfortunately they weren’t able to locate themselves in the mosaic. So now I had the source image of an avatar which was quite likely to be included (as digirati was one of the first 1,000 people to tweet their support) but still no (edited?) tile. Luckily, digirati’s avatar had quite a lot of pixels of the same color (R = 34, G = 34, B = 34), so I decided to pixel scan all tiles I had separated from the mosaic earlier and save them to a database.

Here’s digirati’s avatar:

digirati's twitter avatar

And here’s the code:

$start = $argv[1];
$loop = 15;
for ($i = $start; $i < ($start+$loop); $i++) {
    // Create resource from image
    $image = @imagecreatefrompng('tiles/tile_' . $i . '.png');

    $width = imagesx($image);
    $height = imagesy($image);

    // Loop through all pixels
    for ($y = 0; $y < $height; $y++) {
        for ($x = 0; $x < $width; $x++) {             // Extract RGBA values from pixel             $rgba = imagecolorat($image, $x, $y);             $r = ($rgba >> 16) & 0xFF;
            $g = ($rgba >> 8) & 0xFF;
            $b = $rgba & 0xFF;
            $alpha = ($rgba & 0x7F000000) >> 24;

            // Save pixel RGBA values to database
            $query = sprintf("INSERT INTO gd_pixels (tile, x, y, r, g, b, alpha) VALUES (%d, %d, %d, %d, %d, %d, %d)", mysql_real_escape_string($i), mysql_real_escape_string($x), mysql_real_escape_string($y), mysql_real_escape_string($r), mysql_real_escape_string($g), mysql_real_escape_string($b), mysql_real_escape_string($alpha));
            $db-> query($query);
        }
    }
}

Because I already had separate tiles I didn’t have to scan the whole image at once but could just scan tile for tile. I created a little bash script which called the PHP script with a $start argument. This argument contained the first tile to process, after which the PHP script processed 15 tiles before finishing execution after which the next 15 tiles would be processed. My MacBook pixel scanned about 4 tiles per second, so after about 75 minutes all tiles were scanned. Now that I have a gd_pixel table weighing just over 30 million rows it’s time to search for digirati’s avatar.

The following query yielded quite some results:

SELECT tile,COUNT(*) AS pixel_count FROM gd_pixels WHERE (r = 34 AND g = 34 AND b = 34) GROUP BY tile ORDER BY pixel_count DESC;

Avatars with RGB values set to 34

But unfortunately, not the right one. So I tried to broaden the search area by looking for RGB values between 30 and 38. The pixel colors could have changed due to JPG compression or editing by the mosaic creators of course.

SELECT tile,COUNT(*) AS pixel_count FROM gd_pixels WHERE ((r > 30 AND r < 38) AND (g > 30 AND g < 38) AND (b > 30 AND b < 38)) GROUP BY tile ORDER BY pixel_count DESC;

Tiles with RGB values varying between 30 and 38

Still no dice :( Broadening the search even more than this would yield to much irrelevant results. So now there are three options:

  1. I’m doing something wrong;
  2. through editing the pixel colors changed so much that it would be very hard to look up any specific avatar at all;
  3. or digirati is not in the mosaic at all.

Unfortunately, now I’m back at square 1. So if you happen to found yourself in the mosaic, please let me know :)


    No Recent Comments
  • Published On Sep. 16, 2009 by admin
  • FixOutlook mosaic avatar finder

    As I wrote earlier, the fantastic FixOutlook.org initiative created an enormous mosaic of all supporter’s avatars. Because it’s quite a lot of work to find your own avatar between 18,040 avatars I decided to give it a try using PHP and GD.

    First I tried to do it by pixel scanning, using GD’s imagecolorat() function. By looping over every pixel (there are 30,992,064 in the image) and saving its RGB values to a MySQL database we create a table describing every pixel. By feeding a tile to the same pixel scanning functions we can look the pixels of that tile up in the table and have the coordinates of the tile returned. Nice solutions, but an enormous resource hog.

    My colleague Andries suggested a different method: clipping the image in separate tiles and then calculating the MD5 hash of the image. We then do the same for the needle tile and look for a collision. This should be much faster but only works when the original tiles are not edited when put in the mosaic. I know that the avatars are resized from the original 73×73 pixels to 48×36 pixels, but I don’t know whether any other filters are applied. My own avatar is actually not in the mosaic (I can tell that with certainty because the mosaic was already high and dry upon the Redmond wall when I tweeted my support) and I don’t know anyone who is included. So if you happen to be in the picture and still have the original Twitter avatar, please leave a comment. I fired off an e-mail to The E-mail Standards Project asking them whether any filters were applied during the creation of the mosaic.

    Another idea (by my colleague Nils) would be to use ImageMagick’s compare function which shows the differences between two images. Using this method has the advantage that the original avatar may be edited, since it can return the actual difference between the needle and the haystack. But first I need a source avatar… I’ll keep you updated!

    For those who are interested in the code which did the clipping, here it is. It only took 16.2656 seconds to complete the tiling of the full mosaic on my Macbook Pro. Quite impressive! I had to increase the memory limit in my php.ini file though. After clipping is completed you’ll have 18,040 avatars sitting in the tiles/ directory which can be read by PHP’s md5_file() function.

    // Create image resource (from mosaic file)
    $image = imagecreatefrompng('fixoutlook-mosaic.png');
    
    $i = 0;
    for ($x = 0; $x < $width; $x = $x + 48) {
    
        for ($y = 0; $y < $height; $y = $y + 36) {
    
            // Create resource for new tile
            $dest = imagecreatetruecolor(48, 36);
    
            // Copy tile from mosaic
            imagecopy($dest, $image, 0, 0, $x, $y, 48, 36);
    
            // Save tile
            imagepng($dest, 'tiles/tile_' . $i . '.png', 0);
    
            // Remove tile from memory
            imagedestroy($dest);
    
            $i++;
        }
    }

    PS: This great syntax highlighting is done using the Syntax Highlighter Wordpress plugin.


    • BOOM! That was my head exploding reading this. All this sort of stuff blows my mind, it's shocking to read (admiration ...
      Tim
  • Published On Sep. 15, 2009 by admin
  • Just another avatar in the wall

    The last few months The E-mail Standards Projects has been actively campaigning against Microsoft’s decision to use the Word render engine in its new Outlook version. This impacts E-mark and other companies involved in e-mail marketing due to the fact that this disables the ability to send rich designed mailings because of very limited HTML support. To make a fist against MS Office The E-mail Standards Projects launched the FixOutlook.org initiative. By tweeting your support your Twitter avatar is added to the Wall of Fame at FixOutlook. After gathering the support of 25.000 fellow protesters The E-mail Standards Projects created a enormous mosaic of all the supporter’s avatars and send it off to Microsoft HQ.

    FixOutlook.org mosaic

    FixOutlook.org mosaic on the wall at Microsoft HQ.

    Want to see if you are included? The 20 mb weighing original mosaic image can be found online.


  • Published On Sep. 14, 2009 by admin
  • Whoohoo! Google put me on the map!

    To see if Google had already indexed my new blog I googled (lower-case ‘g’, right?) my own name. Good news: Google has indeed indexed my new blog already (that’s quite fast!). What I also found out was that my name shows up in Google Query Suggestion when searching on the Dutch Google version (google.nl). Here’s a screenshot:

    Google query for 'Vincent van Scherpenseel'

    I wonder what led to the inclusion of my name in Google Query Suggestions, whether it’s a certain amount of hits or a certain amount of queries for that name (no, I’m not really that narcissistic). Two other interesting things:

    • The Google Query Suggestions tool shows way less results than the actual amount of results (8.590 versus 21.200 total hits).
      I don’t know the reason for this. It could be that it uses only a subset of all available data to improve performance (which is really important with live query suggestions). Or perhaps it only contains domains with a certain pagerank?
    • When clicking on the suggestion, the original query (what you typed so far, before clicking on the suggestion) is included in the URI (‘oq=vincent+van+sch’). I think Google uses this to learn from its users to measure how good their suggestions are.

    The next step is Wolfram Alpha’s index ;) Which -incorrectly, I might add- interprets ’scherpenseel’ as ’scherpenzeel’. A very common (and annoying!) mistake that people make with my last name all the time due to the fact that there is actually a town called Scherpenzeel in Holland.


  • Published On Sep. 10, 2009 by admin
  • The Return of the Dreamcast

    09/09/09 does not only mark the 3-year anniversary of me and my girlfriend but also the 10-year anniversary of the Sega Dreamcast. The Dreamcast was Sega’s last console which was way ahead of its time (it even had a 56K modem!). Unfortunately it was a major failure due to piracy, heavy competition from Sony’s PS2 and lack of support from developers (due to both the piracy issue and the fact that Sega couldn’t really scale to the demand for the console). Also the fact that Sega suddenly rushed to have the Dreamcast released (which caused very few games available on launch day) upset quite a lot developers. In 2001 Sega ceased all activities in the console market and decided to focus on arcade gaming and console gaming for other platforms.

    But now, 10 years later, a company called redspotgames is taking pre-orders for a new Dreamcast game called ‘Rush Rush Rally Racing’. At first I thought this would be a rather clever PR stunt to get the spotlights on redspotgames, but they seem to focus exclusively on developing games for the Sega Dreamcast. I guess they are rooting for the nostalgic Dreamcast-players out there. View the trailer to get that retro-feeling :)


      No Recent Comments
  • Published On Sep. 09, 2009 by admin
  • MacBook Pro un-boxing

    It’s here! :) I’m currently writing this from my brand-new MacBook Pro! And guess what, it actually has that new-car smell going on. Of course, as a new follower of Steve-Jobsism I just had to make pictures of the un-boxing party. Enjoy!

    07092009042070920090440709200904607092009047

    What? Did you really think I was going to upload a video to Youtube? Nah, I’m not that big a fanboi yet. But I didn’t want to keep the pictures to myself. Can you see the halo in the last picture? It’s not edited, I promise.

    Update: After one day of use I absolutely fell in love with this machine. The MacBook Pro is such a solid yet esthetically-beautiful machine, both from a hardware as a software perspective. Truly amazing. One thing that surprised me though: the system already had Snow Leopard installed, even though it was assembled before Mac OS X 10.6 went on sale. Unfortunately I had just ordered Snow Leopard this weekend :( — O well, it’s still by far the best laptop I have ever owned.


    • Dewd.. smelling your laptop.. seriously.. ;-p
      Reno
  • Published On Sep. 07, 2009 by admin
  • So close, and yet so far away

    My first ever Apple notebook, the MacBook Pro 13″, is on its way. Although it’s been traveling faster than expected (Apple promised a delivery on the 9th of September, whereas UPS’s status shows Monday the 7th as the delivery date), it’s actually quite frustrating to know that the package is currently only 20 kilometers away but will stay there for at least two more days. Add that to the fact that I’m not home this Monday (or Tuesday) so I’ll probably won’t have it before the 9th after all.

    UPS Packet Tracking ReportApple Tracking Report of my MacBook Pro

    But let’s take a look at Apple’s order status thingy. For a manufacturer (or should I say ‘designer’) that’s hailed for it’s intuitive ease-of-use systems, the order tracking process is rather blunt. Where’s the world map with the exact location of my divine shipment? Mac users are addicted to Apple’s products as if they shoot it directly into their veins. Ordering a new Mac is as important to them as Jesus’ second resurrection is to the catholics. How on earth can Apple leave their zealous followers continually hit F5 in their browser hoping for a new bit of information that never comes? If seldom updated order statuses isn’t bad enough, I have to look at a second website (UPS.com in my case) to track the location of my shipment!

    Alright, time to cool down now. I sound like a Apple fanboi already. I’ll keep you updated :)

    Update: Just bought myself a Case Logic sleeve for the MacBook 13″, including space for the power charger. The babyroom is ready ;)


    • Aah...for your sake I hope it'll be delivered shortly! Keep us posted!
      Steven van Vessum
  • Published On Sep. 05, 2009 by admin
  • Back from the grave: http://vincent.vanscherpenseel.nl

    Finally, a new place to call ‘homepage’. Now powered by the immensely popular WordPress, this site is looking (and working!) better than ever before. I am absolutely stunned by Wordpress, seldom have I seen a CMS designed as good as this one. Installing was a walk in the park and configuring was even easier. Thanks to Steven van Vessum for converting me to the religion of Wordpress, after being hooked to CMS Made Simple for so long.

    Here you can expect ramblings about anything that interests me. This may vary from great concepts I stumble upon, artists I come across (musical or any other art-form), things I built (while working for dotBlue or E-mark) or anything else I find cool enough to share with the world.

    And now, for the long-time fans of this website (yeah, right), let’s take a walk down memory lane.


  • Published On Sep. 04, 2009 by admin