back to DXSoil page

Questions:

  1. How can I import a series of tiff or jpeg images as a 3D image in OpenDX.

Answers:

1. How can I import a series of tiff or jpeg images as a 3D image in OpenDX

The easiest way to import a series of images as a 3D image is to use matlab: Use imread to read images, combine them as a 3D matrix, binarize it if necessary and save this matrix as a raw file using fopen, fwrite and fclose. Then create a .general file to import it into OpenDX. A matlab program to do the work could look like this:

 function convert2OpenDX()
 image=uint8(zeros(SizeX,SizeY,SizeZ)); % replace SizeX, SizeY and SizeZ with effective values. They can also be deduced from images.
 for z=1:SizeZ,
   tmp=imread(sprintf('image%03d.tiff',z); % would read a series of tiff images: image001.tiff, image002.tiff ...
tmp=uint8(double(tmp)>120); % set a threshold level at 120 image(:,:,z)=tmp; end fid=fopen('result.raw','w'); fwrite(fid,image,'uint8'); fclose(fid);

Then, a .general file could look like this:

 file = result.raw
 grid = SizeX x SizeY x SizeZ
 format = msb ieee
 majority = column
 field = data
 structure = scalar
 type = unsigned byte
 dependency = positions
 positions = regular, regular, regular, 0, 1, 0, 1, 0, 1
 end
 

to my homepage

Any comment? idea?

last update: 8/12/12