Hi All, I've been trying to develop an IDL object graphics approach of putting image swaths onto a 2D Orthographic
projection of the globe. It seems I've got most of it in place put the image that is currently texture mapped does
not look correct. My images are bytarr's of 1354x2030. My approach was to texture map the image onto a IDLgrPolygon
object. I use the known latitude and longitude grid (1354x2030) to convert to an xy grid. These xy grid points
are the polygon vertices. I then normalize these to (0.0 -> 1.0) and use them as the texture_coords.
The code snippet below shows the relevant part of the process,
------------------ code snippet below ----------------------
; Scale the image to a byte
scaledImage = BytScl(image, Top=254) + 1B
sz = size(scaledImage,/dimensions)
; Define a texture image byte array (next power of 2 larger)
; to hold scaledImage. This is preferable because of a vaguery in how
; a texture map is warped onto an image. If not a power of 2 then texture
; mapping introduces sampling artifacts into the image
pwr2Sz = findNextPwr2(sz)
textureImg = bytarr(pwr2Sz[0],pwr2Sz[1])
textureImg[0:sz[0]-1, 0:sz[1]-1] = scaledImage
;
; Make a pallete object for the image
oPal = OBJ_NEW('IDLgrPalette')
oPal->LOADCT, 33
;
; Use the 1354x2030 bytarr the image object. Attempt 2 described below
;oImg = obj_new('IDLgrImage', scaledImage, PALETTE=oPal, ORDER=1)
; Or
; Use a 2048x2048 expanded bytarr the image object. Attempt 3 described below.
oImg = obj_new('IDLgrImage', textureImg, PALETTE=oPal, ORDER=1)
;
; Create the polygon vertices and texture coordinates from the lats lons arrays. Uses
; map_proj_forward to convert lat lons to x,y
makePolyVerts, lats, lons, MAP=map, vertexes, textureCoords
;
; Create a polygon object to hold the texture mapped image to.
oPoly = obj_new('IDLgrPolygon', DATA=vertexes, TEXTURE_MAP=oImg, $
Texture_Coord=textureCoords, COLOR=[255,255,255])
;
;Add the image to the model
oModel->add, oPoly
; Draw image
window->draw, oView
---------------------- code snippet above --------------------
The code snippet above where I use 'scaledImage' (a 1354x2030 bytarr) results in an image that is not correct. Is this due to the known texture mapping sampling problem when using non power of 2 arrays?
The code snippet above where I use 'textureImg' (a 2048x2048 bytarr) is my attempt to follow the suggestion that texture maps work best when the array is a power 2 multiple. The results here actually look worse.
Can anyone suggest how to fix this problem? Is my power of 2 implementation wrong?
Thanks for any help, Mike
|