CSI zoom to my house

Some days ago I was thinking how to make deep Mandelbrot zoom to run in real time. We already have shallow low-res zooms running in real time, but deep zooms require more and more iterations per pixel, so unfortunately our only way to work around this seems to be to precompute zoom in some way, and then make whole thing to appear as if it was running in real time, i.e. make it interactive. Obvious way to do this would be to seek in zoom video, but what’s the fun in that? Instead, I was looking for some way to zoom in single image, CSI style.

What I originally came up with was simple r→rp transformation that produced results similar to spherize filter: multiple scales of same area were combined in a single image. Then, applying inverse transform in realtime would allow to reconstruct any scale within encoded scale range. This worked, but ultimately proved itself to be very inefficient. So I was back to the drawing board, looking for more efficient transform. It turned out to be wellknown trick: polar coords with radius in log scale. This way, I was finally able to do smooth interactive zoom of Google map all the way down to my house in decent quality within wonderfl 500KB image size limit!

Wait, Google map? What about Mandelbrot thing? Well, Anders Sandberg happened to post a lot of log scale Mandelbrot maps on flickr for their aesthetic quality, so I just plugged those in my script, and – presto! I wish they were in higher resolution.

Fuck Mandelbrot – how did you do Google map one?

The key thing to know here is that every zoom step in Google map actually doubles the resolution, so what you do is just snap array of screenshots made while zooming to your point of interest and then use log2 (max (|x|, |y|)) to select a screenshot to read a color for (x,y) from. If you have loads of time, you may want to edit every screenshot to add transparency, and blend all of screenshots together instead to have highest quality composite.

Fuck Google map – where’s the code for this?

Here you go, lazy boy:

<languageVersion : 1.0;>

kernel Zoomer
<   namespace : "experimental";
    vendor : "makc";
    version : 2;
    description : "logarithm image zoomer";
>
{
    input image4 map;
    output pixel4 dst;

    parameter float map_height
    <
        minValue:float(10.0);
        maxValue:float(10000.0);
        defaultValue:float(1000.0);
    >;

    parameter float map_width
    <
        minValue:float(10.0);
        maxValue:float(10000.0);
        defaultValue:float(1000.0);
    >;

    parameter float dst_half_side
    <
        minValue:float(10.0);
        maxValue:float(1000.0);
        defaultValue:float(232.5);
        description:"square images for now";
    >;

    parameter float map_scale
    <
        minValue:float(10.0);
        maxValue:float(1000.0);
        defaultValue:float(200.0);
        description:"where zoom level doubles?";
    >;

    parameter float zoom
    <
        minValue:float(0.0);
        maxValue:float(1.0);
        defaultValue:float(1.0);
    >;

    void
    evaluatePixel()
    {
        float2 c = outCoord () / dst_half_side - float2(1.0, 1.0); // -1 to 1
        dst = sampleLinear(map, float2 (
            (0.5 + atan (c.y, c.x) / 6.2831853) * (map_width -1.0),
            clamp ( -map_scale * log2 (length (c) * zoom), 0.0, map_height -1.0)
        ));
    }
}

12 Responses to “CSI zoom to my house”


  1. 1 nicoptere April 7, 2010 at 11:24

    impressive what you’re up to when it comes to proving that fractals don’t look like shit ;)

    good one, very neat tricks, will doubtlessly prove useful.
    keep up :)

  2. 2 derek knox April 7, 2010 at 21:07

    Pretty cool stuff. I dig it. Keep up the good work.

  3. 3 ian pretorius April 13, 2010 at 20:32

    excellent work here! Ive never even heard about log scale maps until this post. This code will come in handy.

  4. 4 Zach April 29, 2010 at 19:37

    Great demo! But the most puzzling to me is, how do you generate the log-scale polar coordinate image map?

  5. 9 nicoptere October 23, 2010 at 02:29

    why is there no sound?

  6. 10 Odd Nydren December 18, 2010 at 20:30

    Most useful…and in one word: AWESOME :)


  1. 1 Tweets that mention CSI zoom to my house « ¿noʎ ǝɹɐ ʍoɥ 'ʎǝɥ -- Topsy.com Trackback on April 7, 2010 at 03:21
  2. 2 Radial blur in AGAL « Coding on acid. Trackback on May 12, 2012 at 04:26

Ask a Question

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




Old stuff

April 2010
M T W T F S S
« Mar   Jun »
 1234
567891011
12131415161718
19202122232425
2627282930  

Oh, btw…


%d bloggers like this: