|
Image Processing : Mapping an Image onto Geometry |
|
The following example maps an image containing a color representation of world elevation onto a sphere using both Direct and Object Graphics displays. The example is broken down into two sections:
Complete the following steps for a detailed description of the process.
| Example Code See maponsphere_direct.pro in the examples/doc/image subdirectory of the IDL installation directory for code that duplicates this example. |
file = FILEPATH('worldelv.dat', $
SUBDIRECTORY = ['examples', 'data'])
image = READ_BINARY(file, DATA_DIMS = [360, 360])
DEVICE, DECOMPOSED = 0
LOADCT, 33 TVLCT, 255,255,255, !D.TABLE_SIZE - 1
(For comparison, TVLCT, 0, 0, 0, !D.TABLE_SIZE+1 would designate a black window background.)
WINDOW, 0, XSIZE = 360, YSIZE = 360 TVSCL, image
This image, shown in the following figure, will be mapped onto the sphere.
4, indicating a spherical surface type: MESH_OBJ, 4, vertices, polygons, REPLICATE(0.25, 360, 360), $ /CLOSED
The vertices and polygons variables are the lists that contain the mesh vertices and mesh indices of the sphere. REPLICATE generates a 360 by 360 array, each element of which will contain the value 0.25. Using REPLICATE in the Array1 argument of MESH_OBJ specifies that the vertices variable is to consist of 360 by 360 vertices, each positioned at a constant radius of 0.25 from the center of the sphere.
WINDOW, 1, XSIZE = 512, YSIZE = 512 SCALE3, XRANGE = [-0.25,0.25], YRANGE = [-0.25,0.25], $ ZRANGE = [-0.25,0.25], AX = 0, AZ = -90
SET_SHADING, LIGHT = [-0.5, 0.5, 2.0]
!P.BACKGROUND = !P.COLOR
SHADES = image to map the image onto the sphere and uses the image transformation defined by the T3D transformation matrix:TVSCL, POLYSHADE(vertices, polygons, SHADES = image, /T3D)
The specified view of the image mapped onto the sphere is displayed in a Direct Graphics window as shown in the following figure.
![]() |
!P.BACKGROUND = 0
| Note To create a Object Graphics display featuring a sphere that can be interactively rotated and resized, complete the steps contained in the section, Mapping an Image Object onto a Sphere. |
IDL Online Help (March 06, 2007)