PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : RAW-Volumen laden


Jürgen-Müller
2007-06-22, 12:26:01
Hallo,

ich habe eine Volumentextur im RAW Format, die ich laden müsste um sie zu bearbeiten.

Aber ich weiß nicht wie, und vor allem, was muss ich mit ihr machen, damit ich aus ihr eine normale Textur (mit Header) bekomme?

AlSvartr
2007-06-22, 12:44:11
Also das Laden sollte eigentlich nicht das Problem sein. Ich hatte vor nem Jahr mal Marching Cubes implementiert und im Zuge dessen halt auch nen RAW-Reader gebaut, das Ganze in Java. Vielleicht hilft das ja.

public class Reader {

/**
* Returns volume data from an 8-bit volume data file as a 3D byte Array
* @param inputFile The filename of the file to read from
* @param x x-resolution of the volume data
* @param y y-resolution of the volume data
* @param z z-resolution of the volume data
* @return the 3D-Array of volume data if everything went right, null else
*/
public static byte[][][] readVolumeData(String inputFile,int x,int y,int z) {
FileInputStream fis=null;
DataInputStream dis=null;
byte[][][] iByte=new byte[x][y][z];
int i,j,k;

try {
fis=new FileInputStream(inputFile);
dis=new DataInputStream(fis);
i=0;
j=0;
k=0;
while (true) {
iByte[i][j][k]=dis.readByte();
k=(k+1)%z;
if (k==0) {
j=(j+1)%y;
if (j==0)
i=(i+1)%x;
}
}
}
catch (EOFException e) {
try {
fis.close();
return iByte;
}
catch (IOException f) {
f.printStackTrace();
return null;
}
}
catch (IOException e) {
e.printStackTrace();
return null;
}
}
}

Gast
2007-06-22, 12:50:37
while (true) {
iByte[i][j][k]=dis.readByte();
k=(k+1)%z;
if (k==0) {
j=(j+1)%y;
if (j==0)
i=(i+1)%x;


O
M
G

AlSvartr
2007-06-22, 12:51:17
O
M
G
Ja, ich weiß :wink:

Chris Lux
2007-06-22, 15:52:07
ich habe eine Volumentextur im RAW Format, die ich laden müsste um sie zu bearbeiten.

hier ein c++ code schnipsel, was das raw laden macht. du musst dafuer von dem volumen folgende sachen wissen:

dimensionen
anzahl kanaele
byte pro kanal



std::ifstream _file;
const math::vec<unsigned, 3>& offset;
const math::vec<unsigned, 3>& dimensions;
unsigned char*const buffer;

[...]

unsigned offset_src;
unsigned offset_dst;

for (unsigned int slice = 0; slice < dimensions.z; ++slice) {
for (unsigned int line = 0; line < dimensions.y; ++line) {
offset_src = offset.x
+ _vol_desc._data_dimensions.x * (offset.y + line)
+ _vol_desc._data_dimensions.x * _vol_desc._data_dimensions.y * (offset.z + slice);
offset_src *= _vol_desc._data_byte_per_channel * _vol_desc._data_num_channels;

offset_dst = dimensions.x * line
+ dimensions.x * dimensions.y * slice;
offset_dst *= _vol_desc._data_byte_per_channel * _vol_desc._data_num_channels;

_file.seekg(offset_src, std::ios_base::beg);
_file.read((char*)&buffer[offset_dst], dimensions.x);
}
}

return (true);

Aber ich weiß nicht wie, und vor allem, was muss ich mit ihr machen, damit ich aus ihr eine normale Textur (mit Header) bekomme?
bei raw files hast du sowas nicht, wie ich oben beschrieben habe musst du ein paar informationen ueber das volumen haben.