<html>
<body>
Did you try using the SetHeaderSize method in vtkImageReader2 (the
superclass of vtkImageReader)? I know it isn't just specifying a
number of bytes to read, but using that and the SetDataExtent method
(also in vtkImageReader) should do the right thing.<br><br>
- Amy<br><br>
At 10:15 AM 5/31/2005, Randall Hand wrote:<br>
<blockquote type=cite class=cite cite="">Ok, I'm looking at this now
(computers are finally back online :) ), and I can't figure out how to
set the raw number of bytes to read. I see SetDataVOI, but nothing
to "bypass" that and specify a number of bytes.<br><br>
On 5/27/05, <b>Mathieu Malaterre</b>
<<a href="mailto:mathieu.malaterre@kitware.com">
mathieu.malaterre@kitware.com</a>> wrote: <br>
<dl>
<dd>Randall,<br><br>
<dd> Hum I believe you can read
those bytes but never use it... Could you <br>
<dd>try to read 3,840,384,800 bytes + 4 but set properly the dimension.
If<br>
<dd>you are lucky enough no test is done to check consistency of
datasize<br>
<dd>and dimension of data.<br><br>
<dd>My 2 cents,<br>
<dd>Mathieu<br><br>
<dd>Randall Hand wrote: <br>
<dd>> Well, I have an addition 4 bytes at the end of the file to skip
as<br>
<dd>> well.. I suppose I could postprocess & write a new file
without these<br>
<dd>> final 4 bytes, but that's gonna be pretty wasteful of disk
space. Is <br>
<dd>> there a way to skip them?<br>
<dd>><br>
<dd>><br>
<dd>><br>
<dd>> On 5/27/05, *Mathieu Malaterre*
<<a href="mailto:mathieu.malaterre@kitware.com">
mathieu.malaterre@kitware.com</a><br>
<dd>>
<<a href="mailto:%20mathieu.malaterre@kitware.com" eudora="autourl">
mailto: mathieu.malaterre@kitware.com</a>>> wrote:<br>
<dd>><br>
<dd>> Randall,<br>
<dd>><br>
<dd>
>
Could you instead give vtkImageReader a try. Just specify<br>
<dd>> the lenght of<br>
<dd>> data you want to read: 3,840,384,800
bytes. By default vtkImageReader<br>
<dd>> start reading from the end. Thefore you
are garantee to skip a <br>
<dd>> header if<br>
<dd>> any (4 bytes in your case
apparently).<br>
<dd>><br>
<dd>> HTH<br>
<dd>> Mathieu<br>
<dd>><br>
<dd>> Randall Hand wrote:<br>
<dd>> > I'm attempting to load a
simple "Brick of Bytes (BoB)" format <br>
<dd>> file into<br>
<dd>> > VTK. It is
2191x2191x800 unsigned chars (3,840,384,800 bytes).<br>
<dd>> With 4<br>
<dd>> > bytes at the beginning that I
have to skip (Gotta love fortran). My<br>
<dd>> > code is like the following:
<br>
<dd>> ><br>
<dd>> > if
(stat(argv[1], &file_info) == -1) {<br>
<dd>>
> perror("Unable
to stat file!\n\t");<br>
<dd>>
> return -1;<br>
<dd>> >
}<br>
<dd>> > fptr
= fopen(argv[1], "r"); <br>
<dd>> > if
((data = (char*)malloc(file_info.st_size)) == NULL) {<br>
<dd>>
> perror("Unable
to allocate memory!\n\t");<br>
<dd>>
> return -1;<br>
<dd>> >
}<br>
<dd>> >
dataptr = data;<br>
<dd>> >
fread(dataptr, 1, 4, fptr);<br>
<dd>> >
dataptr += 4; <br>
<dd>> >
printf("\n\n");<br>
<dd>> >
for(int i=0; i<xdim; i++) {<br>
<dd>>
> fread(dataptr,
ydim,zdim, fptr);<br>
<dd>>
> dataptr += (ydim *
zdim);<br>
<dd>> >
}<br>
<dd>> ><br>
<dd>> >
vtkImageImport *import = vtkImageImport::New();<br>
<dd>> >
import->AddObserver(vtkCommand::ProgressEvent, progress); <br>
<dd>> >
import->SetDataScalarTypeToUnsignedChar();<br>
<dd>> >
import->SetNumberOfScalarComponents(1);<br>
<dd>> >
import->SetWholeExtent(1, xdim-1,<br>
<dd>>
>
1, ydim-1,<br>
<dd>>
>
1, zdim-1);<br>
<dd>> >
import->SetDataExtentToWholeExtent();<br>
<dd>> >
import->SetImportVoidPointer(data + skip);<br>
<dd>> ><br>
<dd>> >
vtkDataSetWriter *writer = vtkDataSetWriter::New(); <br>
<dd>> >
writer->SetInput(import->GetOutput());<br>
<dd>> >
writer->SetFileName("resulting.vtk");<br>
<dd>> >
writer->Write();<br>
<dd>> ><br>
<dd>> ><br>
<dd>> > When I run this, however, the
output VTK file only contains the<br>
<dd>> following:<br>
<dd>> > # vtk DataFile Version
3.0<br>
<dd>> > vtk output<br>
<dd>> > ASCII<br>
<dd>> > DATASET STRUCTURED_POINTS
<br>
<dd>> > DIMENSIONS 2191 2191 800<br>
<dd>> > SPACING 1 1 1<br>
<dd>> > ORIGIN 1 1 1<br>
<dd>> ><br>
<dd>> > No data is actually written
to the file. When I try to connect<br>
<dd>> this to <br>
<dd>> > a rendering pipeline or start
querying the resulting vtkDataSet for<br>
<dd>> > properties (Scalar ranges,
number of points, etc) I get strange<br>
<dd>> results<br>
<dd>> > and eventually I get
Segfault/Core dumps. Often times the number of <br>
<dd>> > points listed comes out as a
large negative number, instead of the<br>
<dd>> > 3.8bil that it should
be.<br>
<dd>> ><br>
<dd>> > A stack trace of the core
dumps only reveals this:<br>
<dd>> > <br>
<dd>> > [8:50:48am]% dbx
imageimport<br>
<dd>> > dbx version 7.3.4
(86441_Nov11 MR) Nov 11 2002 11:31:55<br>
<dd>> > Core from signal SIGSEGV:
Segmentation violation<br>
<dd>> > (dbx) where<br>
<dd>> ><br>
<dd>> > Thread 0x10000<br>
<dd>> > > 0
vtkDataArrayTemplate<unsigned<br>
<dd>>
char>::ComputeScalarRange(int)(this<br>
<dd>> > = 0xf4eb83c0, comp = 0)<br>
<dd>> ><br>
<dd>>
["/viz/home/rhand/src/ezViz/Utilities/VTK/Common/vtkDataArrayTemplate.txx":644,<br>
<dd>> > 0x85f2758]<br>
<dd>> > (dbx)<br>
<dd>> > (dbx) quit<br>
<dd>> ><br>
<dd>> ><br>
<dd>> > <br>
<dd>> > --<br>
<dd>> > Randall Hand<br>
<dd>> >
<a href="http://www.yeraze.com">http://www.yeraze.com</a><br>
<dd>> ><br>
<dd>> ><br>
<dd>> ><br>
<dd>>
------------------------------------------------------------------------
<br>
<dd>> ><br>
<dd>> >
_______________________________________________<br>
<dd>> > This is the private VTK
discussion list.<br>
<dd>> > Please keep messages
on-topic. Check the FAQ at:<br>
<dd>>
<a href="http://www.vtk.org/Wiki/VTK_FAQ">
http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<dd>> > Follow this link to
subscribe/unsubscribe:<br>
<dd>> >
<a href="http://www.vtk.org/mailman/listinfo/vtkusers">
http://www.vtk.org/mailman/listinfo/vtkusers </a><br>
<dd>><br>
<dd>><br>
<dd>><br>
<dd>><br>
<dd>> --<br>
<dd>> Randall Hand<br>
<dd>> <a href="http://www.yeraze.com">http://www.yeraze.com</a>
<<a href="http://www.yeraze.com/" eudora="autourl">
http://www.yeraze.com</a>><br><br>
</dl><br><br>
<br>
-- <br>
Randall Hand<br>
<a href="http://www.yeraze.com">http://www.yeraze.com</a> <br>
_______________________________________________<br>
This is the private VTK discussion list. <br>
Please keep messages on-topic. Check the FAQ at:
<a href="http://www.vtk.org/Wiki/VTK_FAQ" eudora="autourl">
http://www.vtk.org/Wiki/VTK_FAQ</a><br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" eudora="autourl">
http://www.vtk.org/mailman/listinfo/vtkusers</a></blockquote></body>
</html>