distort image for cylindrical projection on sphere...

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
User avatar
owntheweb
Posts: 20
Joined: 2011-05-24T06:30:15-07:00
Authentication code: 8675308
Location: Colorado

distort image for cylindrical projection on sphere...

Post by owntheweb »

Hello,
I work as part of the Space Foundation and we're getting a really cool new educational tool: Science on a Sphere (SOS):

Image
Image Credit: NASA / GSFC: NASA gave a special Science On a Sphere (SOS)® demonstration to HM Elizabeth II, Queen of England and her husband, HRH Prince Phillip, the Duke of Edinburgh, and other members of the Royal Family on Tuesday, May 8, 2007.

Cool!! Now I'm attempting to create some homemade SOS starter content of my own because it's just that cool. The required image format is an Equatorial Cylindrical Equidistant projection (ECE) that looks like this:

Image

Note the square I added. When projected on a sphere, it appears bloated like this (rendered in Blender for brainstorming purposes):

Image

This bloated graphic look is something I've noticed with a lot of other SOS content creations out there. As a picky artist, I want my square to have the illusion of being a square on a sphere, kind of like this (not perfect, but makes me happy):

Image

I was able to achieve this look in Photoshop by pinching the square graphic a bit like this:

Image

Any thoughts on how to make some ImageMagick magic happen to distort graphics and apply to an ECE image? So far I'm guessing that I need to stretch the X axis more closer to the poles (but not Y axis). There's also the challenge of distorting graphics closer to the edge of the projection (e.g. some looping/tiling needed).

Here are a couple images to play with:
map:
http://farm6.staticflickr.com/5072/7223 ... 1b33_b.jpg

"square square square square" square (a little different from above):
http://farm8.staticflickr.com/7232/7223 ... bffc_m.jpg

Thanks for your brainstorming in advance. :D
Twitter | Blog | Worlds to explore. Worlds to create.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: distort image for cylindrical projection on sphere...

Post by fmw42 »

You can distort the square by using -distort barrel to make it pinch inward (either or both in x or y). Then compose the square onto the map. Then use one of my scripts (linked below or from my web site below), spherize (or the slower but more flexible bubblewarp) or fisheye to warp the composite onto a sphere. I don't know, however, whether that will map your stuff onto the sphere in exactly the way you want as IM does not have proper cartographic projection mapping (yet). If you have your own mapping software, then just warp the square and composite it over the map.

see
http://www.imagemagick.org/Usage/distorts/#barrel
http://www.fmwconcepts.com/imagemagick/ ... /index.php
http://www.fmwconcepts.com/imagemagick/ ... /index.php
http://www.imagemagick.org/Usage/compose/#compose
http://www.imagemagick.org/Usage/layers/#convert
Last edited by fmw42 on 2012-05-18T19:45:37-07:00, edited 1 time in total.
User avatar
owntheweb
Posts: 20
Joined: 2011-05-24T06:30:15-07:00
Authentication code: 8675308
Location: Colorado

Re: distort image for cylindrical projection on sphere...

Post by owntheweb »

Nice!
Thanks for the super fast and super helpful reply. I'll definitely take a look at the barrel distortion first and that should cover what I need. It also sparked some additional fun ideas to try with multiple images on the same map (e.g. logo visible from multiple sides, video playing in multiple spots around the globe for better audience visibility).

If I get something pretty going, I'll be sure to post the results.
Twitter | Blog | Worlds to explore. Worlds to create.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: distort image for cylindrical projection on sphere...

Post by fmw42 »

Actually, you could use my bubblewarp or defisheye scripts and "despherize" it so that when put back on the sphere it will look rectangular. But those will be rather slow compared to -distort barrel.
User avatar
owntheweb
Posts: 20
Joined: 2011-05-24T06:30:15-07:00
Authentication code: 8675308
Location: Colorado

Re: distort image for cylindrical projection on sphere...

Post by owntheweb »

Quality output comes with time. :) I'm not too concerned about the speed of rendering. I'll be sure to experiment with the options you suggested. Today I'm re-familiarizing myself with ImageMagick in general, getting some script helpers built and a new virtual sphere set up on my Mac.

Random thought: It would be awesome to make some pole cap graphics. I remember seeing these in 360 panoramas when iPix was big. Perhaps this would be a good separate discussion some other time after more basic endeavors...
Twitter | Blog | Worlds to explore. Worlds to create.
User avatar
owntheweb
Posts: 20
Joined: 2011-05-24T06:30:15-07:00
Authentication code: 8675308
Location: Colorado

Re: distort image for cylindrical projection on sphere...

Post by owntheweb »

Image Image
Above: same texture seen at different angles

For the moment I think I am reliving the efforts of other sphere content designers who wanted to place a square image (photo, logo or video) on a sphere. It's interesting because the sphere is 3D, but the projection itself is "flat" in a sense, messing with my design coordination. I can't cut holes through the sphere and let people see out the other side like one can in a virtual 3D environment.

When looking at the first image directly, the pinched/barreled box looks square. From a side perspective though the barrel effect is magnified. The good news is that the curve seems pretty consistent. For presentation purposes though I would guess that the box needs to be a touch smaller for better viewing at multiple angles. Also, the "square" looks more like a rectangle now. I guess if I was placing a rectangular video, I would need to stretch the Y axis a bit.

fmw42,
The challenge I see with using bubblewarp or defisheye is that the graphics I create don't start in a sphere or an cylindrical projection. I'm designing them first in Photoshop or exporting still frames from video, then trying to make the graphics blend in nicely with an interesting ECE format. Generally I would have a starter ECE graphic (like the Earth map for example), then attempt to add labels and graphics on top of that. Of course, I'll be making disco balls and death stars too, but that's a different topic.

I almost wonder if I should be applying graphics onto the inside of a sphere in Blender, a 3D modeling program, then try to render an ECE graphic from there somehow. At least for some items like pole cap graphics and interesting lines. I can see text labels, photos and video still using barrel.

Am I still off somehow on the bubblewarp or defisheye part? Thanks again for your continued feedback. At the very least you have helped get the creative juice extraction process going so far. :D
Twitter | Blog | Worlds to explore. Worlds to create.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: distort image for cylindrical projection on sphere...

Post by fmw42 »

Am I still off somehow on the bubblewarp or defisheye part? Thanks again for your continued feedback. At the very least you have helped get the creative juice extraction process going so far.
I don't know. What I thought you could do was an inverse of the sphere projection, so that when you did your sphere projection it would straighten out. I have not tried to experiment with that, though. For bubblewarp, it would the sin projection, not the asin projection. The defisheye would be the equivalent but includes the perspective aspect of the image. The bubblewarp assumes the image is orthgraphic.

What you have from the barrel distortion looks good to me.
Last edited by fmw42 on 2012-05-21T09:51:36-07:00, edited 1 time in total.
User avatar
owntheweb
Posts: 20
Joined: 2011-05-24T06:30:15-07:00
Authentication code: 8675308
Location: Colorado

Re: distort image for cylindrical projection on sphere...

Post by owntheweb »

Thanks a ton for the excellent feedback.

I think I have what I need for quick graphics added to ECE images. On a side note, I'm also getting into rendering ECE images from Blender and panorama stitching software, great for working more at the source of it all. Using ImageMagick's barrel effect still seems like the best option for adding on video frames and other quick graphics to be presented.

Best regards,

Chris
Twitter | Blog | Worlds to explore. Worlds to create.
Post Reply