Stumbling Toward 'Awesomeness'

A Technical Art Blog

Tuesday, March 30, 2010

32K Sistine Chapel CubeMap [Python How-To]

The Vatican recently put up an interactive Sistine Chapel flash application. You can pan around the entire room and zoom in and out in great detail.

The Vatican is not very open with it’s art, the reason they scream ‘NO PHOTO’ when you pull a camera out in the chapel is that they sold the ability to take photos of it to a Japanese TV Station (Nippon TV) for 4.2 million dollars. Because the ceiling has long been in the public domain, the only way they can sell ‘the right to photograph’ the ceiling is by screwing over us tourists who visit. If you take a photo, they have no control over that image –because they don’t own the copyright of the work.

Many of you who know me, know I am a huge fan of Michelangelo’s work, this data was just too awesomely tempting and when I saw it posted publicly online, I really wanted to get my hands on the original assets.

Here is a python script to grab all of the image tiles that the flash app reads, and then generate the 8k faces of the cubemap. In the end you will have a 32,000 pixel cubemap.

First we copy the swatches from the website:

def getSistineCubemap(saveLoc):
	import urllib
	#define the faces of the cubemap, using their own lettering scheme
	faces = ['f','b','u','d','l','r']
	#location of the images
	url = 'http://www.vatican.va/various/cappelle/sistina_vr/Sistine-Chapel.tiles/l3_'
	#copy all the swatches to your local drive
	for face in faces:
		for x in range(1,9):
			for y in range(1,9):
				file = (face + '_' + str(y) + '_' + str(x) + '.jpg')
				urllib.urlretrieve((url + face + '_' + str(y) + '_' + str(x) + '.jpg'), (saveLoc + file))
				urllib.urlcleanup()
				print "saved " + file

Next we use PIL to stitch them together:

def stitchCubeMapFace(theImage, x, y, show):
	from PIL import Image, ImageDraw
	from os import path
 
	file = theImage.split('/')[-1]
	fileSplit = file.split('_')
	im = Image.open(theImage)
	#create an 8k face from the first swatch
	im = im.resize((8000, 8000), Image.NEAREST)
	thePath = path.split(theImage)[0]
 
	xPixel = 0
	yPixel = 0
	#loop through the swatches, stitching them together
	for y_ in range(1, x+1):
		for x_ in range(1,y+1):
			if yPixel == 8000:
				yPixel = 0
			nextImage = (thePath + '/' + fileSplit[0] + '_' + str(x_) + '_' + str(y_) + '.jpg')
			print ('Merging ' + nextImage + ' @' + str(xPixel) + ',' + str(yPixel))
			loadImage = Image.open(nextImage)
			im.paste(loadImage, (xPixel, yPixel))
			yPixel += 1000
		xPixel += 1000
	saveImageFile = (thePath + '/' + fileSplit[0] + '_face.jpg')
	print ('Saving face: ' + saveImageFile)
	#save the image
	im.save(saveImageFile, 'JPEG')
	#load the image in default image viewer for checking
	if show == True:
		import webbrowser
		webbrowser.open(saveImageFile)

Here is an example of the input params:

getSistineCubemap('D:/sistineCubeMap/')
stitchCubeMapFace('D:/sistineCubeMap/r_1_1.jpg', 8, 8, True)
posted by admin at 7:42 PM  

8 Comments »

  1. Just the best!

    Comment by R.'s friend — 2010/03/30 @ 9:33 PM

  2. This is really awesome! I truly stumbled on awesomeness.
    Can you please post the cubemap image? I’m not familiar with python “^”

    Comment by Woo — 2010/06/09 @ 6:49 AM

  3. It’s around 700MB :-\

    Comment by admin — 2010/06/16 @ 12:32 AM

  4. If you put up a torrent, I will seed after downloading. I usually seed until I reach a factor 10 or even 100. The only reason I sometimes can’t achieve that is lack of interest for the files.

    Comment by Anonymous Coward — 2010/07/12 @ 9:38 AM

  5. Oh, as a bit of an afterthought, does PIL do lossless stitching? Probably not, so I decided I prefer the original tiles, and I went ahead and used your script. (Which didn’t take all that long. Woo, just install Python, run python.exe and paste the code for getSistineCubemap in the prompt using the system menu. Then press enter until you’re back at the >>> prompt. Then call the function as explained in the article.)
    The total size of the files I got was about 60 MB. The tiles are 1000×1000 and average to 160 kB per file. Does that mean that they decided to lower the quality of the files in the past months, or that your stitched file is much bigger than it needs to be?
    One minor annoyance is the false copyright notice, but it’s on the floor and I don’t doubt it could be cloned away. I don’t know if I’ll put up a torrent; it seems kind of not worth it for 60 MB. I’ll follow this post for a while to hear your thoughts.

    Comment by Anonymous Coward — 2010/07/12 @ 10:31 AM

  6. […] So it was something of  shock to find just that in ultra-high detail in skybox form here. […]

    Pingback by Making a Skybox from a 360 Panoramic Flash Virtual Tour | How to remember math without really trying — 2012/05/18 @ 2:54 AM

  7. Haha! You are awesome!

    This is a real win for humanity! Imagine those bastards denying access to this common treasure.

    Comment by Tiny Tim — 2012/12/05 @ 12:41 AM

  8. How did you get the url for the actual image locations?
    I’d like to try with other panoramic scenes but the web url provide no pictures and theres seemingly nothing in the pages source code. Awesome example btw=)

    Comment by fooldome — 2016/06/21 @ 1:02 PM

RSS feed for comments on this post. TrackBack URI

Leave a comment

Powered by WordPress