<br><font size=2 face="sans-serif">Christos...even though the file 1e1a10f20.txt description says signed__ short 0 to 4095...looks like 8 bit images to me. The mha file says </font><font size=2 face="Courier New">ElementType = MET_UCHAR</font><font size=2 face="sans-serif"> however so at least one f them got it right (-; ....thats why you are seeing 4 images in one....john</font>
<br>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td>
<td><font size=1 face="sans-serif"><b>Christos Panagiotou <C.Panagiotou@cs.ucl.ac.uk></b></font>
<br><font size=1 face="sans-serif">Sent by: vtkusers-admin@vtk.org</font>
<p><font size=1 face="sans-serif">02/20/2004 02:08 AM</font>
<br>
<td><font size=1 face="Arial"> </font>
<br><font size=1 face="sans-serif"> To: 1__VTK POST <vtkusers@vtk.org></font>
<br><font size=1 face="sans-serif"> cc: (bcc: John Anast-JM/PGI)</font>
<br><font size=1 face="sans-serif"> Subject: [vtkusers] [Fwd: raw slices - single file - visualize problem]</font></table>
<br>
<br>
<br><font size=2 face="Courier New"><br>
guys <br>
<br>
i have a volume of brain slices stored in one single file (.raw)<br>
the file comes from kitware from the following url:<br>
<br>
ftp://public.kitware.com/pub/itk/Data/BrainWeb<br>
<br>
the dimensions of the file are said to be xyz: 181 217 180<br>
<br>
i try to visualize the file by the following code: <br>
<br>
const char *fname = "/home/christos/PhD/Data/raw/Brain1/Brain/brainweb1e1a10f20.raw";<br>
<br>
vtkImageReader2 *v = vtkImageReader2::New();<br>
<br>
v->SetDataExtent(1,181,1,217,1,180);<br>
<br>
v->SetSwapBytes(2);<br>
<br>
v->SetDataScalarTypeToShort();<br>
<br>
v->SetFileName(fname);<br>
<br>
v->SetFileDimensionality(3);<br>
<br>
v->SetDataSpacing (1.0,1.0,1.0);<br>
<br>
v->DebugOn();<br>
<br>
v->Update();<br>
<br>
<br>
<br>
which later on i pass v -> contour filter -> polydatanormals -> <br>
polydatamapper -> actor -> renderer -> window ...<br>
<br>
If run the above code what i get is an error saying:<br>
File operation failed. row = -126, Read = 352, FilePos = -1<br>
<br>
If i run the same example with data extent of (1,181,1,217,1,50) - i just reduced the number of slices i see of course a part of the volume.<br>
(the weird thing is that i see 4 identical volumes in the window, each one taking a small part of the window)<br>
<br>
so i have 2 problems... how to visualize the whole volume and how to have only one instance in the window!<br>
<br>
(the volume is signed short)<br>
<br>
<br>
thanks in advance for your time<br>
christos<br>
<br>
<br>
p.s. i give you the full code incase it helps:<br>
<br>
--------------------------------------------------</font>
<br><font size=2 face="Courier New"><br>
#include "vtkRenderer.h"<br>
#include "vtkRenderWindow.h"<br>
#include "vtkRenderWindowInteractor.h"<br>
#include "vtkImageReader2.h"<br>
#include "vtkPolyDataMapper.h"<br>
#include "vtkActor.h"<br>
#include "vtkOutlineFilter.h"<br>
#include "vtkCamera.h"<br>
#include "vtkProperty.h"<br>
#include "vtkPolyDataNormals.h"<br>
#include "vtkContourFilter.h"<br>
<br>
<br>
int main (int argc, char **argv)<br>
{<br>
<br>
<br>
const char *fname = "/home/christos/PhD/Data/raw/Brain1/Brain/brainweb1e1a10f20.raw";<br>
<br>
<br>
<br>
<br>
<br>
<br>
vtkRenderer *aRenderer = vtkRenderer::New();<br>
vtkRenderWindow *renWin = vtkRenderWindow::New();<br>
renWin->AddRenderer(aRenderer);<br>
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();<br>
iren->SetRenderWindow(renWin);<br>
<br>
//----- read volume<br>
vtkImageReader2 *v = vtkImageReader2::New();<br>
v->SetDataExtent(0,180,0,216,1,50 );<br>
v->SetDataByteOrderToBigEndian();<br>
v->SetDataScalarTypeToShort();<br>
v->SetFileName(fname);<br>
v->SetFileDimensionality(3);<br>
v->SetSwapBytes(2);<br>
v->SetDataSpacing (1.0,1.0,1.0);<br>
v->DebugOn();<br>
v->Update();<br>
<br>
<br>
vtkContourFilter *skinExtractor = vtkContourFilter::New();<br>
skinExtractor->SetInput((vtkDataSet *)v->GetOutput()); <br>
// skinExtractor->SetValue(0, 500); <br>
<br>
vtkPolyDataNormals *skinNormals = vtkPolyDataNormals::New();<br>
skinNormals->SetInput(skinExtractor->GetOutput());<br>
skinNormals->SetFeatureAngle(60.0);<br>
<br>
vtkPolyDataMapper *skinMapper = vtkPolyDataMapper::New();<br>
skinMapper->SetInput(skinNormals->GetOutput());<br>
skinMapper->ScalarVisibilityOff();<br>
<br>
vtkActor *skin = vtkActor::New();<br>
skin->SetMapper(skinMapper);<br>
<br>
vtkOutlineFilter *outlineData = vtkOutlineFilter::New();<br>
outlineData->SetInput((vtkDataSet *) v->GetOutput());<br>
vtkPolyDataMapper *mapOutline = vtkPolyDataMapper::New();<br>
mapOutline->SetInput(outlineData->GetOutput());<br>
vtkActor *outline = vtkActor::New();<br>
outline->SetMapper(mapOutline);<br>
outline->GetProperty()->SetColor(0,0,0);<br>
<br>
<br>
aRenderer->AddActor(outline);<br>
aRenderer->AddActor(skin);<br>
aRenderer->ResetCamera ();<br>
aRenderer->SetBackground(1,1,1);<br>
renWin->SetSize(640, 480);<br>
aRenderer->ResetCameraClippingRange();<br>
<br>
<br>
iren->Initialize();<br>
iren->Start();<br>
<br>
v->Delete();<br>
skinExtractor->Delete();<br>
skinNormals->Delete();<br>
skinMapper->Delete();<br>
skin->Delete();<br>
outlineData->Delete();<br>
mapOutline->Delete();<br>
outline->Delete();<br>
iren->Delete();<br>
renWin->Delete();<br>
aRenderer->Delete();<br>
<br>
<br>
}<br>
-----------------------------------------------------------<br>
<br>
_______________________________________________<br>
This is the private VTK discussion list. <br>
Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq><br>
Follow this link to subscribe/unsubscribe:<br>
http://www.vtk.org/mailman/listinfo/vtkusers<br>
</font>
<br>
<br>