comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Texture Map problems when using IDLgrPolygon
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Texture Map problems when using IDLgrPolygon [message #80424] Sun, 03 June 2012 20:08
mikrin is currently offline  mikrin
Messages: 4
Registered: June 2012
Junior Member
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 implementation of
the larger 2^n array wrong?

Thanks for any help, Mike
[Message index]
 
Read Message
Previous Topic: How to Write Data to File with Particular Dimension Values?
Next Topic: contour plot

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:33:02 PDT 2025

Total time taken to generate the page: 0.01651 seconds