|
Re: 3D Surface Problem [message #30101 is a reply to message #30097] |
Mon, 08 April 2002 18:04  |
btupper
Messages: 55 Registered: January 2002
|
Member |
|
|
Hello,
I think Rick has the right idea about providing the xyz locational
info for each vertex. Since you are showing images projected on a
map, then the original x and y dimensions are lifted from a model of a
spheriod and, in their raw unprojected form, will produce a stretched
flat map. But all that is out of my league.
On Mon, 8 Apr 2002 10:42:27 -0600, Ken Mankoff
<mankoff@I.HATE.SPAM.cs.colorado.edu> wrote:
>> Please post some more detail or code.
>
> I think the problem is a few things
>
> 1) Walls are appearing at the edge of the DEM. Mars has a lot of its
> surface at below sea-level (negative altitude). But even if I say
> "dem = dem - min( dem )", so everything should be positive, I still
> get the "walls"
>
> 2) The images always come out square. I am pretty sure this is just a
> keyword I am missing, but I do not know which one and which object it
> belongs with (surface? window?).
>
> 3) The vertical scaleing is always "0 to 1" in the IDLgrModel (I
> think). This looks good with maps that cover a large vertical area
> (say, Olympus Mons or Valles Marineris). But if the map is of a
> relatively flat area (somewhere in the northern low-lands), and the
> DEM covers a few hundred meters, then those few hundred meters get
> streched vertically, and it appears warped.
>
I have an graphic object model that simplifies process of anisotropic
scaling of dimensions
(www.tidewater.net/~pemaquid/axesgroup__define.pro) Basically, it
automatically builds simple axes for you. You then take the scaling
parameters (*conv_coord, normailzed or not) and pass them along to the
surface object. It maybe helpful as an example. You will need Martin
Schultz's object code distribution and David's NORMALIZE function.
The relevant method is ScaleAxes in AXESGROUP. You can play with the
three element Isotropic property which specifies relative scaling
among the X, Y and Z dimensions.
Here's a mock up of how you might use it. Call both before destroying
the first so you can see how setting parts of the underlying dem to
NaN gets rid of that ugly edge.
IDL> vmars2,axes1
IDL> vmars2,axes2, /nan
;;;;START
PRO vmars2, axes, nan = nan
dem = fltarr(35,45)
dem[2:31,2:31] = dem[2:31,2:31]-dist(30) - 8.0
img = bytscl(dem)
if keyword_set(nan) then begin
a = where(dem GT -8.0, cnt)
if cnt gt 0 then dem[a] = !Values.f_nan
EndIf
;;; image coordinate setup
iDims = size( img, /DIM )
;;; surface coordinate setup
s = (sz = SIZE( dem,/dim ))
maxz = MAX( dem, MIN=minz,/nan )
Axes = OBJ_NEW('axesgroup', [0, s[0]], [0, s[1]], [minZ, maxZ], $
style = [15,15,15], $
xcolor = [255,0,0], $
ycolor = [0,255,0],$
zcolor = [0,0,255], $
exact = [1,1,1], $
/normalize)
scale = axes->GetScale()
;;; image -> surface coordinates
image = obj_new( 'idlgrimage', img )
surface = obj_new( 'idlgrsurface', $
dem, $
style=2, $
color=[255,255,255], $
texture_map=image, $
shading=1, $
xcoord_conv=scale[*,0], $
ycoord_conv=scale[*,1], $
zcoord_conv=scale[*,2] )
Axes->Add, surface
xObjView, axes, background = [0,0,0]
end
;;;;END
> 4) White pixels are appearing in the images.
Are you sure those aren't reflections of grey hair in your monitor?
Ben
|
|
|
Re: 3D Surface Problem [message #30104 is a reply to message #30101] |
Mon, 08 April 2002 12:53  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Rick Towler (rtowler@u.washington.edu) writes:
> I hate the *coord_conv keywords. They don't make sense to me outside the
> context of simple plots. I just settle on a coordinate system for my
> virtual world, say 1 unit = 1 km, and make sure my vertex data agrees. If
> you set up your view properly you don't have to worry about scaling
This is why I don't write a book. I couldn't even breathe
without using coord_conv keywords and really simple
coordinate systems (say, 0 to 1) that I can understand!
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: 3D Surface Problem [message #30105 is a reply to message #30104] |
Mon, 08 April 2002 12:22  |
Rick Towler
Messages: 821 Registered: August 1998
|
Senior Member |
|
|
Hi Ken.
"Ken Mankoff" <mankoff@I.HATE.SPAM.cs.colorado.edu> wrote :
>
> I think the problem is a few things
>
> 1) Walls are appearing at the edge of the DEM. Mars has a lot of its
> surface at below sea-level (negative altitude). But even if I say
> "dem = dem - min( dem )", so everything should be positive, I still
> get the "walls"
It looks like you have a 2d array of elevational data (dem). Is the data
you have placed in it square or do you have some null values (data not
square but array is)?
> 2) The images always come out square. I am pretty sure this is just a
> keyword I am missing, but I do not know which one and which object it
> belongs with (surface? window?).
What images? The texture maps? The final image?
The surface will always be square since you are providing x and y verticies
that define it as such. I am not a cartographer but I think you will want
to specify your surface verts explicitly, and not by indgen. I would assume
each datum has a martian lat,lon and an elevation. Do you have routines to
convert the lat/lon to x,y on a localized grid?
> 3) The vertical scaleing is always "0 to 1" in the IDLgrModel (I
> think). This looks good with maps that cover a large vertical area
> (say, Olympus Mons or Valles Marineris). But if the map is of a
> relatively flat area (somewhere in the northern low-lands), and the
> DEM covers a few hundred meters, then those few hundred meters get
> streched vertically, and it appears warped.
I hate the *coord_conv keywords. They don't make sense to me outside the
context of simple plots. I just settle on a coordinate system for my
virtual world, say 1 unit = 1 km, and make sure my vertex data agrees. If
you set up your view properly you don't have to worry about scaling
Setting up the view is the trick. You may want to give my camera object a
try. It will simplify setting up scene composition and you will be able to
place the viewer anywhere in the scene.
http://www.acoustics.washington.edu/~towler/
If you don't want to do that, you need to normalize on the min and max of
the entire martian surface (or at least the parts you want to plot) not the
min and max of the localized data.
> 4) White pixels are appearing in the images.
I would deal with the other issues and this might go away.
In general, I would try to simplify. Fix the verticies first. Create the
surface and view it in xobjview. Forget texturing and don't go any further
until you have the verticies sorted out. Then add the texture. Once you
get the texture added, deal with the view.
-Rick
|
|
|
Re: 3D Surface Problem [message #30106 is a reply to message #30105] |
Mon, 08 April 2002 12:12  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Ken Mankoff (mankoff@I.HATE.SPAM.cs.colorado.edu) writes:
> I think the problem is a few things
>
> 1) Walls are appearing at the edge of the DEM. Mars has a lot of its
> surface at below sea-level (negative altitude). But even if I say
> "dem = dem - min( dem )", so everything should be positive, I still
> get the "walls"
>
> 2) The images always come out square. I am pretty sure this is just a
> keyword I am missing, but I do not know which one and which object it
> belongs with (surface? window?).
>
> 3) The vertical scaleing is always "0 to 1" in the IDLgrModel (I
> think). This looks good with maps that cover a large vertical area
> (say, Olympus Mons or Valles Marineris). But if the map is of a
> relatively flat area (somewhere in the northern low-lands), and the
> DEM covers a few hundred meters, then those few hundred meters get
> streched vertically, and it appears warped.
>
> 4) White pixels are appearing in the images.
I don't know what the actual problems might be. But
I did just now update my Texture_Surface program which
maps an image onto a surface. The updates now preserve
the aspect ratio of the input surface data (I.e., the
data "keeps its shape"). I also added a ZSCALE keyword,
which takes a value between 0.001 and 1.0 that provides
relative "scaling" of the surface in the Z direction.
In other words, if you want a flatter surface, you would
type something like this:
IDL> Texture_Surface, dem_data, Image=marsImage, ZSCALE=0.25
I notice (in both IDL 5.4 and 5.5) that the texture mapping is
not always perfect. For example, try this:
IDL> Texture_Surface
IDL> Texture_Surface, Dist(15,30)
There will be an extraneous extra row of pixels at about Y=30
on this image, compared to the first. (Some kind of wrapping
effect?) It could be that this is what is causing your "wall"
problems.
You will also need the Aspect program from my Coyote library
to run the program:
http://www.dfanning.com/programs/texture_surface.pro
http://www.dfanning.com/programs/aspect.pro
I'd be curious to see your data in my program and see
if the problems persist.
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: 3D Surface Problem [message #30112 is a reply to message #30106] |
Mon, 08 April 2002 09:42  |
Ken Mankoff
Messages: 158 Registered: February 2000
|
Senior Member |
|
|
> "Ken Mankoff" <mankoff@I.HATE.SPAM.cs.colorado.edu> wrote :
>> I am using IDL Object Graphics to combine a Digital Elevation Model
>> (DEM) with a photograph in an attempt to get a pseudo-realistic 3D
>> view of a surface.
>>
>> I have it mostly working, but have a shear effect that I cannot get
>> rid of... I do not fully understand this whole 3D viewpoint thingey.
>> Also, my images shapes vary. Sometimes they cover a 1x1 degree lat/lon
>> grid, other times its a 1x10 (it is not always two squares I am
>> putting together, although the DEM and the image are always the same
>> shape). Also, the DEM sometimes has a range of a few hundred meters,
>> and other times a few thousand meters...
>
> The image shape shouldn't matter as long as you have the correct texcoords
> and for the most part they look good. It looks like you might have a white
> background for your non-square images? Is that where the "noise" in the
> texture comes from or is that a rendering issue?
>
> Where do you think the problem is? Can you render the object correctly and
> then you botch the transform? Or is the problem before you render a view?
> There could be a number of possible issues with your examples.
>
>> Ideally, I would love a function to do this for me that is canned and
>> pre-written. (I will give the author credit on the site, if you are
>> interested in helping, let me know!). But I expect to have to code it
>> up myself. Can anyone see from these images what I am doing wrong? If
>> it will help if I give a code example, let me know and I will post
>> that...
>
> Please post some more detail or code.
I think the problem is a few things
1) Walls are appearing at the edge of the DEM. Mars has a lot of its
surface at below sea-level (negative altitude). But even if I say
"dem = dem - min( dem )", so everything should be positive, I still
get the "walls"
2) The images always come out square. I am pretty sure this is just a
keyword I am missing, but I do not know which one and which object it
belongs with (surface? window?).
3) The vertical scaleing is always "0 to 1" in the IDLgrModel (I
think). This looks good with maps that cover a large vertical area
(say, Olympus Mons or Valles Marineris). But if the map is of a
relatively flat area (somewhere in the northern low-lands), and the
DEM covers a few hundred meters, then those few hundred meters get
streched vertically, and it appears warped.
4) White pixels are appearing in the images.
Here is my code:
------------------------------------------------------------ -------
FUNCTION vmars, dem, img
;;; image coordinate setup
iDims = size( img, /DIM )
;;; surface coordinate setup
sz = SIZE( dem )
minx = ( miny = 0 )
maxx = sz[ 1 ] - 1 & maxy = sz[ 2 ] - 1
maxz = MAX( dem, MIN=minz )
xs = [-minx / (maxx-minx), 1.0 / (maxx-minx) ]
ys = [-miny / (maxy-miny), 1.0 / (maxy-miny) ]
zs = [-minz / (maxz-minz), 1.0 / (maxz-minz) ] ; vert exag
;;; image -> surface coordinates
s = size( dem, /dim )
texcoords = fltarr( 2, s[0], s[1] )
texcoords[ 0, *, * ] = (findgen(s[0])#replicate(1,s[1])) / (s[0]-1)
texcoords[ 1, *, * ] = (replicate(1,s[1])#findgen(s[0])) / (s[0]-1)
;;; objects creation
window = obj_new( 'idlgrbuffer');, renderer=1 )
view = obj_new( 'idlgrview' , location=[0,-25] )
model = obj_new( 'idlgrmodel' )
rotate = obj_new( 'idlgrmodel' )
translate = obj_new( 'idlgrmodel' )
image = obj_new( 'idlgrimage', img )
surface = obj_new( 'idlgrsurface', $
dem, $
indgen(n_elements(dem[*,0])),$
indgen(n_elements(dem[0,*])), $
style=2, $
color=[255,255,255], $
texture_map=image, $
texture_coord=texcoords, $
shading=1, $
xcoord_conv=xs, $
ycoord_conv=ys, $
zcoord_conv=zs/5., $
dataz=dem )
;;; object heirarchy
view->add, translate
translate->add, rotate
rotate->add, model
model->add, surface
;;; view setup
rotate->rotate, [0,0,1], 45
rotate->rotate, [1,0,0], -50 ;;; down
translate->translate, 00.00, -0.8, 0.7
;;; display
window->draw, view
window->getProperty, image_data=surface
return, surface
END
|
|
|
Re: 3D Surface Problem [message #30139 is a reply to message #30112] |
Fri, 05 April 2002 23:06  |
Rick Towler
Messages: 821 Registered: August 1998
|
Senior Member |
|
|
"Ken Mankoff" <mankoff@I.HATE.SPAM.cs.colorado.edu> wrote :
>
> I am using IDL Object Graphics to combine a Digital Elevation Model
> (DEM) with a photograph in an attempt to get a pseudo-realistic 3D
> view of a surface.
>
> I have it mostly working, but have a shear effect that I cannot get
> rid of... I do not fully understand this whole 3D viewpoint thingey.
> Also, my images shapes vary. Sometimes they cover a 1x1 degree lat/lon
> grid, other times its a 1x10 (it is not always two squares I am
> putting together, although the DEM and the image are always the same
> shape). Also, the DEM sometimes has a range of a few hundred meters,
> and other times a few thousand meters...
The image shape shouldn't matter as long as you have the correct texcoords
and for the most part they look good. It looks like you might have a white
background for your non-square images? Is that where the "noise" in the
texture comes from or is that a rendering issue?
Where do you think the problem is? Can you render the object correctly and
then you botch the transform? Or is the problem before you render a view?
There could be a number of possible issues with your examples.
> Ideally, I would love a function to do this for me that is canned and
> pre-written. (I will give the author credit on the site, if you are
> interested in helping, let me know!). But I expect to have to code it
> up myself. Can anyone see from these images what I am doing wrong? If
> it will help if I give a code example, let me know and I will post
> that...
Please post some more detail or code.
-Rick
|
|
|