[vtkusers] [Fwd: raw slices - single file - visualize problem]

Christos Panagiotou C.Panagiotou at cs.ucl.ac.uk
Fri Feb 20 02:08:14 EST 2004


guys 

i have a volume of brain slices stored in one single file (.raw)
the file comes from kitware from the following url:

ftp://public.kitware.com/pub/itk/Data/BrainWeb

the dimensions of the file are said to be xyz: 181 217 180

i try to visualize the file by the following code: 

 const char *fname = "/home/christos/PhD/Data/raw/Brain1/Brain/brainweb1e1a10f20.raw";

 vtkImageReader2 *v = vtkImageReader2::New();

   v->SetDataExtent(1,181,1,217,1,180);

   v->SetSwapBytes(2);

   v->SetDataScalarTypeToShort();

   v->SetFileName(fname);

   v->SetFileDimensionality(3);

   v->SetDataSpacing (1.0,1.0,1.0);

   v->DebugOn();

   v->Update();



which later on i pass v -> contour filter -> polydatanormals -> 
polydatamapper -> actor  -> renderer -> window ...

If run the above code what i get is an error saying:
File operation failed. row = -126, Read = 352, FilePos = -1

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.
(the weird thing is that i see 4 identical volumes in the window, each one taking a small part of the window)

so i have 2 problems... how to visualize the whole volume and how to have only one instance in the window!

(the volume is signed short)


thanks in advance for your time
christos


p.s. i give you the full code incase it helps:

--------------------------------------------------

#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkImageReader2.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkOutlineFilter.h"
#include "vtkCamera.h"
#include "vtkProperty.h"
#include "vtkPolyDataNormals.h"
#include "vtkContourFilter.h"


int main (int argc, char **argv)
{


 const char *fname = "/home/christos/PhD/Data/raw/Brain1/Brain/brainweb1e1a10f20.raw";




 

 vtkRenderer *aRenderer = vtkRenderer::New();
 vtkRenderWindow *renWin = vtkRenderWindow::New();
 renWin->AddRenderer(aRenderer);
 vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
 iren->SetRenderWindow(renWin);

 //----- read volume
 vtkImageReader2 *v = vtkImageReader2::New();
   v->SetDataExtent(0,180,0,216,1,50 );
   v->SetDataByteOrderToBigEndian();
   v->SetDataScalarTypeToShort();
   v->SetFileName(fname);
   v->SetFileDimensionality(3);
   v->SetSwapBytes(2);
   v->SetDataSpacing (1.0,1.0,1.0);
   v->DebugOn();
   v->Update();


 vtkContourFilter *skinExtractor = vtkContourFilter::New();
   skinExtractor->SetInput((vtkDataSet *)v->GetOutput());    
//    skinExtractor->SetValue(0, 500); 

 vtkPolyDataNormals *skinNormals = vtkPolyDataNormals::New();
   skinNormals->SetInput(skinExtractor->GetOutput());
   skinNormals->SetFeatureAngle(60.0);

 vtkPolyDataMapper *skinMapper = vtkPolyDataMapper::New();
   skinMapper->SetInput(skinNormals->GetOutput());
   skinMapper->ScalarVisibilityOff();

 vtkActor *skin = vtkActor::New();
   skin->SetMapper(skinMapper);

 vtkOutlineFilter *outlineData = vtkOutlineFilter::New();
   outlineData->SetInput((vtkDataSet *) v->GetOutput());
 vtkPolyDataMapper *mapOutline = vtkPolyDataMapper::New();
   mapOutline->SetInput(outlineData->GetOutput());
 vtkActor *outline = vtkActor::New();
   outline->SetMapper(mapOutline);
   outline->GetProperty()->SetColor(0,0,0);


 aRenderer->AddActor(outline);
 aRenderer->AddActor(skin);
 aRenderer->ResetCamera ();
 aRenderer->SetBackground(1,1,1);
 renWin->SetSize(640, 480);
 aRenderer->ResetCameraClippingRange();


 iren->Initialize();
 iren->Start();

 v->Delete();
 skinExtractor->Delete();
 skinNormals->Delete();
 skinMapper->Delete();
 skin->Delete();
 outlineData->Delete();
 mapOutline->Delete();
 outline->Delete();
 iren->Delete();
 renWin->Delete();
 aRenderer->Delete();


}
-----------------------------------------------------------




More information about the vtkusers mailing list