Generating maps from images with MMPS, Part II

Take a four view image eg:


Black out the text and crop to four separate images with your favourite image editor:

p0.jpg  p90.jpg  p180.jpg  p270.jpg 

Trim off the borders, using 30% fuzz to trim the rather indistinct borders aggressively:

convert -fuzz 30% -trim p0.ppm p0a.ppm
convert -fuzz 30% -trim p90.ppm p90a.ppm
convert -fuzz 30% -trim p180.ppm p180a.ppm
convert -fuzz 30% -trim p270.ppm p270a.ppm

p0a.jpg  p90a.jpg  p180a.jpg  p270a.jpg 

Use the circularize utility to convert to an exactly circular image:

circularize -fuzz 2.5 -f p0a.ppm > p0b.ppm
circularize -fuzz 2.5 -f p90a.ppm > p90b.ppm
circularize -fuzz 2.5 -f p180a.ppm > p180b.ppm
circularize -fuzz 2.5 -f p270a.ppm > p270b.ppm

p0b.jpg  p90b.jpg  p180b.jpg  p270b.jpg 

(The fuzz parameter determines how close a match should be made with the edge color, similar to the fuzz convert parameter).

Now do an inverse projection:

project rectilinear -w 1000 -h 500 -i -long 0   -f p0b.ppm > pmap0.ppm
project rectilinear -w 1000 -h 500 -i -long -90  -f p90b.ppm > pmap90.ppm
project rectilinear -w 1000 -h 500 -i -long -180 -back pmap0.ppm -f p180b.ppm > pmap180.ppm
project rectilinear -w 1000 -h 500 -i -long -270 -back pmap90.ppm -f p270b.ppm > pmap270.ppm

generating two maps from complementary parts of the original images:

pmap180.jpg  pmap270.jpg 

The surface features on the two maps line up reasonably well, though not exactly (unsurprising since we have a fairly non-ellipsoidal moon, are ignoring perspective effects, and the original images seem to be lit from different directions). The area where the alignment is worst seems to be the large blue area, corresponding to the least spherical part of moon.

The two images can be combined with the combine utility, which takes two identically sized images and produces a combined image. Pixels in the input background color (parameter -ibg color, default black) are ignored, when neither pixel is ignored, the output image uses the maximum rgb values from the two input pixels:

combine -fuzz 2 pmap180.ppm pmap270.ppm > map.ppm


Darkish lines in the image show where the original images joined up.

Now this can be used for projections:

project perspective -w 250 -h 250 -x 6.0 -long 45 -f map.ppm > i1.ppm
project perspective -w 250 -h 250 -x 6.0 -long 135 -f map.ppm > i2.ppm
project perspective -w 250 -h 250 -x 6.0 -long 225 -f map.ppm > i3.ppm
project perspective -w 250 -h 250 -x 6.0 -long 315 -f map.ppm > i4.ppm

i1.jpg  i2.jpg  i3.jpg  i4.jpg 

Of course, projecting a proper 3D model would look rather better...