Printable Version of Topic

Click here to view this topic in its original format

Unmanned Spaceflight.com _ LRO & LCROSS _ Physical 3-D from LOLA GDR IMG or JP2

Posted by: Rick Sternbach Mar 16 2011, 06:31 PM

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

Posted by: zeBeamer Mar 17 2011, 03:49 AM

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.)

Posted by: Rick Sternbach Mar 17 2011, 05:51 PM

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.

Posted by: zeBeamer Mar 17 2011, 07:35 PM

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');

Posted by: Rick Sternbach Mar 17 2011, 11:42 PM

Erwan - Thanks for that. I'll pass it on and see what might be done. - Rick

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)