IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
Physical 3-D from LOLA GDR IMG or JP2
Rick Sternbach
post Mar 16 2011, 06:31 PM
Post #1


Junior Member
**

Group: Members
Posts: 23
Joined: 6-November 09
Member No.: 5017



Admittedly I'm way behind the curve in both understanding and computing horsepower when it comes to the LOLA IMG and JP2 files. I've been able to work with some of the lower resolution files to make pretty pictures, but making the jump to physical 3-D boggles me. While waiting to hear back from some folks I worked with before on turning MOLA data into rapid prototype models, I was curious about whether any posters here can say how to take an LDEM/GDR type file and make it into STL. Can it be done? Would a different LOLA file be better? Thanks.

Rick
Go to the top of the page
 
+Quote Post
zeBeamer
post Mar 17 2011, 03:49 AM
Post #2


Junior Member
**

Group: Members
Posts: 22
Joined: 20-June 09
Member No.: 4830



Rick,

The IMG file is probably the best to use.
I could do that pretty easily with Matlab (and probably the open-source Octave can do it similarly).
Basically, I read the IMG as an int16 array, divided the values by 2000 to scale to km, created X/Y arrays (see the LBL files for the relevant info). Then, I used a script on the Matlab File Exchange (http://www.mathworks.com/matlabcentral/fileexchange/4512-surf2stl) to convert those 3 arrays (x,y,z) to a binary STL file (it can also do ascii).
That last step is pretty slow, so I actually created a STL from a small subset region of the IMG file I was trying out (LDEM_75N_240M.IMG).
I tested it out with MeshLab (http://meshlab.sourceforge.net), and it seems to be working fine.

Erwan
(I'm not including the (short) code I wrote because you might not be using Matlab, but let me know if you're interested.)
Go to the top of the page
 
+Quote Post
Rick Sternbach
post Mar 17 2011, 05:51 PM
Post #3


Junior Member
**

Group: Members
Posts: 23
Joined: 6-November 09
Member No.: 5017



Erwan - Thank you; yes, I believe I could use the code. I've got the ear of the STL folks who helped produce the 22" Valles Marineris model for me in 2006 from the MOLA data, and they know Matlab.
Go to the top of the page
 
+Quote Post
zeBeamer
post Mar 17 2011, 07:35 PM
Post #4


Junior Member
**

Group: Members
Posts: 22
Joined: 20-June 09
Member No.: 4830



Rick,

see the code below.
The files produced are very large, but I guess that the way it is with the STL format. For such well-defined uniform grids, it seems quite overkill though. A 2400x2400 grid converts to 11,520,000 facets and ~550MB.

Erwan

CODE
%%
clear

IMGfile='ldem_875S_20m.img';
STLfile='ldem_875S_20m.stl';

%% read IMG file
fidbin=fopen(IMGfile,'rb');
tmpbin=single(fread(fidbin,inf,'int16','ieee-le')/2000.0);
fclose(fidbin);

%% construct x/y vectors
dxy=0.02;
xymax=75.84;

xps=single((-xymax+dxy/2):dxy:(xymax-dxy/2));
yps=single((xymax-dxy/2):-dxy:(-xymax+dxy/2));

%% construct x/y arrays
[xps_,yps_]=meshgrid(xps,yps);

%%
zp=reshape(tmpbin,length(yps),length(xps))';
clear tmpbin

%% select subset to plot/convert
kx=3792+(-1200:1200);
ky=3792+(-1200:1200);

%% plot to check correct orientation
clf; hold on; box on; set(gca,'FontSize',13);
pcolor(xps_(ky,kx),yps_(ky,kx),zp(ky,kx));
shading flat;
axis equal; axis image;
xlabel('Stereographic X [km]   ');
ylabel('Stereographic Y [km]   ');

%% write STL file
surf2stl(STLfile,xps_(ky,kx),yps_(ky,kx),zp(ky,kx),'binary');
Go to the top of the page
 
+Quote Post
Rick Sternbach
post Mar 17 2011, 11:42 PM
Post #5


Junior Member
**

Group: Members
Posts: 23
Joined: 6-November 09
Member No.: 5017



Erwan - Thanks for that. I'll pass it on and see what might be done. - Rick
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

 



RSS Lo-Fi Version Time is now: 19th March 2024 - 09:58 AM
RULES AND GUIDELINES
Please read the Forum Rules and Guidelines before posting.

IMAGE COPYRIGHT
Images posted on UnmannedSpaceflight.com may be copyrighted. Do not reproduce without permission. Read here for further information on space images and copyright.

OPINIONS AND MODERATION
Opinions expressed on UnmannedSpaceflight.com are those of the individual posters and do not necessarily reflect the opinions of UnmannedSpaceflight.com or The Planetary Society. The all-volunteer UnmannedSpaceflight.com moderation team is wholly independent of The Planetary Society. The Planetary Society has no influence over decisions made by the UnmannedSpaceflight.com moderators.
SUPPORT THE FORUM
Unmannedspaceflight.com is funded by the Planetary Society. Please consider supporting our work and many other projects by donating to the Society or becoming a member.